Home > RGSS Script Reference > Window_EquipRight
Window_EquipRight
Inherits from: Window_Selectable
Description: This window shows the items the character currently has equipped. When the player selects an item from the list, the item window becomes active and allows the player to select an item to repalce the currently equipped item.
class Window_EquipRight < Window_Selectable
# ------------------------------------
def initialize(actor)
super(272, 64, 368, 192)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
self.index = 0
end
# ------------------------------------
def item
return @data[self.index]
end
# ------------------------------------
def refresh
self.contents.clear
@data = []
@data.push($data_weapons[@actor.weapon_id])
@data.push($data_armors[@actor.armor1_id])
@data.push($data_armors[@actor.armor2_id])
@data.push($data_armors[@actor.armor3_id])
@data.push($data_armors[@actor.armor4_id])
@item_max = @data.size
self.contents.font.color = system_color
self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1)
self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4)
draw_item_name(@data[0], 92, 32 * 0)
draw_item_name(@data[1], 92, 32 * 1)
draw_item_name(@data[2], 92, 32 * 2)
draw_item_name(@data[3], 92, 32 * 3)
draw_item_name(@data[4], 92, 32 * 4)
end
# ------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
|
Actor: The actor whose equipment is being changed.
Data: An array containing the five items the actor currently has equipped.
Initialize
Arguments:
Actor: The actor whose equipment is being changed.
Local Variables: None
How it Works: This method initializes the window. First, the window's x coordinate is initialized to 272, the y coordinate is initialized to 64, the width to 368, and the height to 192. Then, the @actor instance variables is set to the actor whose equipment is being changed. The window is then refreshed using the refresh method.
Item
Arguments: None
Local Variables: None
How it Works: This method returns the item in the @data array corresponding to the index of the currently selected item.
Refresh
Arguments: None
Local Variables: None
How it Works: This method draws the contents of the item window. The @data array is first initialized to an empty array. The IDs of the weapon, shield, helmet, armor, and accessory are then added to the @data array, in this order. The method then draws the custom words for the five equipment types, in the system color, all at x coordinate 4. The y coordinate is 0 for weapon, 32 for shield, 64 for helmet, 96 for armor, and 128 for accessory. The final part of the method uses the Window_Base#Draw_Item_Name method to draw the icon and item name for each of the actor's five pieces of equipment from the @data array. The x coordinate at which these items are drawn is 92 for all five pieces of equipment. The y coordinates are the same as the ones described above for drawing the custom words.
Update_Help
Arguments: None
Local Variables: None
How it Works: This method updates the help window with the description of the currently selected item, or nil if an empty space is currently selected.
|
|