LeonMMS

LM² - Account Bank 1.0

Aug 30th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.49 KB | None | 0 0
  1. #       LM² - Account Bank 1.0
  2. #       Data 30/08/17
  3. #   Criado por LeonMM
  4. class Bank < Window_Selectable
  5.   attr_accessor :bankdata
  6.   def initialize
  7.     super(300, 260, 182, 152, 30)
  8.     self.visible = self.active = false
  9.     @bankdata = []
  10.     draw_help
  11.     draw_title("Banco")
  12.     @column_max = 5
  13.     @dragable = true
  14.     @closable = true
  15.   end
  16.   def trigger
  17.     super
  18.     $windows[:equip].trigger
  19.     $network.request_bank
  20.   end
  21.   def on_close
  22.     super
  23.     $windows[:equip].on_close
  24.     $windows[:amount].on_close    
  25.   end
  26.   def item
  27.     return @data[self.index]
  28.   end
  29.   def refresh
  30.     if self.contents != nil
  31.       self.contents.dispose
  32.       self.contents = nil
  33.     end
  34.     @data = []
  35.     for i in 0...@bankdata.size
  36.       case @bankdata[i][0]
  37.       when 0
  38.         @data << $data_items[@bankdata[i][1]]
  39.       when 1
  40.         @data << $data_weapons[@bankdata[i][1]]
  41.       when 2
  42.         @data << $data_armors[@bankdata[i][1]]
  43.       end  
  44.     end  
  45.     @item_max = @data.size
  46.     if @item_max > 0
  47.       self.contents = Bitmap.new(width - 32, row_max * @spacing)
  48.       for i in 0...@item_max
  49.         draw_item(i)
  50.       end
  51.     end
  52.   end
  53.   def draw_item(index)
  54.     item = @data[index]
  55.     number = @bankdata[index][2]
  56.     cursor_width = contents.width / @column_max
  57.     x = index % @column_max * cursor_width
  58.     y = index / @column_max * @spacing
  59.     rect = Rect.new(x, y, cursor_width, @spacing)
  60.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  61.     self.contents.blt(x + 3, y + 3, RPG::Cache.icon(item.icon_name), Rect.new(0, 0, 24, 24))
  62.     self.contents.draw_text(x - 2, y + 13, 30, 18, convert_gold(number), 2)
  63.   end
  64.   def update
  65.     super
  66.     if self.index >= 0 and item and $mouse.object == nil
  67.       show_help(item)
  68.     else
  69.       hide_help
  70.     end
  71.     if in_area?(0, 16)
  72.       update_drag
  73.       update_drop
  74.     end
  75.   end
  76.   def update_drag
  77.     return unless self.index >= 0
  78.     return unless Input.press?(Input::Key['Mouse Left'])
  79.     return unless $mouse.object == nil
  80.     return if item == nil
  81.     $mouse.object = item
  82.     $mouse.type = 6
  83.   end
  84.   def update_drop
  85.     return if Input.press?(Input::Key['Mouse Left'])
  86.     return unless $mouse.object
  87.     return unless $mouse.type == 1
  88.     $windows[:amount].open($mouse.object, 6)
  89.   end
  90.   def check_number(id,number)
  91.     for i in 0...@bankdata.size
  92.       if id == @bankdata[i][1] and @bankdata[i][2] < number      
  93.         return true
  94.       end  
  95.     end
  96.     return false
  97.   end  
  98. end
Add Comment
Please, Sign In to add comment