查看: 1292|回复: 0

[已经过期] 关于yanfly的物品系统脚本的一点问题

[复制链接]
梦石
0
星屑
170
在线时间
181 小时
注册时间
2012-6-11
回帖
58
发表于 2013-4-7 12:43:04 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
  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. $imported = {} if $imported.nil?
  10. $imported["YEA-ItemMenu"] = true

  11. #==============================================================================
  12. # ▼ Updates
  13. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  14. # 2012.01.05 - Compatibility Update with Equip Dynamic Stats.
  15. # 2012.01.03 - Started Script and Finished.
  16. #            - Compatibility Update with Ace Menu Engine.
  17. #
  18. #==============================================================================
  19. # ▼ Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # The Ace Item Menu offers more item categorization control and a better layout
  22. # that simulatenously provides information regarding the items to the player,
  23. # while keeping a good amount of the item list visible on screen at once. The
  24. # script can also be customized to rearrange commands and categories.
  25. #
  26. #==============================================================================
  27. # ▼ Instructions
  28. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. # To install this script, open up your script editor and copy/paste this script
  30. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  31. #
  32. # -----------------------------------------------------------------------------
  33. # Item Notetags - These notetags go in the item notebox in the database.
  34. # -----------------------------------------------------------------------------
  35. # <category: string>
  36. # Places this object into the item category for "string". Whenever the selected
  37. # category is highlighted in the Ace Item Menu command window, this object will
  38. # be included and shown in the item window.
  39. #
  40. # <image: string>
  41. # Uses a picture from Graphics\Pictures\ of your RPG Maker VX Ace Project's
  42. # directory with the filename of "string" (without the extension) as the image
  43. # picture shown in the Ace Item Menu.
  44. #
  45. # -----------------------------------------------------------------------------
  46. # Weapon Notetags - These notetags go in the weapon notebox in the database.
  47. # -----------------------------------------------------------------------------
  48. # <category: string>
  49. # Places this object into the item category for "string". Whenever the selected
  50. # category is highlighted in the Ace Item Menu command window, this object will
  51. # be included and shown in the item window.
  52. #
  53. # <image: string>
  54. # Uses a picture from Graphics\Pictures\ of your RPG Maker VX Ace Project's
  55. # directory with the filename of "string" (without the extension) as the image
  56. # picture shown in the Ace Item Menu.
  57. #
  58. # -----------------------------------------------------------------------------
  59. # Armour Notetags - These notetags go in the armour notebox in the database.
  60. # -----------------------------------------------------------------------------
  61. # <category: string>
  62. # Places this object into the item category for "string". Whenever the selected
  63. # category is highlighted in the Ace Item Menu command window, this object will
  64. # be included and shown in the item window.
  65. #
  66. # <image: string>
  67. # Uses a picture from Graphics\Pictures\ of your RPG Maker VX Ace Project's
  68. # directory with the filename of "string" (without the extension) as the image
  69. # picture shown in the Ace Item Menu.
  70. #
  71. #==============================================================================
  72. # ▼ Compatibility
  73. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  74. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  75. # it will run with RPG Maker VX without adjusting.
  76. #
  77. #==============================================================================

  78. module YEA
  79.   module ITEM
  80.    
  81.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  82.     # - Item Command Settings -
  83.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  84.     # This array adjusts what options appear in the initial item command window
  85.     # before the items are split into separate categories. Add commands, remove
  86.     # commands, or rearrange them. Here's a list of which does what:
  87.     #
  88.     # -------------------------------------------------------------------------
  89.     # :command         Description
  90.     # -------------------------------------------------------------------------
  91.     # :item            Opens up the various item categories. Default.
  92.     # :weapon          Opens up the various weapon categories. Default.
  93.     # :armor           Opens up the various armour categories. Default.
  94.     # :key_item        Shows a list of the various key items. Default.
  95.     #
  96.     # :gogototori      Requires Kread-EX's Go Go Totori Synthesis.
  97.     #
  98.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  99.     COMMANDS =[
  100.       :item,         # Opens up the various item categories. Default.
  101.       :weapon,       # Opens up the various weapon categories. Default.
  102.       :armor,        # Opens up the various armour categories. Default.
  103.       :key_item,     # Shows a list of the various key items. Default.
  104.       :gogototori,   # Requires Kread-EX's Go Go Totori Synthesis.
  105.     # :custom1,      # Custom command 1.
  106.     # :custom2,      # Custom command 2.
  107.     ] # Do not remove this.
  108.    
  109.     #--------------------------------------------------------------------------
  110.     # - Item Custom Commands -
  111.     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  112.     # For those who use scripts to that may produce unique effects for the item
  113.     # scene, use this hash to manage the custom commands for the Item Command
  114.     # Window. You can disable certain commands or prevent them from appearing
  115.     # by using switches. If you don't wish to bind them to a switch, set the
  116.     # proper switch to 0 for it to have no impact.
  117.     #--------------------------------------------------------------------------
  118.     CUSTOM_ITEM_COMMANDS ={
  119.     # :command => ["Display Name", EnableSwitch, ShowSwitch, Handler Method],
  120.       :gogototori => ["Synthesis",            0,         0, :command_totori],
  121.       :custom1 => [ "Custom Name",            0,          0, :command_name1],
  122.       :custom2 => [ "Custom Text",           13,          0, :command_name2],
  123.     } # Do not remove this.
  124.     ITEM_TYPES =[
  125.       [:category,"道具"],
  126.       [:category,"收集物"],
  127.       [:category,"书籍"],
  128.     ]
  129.     WEAPON_TYPES =[
  130.       [:category,  "近程武器"],
  131.       [:category,  "远程武器"],
  132.       [:category,  "其他武器"],
  133.     ]
  134.     ARMOUR_TYPES =[
  135.       [:category,"身体防具"],
  136.       [:category,"头部防具"],
  137.       [:category,"装饰品"],
  138.     ]
  139.    
  140.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  141.     # - Item Status Settings -
  142.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  143.     # The item status window displays information about the item in detail.
  144.     # Adjust the settings below to change the way the status window appears.
  145.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  146.     STATUS_FONT_SIZE = 20       # Font size used for status window.
  147.     MAX_ICONS_DRAWN  = 10       # Maximum number of icons drawn for states.
  148.    
  149.     # The following adjusts the vocabulary used for the status window. Each
  150.     # of the vocabulary settings are self explanatory.
  151.     VOCAB_STATUS ={
  152.       :empty      => " ",          # Text used when nothing is shown.
  153.       :hp_recover => "HP回复",      # Text used for HP Recovery.
  154.       :mp_recover => "TP回复",      # Text used for MP Recovery.
  155.       :applies    => "附加",      # Text used for applied states and buffs.
  156.       :removes    => "解除",      # Text used for removed states and buffs.
  157.     } # Do not remove this.
  158.    
  159.   end # ITEM
  160. end # YEA

  161. #==============================================================================
  162. # ▼ Editting anything past this point may potentially result in causing
  163. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  164. # halitosis so edit at your own risk.
  165. #==============================================================================
  166. module YEA
  167.   module REGEXP
  168.   module BASEITEM
  169.    
  170.     CATEGORY = /<(?:CATEGORIES|category):[ ](.*)>/i
  171.     IMAGE    = /<(?:IMAGE|image):[ ](.*)>/i
  172.    
  173.   end # BASEITEM
  174.   end # REGEXP
  175. end # YEA

  176. #==============================================================================
  177. # ■ Numeric
  178. #==============================================================================

  179. class Numeric
  180.   
  181.   #--------------------------------------------------------------------------
  182.   # new method: group_digits
  183.   #--------------------------------------------------------------------------
  184.   unless $imported["YEA-CoreEngine"]
  185.   def group; return self.to_s; end
  186.   end # $imported["YEA-CoreEngine"]
  187.    
  188. end # Numeric

  189. #==============================================================================
  190. # ■ Vocab
  191. #==============================================================================

  192. module Vocab
  193.   
  194.   #--------------------------------------------------------------------------
  195.   # new method: self.item_status
  196.   #--------------------------------------------------------------------------
  197.   def self.item_status(type)
  198.     return YEA::ITEM::VOCAB_STATUS[type]
  199.   end
  200.   
  201. end # Vocab

  202. #==============================================================================
  203. # ■ DataManager
  204. #==============================================================================

  205. module DataManager
  206.   
  207.   #--------------------------------------------------------------------------
  208.   # alias method: load_database
  209.   #--------------------------------------------------------------------------
  210.   class <<self; alias load_database_aim load_database; end
  211.   def self.load_database
  212.     load_database_aim
  213.     load_notetags_aim
  214.   end
  215.   
  216.   #--------------------------------------------------------------------------
  217.   # new method: load_notetags_aim
  218.   #--------------------------------------------------------------------------
  219.   def self.load_notetags_aim
  220.     groups = [$data_items, $data_weapons, $data_armors]
  221.     for group in groups
  222.       for obj in group
  223.         next if obj.nil?
  224.         obj.load_notetags_aim
  225.       end
  226.     end
  227.   end
  228.   
  229. end # DataManager

  230. #==============================================================================
  231. # ■ RPG::BaseItem
  232. #==============================================================================

  233. class RPG::BaseItem
  234.   
  235.   #--------------------------------------------------------------------------
  236.   # public instance variables
  237.   #--------------------------------------------------------------------------
  238.   attr_accessor :category
  239.   attr_accessor :image
  240.   
  241.   #--------------------------------------------------------------------------
  242.   # common cache: load_notetags_aim
  243.   #--------------------------------------------------------------------------
  244.   def load_notetags_aim
  245.     @category = []
  246.     #---
  247.     self.note.split(/[\r\n]+/).each { |line|
  248.       case line
  249.       #---
  250.       when YEA::REGEXP::BASEITEM::CATEGORY
  251.         @category.push($1.upcase.to_s)
  252.       when YEA::REGEXP::BASEITEM::IMAGE
  253.         @image = $1.to_s
  254.       end
  255.     } # self.note.split
  256.     #---
  257.   end
  258.   
  259. end # RPG::BaseItem

  260. #==============================================================================
  261. # ■ Game_Temp
  262. #==============================================================================

  263. class Game_Temp
  264.   
  265.   #--------------------------------------------------------------------------
  266.   # public instance variables
  267.   #--------------------------------------------------------------------------
  268.   attr_accessor :scene_item_index
  269.   attr_accessor :scene_item_oy
  270.   
  271. end # Game_Temp

  272. #==============================================================================
  273. # ■ Window_ItemList
  274. #==============================================================================

  275. class Window_ItemList < Window_Selectable
  276.   
  277.   #--------------------------------------------------------------------------
  278.   # overwrite method: draw_item
  279.   #--------------------------------------------------------------------------
  280.   def draw_item(index)
  281.     item = @data[index]
  282.     return if item.nil?
  283.     rect = item_rect(index)
  284.     rect.width -= 4
  285.     draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
  286.     draw_item_number(rect, item)
  287.   end
  288.   
  289. end # Window_ItemList

  290. #==============================================================================
  291. # ■ Window_ItemCommand
  292. #==============================================================================

  293. class Window_ItemCommand < Window_Command
  294.   
  295.   #--------------------------------------------------------------------------
  296.   # public instance variables
  297.   #--------------------------------------------------------------------------
  298.   attr_reader   :item_window
  299.   
  300.   #--------------------------------------------------------------------------
  301.   # initialize
  302.   #--------------------------------------------------------------------------
  303.   def initialize(x, y)
  304.     super(x, y)
  305.   end
  306.   
  307.   #--------------------------------------------------------------------------
  308.   # window_width
  309.   #--------------------------------------------------------------------------
  310.   def window_width; return 160; end
  311.   
  312.   #--------------------------------------------------------------------------
  313.   # visible_line_number
  314.   #--------------------------------------------------------------------------
  315.   def visible_line_number; return 4; end
  316.   
  317.   #--------------------------------------------------------------------------
  318.   # process_ok
  319.   #--------------------------------------------------------------------------
  320.   def process_ok
  321.     $game_temp.scene_item_index = index
  322.     $game_temp.scene_item_oy = self.oy
  323.     super
  324.   end
  325.   
  326.   #--------------------------------------------------------------------------
  327.   # make_command_list
  328.   #--------------------------------------------------------------------------
  329.   def make_command_list
  330.     for command in YEA::ITEM::COMMANDS
  331.       case command
  332.       #--- Default Commands ---
  333.       when :item
  334.         add_command(Vocab::item, :item)
  335.       when :weapon
  336.         add_command(Vocab::weapon, :weapon)
  337.       when :armor
  338.         add_command(Vocab::armor, :armor)
  339.       when :key_item
  340.         add_command(Vocab::key_item, :key_item)
  341.       #--- Imported ---
  342.       when :gogototori
  343.         next unless $imported["KRX-AlchemicSynthesis"]
  344.         process_custom_command(command)
  345.       #--- Custom Commands ---
  346.       else
  347.         process_custom_command(command)
  348.       end
  349.     end
  350.   end
  351.   
  352.   #--------------------------------------------------------------------------
  353.   # process_custom_command
  354.   #--------------------------------------------------------------------------
  355.   def process_custom_command(command)
  356.     return unless YEA::ITEM::CUSTOM_ITEM_COMMANDS.include?(command)
  357.     show = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][2]
  358.     continue = show <= 0 ? true : $game_switches[show]
  359.     return unless continue
  360.     text = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][0]
  361.     switch = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][1]
  362.     enabled = switch <= 0 ? true : $game_switches[switch]
  363.     add_command(text, command, enabled)
  364.   end
  365.   
  366.   #--------------------------------------------------------------------------
  367.   # update
  368.   #--------------------------------------------------------------------------
  369.   def update
  370.     super
  371.     return unless self.active
  372.     @item_window.category = current_symbol if @item_window
  373.   end
  374.   
  375.   #--------------------------------------------------------------------------
  376.   # item_window=
  377.   #--------------------------------------------------------------------------
  378.   def item_window=(item_window)
  379.     @item_window = item_window
  380.     update
  381.   end
  382.   
  383. end # Window_ItemCommand

  384. #==============================================================================
  385. # ■ Window_ItemType
  386. #==============================================================================

  387. class Window_ItemType < Window_Command
  388.   
  389.   #--------------------------------------------------------------------------
  390.   # public instance variables
  391.   #--------------------------------------------------------------------------
  392.   attr_reader   :item_window
  393.   
  394.   #--------------------------------------------------------------------------
  395.   # initialize
  396.   #--------------------------------------------------------------------------
  397.   def initialize(x, y)
  398.     super(x, y)
  399.     deactivate
  400.     @type = nil
  401.   end
  402.   
  403.   #--------------------------------------------------------------------------
  404.   # window_width
  405.   #--------------------------------------------------------------------------
  406.   def window_width; return 160; end
  407.   
  408.   #--------------------------------------------------------------------------
  409.   # visible_line_number
  410.   #--------------------------------------------------------------------------
  411.   def visible_line_number; return 4; end
  412.   
  413.   #--------------------------------------------------------------------------
  414.   # reveal
  415.   #--------------------------------------------------------------------------
  416.   def reveal(type)
  417.     @type = type
  418.     refresh
  419.     activate
  420.     select(0)
  421.   end
  422.   
  423.   #--------------------------------------------------------------------------
  424.   # make_command_list
  425.   #--------------------------------------------------------------------------
  426.   def make_command_list
  427.     return if @type.nil?
  428.     #---
  429.     case @type
  430.     when :item
  431.       commands = YEA::ITEM::ITEM_TYPES
  432.     when :weapon
  433.       commands = YEA::ITEM::WEAPON_TYPES
  434.     else
  435.       commands = YEA::ITEM::ARMOUR_TYPES
  436.     end
  437.     #---
  438.     for command in commands
  439.       case command[0]
  440.       #---
  441.       when :types
  442.         case @type
  443.         when :weapon
  444.           for i in 1...$data_system.weapon_types.size
  445.             name = $data_system.weapon_types[i]
  446.             add_command(name, :w_type, true, i)
  447.           end
  448.         else
  449.           for i in 1...$data_system.armor_types.size
  450.             name = $data_system.armor_types[i]
  451.             add_command(name, :a_type, true, i)
  452.           end
  453.         end
  454.       #---
  455.       when :slots
  456.         if $imported["YEA-AceEquipEngine"]
  457.           maximum = 1
  458.           for key in YEA::EQUIP::TYPES
  459.             maximum = [maximum, key[0]].max
  460.           end
  461.         else
  462.           maximum = 4
  463.         end
  464.         for i in 1..maximum
  465.           name = Vocab::etype(i)
  466.           add_command(name, :e_type, true, i) if name != ""
  467.         end
  468.       #---
  469.       else
  470.         add_command(command[1], command[0], true, @type)
  471.       end
  472.     end
  473.   end
  474.   
  475.   #--------------------------------------------------------------------------
  476.   # update
  477.   #--------------------------------------------------------------------------
  478.   def update
  479.     super
  480.     return unless self.active
  481.     @item_window.category = current_symbol if @item_window
  482.   end
  483.   
  484.   #--------------------------------------------------------------------------
  485.   # item_window=
  486.   #--------------------------------------------------------------------------
  487.   def item_window=(item_window)
  488.     @item_window = item_window
  489.     update
  490.   end
  491.   
  492. end # Window_ItemType

  493. #==============================================================================
  494. # ■ Window_ItemList
  495. #==============================================================================

  496. class Window_ItemList < Window_Selectable
  497.   
  498.   #--------------------------------------------------------------------------
  499.   # alias method: initialize
  500.   #--------------------------------------------------------------------------
  501.   alias window_itemlist_initialize_aim initialize
  502.   def initialize(dx, dy, dw, dh)
  503.     window_itemlist_initialize_aim(dx, dy, dw, dh)
  504.     @ext = :none
  505.     @name = ""
  506.   end
  507.   
  508.   #--------------------------------------------------------------------------
  509.   # alias method: category=
  510.   #--------------------------------------------------------------------------
  511.   alias window_itemlist_category_aim category=
  512.   def category=(category)
  513.     if @types_window.nil?
  514.       window_itemlist_category_aim(category)
  515.     else
  516.       return unless update_types?(category)
  517.       @category = category
  518.       if @types_window.active
  519.         @name = @types_window.current_data[:name]
  520.         @ext = @types_window.current_ext
  521.       end
  522.       refresh
  523.       self.oy = 0
  524.     end
  525.   end
  526.   
  527.   #--------------------------------------------------------------------------
  528.   # new method: update_types?
  529.   #--------------------------------------------------------------------------
  530.   def update_types?(category)
  531.     return true if @category != category
  532.     return false unless @types_window.active
  533.     if category == :category
  534.       return @name != @types_window.current_data[:name]
  535.     end
  536.     return @ext != @types_window.current_ext
  537.   end
  538.   
  539.   #--------------------------------------------------------------------------
  540.   # new method: types_window=
  541.   #--------------------------------------------------------------------------
  542.   def types_window=(window)
  543.     @types_window = window
  544.   end
  545.   
  546.   #--------------------------------------------------------------------------
  547.   # alias method: include?
  548.   #--------------------------------------------------------------------------
  549.   alias window_itemlist_include_aim include?
  550.   def include?(item)
  551.     if @types_window.nil?
  552.       return window_itemlist_include_aim(item)
  553.     else
  554.       return ace_item_menu_include?(item)
  555.     end
  556.   end
  557.   
  558.   #--------------------------------------------------------------------------
  559.   # new method: ace_item_menu_include?
  560.   #--------------------------------------------------------------------------
  561.   def ace_item_menu_include?(item)
  562.     case @category
  563.     #---
  564.     when :field
  565.       return false unless item.is_a?(RPG::Item)
  566.       return item.menu_ok?
  567.     when :battle
  568.       return false unless item.is_a?(RPG::Item)
  569.       return item.battle_ok?
  570.     #---
  571.     when :w_type
  572.       return false unless item.is_a?(RPG::Weapon)
  573.       return item.wtype_id == @types_window.current_ext
  574.     when :a_type
  575.       return false unless item.is_a?(RPG::Armor)
  576.       return item.atype_id == @types_window.current_ext
  577.     when :e_type
  578.       return false unless item.is_a?(RPG::Armor)
  579.       return item.etype_id == @types_window.current_ext
  580.     #---
  581.     when :all
  582.       case @types_window.current_ext
  583.       when :item
  584.         return item.is_a?(RPG::Item)
  585.       when :weapon
  586.         return item.is_a?(RPG::Weapon)
  587.       else
  588.         return item.is_a?(RPG::Armor)
  589.       end
  590.     #---
  591.     when :category
  592.       case @types_window.current_ext
  593.       when :item
  594.         return false unless item.is_a?(RPG::Item)
  595.       when :weapon
  596.         return false unless item.is_a?(RPG::Weapon)
  597.       else
  598.         return false unless item.is_a?(RPG::Armor)
  599.       end
  600.       return item.category.include?(@types_window.current_data[:name].upcase)
  601.     #---
  602.     else
  603.       return window_itemlist_include_aim(item)
  604.     end
  605.   end
  606.   
  607. end # Window_ItemList

  608. #==============================================================================
  609. # ■ Window_ItemStatus
  610. #==============================================================================

  611. class Window_ItemStatus < Window_Base
  612.   
  613.   #--------------------------------------------------------------------------
  614.   # initialize
  615.   #--------------------------------------------------------------------------
  616.   def initialize(dx, dy, item_window)
  617.     super(dx, dy, Graphics.width - dx, fitting_height(4))
  618.     @item_window = item_window
  619.     @item = nil
  620.     refresh
  621.   end
  622.   
  623.   #--------------------------------------------------------------------------
  624.   # update
  625.   #--------------------------------------------------------------------------
  626.   def update
  627.     super
  628.     update_item(@item_window.item)
  629.   end
  630.   
  631.   #--------------------------------------------------------------------------
  632.   # update_item
  633.   #--------------------------------------------------------------------------
  634.   def update_item(item)
  635.     return if @item == item
  636.     @item = item
  637.     refresh
  638.   end
  639.   
  640.   #--------------------------------------------------------------------------
  641.   # refresh
  642.   #--------------------------------------------------------------------------
  643.   def refresh
  644.     contents.clear
  645.     reset_font_settings
  646.     return draw_empty if @item.nil?
  647.     contents.font.size = YEA::ITEM::STATUS_FONT_SIZE
  648.     draw_item_image
  649.     draw_item_stats
  650.     draw_item_effects
  651.   end
  652.   
  653.   #--------------------------------------------------------------------------
  654.   # draw_empty
  655.   #--------------------------------------------------------------------------
  656.   def draw_empty
  657.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  658.     rect = Rect.new(1, 1, 94, 94)
  659.     contents.fill_rect(rect, colour)
  660.     dx = 96; dy = 0
  661.     dw = (contents.width - 96) / 2
  662.     for i in 0...8
  663.       draw_background_box(dx, dy, dw)
  664.       dx = dx >= 96 + dw ? 96 : 96 + dw
  665.       dy += line_height if dx == 96
  666.     end
  667.   end
  668.   
  669.   #--------------------------------------------------------------------------
  670.   # draw_background_box
  671.   #--------------------------------------------------------------------------
  672.   def draw_background_box(dx, dy, dw)
  673.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  674.     rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)
  675.     contents.fill_rect(rect, colour)
  676.   end
  677.   
  678.   #--------------------------------------------------------------------------
  679.   # draw_item_image
  680.   #--------------------------------------------------------------------------
  681.   def draw_item_image
  682.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  683.     rect = Rect.new(1, 1, 94, 94)
  684.     contents.fill_rect(rect, colour)
  685.     if @item.image.nil?
  686.       icon_index = @item.icon_index
  687.       bitmap = Cache.system("Iconset")
  688.       rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  689.       target = Rect.new(0, 0, 96, 96)
  690.       contents.stretch_blt(target, bitmap, rect)
  691.     else
  692.       bitmap = Cache.picture(@item.image)
  693.       contents.blt(0, 0, bitmap, bitmap.rect, 255)
  694.     end
  695.   end
  696.   
  697.   #--------------------------------------------------------------------------
  698.   # draw_item_stats
  699.   #--------------------------------------------------------------------------
  700.   def draw_item_stats
  701.     return unless @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
  702.     dx = 96; dy = 0
  703.     dw = (contents.width - 96) / 2
  704.     for i in 0...8
  705.       draw_equip_param(i, dx, dy, dw)
  706.       dx = dx >= 96 + dw ? 96 : 96 + dw
  707.       dy += line_height if dx == 96
  708.     end
  709.   end
  710.   
  711.   #--------------------------------------------------------------------------
  712.   # draw_equip_param
  713.   #--------------------------------------------------------------------------
  714.   def draw_equip_param(param_id, dx, dy, dw)
  715.     draw_background_box(dx, dy, dw)
  716.     change_color(system_color)
  717.     draw_text(dx+4, dy, dw-8, line_height, Vocab::param(param_id))
  718.     if $imported["YEA-EquipDynamicStats"]
  719.       draw_percentage_param(param_id, dx, dy, dw)
  720.     else
  721.       draw_set_param(param_id, dx, dy, dw)
  722.     end
  723.   end
  724.   
  725.   #--------------------------------------------------------------------------
  726.   # draw_percentage_param
  727.   #--------------------------------------------------------------------------
  728.   def draw_percentage_param(param_id, dx, dy, dw)
  729.     if @item.per_params[param_id] != 0 && @item.params[param_id] != 0
  730.       text = draw_set_param(param_id, dx, dy, dw)
  731.       dw -= text_size(text).width
  732.       draw_percent_param(param_id, dx, dy, dw)
  733.     elsif @item.per_params[param_id] != 0 && @item.params[param_id] == 0
  734.       draw_percent_param(param_id, dx, dy, dw)
  735.     else
  736.       draw_set_param(param_id, dx, dy, dw)
  737.     end
  738.   end
  739.   
  740.   #--------------------------------------------------------------------------
  741.   # draw_set_param
  742.   #--------------------------------------------------------------------------
  743.   def draw_set_param(param_id, dx, dy, dw)
  744.     value = @item.params[param_id]
  745.     if $imported["YEA-EquipDynamicStats"] && @item.var_params[param_id] > 0
  746.       value += $game_variables[@item.var_params[param_id]] rescue 0
  747.     end
  748.     change_color(param_change_color(value), value != 0)
  749.     text = value.group
  750.     text = "+" + text if value > 0
  751.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  752.     return text
  753.   end
  754.   
  755.   #--------------------------------------------------------------------------
  756.   # draw_percent_param
  757.   #--------------------------------------------------------------------------
  758.   def draw_percent_param(param_id, dx, dy, dw)
  759.     value = @item.per_params[param_id]
  760.     change_color(param_change_color(value))
  761.     text = (@item.per_params[param_id] * 100).to_i.group + "%"
  762.     text = "+" + text if @item.per_params[param_id] > 0
  763.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  764.     return text
  765.   end
  766.   
  767.   #--------------------------------------------------------------------------
  768.   # draw_item_effects
  769.   #--------------------------------------------------------------------------
  770.   def draw_item_effects
  771.     return unless @item.is_a?(RPG::Item)
  772.     dx = 96; dy = 0
  773.     dw = (contents.width - 96) / 2
  774.     draw_hp_recover(dx, dy + line_height * 0, dw)
  775.     draw_mp_recover(dx, dy + line_height * 1, dw)
  776.     draw_tp_recover(dx + dw, dy + line_height * 0, dw)
  777.     draw_tp_gain(dx + dw, dy + line_height * 1, dw)
  778.     dw = contents.width - 96
  779.     draw_applies(dx, dy + line_height * 2, dw)
  780.     draw_removes(dx, dy + line_height * 3, dw)
  781.   end
  782.   
  783.   #--------------------------------------------------------------------------
  784.   # draw_hp_recover
  785.   #--------------------------------------------------------------------------
  786.   def draw_hp_recover(dx, dy, dw)
  787.     draw_background_box(dx, dy, dw)
  788.     change_color(system_color)
  789.     draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:hp_recover))
  790.     per = 0
  791.     set = 0
  792.     for effect in @item.effects
  793.       next unless effect.code == 11
  794.       per += (effect.value1 * 100).to_i
  795.       set += effect.value2.to_i
  796.     end
  797.     if per != 0 && set != 0
  798.       change_color(param_change_color(set))
  799.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  800.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  801.       dw -= text_size(text).width
  802.       change_color(param_change_color(per))
  803.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  804.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  805.       return
  806.     elsif per != 0
  807.       change_color(param_change_color(per))
  808.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  809.     elsif set != 0
  810.       change_color(param_change_color(set))
  811.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  812.     else
  813.       change_color(normal_color, false)
  814.       text = Vocab::item_status(:empty)
  815.     end
  816.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  817.   end
  818.   
  819.   #--------------------------------------------------------------------------
  820.   # draw_mp_recover
  821.   #--------------------------------------------------------------------------
  822.   def draw_mp_recover(dx, dy, dw)
  823.     draw_background_box(dx, dy, dw)
  824.     change_color(system_color)
  825.     draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:mp_recover))
  826.     per = 0
  827.     set = 0
  828.     for effect in @item.effects
  829.       next unless effect.code == 12
  830.       per += (effect.value1 * 100).to_i
  831.       set += effect.value2.to_i
  832.     end
  833.     if per != 0 && set != 0
  834.       change_color(param_change_color(set))
  835.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  836.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  837.       dw -= text_size(text).width
  838.       change_color(param_change_color(per))
  839.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  840.       draw_text(dx+4, dy, dw-8, line_height, text, 2)
  841.       return
  842.     elsif per != 0
  843.       change_color(param_change_color(per))
  844.       text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
  845.     elsif set != 0
  846.       change_color(param_change_color(set))
  847.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  848.     else
  849.       change_color(normal_color, false)
  850.       text = Vocab::item_status(:empty)
  851.     end
  852.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  853.   end
  854.   
  855.   #--------------------------------------------------------------------------
  856.   # draw_tp_recover
  857.   #--------------------------------------------------------------------------
  858.   def draw_tp_recover(dx, dy, dw)
  859.     draw_background_box(dx, dy, dw)
  860.     change_color(system_color)
  861.     draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:tp_recover))
  862.     set = 0
  863.     for effect in @item.effects
  864.       next unless effect.code == 13
  865.       set += effect.value1.to_i
  866.     end
  867.     if set != 0
  868.       change_color(param_change_color(set))
  869.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  870.     else
  871.       change_color(normal_color, false)
  872.       text = Vocab::item_status(:empty)
  873.     end
  874.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  875.   end
  876.   
  877.   #--------------------------------------------------------------------------
  878.   # draw_tp_gain
  879.   #--------------------------------------------------------------------------
  880.   def draw_tp_gain(dx, dy, dw)
  881.     draw_background_box(dx, dy, dw)
  882.     change_color(system_color)
  883.     draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:tp_gain))
  884.     set = @item.tp_gain
  885.     if set != 0
  886.       change_color(param_change_color(set))
  887.       text = set > 0 ? sprintf("+%s", set.group) : set.group
  888.     else
  889.       change_color(normal_color, false)
  890.       text = Vocab::item_status(:empty)
  891.     end
  892.     draw_text(dx+4, dy, dw-8, line_height, text, 2)
  893.   end
  894.   
  895.   #--------------------------------------------------------------------------
  896.   # draw_applies
  897.   #--------------------------------------------------------------------------
  898.   def draw_applies(dx, dy, dw)
  899.     draw_background_box(dx, dy, dw)
  900.     change_color(system_color)
  901.     draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:applies))
  902.     icons = []
  903.     for effect in @item.effects
  904.       case effect.code
  905.       when 21
  906.         next unless effect.value1 > 0
  907.         next if $data_states[effect.value1].nil?
  908.         icons.push($data_states[effect.data_id].icon_index)
  909.       when 31
  910.         icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
  911.       when 32
  912.         icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
  913.       end
  914.       icons.delete(0)
  915.       break if icons.size >= YEA::ITEM::MAX_ICONS_DRAWN
  916.     end
  917.     draw_icons(dx, dy, dw, icons)
  918.   end
  919.   
  920.   #--------------------------------------------------------------------------
  921.   # draw_removes
  922.   #--------------------------------------------------------------------------
  923.   def draw_removes(dx, dy, dw)
  924.     draw_background_box(dx, dy, dw)
  925.     change_color(system_color)
  926.     draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:removes))
  927.     icons = []
  928.     for effect in @item.effects
  929.       case effect.code
  930.       when 22
  931.         next unless effect.value1 > 0
  932.         next if $data_states[effect.value1].nil?
  933.         icons.push($data_states[effect.data_id].icon_index)
  934.       when 33
  935.         icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
  936.       when 34
  937.         icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
  938.       end
  939.       icons.delete(0)
  940.       break if icons.size >= YEA::ITEM::MAX_ICONS_DRAWN
  941.     end
  942.     draw_icons(dx, dy, dw, icons)
  943.   end
  944.   
  945.   #--------------------------------------------------------------------------
  946.   # draw_icons
  947.   #--------------------------------------------------------------------------
  948.   def draw_icons(dx, dy, dw, icons)
  949.     dx += dw - 4
  950.     dx -= icons.size * 24
  951.     for icon_id in icons
  952.       draw_icon(icon_id, dx, dy)
  953.       dx += 24
  954.     end
  955.     if icons.size == 0
  956.       change_color(normal_color, false)
  957.       text = Vocab::item_status(:empty)
  958.       draw_text(4, dy, contents.width-8, line_height, text, 2)
  959.     end
  960.   end
  961.   
  962. end # Window_ItemStatus

  963. #==============================================================================
  964. # ■ Scene_Item
  965. #==============================================================================

  966. class Scene_Item < Scene_ItemBase
  967.   
  968.   #--------------------------------------------------------------------------
  969.   # alias method: start
  970.   #--------------------------------------------------------------------------
  971.   alias scene_item_start_aim start
  972.   def start
  973.     scene_item_start_aim
  974.     create_types_window
  975.     create_status_window
  976.     relocate_windows
  977.   end
  978.   
  979.   #--------------------------------------------------------------------------
  980.   # overwrite method: return_scene
  981.   #--------------------------------------------------------------------------
  982.   def return_scene
  983.     $game_temp.scene_item_index = nil
  984.     $game_temp.scene_item_oy = nil
  985.     super
  986.   end
  987.   
  988.   #--------------------------------------------------------------------------
  989.   # overwrite method: create_category_window
  990.   #--------------------------------------------------------------------------
  991.   def create_category_window
  992.     wy = @help_window.height
  993.     @category_window = Window_ItemCommand.new(0, wy)
  994.     @category_window.viewport = @viewport
  995.     @category_window.help_window = @help_window
  996.     @category_window.y = @help_window.height
  997.     if !$game_temp.scene_item_index.nil?
  998.       @category_window.select($game_temp.scene_item_index)
  999.       @category_window.oy = $game_temp.scene_item_oy
  1000.     end
  1001.     $game_temp.scene_item_index = nil
  1002.     $game_temp.scene_item_oy = nil
  1003.     @category_window.set_handler(:ok, method(:on_category_ok))
  1004.     @category_window.set_handler(:cancel, method(:return_scene))
  1005.     @category_window.set_handler(:item, method(:open_types))
  1006.     @category_window.set_handler(:weapon, method(:open_types))
  1007.     @category_window.set_handler(:armor, method(:open_types))
  1008.     process_custom_item_commands
  1009.   end
  1010.   
  1011.   #--------------------------------------------------------------------------
  1012.   # new method: process_custom_item_commands
  1013.   #--------------------------------------------------------------------------
  1014.   def process_custom_item_commands
  1015.     for command in YEA::ITEM::COMMANDS
  1016.       next unless YEA::ITEM::CUSTOM_ITEM_COMMANDS.include?(command)
  1017.       called_method = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][3]
  1018.       @category_window.set_handler(command, method(called_method))
  1019.     end
  1020.   end
  1021.   
  1022.   #--------------------------------------------------------------------------
  1023.   # new method: create_types_window
  1024.   #--------------------------------------------------------------------------
  1025.   def create_types_window
  1026.     wy = @category_window.y
  1027.     @types_window = Window_ItemType.new(Graphics.width, wy)
  1028.     @types_window.viewport = @viewport
  1029.     @types_window.help_window = @help_window
  1030.     @types_window.y = @help_window.height
  1031.     @types_window.item_window = @item_window
  1032.     @item_window.types_window = @types_window
  1033.     @types_window.set_handler(:ok, method(:on_types_ok))
  1034.     @types_window.set_handler(:cancel, method(:on_types_cancel))
  1035.   end
  1036.   
  1037.   #--------------------------------------------------------------------------
  1038.   # new method: create_status_window
  1039.   #--------------------------------------------------------------------------
  1040.   def create_status_window
  1041.     wx = @category_window.width
  1042.     wy = @category_window.y
  1043.     @status_window = Window_ItemStatus.new(wx, wy, @item_window)
  1044.     @status_window.viewport = @viewport
  1045.   end
  1046.   
  1047.   #--------------------------------------------------------------------------
  1048.   # new method: relocate_windows
  1049.   #--------------------------------------------------------------------------
  1050.   def relocate_windows
  1051.     return unless $imported["YEA-AceMenuEngine"]
  1052.     case Menu.help_window_location
  1053.     when 0 # Top
  1054.       @help_window.y = 0
  1055.       @category_window.y = @help_window.height
  1056.       @item_window.y = @category_window.y + @category_window.height
  1057.     when 1 # Middle
  1058.       @category_window.y = 0
  1059.       @help_window.y = @category_window.height
  1060.       @item_window.y = @help_window.y + @help_window.height
  1061.     else # Bottom
  1062.       @category_window.y = 0
  1063.       @item_window.y = @category_window.height
  1064.       @help_window.y = @item_window.y + @item_window.height
  1065.     end
  1066.     @types_window.y = @category_window.y
  1067.     @status_window.y = @category_window.y
  1068.   end
  1069.   
  1070.   #--------------------------------------------------------------------------
  1071.   # new method: open_categories
  1072.   #--------------------------------------------------------------------------
  1073.   def open_types
  1074.     @category_window.x = Graphics.width
  1075.     @types_window.x = 0
  1076.     @types_window.reveal(@category_window.current_symbol)
  1077.   end
  1078.   
  1079.   #--------------------------------------------------------------------------
  1080.   # new method: on_types_ok
  1081.   #--------------------------------------------------------------------------
  1082.   def on_types_ok
  1083.     @item_window.activate
  1084.     @item_window.select_last
  1085.   end
  1086.   
  1087.   #--------------------------------------------------------------------------
  1088.   # new method: on_types_cancel
  1089.   #--------------------------------------------------------------------------
  1090.   def on_types_cancel
  1091.     @category_window.x = 0
  1092.     @category_window.activate
  1093.     @types_window.unselect
  1094.     @types_window.x = Graphics.width
  1095.   end
  1096.   
  1097.   #--------------------------------------------------------------------------
  1098.   # alias method: on_item_cancel
  1099.   #--------------------------------------------------------------------------
  1100.   alias scene_item_on_item_cancel_aim on_item_cancel
  1101.   def on_item_cancel
  1102.     if @types_window.x <= 0
  1103.       @item_window.unselect
  1104.       @types_window.activate
  1105.     else
  1106.       scene_item_on_item_cancel_aim
  1107.     end
  1108.   end
  1109.   
  1110.   #--------------------------------------------------------------------------
  1111.   # new method: command_totori
  1112.   #--------------------------------------------------------------------------
  1113.   def command_totori
  1114.     SceneManager.call(Scene_Alchemy)
  1115.   end
  1116.   
  1117.   #--------------------------------------------------------------------------
  1118.   # new method: command_name1
  1119.   #--------------------------------------------------------------------------
  1120.   def command_name1
  1121.     # Do nothing.
  1122.   end
  1123.   
  1124.   #--------------------------------------------------------------------------
  1125.   # new method: command_name2
  1126.   #--------------------------------------------------------------------------
  1127.   def command_name2
  1128.     # Do nothing.
  1129.   end
  1130.   
  1131. end # Scene_Item

  1132. #==============================================================================
  1133. #
  1134. # ▼ End of File
  1135. #
  1136. #==============================================================================
复制代码


想问问:第117行的注释机翻了下貌似是可以隐藏某类物品的意思?如果可以的话具体怎么用?
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部