Advertisement
pigu_6

XS| Icon item

Dec 16th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.21 KB | None | 0 0
  1. #==============================================================================
  2. # XaiL System - Icon Item
  3. # Author: Nicke
  4. # Created: 09/04/2012
  5. # Edited: 01/11/2012
  6. # Version: 1.0f
  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 the item list to display icons as items 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 = false
  46.  
  47. # REQ_ICONS[id] = icon_id
  48. # Set the req icon_id. (0 to disable)
  49. # Only used if XS - Equip Requirements is installed.
  50. REQ_ICONS = []
  51. REQ_ICONS[0] = 4143 # LVL
  52. REQ_ICONS[1] = 4145 # ATK
  53. REQ_ICONS[2] = 4150 # DEF
  54. REQ_ICONS[3] = 4147 # MAGIC
  55. REQ_ICONS[4] = 4148 # RES
  56. REQ_ICONS[5] = 4140 # AGL
  57. REQ_ICONS[6] = 4131 # LUK
  58. REQ_ICONS[7] = 4149 # HP
  59. REQ_ICONS[8] = 4132 # MP
  60.  
  61. # REQ_VOCABS = true/false
  62. # Enable or disable vocabs for requirement stats.
  63. REQ_VOCABS = false
  64.  
  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.  
  73. alias xail_item_icon_win_help_init initialize
  74. def initialize(line_number = 2)
  75. # // Method to initialize window help.
  76. num = XAIL::ICON_ITEM::REQ_VOCABS ? 5 : 4
  77. line_number = $imported["XAIL-EQUIP-REQ"] ? num : 2 if SceneManager.scene_is?(Scene_Item)
  78. xail_item_icon_win_help_init(line_number)
  79. end
  80.  
  81. def set_item_help(item)
  82. # // Method to set the item for window help.
  83. contents.font.name = XAIL::ICON_ITEM::FONT[0]
  84. contents.font.bold = XAIL::ICON_ITEM::FONT[3]
  85. contents.font.shadow = XAIL::ICON_ITEM::FONT[4]
  86. contents.font.out_color = Color.new(0,0,0,255)
  87. if item
  88. new_line = "\n"
  89. icon = XAIL::ICON_ITEM::DISPLAY[0] ? '\i[' + item.icon_index.to_s + ']' : ""
  90. name = XAIL::ICON_ITEM::DISPLAY[1] ? '\c[2] »» ' + item.name + '\c[0]' : ""
  91. weight = $imported["XAIL-INVENTORY-WEIGHT"] ? weight = " - Weight: #{item.weight}." : ""
  92. durability = $imported["XAIL-ITEM-DURABILITY"] ? durability = " - Durability: #{item.durability} / #{item.max_durability}." : ""
  93. if $imported["XAIL-EQUIP-REQ"]
  94. @req = '\c[4]»'
  95. req_skills = '\c[5]» Req Skills: '
  96. req_items = ' \c[6]» Req Items: '
  97. if XAIL::ICON_ITEM::REQ_VOCABS
  98. @req2 = '\c[4]»'
  99. 4.times {|i| @req += get_icon_equip_req(item, i)}
  100. 5.times {|i| @req2 += get_icon_equip_req(item, i+4)}
  101. @req2 += '\c[0]'
  102. else
  103. @req2 = ""
  104. 9.times {|i| @req += get_icon_equip_req(item, i)}
  105. end
  106. @req += '\c[0]'
  107. unless item.req_equipment_skills == []
  108. item.req_equipment_skills.size.times {|i|
  109. req_skills += get_icon_equip_req_items(item, i)
  110. }
  111. else
  112. req_skills += "None."
  113. end
  114. req_skills += '\c[0]'
  115. unless item.req_equipment_weapons == []
  116. item.req_equipment_weapons.size.times {|i|
  117. req_items += get_icon_equip_req_items(item, i, :weapons)
  118. }
  119. end
  120. unless item.req_equipment_armors == []
  121. item.req_equipment_armors.size.times {|i|
  122. req_items += get_icon_equip_req_items(item, i, :armors)
  123. }
  124. end
  125. req_items += '\c[0]'
  126. else
  127. @req, @req2, req_skills, req_items = ""
  128. end
  129. if item.is_a?(RPG::Item) && XAIL::ICON_ITEM::DISPLAY[2]
  130. consumable = item.consumable ? " (Consumable)" : " (Non-consumable)"
  131. else
  132. consumable = ""
  133. end
  134. desc = XAIL::ICON_ITEM::DISPLAY[3] ? item.description : ""
  135. if $imported["XAIL-EQUIP-REQ"]
  136. @req
  137. req = XAIL::ICON_ITEM::REQ_VOCABS ? @req + new_line +
  138. @req2 + new_line : @req + new_line
  139. item_text = icon + name + weight + durability + new_line +
  140. req + req_skills + req_items + new_line + desc
  141. else
  142. item_text = icon + name + weight + durability + new_line + desc
  143. end
  144. else
  145. item_text = ""
  146. end
  147. set_text(item_text)
  148. end
  149.  
  150. def get_icon_item_req(item, id)
  151. # // Method to get requirements.
  152. # // Only used if XS - Equip Requirements is installed.
  153. case id
  154. when 0 ; name = Vocab::level
  155. when 1 ; name = Vocab::param(2)
  156. when 2 ; name = Vocab::param(3)
  157. when 3 ; name = Vocab::param(4)
  158. when 4 ; name = Vocab::param(5)
  159. when 5 ; name = Vocab::param(6)
  160. when 6 ; name = Vocab::param(7)
  161. when 7 ; name = Vocab::param(0)
  162. when 8 ; name = Vocab::param(1)
  163. end
  164. name = XAIL::ICON_ITEM::REQ_VOCABS ? name + " = " : "="
  165. return '\i[' + XAIL::ICON_ITEM::REQ_ICONS[id].to_s + ']' + name.to_s + item.req_equipment[id].to_s + " "
  166. end
  167.  
  168. def get_icon_equip_req_items(item, id, type = :skills)
  169. # // Method to get skill, weapon or armor requirements.
  170. # // Only used if XS - Equip Requirements is installed.
  171. case type
  172. when :skills
  173. return '\i[' + $data_skills[item.req_equipment_skills[id]].icon_index.to_s + ']'
  174. when :weapons
  175. return '\i[' + $data_weapons[item.req_equipment_weapons[id]].icon_index.to_s + ']'
  176. when :armors
  177. return '\i[' + $data_armors[item.req_equipment_weapons[id]].icon_index.to_s + ']'
  178. end
  179. end
  180.  
  181.  
  182. end
  183. #==============================================================================#
  184. # ** Window_ItemList_Icon
  185. #==============================================================================#
  186. class Window_ItemList_Icon < Window_ItemList
  187.  
  188. def col_max
  189. # // Method to get col_max.
  190. return 14
  191. end
  192.  
  193. def spacing
  194. # // Method to get spacing.
  195. return 14
  196. end
  197.  
  198. def item_width
  199. # // Method to get item_width.
  200. return 24
  201. end
  202.  
  203. def item_height
  204. # // Method to get item_height.
  205. return 24
  206. end
  207.  
  208. def row_max
  209. # // Method to get row_max.
  210. return item_max
  211. end
  212.  
  213. def update_help
  214. # // Method to update help details.
  215. @help_window.set_item_help(item)
  216. end
  217.  
  218. def item_rect(index)
  219. # // Method to draw item rect.
  220. rect = Rect.new
  221. rect.width = item_width
  222. rect.height = item_height
  223. rect.x = index % col_max * (item_width + spacing)
  224. rect.y = index / col_max * (item_height + 3)
  225. rect
  226. end
  227.  
  228. def page_row_max
  229. # // Method to define page row max.
  230. return 1
  231. end
  232.  
  233. def scan_items(item)
  234. # // Method to scan the notes for the items.
  235. item.note.scan(/<category[:]*\s*(.+)>/i)
  236. return $1 if !$1.nil?
  237. end
  238.  
  239. def draw_item(index)
  240. # // Method override to draw item.
  241. item = @data[index]
  242. if item
  243. rect = item_rect(index)
  244. draw_item_rect(index, item, rect, rect.x, rect.y)
  245. draw_item_number(rect, item) if $game_party.item_number(item) > 1 and XAIL::ICON_ITEM::DISPLAY[3]
  246. end
  247. end
  248.  
  249. def draw_item_icon(icon_index, x, y, enabled = true)
  250. # // Method to draw icon.
  251. bitmap = Cache.system("Iconset")
  252. rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  253. contents.blt(x, y, bitmap, rect, enabled ? 255 : 75)
  254. end
  255.  
  256. def draw_item_rect(index, item, rect, x, y)
  257. # // Method to draw rect.
  258. outline = rect.clone
  259. outline.width = rect.width + 1
  260. outline.height = rect.height + 1
  261. contents.fill_rect(outline,Color.new(255,255,255,80))
  262. unless XAIL::ICON_ITEM::NO_CATEGORIES
  263. case scan_items(item)
  264. when "health"
  265. color = Color.new(150,0,0,45)
  266. when "mana"
  267. color = Color.new(0,0,150,45)
  268. when "cure"
  269. color = Color.new(0,130,0,45)
  270. when "elixir"
  271. color = Color.new(250,250,0,45)
  272. when "herbs"
  273. color = Color.new(0,215,0,45)
  274. when nil
  275. color = Color.new(0,0,0,128)
  276. else
  277. color = Color.new(0,0,0,128)
  278. end
  279. else
  280. color = Color.new(0,0,0,128)
  281. end
  282. color = enable?(item) ? color : Color.new(0,0,0,128)
  283. contents.fill_rect(rect, color)
  284. draw_item_icon(item.icon_index, x + 1, y, enable?(item))
  285. end
  286.  
  287. def check_color(color, enabled = true)
  288. # // Method to set the color and alpha.
  289. contents.font.color.set(color)
  290. contents.font.color.alpha = 95 unless enabled
  291. end
  292.  
  293. def draw_item_number(rect, item)
  294. # // Method to draw the item number.
  295. rect.y += 8
  296. if $game_party.item_number(item) < 10
  297. rect.x -= 2
  298. end
  299. contents.font = Font.new(XAIL::ICON_ITEM::FONT[0], XAIL::ICON_ITEM::FONT[1])
  300. check_color(XAIL::ICON_ITEM::FONT[2], enable?(item))
  301. contents.font.bold = XAIL::ICON_ITEM::FONT[3]
  302. contents.font.shadow = XAIL::ICON_ITEM::FONT[4]
  303. contents.font.out_color = Color.new(0,0,0,255)
  304. draw_text(rect, sprintf("%2d", $game_party.item_number(item)), 1)
  305. reset_font_settings
  306. end
  307.  
  308. end
  309. #==============================================================================#
  310. # ** Scene_Item
  311. #==============================================================================#
  312. class Scene_Item < Scene_ItemBase
  313.  
  314. def create_item_window
  315. # // Method override create the item list window.
  316. wy = @category_window.y + @category_window.height
  317. wh = Graphics.height - wy
  318. @item_window = Window_ItemList_Icon.new(0, wy, Graphics.width, wh)
  319. @item_window.viewport = @viewport
  320. @item_window.help_window = @help_window
  321. @item_window.set_handler(:ok, method(:on_item_ok))
  322. @item_window.set_handler(:cancel, method(:on_item_cancel))
  323. @category_window.item_window = @item_window
  324. end
  325.  
  326. end # END OF FILE
  327.  
  328. #=*==========================================================================*=#
  329. # ** END OF FILE
  330. #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement