#==============================================================================
# ** Window_Horizantal
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Horizantal < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(commands,height=32)
# Get biggest Item
bitmap = Bitmap.new(1,1); sz = 0
commands.each { |c|
i = bitmap.text_size(c).width
sz = i if i > sz
}
@mw = sz+16
# Compute window height from command quantity
super(0, 0, commands.size * @mw + 32,height+32)
@item_max = commands.size
@column_max = @item_max
@commands = commands
self.contents = Bitmap.new(@item_max * @mw,height)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(@mw * index, 4, @mw, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index],1)
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set( @index * @mw, 4, @mw, self.height-32)
end
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end