#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Constant Variables
#--------------------------------------------------------------------------
FOCUS_COLOR = 6
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias ikos_highlight_window_command_initialize initialize
alias ikos_highlight_window_command_draw_item draw_item
#--------------------------------------------------------------------------
# * Object Initialization !ALIAS!
# 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, commands, column_max = 1, row_max = 0, spacing = 32)
@disabled = []
@old_index = 0
ikos_highlight_window_command_initialize(width, commands, column_max,
row_max, spacing)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@old_index = @index if cursor_movable?
super
if cursor_movable?
draw_focus_item if @old_index != @index
end
end
#--------------------------------------------------------------------------
# * Set Cursor Position
# index : new cursor position
#--------------------------------------------------------------------------
def index=(index)
@old_index = @index
super
draw_focus_item
end
#--------------------------------------------------------------------------
# * Draw Focused Item
#--------------------------------------------------------------------------
def draw_focus_item
unless @old_index == -1
rect = item_rect(@old_index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = @disabled.include?(@old_index) ?
128 : 255
self.contents.draw_text(rect, @commands[@old_index])
end
# Draw the new item.
rect = item_rect(@index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = text_color(FOCUS_COLOR)
self.contents.font.color.alpha = @disabled.include?(@index) ?
128 : 255
self.contents.draw_text(rect, @commands[@index])
end
#--------------------------------------------------------------------------
# * Draw Item !ALIAS!
# index : item number
# enabled : enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
@disabled << index if !enabled && !@disabled.include?(index)
ikos_highlight_window_command_draw_item(index, enabled)
end
end