设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1087|回复: 0
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
154
在线时间
181 小时
注册时间
2012-6-11
帖子
65
跳转到指定楼层
1
发表于 2013-4-7 12:43:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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


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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-30 13:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表