LeonMMS

LM² - Forge List

Aug 29th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.16 KB | None | 0 0
  1. #       LM² - Forge List
  2. #       Data 29/08/17
  3. #   Criado por LeonMM
  4. # Necessário para o LM² - Forge
  5. class Forge_List < Window_Selectable
  6.   include LMM_Forge
  7.   attr_accessor :recipeS
  8.   def initialize
  9.     super(230, 110, 152, 152, 30)
  10.     self.windowskin = RPG::Cache.windowskin('Windowskin03')
  11.     @scrollbar = Scroll_Bar.new(self, 5)
  12.     self.visible = self.active = false
  13.     @recipeS = 0
  14.   end
  15.   def trigger
  16.     super
  17.     self.index = @recipeS
  18.   end  
  19.   def recipe
  20.     return @data[self.index]
  21.   end
  22.   def refresh
  23.     if self.contents != nil
  24.       self.contents.dispose
  25.       self.contents = nil
  26.     end
  27.     @data = []
  28.     for i in 0...RECIPES.size
  29.       @data <<  RECIPES[i]
  30.     end
  31.     @item_max = @data.size
  32.     if @item_max > 0
  33.       self.contents = Bitmap.new(width - 32, row_max * @spacing)
  34.       for i in 0...@item_max
  35.         draw_item(i)
  36.       end
  37.     end
  38.   end
  39.   def draw_item(index)
  40.     recipe = @data[index]
  41.     cursor_width = contents.width / @column_max
  42.     x = 15
  43.     y = index / @column_max * @spacing
  44.     rect = Rect.new(26, y+2, 1, 26)
  45.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 100))
  46.     if @recipeS == index
  47.       self.contents.font.color = $windows[:forge].check_ing ? PCOLOR : NCOLOR
  48.     else
  49.       self.contents.font.color = normal_color
  50.     end  
  51.     case recipe[0][0]
  52.       when 0  
  53.         desc = $data_items[recipe[0][1]].name
  54.         recicon = RPG::Cache.icon($data_items[recipe[0][1]].icon_name)
  55.       when 1
  56.         desc = $data_weapons[recipe[0][1]].name
  57.         recicon = RPG::Cache.icon($data_weapons[recipe[0][1]].icon_name)
  58.       when 2        
  59.         desc = $data_armors[recipe[0][1]].name
  60.         recicon = RPG::Cache.icon($data_armors[recipe[0][1]].icon_name)
  61.     end    
  62.     self.contents.draw_text(30, y, 90, 24, desc, 0)
  63.     self.contents.blt(1,y+2, recicon, Rect.new(0, 0, 24, 24))
  64.   end
  65.   def update
  66.     super
  67.     if self.index >= 0 and recipe
  68.       select_recipe
  69.     end
  70.   end
  71.   def select_recipe
  72.     return unless Input.trigger?(Input::Key['Mouse Left'])
  73.     return unless in_area?(0, 16)
  74.     @recipeS = self.index
  75.     refresh
  76.     $windows[:forge].refresh
  77.   end  
  78. end
Add Comment
Please, Sign In to add comment