brainstorm
Member
Window_Icon Command
This script-let is a simple edit of RPG Maker VX's Window_Command. If used correctly it draws a command window with icons at the left hand side of the text.
Setting the window up it's fairly simple. Down below is an ![tested]! example of how the script works in Scene_Title (Where the numbers are is the index of the icon beside the command) :
This script-let is a simple edit of RPG Maker VX's Window_Command. If used correctly it draws a command window with icons at the left hand side of the text.
Setting the window up it's fairly simple. Down below is an ![tested]! example of how the script works in Scene_Title (Where the numbers are is the index of the icon beside the command) :
Code:
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
s1 = [10,Vocab::new_game]
s2 = [15,Vocab::continue]
s3 = [20,Vocab::shutdown]
@command_window = Window_IconCommand.new(172, [s1, s2, s3])
@command_window.x = (544 - @command_window.width) / 2
@command_window.y = 288
if @continue_enabled # If continue is enabled
@command_window.index = 1 # Move cursor over command
else # If disabled
@command_window.draw_item(1, false) # Make command semi-transparent
end
@command_window.openness = 0
@command_window.open
end
end
Code:
#==============================================================================
# ** Window_IconCommand
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_IconCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
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, commands, column_max = 1, row_max = 0, spacing = 32)
if row_max == 0
row_max = (commands.size + column_max - 1) / column_max
end
super(0, 0, width, row_max * WLH + 32, spacing)
@commands = commands
@item_max = commands.size
@column_max = column_max
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
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 + 24
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
draw_icon(@commands[index][0], rect.x - 24, rect.y)
self.contents.draw_text(rect, @commands[index][1])
end
#--------------------------------------------------------------------------
# * Draw Item Name
# item : Item (skill, weapon, armor are also possible)
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# enabled : Enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item_name(index, x, y, enabled = true)
draw_icon(index, x, y, enabled)
end
end
http://img100.imageshack.us/img100/2168/testediconcommandfx7.png[/img]