Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # LM² - Account Bank 1.0
- # Data 30/08/17
- # Criado por LeonMM
- class Bank < Window_Selectable
- attr_accessor :bankdata
- def initialize
- super(300, 260, 182, 152, 30)
- self.visible = self.active = false
- @bankdata = []
- draw_help
- draw_title("Banco")
- @column_max = 5
- @dragable = true
- @closable = true
- end
- def trigger
- super
- $windows[:equip].trigger
- $network.request_bank
- end
- def on_close
- super
- $windows[:equip].on_close
- $windows[:amount].on_close
- end
- def item
- return @data[self.index]
- end
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- for i in 0...@bankdata.size
- case @bankdata[i][0]
- when 0
- @data << $data_items[@bankdata[i][1]]
- when 1
- @data << $data_weapons[@bankdata[i][1]]
- when 2
- @data << $data_armors[@bankdata[i][1]]
- end
- end
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * @spacing)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- def draw_item(index)
- item = @data[index]
- number = @bankdata[index][2]
- cursor_width = contents.width / @column_max
- x = index % @column_max * cursor_width
- y = index / @column_max * @spacing
- rect = Rect.new(x, y, cursor_width, @spacing)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- self.contents.blt(x + 3, y + 3, RPG::Cache.icon(item.icon_name), Rect.new(0, 0, 24, 24))
- self.contents.draw_text(x - 2, y + 13, 30, 18, convert_gold(number), 2)
- end
- def update
- super
- if self.index >= 0 and item and $mouse.object == nil
- show_help(item)
- else
- hide_help
- end
- if in_area?(0, 16)
- update_drag
- update_drop
- end
- end
- def update_drag
- return unless self.index >= 0
- return unless Input.press?(Input::Key['Mouse Left'])
- return unless $mouse.object == nil
- return if item == nil
- $mouse.object = item
- $mouse.type = 6
- end
- def update_drop
- return if Input.press?(Input::Key['Mouse Left'])
- return unless $mouse.object
- return unless $mouse.type == 1
- $windows[:amount].open($mouse.object, 6)
- end
- def check_number(id,number)
- for i in 0...@bankdata.size
- if id == @bankdata[i][1] and @bankdata[i][2] < number
- return true
- end
- end
- return false
- end
- end
Add Comment
Please, Sign In to add comment