class Window_Command::Volley < Window_Selectable
def initialize(width, height, commands)
super(0, 0, width, height)
self.contents = Bitmap.new(width - 32, height - 32)
@commands = commands
@item_max = @commands.size
@disabled = Hash.new(false)
refresh
end
def refresh
for i in 0...@item_max
draw_command(i)
end
end
def disabled?(index = @index)
return @disabled[index]
end
def disable_item(index)
@disabled[index] = true
draw_command(index)
end
def draw_command(i)
x, y, command = *@commands[i]
size = self.contents.text_size(command)
color = disabled?(i) ? disabled_color : normal_color
self.contents.font.color = color
self.contents.draw_text(x, y, size.width, size.height, command)
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
x, y, command = *@commands[@index]
size = self.contents.text_size(command)
self.cursor_rect.set(x - 2, y - 2, size.width + 4, size.height + 4)
end
end
class Window_Command::Volley::Picture < Window_Command::Volley
def draw_command(i)
x, y, filename = *@commands[i]
bitmap = RPG::Cache.picture(filename)
@sizes = {} if @sizes == nil
@sizes[i] = [bitmap.width, bitmap.height]
color = disabled?(i) ? disabled_color : normal_color
self.contents.blt(x, y, bitmap, bitmap.rect, color.alhpa)
end
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
return
end
x, y, filename = *@commands[@index]
w, h = *@sizes[@index]
self.cursor_rect.set(x - 2, y - 2, w + 4, h + 4)
end
end