IceDragon200

[VXA][IED]XaiL System - Icon Item

Apr 10th, 2012
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.26 KB | None | 0 0
  1. #==============================================================================
  2. #   XaiL System - Icon Item
  3. #   Author: Nicke
  4. #   Created: 09/04/2012
  5. #   Edited: 09/04/2012
  6. #   Version: 1.0
  7. #==============================================================================
  8. # Instructions
  9. # -----------------------------------------------------------------------------
  10. # To install this script, open up your script editor and copy/paste this script
  11. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  12. #
  13. # This script changes Item Scene to display a icon as command instead.
  14. # There is also a category feature which allows you to change the background
  15. # color of each items/weapons/armour etc.
  16. #
  17. # Right now there is a setup of 6 categories one being the default one.
  18. # You can easily edit the draw_item_rect method to add new ones.
  19. #
  20. # To setup a category for a item use the following code in the note field of the
  21. # item:
  22. # <category health>
  23. # or
  24. # <category mana>
  25. # The above will only work if you did not edit the category list.
  26. #
  27. # *** Only for RPG Maker VX Ace. ***
  28. #==============================================================================
  29. ($imported ||= {})["XAIL-ICON-SKILLS"] = true
  30. module XAIL
  31.   module ICON_ITEM
  32.   #--------------------------------------------------------------------------#
  33.   # * Settings
  34.   #--------------------------------------------------------------------------#
  35.     # FONT = [name, size, color, bold, shadow]
  36.     FONT = [["Anklada™", "Verdana"], 16, Color.new(255,225,255), true, true]
  37.    
  38.     # Show/hide option for the item scene.
  39.     # DISPLAY = [show_help_icon, show_name, show_description,
  40.     # show_consumable, show_amount]
  41.     DISPLAY = [true, true, true, true, true]
  42.    
  43.     # If this is false every item will have the same default black color.
  44.     # NO_CATEGORIES = true/false
  45.     NO_CATEGORIES = true
  46.    
  47.   end
  48. end
  49. class Rect
  50.   # // Rect - IceDragon Surface Xpansion
  51.   def contract!( n=1 )
  52.     contract_horz!(n)
  53.     contract_vert!(n)
  54.     return self
  55.   end  
  56.   def contract_horz!( n=1 )
  57.     self.x += n
  58.     self.width -= n*2
  59.     return self
  60.   end  
  61.   def contract_vert!( n=1 )
  62.     self.y += n
  63.     self.height -= n*2
  64.     return self
  65.   end
  66. end  
  67. # *** Don't edit below unless you know what you are doing. ***
  68. #==============================================================================#
  69. # ** Window_Help
  70. #==============================================================================#
  71. class Window_Help < Window_Base
  72.   def set_item_help(item)
  73.     # // Method to set the item for window help.
  74.     contents.font.name = XAIL::ICON_ITEM::FONT[0]
  75.     contents.font.bold = XAIL::ICON_ITEM::FONT[3]
  76.     contents.font.shadow = XAIL::ICON_ITEM::FONT[4]
  77.     contents.font.out_color = Color.new(0,0,0,255)
  78.     if item
  79.       icon = XAIL::ICON_ITEM::DISPLAY[0] ? '\i[' + item.icon_index.to_s + ']' : ""
  80.       name = XAIL::ICON_ITEM::DISPLAY[1] ? '\c[2] »» ' + item.name + '\c[0]' : ""
  81.       if item.is_a?(RPG::Item) and XAIL::ICON_ITEM::DISPLAY[2]
  82.         consumable = item.consumable ? " (Consumable)" : " (Non-consumable)"
  83.       else
  84.         consumable = ""
  85.       end
  86.       desc = XAIL::ICON_ITEM::DISPLAY[3] ? item.description : ""
  87.       new_line = "\n"
  88.       item_text = icon + name + consumable + new_line + desc
  89.     else
  90.       item_text = ""
  91.     end
  92.     set_text(item_text)
  93.   end
  94. end
  95. #==============================================================================#
  96. # ** Window_ItemList_Icon
  97. #==============================================================================#
  98. class Window_ItemList_Icon < Window_ItemList
  99.   #alias xail_itemlist_win_col_max col_max # // No reason to alias
  100.   def col_max(*args, &block)
  101.     return 14
  102.   end
  103.   #alias xail_itemlist_win_spacing spacing # // No reason to alias
  104.   def spacing(*args, &block)
  105.     return 8
  106.   end
  107.   def item_height
  108.     return 26
  109.   end  
  110.   def item_width
  111.     return 26
  112.   end  
  113.   def update_help(*args, &block)
  114.     # // Method to update help details.
  115.     @help_window.set_item_help(item)
  116.   end
  117.   def refresh
  118.     # // Method to refresh the window.
  119.     contents.clear
  120.     make_item_list
  121.     create_contents
  122.     draw_all_items
  123.   end
  124.   def scan_items(item)
  125.     # // Method to scan the notes for the items.
  126.     item.note.scan(/<category[:]*\s*(.+)>/i)
  127.     return $1
  128.   end
  129.   def draw_item(index)
  130.     # // Method override to draw item.
  131.     item = @data[index]
  132.     if item
  133.       rect = item_rect(index).contract(1)
  134.       draw_item_rect(index, item, rect, rect.x, rect.y)
  135.       draw_item_number(rect, item) if $game_party.item_number(item) > 1 and XAIL::ICON_ITEM::DISPLAY[3]
  136.     end
  137.   end
  138.   def draw_item_icon(icon_index, x, y, enabled = true)
  139.     # // Method to draw icon.
  140.     bitmap = Cache.system("Iconset")
  141.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  142.     contents.blt(x, y, bitmap, rect, enabled ? 255 : 75)
  143.   end
  144.   def draw_item_rect(index, item, rect, x, y)
  145.     # // Method to draw rect.
  146.     outline = rect.clone
  147.     outline.width = rect.width + 1
  148.     outline.height = rect.height + 1
  149.     contents.fill_rect(outline,Color.new(255,255,255,80))
  150.     if XAIL::ICON_ITEM::NO_CATEGORIES
  151.       case scan_items(item)
  152.       when "health"
  153.         color = Color.new(150,0,0,45)
  154.       when "mana"
  155.         color = Color.new(0,0,150,45)
  156.       when "cure"
  157.        color = Color.new(0,130,0,45)
  158.       when "elixir"
  159.         color = Color.new(250,250,0,45)
  160.       when "herbs"
  161.         color = Color.new(0,215,0,45)
  162.       when nil
  163.         color = Color.new(0,0,0,128)
  164.       else
  165.        color = Color.new(0,0,0,128)
  166.       end
  167.     else
  168.       color = Color.new(0,0,0,128)
  169.     end
  170.     color = enable?(item) ? color : Color.new(0,0,0,128)
  171.     contents.fill_rect(rect, color)
  172.     draw_item_icon(item.icon_index, x + 1, y, enable?(item))
  173.   end
  174.   def check_color(color, enabled = true)
  175.      # // Method to set the color and alpha.
  176.     contents.font.color.set(color)
  177.     contents.font.color.alpha = 95 unless enabled
  178.   end
  179.   def draw_item_number(rect, item)
  180.     # // Method to draw the item number.
  181.     rect.y += 15
  182.     if $game_party.item_number(item) < 10
  183.       rect.x -= 2
  184.     end
  185.     contents.font = Font.new(XAIL::ICON_ITEM::FONT[0], XAIL::ICON_ITEM::FONT[1])
  186.     check_color(XAIL::ICON_ITEM::FONT[2], enable?(item))
  187.     contents.font.bold = XAIL::ICON_ITEM::FONT[3]
  188.     contents.font.shadow = XAIL::ICON_ITEM::FONT[4]
  189.     contents.font.out_color = Color.new(0,0,0,255)
  190.     draw_text(rect, sprintf("%2d", $game_party.item_number(item)), 1)
  191.     reset_font_settings
  192.   end
  193. end
  194. class Scene_Item < Scene_ItemBase
  195.   def create_item_window
  196.     # // Method override create the item list window.
  197.     wy = @category_window.y + @category_window.height
  198.     wh = Graphics.height - wy
  199.     @item_window = Window_ItemList_Icon.new(0, wy, Graphics.width, wh)
  200.     @item_window.viewport = @viewport
  201.     @item_window.help_window = @help_window
  202.     @item_window.set_handler(:ok,     method(:on_item_ok))
  203.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  204.     @category_window.item_window = @item_window
  205.   end
  206. end # END OF FILE
  207. #=*==========================================================================*=#
  208. # ** END OF FILE
  209. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment