[VX] CAPTIONS ON CONFIRMATION WINDOWS (BEFORE I GO REINVENTING THE WHEEL)
Posts
Pages:
1
So for the commission I'm currently working on, I have a shop scene with a confirmation window when you're buying the items in question. However, never have I seen a facility for actual captions on confirm windows (which are usually just instances of Window_Command) for example: "Do you want to buy the X?" then selectable "Yes", "No" options. Obviously the inherent difficulty lies in the fact that Window_Command is intended only for the actual commands, and no support has been implemented for anything that isn't selectable to be part of the window.
Now although I haven't tried it myself yet, I'm 99% sure I can edit Window_Command to support this, but before I go experimenting with code that might not work I was just wondering if anyone already knows of a script that does this? No point reinventing the wheel if someone's already realised they're better off round.
Thanks in advance for anyone who can point me in the direction of such a script.
Now although I haven't tried it myself yet, I'm 99% sure I can edit Window_Command to support this, but before I go experimenting with code that might not work I was just wondering if anyone already knows of a script that does this? No point reinventing the wheel if someone's already realised they're better off round.
Thanks in advance for anyone who can point me in the direction of such a script.
Disregard, I figured it out. In case anyone's looking to do the same thing, here's my rather inelegant solution (which at present only supports two choices, since that's what I needed)
class Window_Confirm < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :caption
attr_reader :commands # command
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command string array
# column_max : digit count (if 2 or more, horizontal selection)
# row_max : row count (0: match command count)
# spacing : blank space when items are arrange horizontally
#--------------------------------------------------------------------------
def initialize(width, caption, commands, column_max = 2, spacing = 32)
super(0, 0, width, 3 * WLH + 32, spacing)
@caption = caption
@commands = commands
@item_max = commands.size
@column_max = column_max
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.draw_text(0, 0, self.contents.text_size(@caption).width, WLH, @caption)
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# enabled : enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.y += WLH * 2
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands[index])
end
#--------------------------------------------------------------------------
# * Update cursor
#--------------------------------------------------------------------------
def update_cursor
if @index < 0 # If the cursor position is less than 0
self.cursor_rect.empty # Empty cursor
else # If the cursor position is 0 or more
rect = item_rect(@index) # Get rectangle of selected item
rect.y += self.oy + WLH * 2 # Match rectangle to scroll position
self.cursor_rect = rect # Refresh cursor rectangle
end
end
end
Yeah, Window_Command doesn't have any captions as part of the window.
Although your way works, you could always just make the confirmation a separate window (inheriting from Window_Command). Then you simply make that window's graphic transparent. So, the person would just see the one window (with a caption) and the desired choices. I'm pretty sure that would be an easier way of solving this problem, no?
Although your way works, you could always just make the confirmation a separate window (inheriting from Window_Command). Then you simply make that window's graphic transparent. So, the person would just see the one window (with a caption) and the desired choices. I'm pretty sure that would be an easier way of solving this problem, no?
That would work too I guess. Not a bad idea, but I've already implemented it this way so I'll keep it as-is.
To be honest I'd probably have done it my way anyway; I'd rather have a window that allows for the caption than jury-rig it with an invisible window. I guess I'm just weird like that. :P
Pages:
1














