Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-------------------------------------------------------------------------------
- # page 7 of 12
- # Shopoholic v 2.0
- # code by cmpsr2000
- # available exclusively @ rpgrevolution.com/forums
- # Released June 25, 2008
- #
- #-------------------------------------------------------------------------------
- class Window_Bank_Vault < Window_Selectable
- #-----------------------------------------------------------------------------
- # Creates the bank vault window
- # x: The x-coordinate of the window
- # y: The y-coordinate of the window
- # bankID: The ID of the bank creating the window
- #-----------------------------------------------------------------------------
- def initialize(x, y, bankID)
- super(x, y, 304, 304)
- @bankID = bankID
- @column_max = 8
- @boxLabel = "Safety Deposit Boxes"
- @buyBoxesLabel = "Buy more boxes"
- refresh
- self.index = 0
- end
- #-----------------------------------------------------------------------------
- # Refreshes the contents of the window
- #-----------------------------------------------------------------------------
- def refresh
- @data = []
- @data.push(nil) #for heading
- for slot in $game_banking.bankVaults[@bankID]
- @data.push(slot)
- end
- @data.push(nil) #for buying more slots
- @item_max = @data.length
- create_contents
- for i in 0...@item_max
- if @data[i] != nil
- draw_item(i)
- else
- draw_label(i)
- end
- end
- if self.index > @item_max - 1
- self.index = @item_max - 1
- end
- end
- #-----------------------------------------------------------------------------
- # Determines the rectangle for the specified object index
- # index: The index of the object that needs a rectangle
- #-----------------------------------------------------------------------------
- def item_rect(index)
- rect = Rect.new(0, 0, 0, 0)
- if index == 0 or index == @data.length - 1
- rect.width = contents.width
- rect.height = WLH
- rect.x = 0
- rect.y = index == 0 ? 0 : WLH + (28 * ((@data.length - 2).to_f / @column_max).ceil)
- else
- rect.width = 28
- rect.height = 28
- rect.x = ((index - 1) % @column_max * (rect.width)) + 24
- rect.y = ((index - 1) / @column_max * rect.height) + WLH
- end
- return rect
- end
- #-----------------------------------------------------------------------------
- # Draws the label for the specified object index
- # index: The index of the label
- #-----------------------------------------------------------------------------
- def draw_label(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- self.contents.font.color = system_color
- self.contents.font.color.alpha = 255
- width = contents.width
- if index == 0
- self.contents.draw_text(rect.x, rect.y, width, WLH, @boxLabel, 1)
- else
- self.contents.draw_text(rect.x, rect.y, width, WLH, @buyBoxesLabel, 1)
- end
- end
- #-----------------------------------------------------------------------------
- # Draws the item for the specified object index
- # index: The index of the item
- #-----------------------------------------------------------------------------
- def draw_item(index)
- slot = @data[index]
- enabled = !slot.locked
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- x = rect.x
- y = rect.y
- draw_icon(slot.icon_index, x + 2, y + 2, enabled)
- if slot.item != nil
- draw_icon(slot.item.icon_index, x + 2, y + 2, false)
- self.contents.font.color = text_color(6) #yellow
- self.contents.font.size = 16
- self.contents.font.color.alpha = 255
- self.contents.draw_text(x + 1, y + 2, 24, 16, slot.amount.to_s, 2)
- self.contents.font.size = 20
- end
- end
- #--------------------------------------------------------------------------
- # * Move cursor down
- # wrap : Wraparound allowed
- #--------------------------------------------------------------------------
- def cursor_down(wrap = false)
- if (@index < @item_max - 1)
- if @index == 0
- @index = 1
- else
- @index = (@index + @column_max)
- if @index > @item_max -1
- @index = @item_max - 1
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Move cursor up
- # wrap : Wraparound allowed
- #--------------------------------------------------------------------------
- def cursor_up(wrap = false)
- if (@index > 0)
- if @index == @item_max - 1
- move = ((@item_max - 2) % @column_max)
- move = @column_max if move == 0
- @index -= move
- else
- @index = @index - @column_max
- if @index < 0
- @index = 0
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Move cursor right
- # wrap : Wraparound allowed
- #--------------------------------------------------------------------------
- def cursor_right(wrap = false)
- if (@column_max >= 2) and (@index < @item_max - 1)
- @index = (@index + 1) % @item_max
- end
- end
- #--------------------------------------------------------------------------
- # * Move cursor left
- # wrap : Wraparound allowed
- #--------------------------------------------------------------------------
- def cursor_left(wrap = false)
- if (@column_max >= 2) and (@index > 0)
- @index = (@index - 1 + @item_max) % @item_max
- end
- end
- #-----------------------------------------------------------------------------
- # Returns the slot object at the currently highlighted index
- # RETURNS: Storage_Slot
- #-----------------------------------------------------------------------------
- def slot
- return @data[@index]
- end
- end
RAW Paste Data