cooldoode325

YEA- Item Menu

Mar 22nd, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.92 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Ace Item Menu v1.02
  4. # -- Last Updated: 2012.01.05
  5. # -- Level: Normal, Hard
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-ItemMenu"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.01.05 - Compatibility Update with Equip Dynamic Stats.
  17. # 2012.01.03 - Started Script and Finished.
  18. # - Compatibility Update with Ace Menu Engine.
  19. #
  20. #==============================================================================
  21. # ▼ Introduction
  22. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  23. # The Ace Item Menu offers more item categorization control and a better layout
  24. # that simulatenously provides information regarding the items to the player,
  25. # while keeping a good amount of the item list visible on screen at once. The
  26. # script can also be customized to rearrange commands and categories.
  27. #
  28. #==============================================================================
  29. # ▼ Instructions
  30. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31. # To install this script, open up your script editor and copy/paste this script
  32. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  33. #
  34. # -----------------------------------------------------------------------------
  35. # Item Notetags - These notetags go in the item notebox in the database.
  36. # -----------------------------------------------------------------------------
  37. # <category: string>
  38. # Places this object into the item category for "string". Whenever the selected
  39. # category is highlighted in the Ace Item Menu command window, this object will
  40. # be included and shown in the item window.
  41. #
  42. # <image: string>
  43. # Uses a picture from Graphics\Pictures\ of your RPG Maker VX Ace Project's
  44. # directory with the filename of "string" (without the extension) as the image
  45. # picture shown in the Ace Item Menu.
  46. #
  47. # -----------------------------------------------------------------------------
  48. # Weapon Notetags - These notetags go in the weapon notebox in the database.
  49. # -----------------------------------------------------------------------------
  50. # <category: string>
  51. # Places this object into the item category for "string". Whenever the selected
  52. # category is highlighted in the Ace Item Menu command window, this object will
  53. # be included and shown in the item window.
  54. #
  55. # <image: string>
  56. # Uses a picture from Graphics\Pictures\ of your RPG Maker VX Ace Project's
  57. # directory with the filename of "string" (without the extension) as the image
  58. # picture shown in the Ace Item Menu.
  59. #
  60. # -----------------------------------------------------------------------------
  61. # Armour Notetags - These notetags go in the armour notebox in the database.
  62. # -----------------------------------------------------------------------------
  63. # <category: string>
  64. # Places this object into the item category for "string". Whenever the selected
  65. # category is highlighted in the Ace Item Menu command window, this object will
  66. # be included and shown in the item window.
  67. #
  68. # <image: string>
  69. # Uses a picture from Graphics\Pictures\ of your RPG Maker VX Ace Project's
  70. # directory with the filename of "string" (without the extension) as the image
  71. # picture shown in the Ace Item Menu.
  72. #
  73. #==============================================================================
  74. # ▼ Compatibility
  75. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  76. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  77. # it will run with RPG Maker VX without adjusting.
  78. #
  79. #==============================================================================
  80.  
  81. module YEA
  82. module ITEM
  83.  
  84. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  85. # - Item Command Settings -
  86. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  87. # This array adjusts what options appear in the initial item command window
  88. # before the items are split into separate categories. Add commands, remove
  89. # commands, or rearrange them. Here's a list of which does what:
  90. #
  91. # -------------------------------------------------------------------------
  92. # :command Description
  93. # -------------------------------------------------------------------------
  94. # :item Opens up the various item categories. Default.
  95. # :weapon Opens up the various weapon categories. Default.
  96. # :armor Opens up the various armour categories. Default.
  97. # :key_item Shows a list of the various key items. Default.
  98. #
  99. # :gogototori Requires Kread-EX's Go Go Totori Synthesis.
  100. #
  101. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  102. COMMANDS =[
  103. :item, # Opens up the various item categories. Default.
  104. :weapon, # Opens up the various weapon categories. Default.
  105. :armor, # Opens up the various armour categories. Default.
  106. :key_item, # Shows a list of the various key items. Default.
  107. # :custom1, # Custom command 1.
  108. # :custom2, # Custom command 2.
  109. ] # Do not remove this.
  110.  
  111. #--------------------------------------------------------------------------
  112. # - Item Custom Commands -
  113. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  114. # For those who use scripts to that may produce unique effects for the item
  115. # scene, use this hash to manage the custom commands for the Item Command
  116. # Window. You can disable certain commands or prevent them from appearing
  117. # by using switches. If you don't wish to bind them to a switch, set the
  118. # proper switch to 0 for it to have no impact.
  119. #--------------------------------------------------------------------------
  120. CUSTOM_ITEM_COMMANDS ={
  121. # :command => ["Display Name", EnableSwitch, ShowSwitch, Handler Method],
  122. :custom1 => [ "Custom Name", 0, 0, :command_name1],
  123. :custom2 => [ "Custom Text", 0, 0, :command_name2],
  124. } # Do not remove this.
  125.  
  126. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  127. # - Item Type Settings -
  128. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  129. # These arrays adjusts and shows the various item types shown for Items,
  130. # Weapons, and Armours. Note that when using :category symbols, the
  131. # specific category shown will be equal to the text used for the Display
  132. # and the included item must contain a category equal to the Display name.
  133. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  134. # This array contains the order for the Item categories.
  135. ITEM_TYPES =[
  136. # [ :symbol, "Display"],
  137. [ :field, "Field"], # Shows Menu-usable items.
  138. [ :battle, "Battle"], # Shows Battle-usable items.
  139. #[:category, "Special"], # Categorized by <category: string>
  140. #[:category,"Ingredient"], # Categorized by <category: string>
  141. [:key_item, "Key Item"], # Shows all key items.
  142. [ :all, "All"], # Shows all usable items.
  143. ] # Do not remove this.
  144.  
  145. # This array contains the order for the Weapon categories.
  146. WEAPON_TYPES =[
  147. # [ :symbol, "Display"],
  148. #[ :types, "WPNTYPES"],
  149. [ :category, "Hand Axe"],
  150. [ :category, "Battle Axe"],
  151. [ :category, "Short Bow"],
  152. [ :category, "Long Bow"],
  153. [ :category, "Crossbow"],
  154. [ :category, "Dagger"],
  155. [ :category, "Small Hammer"],
  156. [ :category, "Mace"],
  157. [ :category, "Spear"],
  158. [ :category, "Staff"],
  159. [ :category, "Short Sword"],
  160. [ :category, "Long Sword"],
  161. [ :category, "Broad Sword"],
  162. [ :category, "Great Sword"],
  163. [ :category, "Javelin"],
  164. [ :category, "Throwable"],
  165. [ :category, "Claw"],
  166. [ :category, "Warhammer"],
  167. [ :category, "Light Shield"],
  168. [ :category, "Heavy Shield"],
  169. [ :all, "All"], # Shows all weapons.
  170. ] # Do not remove this.
  171.  
  172. # This array contains the order for the Armour categories.
  173. ARMOUR_TYPES =[
  174. # [ :symbol, "Display"],
  175. #[ :slots, "ARMSLOTS"],
  176. [ :category, "Head"],
  177. [ :category, "Torso"],
  178. [ :category, "Arms"],
  179. [ :category, "Waist"],
  180. [ :category, "Legs"],
  181. [ :category, "Feet"],
  182. [ :category, "Tome"],
  183. [ :category, "Ring"],
  184. [ :category, "Gem"],
  185. [ :category, "Orb"],
  186. [ :category, "Badge"],# Lists all of the individual armour slots.
  187. [ :all, "All"], # Shows all armours.
  188. ] # Do not remove this.
  189.  
  190. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  191. # - Item Status Settings -
  192. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  193. # The item status window displays information about the item in detail.
  194. # Adjust the settings below to change the way the status window appears.
  195. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  196. STATUS_FONT_SIZE = 20 # Font size used for status window.
  197. MAX_ICONS_DRAWN = 10 # Maximum number of icons drawn for states.
  198.  
  199. # The following adjusts the vocabulary used for the status window. Each
  200. # of the vocabulary settings are self explanatory.
  201. VOCAB_STATUS ={
  202. :empty => "---", # Text used when nothing is shown.
  203. :hp_recover => "HP Heal", # Text used for HP Recovery.
  204. :mp_recover => "MP Heal", # Text used for MP Recovery.
  205. #:tp_recover => "TP Heal", # Text used for TP Recovery.
  206. #:tp_gain => "TP Gain", # Text used for TP Gain.
  207. :applies => "Applies", # Text used for applied states and buffs.
  208. :removes => "Removes", # Text used for removed states and buffs.
  209. } # Do not remove this.
  210.  
  211. end # ITEM
  212. end # YEA
  213.  
  214. #==============================================================================
  215. # ▼ Editting anything past this point may potentially result in causing
  216. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  217. # halitosis so edit at your own risk.
  218. #==============================================================================
  219.  
  220. module YEA
  221. module REGEXP
  222. module BASEITEM
  223.  
  224. CATEGORY = /<(?:CATEGORIES|category):[ ](.*)>/i
  225. IMAGE = /<(?:IMAGE|image):[ ](.*)>/i
  226.  
  227. end # BASEITEM
  228. end # REGEXP
  229. end # YEA
  230.  
  231. #==============================================================================
  232. # ■ Numeric
  233. #==============================================================================
  234.  
  235. class Numeric
  236.  
  237. #--------------------------------------------------------------------------
  238. # new method: group_digits
  239. #--------------------------------------------------------------------------
  240. unless $imported["YEA-CoreEngine"]
  241. def group; return self.to_s; end
  242. end # $imported["YEA-CoreEngine"]
  243.  
  244. end # Numeric
  245.  
  246. #==============================================================================
  247. # ■ Vocab
  248. #==============================================================================
  249.  
  250. module Vocab
  251.  
  252. #--------------------------------------------------------------------------
  253. # new method: self.item_status
  254. #--------------------------------------------------------------------------
  255. def self.item_status(type)
  256. return YEA::ITEM::VOCAB_STATUS[type]
  257. end
  258.  
  259. end # Vocab
  260.  
  261. #==============================================================================
  262. # ■ DataManager
  263. #==============================================================================
  264.  
  265. module DataManager
  266.  
  267. #--------------------------------------------------------------------------
  268. # alias method: load_database
  269. #--------------------------------------------------------------------------
  270. class <<self; alias load_database_aim load_database; end
  271. def self.load_database
  272. load_database_aim
  273. load_notetags_aim
  274. end
  275.  
  276. #--------------------------------------------------------------------------
  277. # new method: load_notetags_aim
  278. #--------------------------------------------------------------------------
  279. def self.load_notetags_aim
  280. groups = [$data_items, $data_weapons, $data_armors]
  281. for group in groups
  282. for obj in group
  283. next if obj.nil?
  284. obj.load_notetags_aim
  285. end
  286. end
  287. end
  288.  
  289. end # DataManager
  290.  
  291. #==============================================================================
  292. # ■ RPG::BaseItem
  293. #==============================================================================
  294.  
  295. class RPG::BaseItem
  296.  
  297. #--------------------------------------------------------------------------
  298. # public instance variables
  299. #--------------------------------------------------------------------------
  300. attr_accessor :category
  301. attr_accessor :image
  302.  
  303. #--------------------------------------------------------------------------
  304. # common cache: load_notetags_aim
  305. #--------------------------------------------------------------------------
  306. def load_notetags_aim
  307. @category = []
  308. #---
  309. self.note.split(/[\r\n]+/).each { |line|
  310. case line
  311. #---
  312. when YEA::REGEXP::BASEITEM::CATEGORY
  313. @category.push($1.upcase.to_s)
  314. when YEA::REGEXP::BASEITEM::IMAGE
  315. @image = $1.to_s
  316. end
  317. } # self.note.split
  318. #---
  319. end
  320.  
  321. end # RPG::BaseItem
  322.  
  323. #==============================================================================
  324. # ■ Game_Temp
  325. #==============================================================================
  326.  
  327. class Game_Temp
  328.  
  329. #--------------------------------------------------------------------------
  330. # public instance variables
  331. #--------------------------------------------------------------------------
  332. attr_accessor :scene_item_index
  333. attr_accessor :scene_item_oy
  334.  
  335. end # Game_Temp
  336.  
  337. #==============================================================================
  338. # ■ Window_ItemList
  339. #==============================================================================
  340.  
  341. class Window_ItemList < Window_Selectable
  342.  
  343. #--------------------------------------------------------------------------
  344. # overwrite method: draw_item
  345. #--------------------------------------------------------------------------
  346. def draw_item(index)
  347. item = @data[index]
  348. return if item.nil?
  349. rect = item_rect(index)
  350. rect.width -= 4
  351. draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
  352. draw_item_number(rect, item)
  353. end
  354.  
  355. end # Window_ItemList
  356.  
  357. #==============================================================================
  358. # ■ Window_ItemCommand
  359. #==============================================================================
  360.  
  361. class Window_ItemCommand < Window_Command
  362.  
  363. #--------------------------------------------------------------------------
  364. # public instance variables
  365. #--------------------------------------------------------------------------
  366. attr_reader :item_window
  367.  
  368. #--------------------------------------------------------------------------
  369. # initialize
  370. #--------------------------------------------------------------------------
  371. def initialize(x, y)
  372. super(x, y)
  373. end
  374.  
  375. #--------------------------------------------------------------------------
  376. # window_width
  377. #--------------------------------------------------------------------------
  378. def window_width; return 160; end
  379.  
  380. #--------------------------------------------------------------------------
  381. # visible_line_number
  382. #--------------------------------------------------------------------------
  383. def visible_line_number; return 4; end
  384.  
  385. #--------------------------------------------------------------------------
  386. # process_ok
  387. #--------------------------------------------------------------------------
  388. def process_ok
  389. $game_temp.scene_item_index = index
  390. $game_temp.scene_item_oy = self.oy
  391. super
  392. end
  393.  
  394. #--------------------------------------------------------------------------
  395. # make_command_list
  396. #--------------------------------------------------------------------------
  397. def make_command_list
  398. for command in YEA::ITEM::COMMANDS
  399. case command
  400. #--- Default Commands ---
  401. when :item
  402. add_command(Vocab::item, :item)
  403. when :weapon
  404. add_command(Vocab::weapon, :weapon)
  405. when :armor
  406. add_command(Vocab::armor, :armor)
  407. when :key_item
  408. add_command(Vocab::key_item, :key_item)
  409. #--- Imported ---
  410. when :gogototori
  411. next unless $imported["KRX-AlchemicSynthesis"]
  412. process_custom_command(command)
  413. #--- Custom Commands ---
  414. else
  415. process_custom_command(command)
  416. end
  417. end
  418. end
  419.  
  420. #--------------------------------------------------------------------------
  421. # process_custom_command
  422. #--------------------------------------------------------------------------
  423. def process_custom_command(command)
  424. return unless YEA::ITEM::CUSTOM_ITEM_COMMANDS.include?(command)
  425. show = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][2]
  426. continue = show <= 0 ? true : $game_switches[show]
  427. return unless continue
  428. text = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][0]
  429. switch = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][1]
  430. enabled = switch <= 0 ? true : $game_switches[switch]
  431. add_command(text, command, enabled)
  432. end
  433.  
  434. #--------------------------------------------------------------------------
  435. # update
  436. #--------------------------------------------------------------------------
  437. def update
  438. super
  439. return unless self.active
  440. @item_window.category = current_symbol if @item_window
  441. end
  442.  
  443. #--------------------------------------------------------------------------
  444. # item_window=
  445. #--------------------------------------------------------------------------
  446. def item_window=(item_window)
  447. @item_window = item_window
  448. update
  449. end
  450.  
  451. end # Window_ItemCommand
  452.  
  453. #==============================================================================
  454. # ■ Window_ItemType
  455. #==============================================================================
  456.  
  457. class Window_ItemType < Window_Command
  458.  
  459. #--------------------------------------------------------------------------
  460. # public instance variables
  461. #--------------------------------------------------------------------------
  462. attr_reader :item_window
  463.  
  464. #--------------------------------------------------------------------------
  465. # initialize
  466. #--------------------------------------------------------------------------
  467. def initialize(x, y)
  468. super(x, y)
  469. deactivate
  470. @type = nil
  471. end
  472.  
  473. #--------------------------------------------------------------------------
  474. # window_width
  475. #--------------------------------------------------------------------------
  476. def window_width; return 160; end
  477.  
  478. #--------------------------------------------------------------------------
  479. # visible_line_number
  480. #--------------------------------------------------------------------------
  481. def visible_line_number; return 4; end
  482.  
  483. #--------------------------------------------------------------------------
  484. # reveal
  485. #--------------------------------------------------------------------------
  486. def reveal(type)
  487. @type = type
  488. refresh
  489. activate
  490. select(0)
  491. end
  492.  
  493. #--------------------------------------------------------------------------
  494. # make_command_list
  495. #--------------------------------------------------------------------------
  496. def make_command_list
  497. return if @type.nil?
  498. #---
  499. case @type
  500. when :item
  501. commands = YEA::ITEM::ITEM_TYPES
  502. when :weapon
  503. commands = YEA::ITEM::WEAPON_TYPES
  504. else
  505. commands = YEA::ITEM::ARMOUR_TYPES
  506. end
  507. #---
  508. for command in commands
  509. case command[0]
  510. #---
  511. when :types
  512. case @type
  513. when :weapon
  514. for i in 1...$data_system.weapon_types.size
  515. name = $data_system.weapon_types[i]
  516. add_command(name, :w_type, true, i)
  517. end
  518. else
  519. for i in 1...$data_system.armor_types.size
  520. name = $data_system.armor_types[i]
  521. add_command(name, :a_type, true, i)
  522. end
  523. end
  524. #---
  525. when :slots
  526. if $imported["YEA-AceEquipEngine"]
  527. maximum = 1
  528. for key in YEA::EQUIP::TYPES
  529. maximum = [maximum, key[0]].max
  530. end
  531. else
  532. maximum = 4
  533. end
  534. for i in 1..maximum
  535. name = Vocab::etype(i)
  536. add_command(name, :e_type, true, i) if name != ""
  537. end
  538. #---
  539. else
  540. add_command(command[1], command[0], true, @type)
  541. end
  542. end
  543. end
  544.  
  545. #--------------------------------------------------------------------------
  546. # update
  547. #--------------------------------------------------------------------------
  548. def update
  549. super
  550. return unless self.active
  551. @item_window.category = current_symbol if @item_window
  552. end
  553.  
  554. #--------------------------------------------------------------------------
  555. # item_window=
  556. #--------------------------------------------------------------------------
  557. def item_window=(item_window)
  558. @item_window = item_window
  559. update
  560. end
  561.  
  562. end # Window_ItemType
  563.  
  564. #==============================================================================
  565. # ■ Window_ItemList
  566. #==============================================================================
  567.  
  568. class Window_ItemList < Window_Selectable
  569.  
  570. #--------------------------------------------------------------------------
  571. # alias method: initialize
  572. #--------------------------------------------------------------------------
  573. alias window_itemlist_initialize_aim initialize
  574. def initialize(dx, dy, dw, dh)
  575. window_itemlist_initialize_aim(dx, dy, dw, dh)
  576. @ext = :none
  577. @name = ""
  578. end
  579.  
  580. #--------------------------------------------------------------------------
  581. # alias method: category=
  582. #--------------------------------------------------------------------------
  583. alias window_itemlist_category_aim category=
  584. def category=(category)
  585. if @types_window.nil?
  586. window_itemlist_category_aim(category)
  587. else
  588. return unless update_types?(category)
  589. @category = category
  590. if @types_window.active
  591. @name = @types_window.current_data[:name]
  592. @ext = @types_window.current_ext
  593. end
  594. refresh
  595. self.oy = 0
  596. end
  597. end
  598.  
  599. #--------------------------------------------------------------------------
  600. # new method: update_types?
  601. #--------------------------------------------------------------------------
  602. def update_types?(category)
  603. return true if @category != category
  604. return false unless @types_window.active
  605. if category == :category
  606. return @name != @types_window.current_data[:name]
  607. end
  608. return @ext != @types_window.current_ext
  609. end
  610.  
  611. #--------------------------------------------------------------------------
  612. # new method: types_window=
  613. #--------------------------------------------------------------------------
  614. def types_window=(window)
  615. @types_window = window
  616. end
  617.  
  618. #--------------------------------------------------------------------------
  619. # alias method: include?
  620. #--------------------------------------------------------------------------
  621. alias window_itemlist_include_aim include?
  622. def include?(item)
  623. if @types_window.nil?
  624. return window_itemlist_include_aim(item)
  625. else
  626. return ace_item_menu_include?(item)
  627. end
  628. end
  629.  
  630. #--------------------------------------------------------------------------
  631. # new method: ace_item_menu_include?
  632. #--------------------------------------------------------------------------
  633. def ace_item_menu_include?(item)
  634. case @category
  635. #---
  636. when :field
  637. return false unless item.is_a?(RPG::Item)
  638. return item.menu_ok?
  639. when :battle
  640. return false unless item.is_a?(RPG::Item)
  641. return item.battle_ok?
  642. #---
  643. when :w_type
  644. return false unless item.is_a?(RPG::Weapon)
  645. return item.wtype_id == @types_window.current_ext
  646. when :a_type
  647. return false unless item.is_a?(RPG::Armor)
  648. return item.atype_id == @types_window.current_ext
  649. when :e_type
  650. return false unless item.is_a?(RPG::Armor)
  651. return item.etype_id == @types_window.current_ext
  652. #---
  653. when :all
  654. case @types_window.current_ext
  655. when :item
  656. return item.is_a?(RPG::Item)
  657. when :weapon
  658. return item.is_a?(RPG::Weapon)
  659. else
  660. return item.is_a?(RPG::Armor)
  661. end
  662. #---
  663. when :category
  664. case @types_window.current_ext
  665. when :item
  666. return false unless item.is_a?(RPG::Item)
  667. when :weapon
  668. return false unless item.is_a?(RPG::Weapon)
  669. else
  670. return false unless item.is_a?(RPG::Armor)
  671. end
  672. return item.category.include?(@types_window.current_data[:name].upcase)
  673. #---
  674. else
  675. return window_itemlist_include_aim(item)
  676. end
  677. end
  678.  
  679. end # Window_ItemList
  680.  
  681. #==============================================================================
  682. # ■ Window_ItemStatus
  683. #==============================================================================
  684.  
  685. class Window_ItemStatus < Window_Base
  686.  
  687. #--------------------------------------------------------------------------
  688. # initialize
  689. #--------------------------------------------------------------------------
  690. def initialize(dx, dy, item_window)
  691. super(dx, dy, Graphics.width - dx, fitting_height(4))
  692. @item_window = item_window
  693. @item = nil
  694. refresh
  695. end
  696.  
  697. #--------------------------------------------------------------------------
  698. # update
  699. #--------------------------------------------------------------------------
  700. def update
  701. super
  702. update_item(@item_window.item)
  703. end
  704.  
  705. #--------------------------------------------------------------------------
  706. # update_item
  707. #--------------------------------------------------------------------------
  708. def update_item(item)
  709. return if @item == item
  710. @item = item
  711. refresh
  712. end
  713.  
  714. #--------------------------------------------------------------------------
  715. # refresh
  716. #--------------------------------------------------------------------------
  717. def refresh
  718. contents.clear
  719. reset_font_settings
  720. return draw_empty if @item.nil?
  721. contents.font.size = YEA::ITEM::STATUS_FONT_SIZE
  722. draw_item_image
  723. draw_item_stats
  724. draw_item_effects
  725. end
  726.  
  727. #--------------------------------------------------------------------------
  728. # draw_empty
  729. #--------------------------------------------------------------------------
  730. def draw_empty
  731. colour = Color.new(0, 0, 0, translucent_alpha/2)
  732. rect = Rect.new(1, 1, 94, 94)
  733. contents.fill_rect(rect, colour)
  734. dx = 96; dy = 0
  735. dw = (contents.width - 96) / 2
  736. for i in 0...8
  737. draw_background_box(dx, dy, dw)
  738. dx = dx >= 96 + dw ? 96 : 96 + dw
  739. dy += line_height if dx == 96
  740. end
  741. end
  742.  
  743. #--------------------------------------------------------------------------
  744. # draw_background_box
  745. #--------------------------------------------------------------------------
  746. def draw_background_box(dx, dy, dw)
  747. colour = Color.new(0, 0, 0, translucent_alpha/2)
  748. rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)
  749. contents.fill_rect(rect, colour)
  750. end
  751.  
  752. #--------------------------------------------------------------------------
  753. # draw_item_image
  754. #--------------------------------------------------------------------------
  755. def draw_item_image
  756. colour = Color.new(0, 0, 0, translucent_alpha/2)
  757. rect = Rect.new(1, 1, 94, 94)
  758. contents.fill_rect(rect, colour)
  759. if @item.image.nil?
  760. icon_index = @item.icon_index
  761. bitmap = Cache.system("Iconset")
  762. rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  763. target = Rect.new(0, 0, 96, 96)
  764. contents.stretch_blt(target, bitmap, rect)
  765. else
  766. bitmap = Cache.picture(@item.image)
  767. contents.blt(0, 0, bitmap, bitmap.rect, 255)
  768. end
  769. end
  770.  
  771. #--------------------------------------------------------------------------
  772. # draw_item_stats
  773. #--------------------------------------------------------------------------
  774. def draw_item_stats
  775. return unless @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  776. dx = 96; dy = 0
  777. dw = (contents.width - 96) / 2
  778. for i in 0...8
  779. draw_equip_param(i, dx, dy, dw)
  780. dx = dx >= 96 + dw ? 96 : 96 + dw
  781. dy += line_height if dx == 96
  782. end
  783. end
  784.  
  785. #--------------------------------------------------------------------------
  786. # draw_equip_param
  787. #--------------------------------------------------------------------------
  788. def draw_equip_param(param_id, dx, dy, dw)
  789. draw_background_box(dx, dy, dw)
  790. change_color(system_color)
  791. draw_text(dx+4, dy, dw-8, line_height, Vocab::param(param_id))
  792. if $imported["YEA-EquipDynamicStats"]
  793. draw_percentage_param(param_id, dx, dy, dw)
  794. else
  795. draw_set_param(param_id, dx, dy, dw)
  796. end
  797. end
  798.  
  799. #--------------------------------------------------------------------------
  800. # draw_percentage_param
  801. #--------------------------------------------------------------------------
  802. def draw_percentage_param(param_id, dx, dy, dw)
  803. if @item.per_params[param_id] != 0 && @item.params[param_id] != 0
  804. text = draw_set_param(param_id, dx, dy, dw)
  805. dw -= text_size(text).width
  806. draw_percent_param(param_id, dx, dy, dw)
  807. elsif @item.per_params[param_id] != 0 && @item.params[param_id] == 0
  808. draw_percent_param(param_id, dx, dy, dw)
  809. else
  810. draw_set_param(param_id, dx, dy, dw)
  811. end
  812. end
  813.  
  814. #--------------------------------------------------------------------------
  815. # draw_set_param
  816. #--------------------------------------------------------------------------
  817. def draw_set_param(param_id, dx, dy, dw)
  818. value = @item.params[param_id]
  819. if $imported["YEA-EquipDynamicStats"] && @item.var_params[param_id] > 0
  820. value += $game_variables[@item.var_params[param_id]] rescue 0
  821. end
  822. change_color(param_change_color(value), value != 0)
  823. text = value.group
  824. text = "+" + text if value > 0
  825. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  826. return text
  827. end
  828.  
  829. #--------------------------------------------------------------------------
  830. # draw_percent_param
  831. #--------------------------------------------------------------------------
  832. def draw_percent_param(param_id, dx, dy, dw)
  833. value = @item.per_params[param_id]
  834. change_color(param_change_color(value))
  835. text = (@item.per_params[param_id] * 100).to_i.group + "%"
  836. text = "+" + text if @item.per_params[param_id] > 0
  837. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  838. return text
  839. end
  840.  
  841. #--------------------------------------------------------------------------
  842. # draw_item_effects
  843. #--------------------------------------------------------------------------
  844. def draw_item_effects
  845. return unless @item.is_a?(RPG::Item)
  846. dx = 96; dy = 0
  847. dw = (contents.width - 96) / 2
  848. draw_hp_recover(dx, dy + line_height * 0, dw)
  849. draw_mp_recover(dx, dy + line_height * 1, dw)
  850. draw_tp_recover(dx + dw, dy + line_height * 0, dw)
  851. draw_tp_gain(dx + dw, dy + line_height * 1, dw)
  852. dw = contents.width - 96
  853. draw_applies(dx, dy + line_height * 2, dw)
  854. draw_removes(dx, dy + line_height * 3, dw)
  855. end
  856.  
  857. #--------------------------------------------------------------------------
  858. # draw_hp_recover
  859. #--------------------------------------------------------------------------
  860. def draw_hp_recover(dx, dy, dw)
  861. draw_background_box(dx, dy, dw)
  862. change_color(system_color)
  863. draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:hp_recover))
  864. per = 0
  865. set = 0
  866. for effect in @item.effects
  867. next unless effect.code == 11
  868. per += (effect.value1 * 100).to_i
  869. set += effect.value2.to_i
  870. end
  871. if per != 0 && set != 0
  872. change_color(param_change_color(set))
  873. text = set > 0 ? sprintf("+%s", set.group) : set.group
  874. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  875. dw -= text_size(text).width
  876. change_color(param_change_color(per))
  877. text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  878. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  879. return
  880. elsif per != 0
  881. change_color(param_change_color(per))
  882. text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  883. elsif set != 0
  884. change_color(param_change_color(set))
  885. text = set > 0 ? sprintf("+%s", set.group) : set.group
  886. else
  887. change_color(normal_color, false)
  888. text = Vocab::item_status(:empty)
  889. end
  890. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  891. end
  892.  
  893. #--------------------------------------------------------------------------
  894. # draw_mp_recover
  895. #--------------------------------------------------------------------------
  896. def draw_mp_recover(dx, dy, dw)
  897. draw_background_box(dx, dy, dw)
  898. change_color(system_color)
  899. draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:mp_recover))
  900. per = 0
  901. set = 0
  902. for effect in @item.effects
  903. next unless effect.code == 12
  904. per += (effect.value1 * 100).to_i
  905. set += effect.value2.to_i
  906. end
  907. if per != 0 && set != 0
  908. change_color(param_change_color(set))
  909. text = set > 0 ? sprintf("+%s", set.group) : set.group
  910. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  911. dw -= text_size(text).width
  912. change_color(param_change_color(per))
  913. text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  914. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  915. return
  916. elsif per != 0
  917. change_color(param_change_color(per))
  918. text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  919. elsif set != 0
  920. change_color(param_change_color(set))
  921. text = set > 0 ? sprintf("+%s", set.group) : set.group
  922. else
  923. change_color(normal_color, false)
  924. text = Vocab::item_status(:empty)
  925. end
  926. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  927. end
  928.  
  929. #--------------------------------------------------------------------------
  930. # draw_tp_recover
  931. #--------------------------------------------------------------------------
  932. def draw_tp_recover(dx, dy, dw)
  933. draw_background_box(dx, dy, dw)
  934. change_color(system_color)
  935. draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:tp_recover))
  936. set = 0
  937. for effect in @item.effects
  938. next unless effect.code == 13
  939. set += effect.value1.to_i
  940. end
  941. if set != 0
  942. change_color(param_change_color(set))
  943. text = set > 0 ? sprintf("+%s", set.group) : set.group
  944. else
  945. change_color(normal_color, false)
  946. text = Vocab::item_status(:empty)
  947. end
  948. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  949. end
  950.  
  951. #--------------------------------------------------------------------------
  952. # draw_tp_gain
  953. #--------------------------------------------------------------------------
  954. def draw_tp_gain(dx, dy, dw)
  955. draw_background_box(dx, dy, dw)
  956. change_color(system_color)
  957. draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:tp_gain))
  958. set = @item.tp_gain
  959. if set != 0
  960. change_color(param_change_color(set))
  961. text = set > 0 ? sprintf("+%s", set.group) : set.group
  962. else
  963. change_color(normal_color, false)
  964. text = Vocab::item_status(:empty)
  965. end
  966. draw_text(dx+4, dy, dw-8, line_height, text, 2)
  967. end
  968.  
  969. #--------------------------------------------------------------------------
  970. # draw_applies
  971. #--------------------------------------------------------------------------
  972. def draw_applies(dx, dy, dw)
  973. draw_background_box(dx, dy, dw)
  974. change_color(system_color)
  975. draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:applies))
  976. icons = []
  977. for effect in @item.effects
  978. case effect.code
  979. when 21
  980. next unless effect.value1 > 0
  981. next if $data_states[effect.value1].nil?
  982. icons.push($data_states[effect.data_id].icon_index)
  983. when 31
  984. icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
  985. when 32
  986. icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
  987. end
  988. icons.delete(0)
  989. break if icons.size >= YEA::ITEM::MAX_ICONS_DRAWN
  990. end
  991. draw_icons(dx, dy, dw, icons)
  992. end
  993.  
  994. #--------------------------------------------------------------------------
  995. # draw_removes
  996. #--------------------------------------------------------------------------
  997. def draw_removes(dx, dy, dw)
  998. draw_background_box(dx, dy, dw)
  999. change_color(system_color)
  1000. draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:removes))
  1001. icons = []
  1002. for effect in @item.effects
  1003. case effect.code
  1004. when 22
  1005. next unless effect.value1 > 0
  1006. next if $data_states[effect.value1].nil?
  1007. icons.push($data_states[effect.data_id].icon_index)
  1008. when 33
  1009. icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
  1010. when 34
  1011. icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
  1012. end
  1013. icons.delete(0)
  1014. break if icons.size >= YEA::ITEM::MAX_ICONS_DRAWN
  1015. end
  1016. draw_icons(dx, dy, dw, icons)
  1017. end
  1018.  
  1019. #--------------------------------------------------------------------------
  1020. # draw_icons
  1021. #--------------------------------------------------------------------------
  1022. def draw_icons(dx, dy, dw, icons)
  1023. dx += dw - 4
  1024. dx -= icons.size * 24
  1025. for icon_id in icons
  1026. draw_icon(icon_id, dx, dy)
  1027. dx += 24
  1028. end
  1029. if icons.size == 0
  1030. change_color(normal_color, false)
  1031. text = Vocab::item_status(:empty)
  1032. draw_text(4, dy, contents.width-8, line_height, text, 2)
  1033. end
  1034. end
  1035.  
  1036. end # Window_ItemStatus
  1037.  
  1038. #==============================================================================
  1039. # ■ Scene_Item
  1040. #==============================================================================
  1041.  
  1042. class Scene_Item < Scene_ItemBase
  1043.  
  1044. #--------------------------------------------------------------------------
  1045. # alias method: start
  1046. #--------------------------------------------------------------------------
  1047. alias scene_item_start_aim start
  1048. def start
  1049. scene_item_start_aim
  1050. create_types_window
  1051. create_status_window
  1052. relocate_windows
  1053. end
  1054.  
  1055. #--------------------------------------------------------------------------
  1056. # overwrite method: return_scene
  1057. #--------------------------------------------------------------------------
  1058. def return_scene
  1059. $game_temp.scene_item_index = nil
  1060. $game_temp.scene_item_oy = nil
  1061. super
  1062. end
  1063.  
  1064. #--------------------------------------------------------------------------
  1065. # overwrite method: create_category_window
  1066. #--------------------------------------------------------------------------
  1067. def create_category_window
  1068. wy = @help_window.height
  1069. @category_window = Window_ItemCommand.new(0, wy)
  1070. @category_window.viewport = @viewport
  1071. @category_window.help_window = @help_window
  1072. @category_window.y = @help_window.height
  1073. if !$game_temp.scene_item_index.nil?
  1074. @category_window.select($game_temp.scene_item_index)
  1075. @category_window.oy = $game_temp.scene_item_oy
  1076. end
  1077. $game_temp.scene_item_index = nil
  1078. $game_temp.scene_item_oy = nil
  1079. @category_window.set_handler(:ok, method(:on_category_ok))
  1080. @category_window.set_handler(:cancel, method(:return_scene))
  1081. @category_window.set_handler(:item, method(:open_types))
  1082. @category_window.set_handler(:weapon, method(:open_types))
  1083. @category_window.set_handler(:armor, method(:open_types))
  1084. process_custom_item_commands
  1085. end
  1086.  
  1087. #--------------------------------------------------------------------------
  1088. # new method: process_custom_item_commands
  1089. #--------------------------------------------------------------------------
  1090. def process_custom_item_commands
  1091. for command in YEA::ITEM::COMMANDS
  1092. next unless YEA::ITEM::CUSTOM_ITEM_COMMANDS.include?(command)
  1093. called_method = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][3]
  1094. @category_window.set_handler(command, method(called_method))
  1095. end
  1096. end
  1097.  
  1098. #--------------------------------------------------------------------------
  1099. # new method: create_types_window
  1100. #--------------------------------------------------------------------------
  1101. def create_types_window
  1102. wy = @category_window.y
  1103. @types_window = Window_ItemType.new(Graphics.width, wy)
  1104. @types_window.viewport = @viewport
  1105. @types_window.help_window = @help_window
  1106. @types_window.y = @help_window.height
  1107. @types_window.item_window = @item_window
  1108. @item_window.types_window = @types_window
  1109. @types_window.set_handler(:ok, method(:on_types_ok))
  1110. @types_window.set_handler(:cancel, method(:on_types_cancel))
  1111. end
  1112.  
  1113. #--------------------------------------------------------------------------
  1114. # new method: create_status_window
  1115. #--------------------------------------------------------------------------
  1116. def create_status_window
  1117. wx = @category_window.width
  1118. wy = @category_window.y
  1119. @status_window = Window_ItemStatus.new(wx, wy, @item_window)
  1120. @status_window.viewport = @viewport
  1121. end
  1122.  
  1123. #--------------------------------------------------------------------------
  1124. # new method: relocate_windows
  1125. #--------------------------------------------------------------------------
  1126. def relocate_windows
  1127. return unless $imported["YEA-AceMenuEngine"]
  1128. case Menu.help_window_location
  1129. when 0 # Top
  1130. @help_window.y = 0
  1131. @category_window.y = @help_window.height
  1132. @item_window.y = @category_window.y + @category_window.height
  1133. when 1 # Middle
  1134. @category_window.y = 0
  1135. @help_window.y = @category_window.height
  1136. @item_window.y = @help_window.y + @help_window.height
  1137. else # Bottom
  1138. @category_window.y = 0
  1139. @item_window.y = @category_window.height
  1140. @help_window.y = @item_window.y + @item_window.height
  1141. end
  1142. @types_window.y = @category_window.y
  1143. @status_window.y = @category_window.y
  1144. end
  1145.  
  1146. #--------------------------------------------------------------------------
  1147. # new method: open_categories
  1148. #--------------------------------------------------------------------------
  1149. def open_types
  1150. @category_window.x = Graphics.width
  1151. @types_window.x = 0
  1152. @types_window.reveal(@category_window.current_symbol)
  1153. end
  1154.  
  1155. #--------------------------------------------------------------------------
  1156. # new method: on_types_ok
  1157. #--------------------------------------------------------------------------
  1158. def on_types_ok
  1159. @item_window.activate
  1160. @item_window.select_last
  1161. end
  1162.  
  1163. #--------------------------------------------------------------------------
  1164. # new method: on_types_cancel
  1165. #--------------------------------------------------------------------------
  1166. def on_types_cancel
  1167. @category_window.x = 0
  1168. @category_window.activate
  1169. @types_window.unselect
  1170. @types_window.x = Graphics.width
  1171. end
  1172.  
  1173. #--------------------------------------------------------------------------
  1174. # alias method: on_item_cancel
  1175. #--------------------------------------------------------------------------
  1176. alias scene_item_on_item_cancel_aim on_item_cancel
  1177. def on_item_cancel
  1178. if @types_window.x <= 0
  1179. @item_window.unselect
  1180. @types_window.activate
  1181. else
  1182. scene_item_on_item_cancel_aim
  1183. end
  1184. end
  1185.  
  1186. #--------------------------------------------------------------------------
  1187. # new method: command_totori
  1188. #--------------------------------------------------------------------------
  1189. def command_totori
  1190. SceneManager.call(Scene_Alchemy)
  1191. end
  1192.  
  1193. #--------------------------------------------------------------------------
  1194. # new method: command_name1
  1195. #--------------------------------------------------------------------------
  1196. def command_name1
  1197. # Do nothing.
  1198. end
  1199.  
  1200. #--------------------------------------------------------------------------
  1201. # new method: command_name2
  1202. #--------------------------------------------------------------------------
  1203. def command_name2
  1204. # Do nothing.
  1205. end
  1206.  
  1207. end # Scene_Item
  1208.  
  1209. #==============================================================================
  1210. #
  1211. # ▼ End of File
  1212. #
  1213. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment