| Ancien membre du staff |
 |
 |
Inscrit le: 24 Juin 2008, 00:00 Messages: 476 Logiciel(s) préféré(s): Scintilla based Point(s) Fort(s): Rubyismes Points d'aide: 60/60
Créations :
- [Rmxp] Vocab
- [Rmxp] Visible Equipment
- [Rmxp] Animated Title
- [XP/VX] Cache Extension
Voir ses créations
|
Scripts :Window_Item- Code: Tout sélectionner
#======================================================= # Window_Item #------------------------------------------------------- # Allows a player to select an item in the item and battle scenes. #=======================================================
class Window_Item < Window_Selectable attr_accessor :use attr_accessor :show_keyitems #----------------------------------------- # Initialize the item window #----------------------------------------- def initialize super(0, 128, 640, 352) @use = true @column_max = 2 @show_keyitems = false refresh self.index = 0 # If in a battle, move the window to the center of the screen and make # it translucent if $game_temp.in_battle self.y = 64 self.height = 256 self.back_opacity = 160 end end #----------------------------------------- # Get selected item #----------------------------------------- def item return @data[self.index] end #----------------------------------------- # Selects the last item in the list #----------------------------------------- def select_last self.index = [@data.size - 1, 0].max end #----------------------------------------- # Refresh the contents of the window #----------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # Add items for i in 1...$data_items.size if $game_party.item_number(i) > 0 # Only show key items when in key item mode if $data_items[i].element_set.include?(KEY_ITEM_ATTRIBUTE) if @show_keyitems # If key items are split, this will give a number of # seperate entries equal to the quantity of the item # possessed if SPLIT_KEYITEMS for j in 0...$game_party.item_number(i) @data.push($data_items[i]) end else # Otherwise, add it once @data.push($data_items[i]) end end elsif not @show_keyitems @data.push($data_items[i]) end end end # Unless in a battle, add weapons and armor unless $game_temp.in_battle for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 # Only show key items when in key item mode if $data_weapons[i].element_set.include?(KEY_ITEM_ATTRIBUTE) if @show_keyitems # If key items are split, this will give a number of # seperate entries equal to the quantity of the item # possessed if SPLIT_KEYITEMS for j in 0...$game_party.weapon_number(i) @data.push($data_weapons[i]) end else # Otherwise, add it once @data.push($data_weapons[i]) end end elsif not @show_keyitems @data.push($data_weapons[i]) end end end for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 # Only show key items when in key item mode if $data_armors[i].guard_element_set.include?(KEY_ITEM_ATTRIBUTE) if @show_keyitems # If key items are split, this will give a number of # seperate entries equal to the quantity of the item # possessed if SPLIT_KEYITEMS for j in 0...$game_party.armor_number(i) @data.push($data_armors[i]) end else # Otherwise, add it once @data.push($data_armors[i]) end end elsif not @show_keyitems @data.push($data_armors[i]) end end end end # If there are items to show, draw them on the screen @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.name = $fontface self.contents.font.size = $fontsize self.contents.font.color = Color.new(101,54,36,255) for i in 0...@item_max draw_item(i) end end end #----------------------------------------- # Draw an item # index : The index (in @data) of the item to draw #----------------------------------------- def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end if @show_keyitems self.contents.font.color = Color.new(101,54,36,255) elsif @use if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id) self.contents.font.color = Color.new(101,54,36,255) else self.contents.font.color = disabled_color end end x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) # Disgusting bit of logic that determines whether or not the quantity # of the item is shown (for key item display) unless @show_keyitems and ((number == 1 and not SHOW_KEYITEM_QUANTITY_WHEN_SINGULAR) or SPLIT_KEYITEMS) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end end #----------------------------------------- # Update help window text #----------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end
|
|