Project1

标题: ACE物品項目強化 [打印本页]

作者: asdrty123    时间: 2012-1-22 23:10
标题: ACE物品項目強化
本帖最后由 asdrty123 于 2012-1-23 00:20 编辑

ACE物品項目強化

已經中文化了 可以自己在做調整
可以自行於添加
  1.       [:category,  "Training"], # Categorized by <category: string>
复制代码
例如
  1.     # [  :symbol,   "Display"],
  2.       [   :types,  "WPNTYPES"], # Lists all of the individual weapon types.
  3.       [:category,  "Training"], # Categorized by <category: string>
  4.       [:category, "Legendary"], # Categorized by <category: string>
  5.       [     :all,       "All"], # Shows all weapons.
复制代码
  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 => ["合成",            0,         0, :command_totori],
  121.       :custom1 => [ "自定義名稱",            0,          0, :command_name1],
  122.       :custom2 => [ "自定義文本",           13,          0, :command_name2],
  123.     } # Do not remove this.
  124.    
  125.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  126.     # - Item Type Settings -
  127.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  128.     # These arrays adjusts and shows the various item types shown for Items,
  129.     # Weapons, and Armours. Note that when using :category symbols, the
  130.     # specific category shown will be equal to the text used for the Display
  131.     # and the included item must contain a category equal to the Display name.
  132.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  133.     # This array contains the order for the Item categories.
  134.     ITEM_TYPES =[
  135.     # [  :symbol,   "Display"],
  136.       [   :field,     "背包內"], # Shows Menu-usable items.
  137.       [  :battle,    "戰鬥用"], # Shows Battle-usable items.
  138.       [:category,   "特別"], # Categorized by <category: string>
  139.       [:category,"成分"], # Categorized by <category: string>
  140.       [:key_item,  "貴重物品"], # Shows all key items.
  141.       [     :all,       "全部"], # Shows all usable items.
  142.     ] # Do not remove this.
  143.    
  144.     # This array contains the order for the Weapon categories.
  145.     WEAPON_TYPES =[
  146.     # [  :symbol,   "Display"],
  147.       [   :types,  "WPNTYPES"], # Lists all of the individual weapon types.
  148.       [     :all,       "全部"], # Shows all weapons.
  149.     ] # Do not remove this.
  150.    
  151.     # This array contains the order for the Armour categories.
  152.     ARMOUR_TYPES =[
  153.     # [  :symbol,   "Display"],
  154.       [   :slots,  "ARMSLOTS"], # Lists all of the individual armour slots.
  155.       [   :types,  "ARMTYPES"], # Lists all of the individual armours types.
  156.       [     :all,       "全部"], # Shows all armours.
  157.     ] # Do not remove this.
  158.    
  159.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  160.     # - Item Status Settings -
  161.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  162.     # The item status window displays information about the item in detail.
  163.     # Adjust the settings below to change the way the status window appears.
  164.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  165.     STATUS_FONT_SIZE = 20       # Font size used for status window.
  166.     MAX_ICONS_DRAWN  = 10       # Maximum number of icons drawn for states.
  167.    
  168.     # The following adjusts the vocabulary used for the status window. Each
  169.     # of the vocabulary settings are self explanatory.
  170.     VOCAB_STATUS ={
  171.       :empty      => "---",          # Text used when nothing is shown.
  172.       :hp_recover => "恢復HP",      # Text used for HP Recovery.
  173.       :mp_recover => "恢復MP",      # Text used for MP Recovery.
  174.       :tp_recover => "恢復TP",      # Text used for TP Recovery.
  175.       :tp_gain    => "增加TP",      # Text used for TP Gain.
  176.       :applies    => "使用效果",      # Text used for applied states and buffs.
  177.       :removes    => "移除效果",      # Text used for removed states and buffs.
  178.     } # Do not remove this.
  179.    
  180.   end # ITEM
  181. end # YEA

  182. #==============================================================================
  183. # ▼ Editting anything past this point may potentially result in causing
  184. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  185. # halitosis so edit at your own risk.
  186. #==============================================================================

  187. module YEA
  188.   module REGEXP
  189.   module BASEITEM
  190.    
  191.     CATEGORY = /<(?:CATEGORIES|category):[ ](.*)>/i
  192.     IMAGE    = /<(?:IMAGE|image):[ ](.*)>/i
  193.    
  194.   end # BASEITEM
  195.   end # REGEXP
  196. end # YEA

  197. #==============================================================================
  198. # ■ Numeric
  199. #==============================================================================

  200. class Numeric
  201.   
  202.   #--------------------------------------------------------------------------
  203.   # new method: group_digits
  204.   #--------------------------------------------------------------------------
  205.   unless $imported["YEA-CoreEngine"]
  206.   def group; return self.to_s; end
  207.   end # $imported["YEA-CoreEngine"]
  208.    
  209. end # Numeric

  210. #==============================================================================
  211. # ■ Vocab
  212. #==============================================================================

  213. module Vocab
  214.   
  215.   #--------------------------------------------------------------------------
  216.   # new method: self.item_status
  217.   #--------------------------------------------------------------------------
  218.   def self.item_status(type)
  219.     return YEA::ITEM::VOCAB_STATUS[type]
  220.   end
  221.   
  222. end # Vocab

  223. #==============================================================================
  224. # ■ DataManager
  225. #==============================================================================

  226. module DataManager
  227.   
  228.   #--------------------------------------------------------------------------
  229.   # alias method: load_database
  230.   #--------------------------------------------------------------------------
  231.   class <<self; alias load_database_aim load_database; end
  232.   def self.load_database
  233.     load_database_aim
  234.     load_notetags_aim
  235.   end
  236.   
  237.   #--------------------------------------------------------------------------
  238.   # new method: load_notetags_aim
  239.   #--------------------------------------------------------------------------
  240.   def self.load_notetags_aim
  241.     groups = [$data_items, $data_weapons, $data_armors]
  242.     for group in groups
  243.       for obj in group
  244.         next if obj.nil?
  245.         obj.load_notetags_aim
  246.       end
  247.     end
  248.   end
  249.   
  250. end # DataManager

  251. #==============================================================================
  252. # ■ RPG::BaseItem
  253. #==============================================================================

  254. class RPG::BaseItem
  255.   
  256.   #--------------------------------------------------------------------------
  257.   # public instance variables
  258.   #--------------------------------------------------------------------------
  259.   attr_accessor :category
  260.   attr_accessor :image
  261.   
  262.   #--------------------------------------------------------------------------
  263.   # common cache: load_notetags_aim
  264.   #--------------------------------------------------------------------------
  265.   def load_notetags_aim
  266.     @category = []
  267.     #---
  268.     self.note.split(/[\r\n]+/).each { |line|
  269.       case line
  270.       #---
  271.       when YEA::REGEXP::BASEITEM::CATEGORY
  272.         @category.push($1.upcase.to_s)
  273.       when YEA::REGEXP::BASEITEM::IMAGE
  274.         @image = $1.to_s
  275.       end
  276.     } # self.note.split
  277.     #---
  278.   end
  279.   
  280. end # RPG::BaseItem

  281. #==============================================================================
  282. # ■ Game_Temp
  283. #==============================================================================

  284. class Game_Temp
  285.   
  286.   #--------------------------------------------------------------------------
  287.   # public instance variables
  288.   #--------------------------------------------------------------------------
  289.   attr_accessor :scene_item_index
  290.   attr_accessor :scene_item_oy
  291.   
  292. end # Game_Temp

  293. #==============================================================================
  294. # ■ Window_ItemList
  295. #==============================================================================

  296. class Window_ItemList < Window_Selectable
  297.   
  298.   #--------------------------------------------------------------------------
  299.   # overwrite method: draw_item
  300.   #--------------------------------------------------------------------------
  301.   def draw_item(index)
  302.     item = @data[index]
  303.     return if item.nil?
  304.     rect = item_rect(index)
  305.     rect.width -= 4
  306.     draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
  307.     draw_item_number(rect, item)
  308.   end
  309.   
  310. end # Window_ItemList

  311. #==============================================================================
  312. # ■ Window_ItemCommand
  313. #==============================================================================

  314. class Window_ItemCommand < Window_Command
  315.   
  316.   #--------------------------------------------------------------------------
  317.   # public instance variables
  318.   #--------------------------------------------------------------------------
  319.   attr_reader   :item_window
  320.   
  321.   #--------------------------------------------------------------------------
  322.   # initialize
  323.   #--------------------------------------------------------------------------
  324.   def initialize(x, y)
  325.     super(x, y)
  326.   end
  327.   
  328.   #--------------------------------------------------------------------------
  329.   # window_width
  330.   #--------------------------------------------------------------------------
  331.   def window_width; return 160; end
  332.   
  333.   #--------------------------------------------------------------------------
  334.   # visible_line_number
  335.   #--------------------------------------------------------------------------
  336.   def visible_line_number; return 4; end
  337.   
  338.   #--------------------------------------------------------------------------
  339.   # process_ok
  340.   #--------------------------------------------------------------------------
  341.   def process_ok
  342.     $game_temp.scene_item_index = index
  343.     $game_temp.scene_item_oy = self.oy
  344.     super
  345.   end
  346.   
  347.   #--------------------------------------------------------------------------
  348.   # make_command_list
  349.   #--------------------------------------------------------------------------
  350.   def make_command_list
  351.     for command in YEA::ITEM::COMMANDS
  352.       case command
  353.       #--- Default Commands ---
  354.       when :item
  355.         add_command(Vocab::item, :item)
  356.       when :weapon
  357.         add_command(Vocab::weapon, :weapon)
  358.       when :armor
  359.         add_command(Vocab::armor, :armor)
  360.       when :key_item
  361.         add_command(Vocab::key_item, :key_item)
  362.       #--- Imported ---
  363.       when :gogototori
  364.         next unless $imported["KRX-AlchemicSynthesis"]
  365.         process_custom_command(command)
  366.       #--- Custom Commands ---
  367.       else
  368.         process_custom_command(command)
  369.       end
  370.     end
  371.   end
  372.   
  373.   #--------------------------------------------------------------------------
  374.   # process_custom_command
  375.   #--------------------------------------------------------------------------
  376.   def process_custom_command(command)
  377.     return unless YEA::ITEM::CUSTOM_ITEM_COMMANDS.include?(command)
  378.     show = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][2]
  379.     continue = show <= 0 ? true : $game_switches[show]
  380.     return unless continue
  381.     text = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][0]
  382.     switch = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][1]
  383.     enabled = switch <= 0 ? true : $game_switches[switch]
  384.     add_command(text, command, enabled)
  385.   end
  386.   
  387.   #--------------------------------------------------------------------------
  388.   # update
  389.   #--------------------------------------------------------------------------
  390.   def update
  391.     super
  392.     return unless self.active
  393.     @item_window.category = current_symbol if @item_window
  394.   end
  395.   
  396.   #--------------------------------------------------------------------------
  397.   # item_window=
  398.   #--------------------------------------------------------------------------
  399.   def item_window=(item_window)
  400.     @item_window = item_window
  401.     update
  402.   end
  403.   
  404. end # Window_ItemCommand

  405. #==============================================================================
  406. # ■ Window_ItemType
  407. #==============================================================================

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

  514. #==============================================================================
  515. # ■ Window_ItemList
  516. #==============================================================================

  517. class Window_ItemList < Window_Selectable
  518.   
  519.   #--------------------------------------------------------------------------
  520.   # alias method: initialize
  521.   #--------------------------------------------------------------------------
  522.   alias window_itemlist_initialize_aim initialize
  523.   def initialize(dx, dy, dw, dh)
  524.     window_itemlist_initialize_aim(dx, dy, dw, dh)
  525.     @ext = :none
  526.     @name = ""
  527.   end
  528.   
  529.   #--------------------------------------------------------------------------
  530.   # alias method: category=
  531.   #--------------------------------------------------------------------------
  532.   alias window_itemlist_category_aim category=
  533.   def category=(category)
  534.     if @types_window.nil?
  535.       window_itemlist_category_aim(category)
  536.     else
  537.       return unless update_types?(category)
  538.       @category = category
  539.       if @types_window.active
  540.         @name = @types_window.current_data[:name]
  541.         @ext = @types_window.current_ext
  542.       end
  543.       refresh
  544.       self.oy = 0
  545.     end
  546.   end
  547.   
  548.   #--------------------------------------------------------------------------
  549.   # new method: update_types?
  550.   #--------------------------------------------------------------------------
  551.   def update_types?(category)
  552.     return true if @category != category
  553.     return false unless @types_window.active
  554.     if category == :category
  555.       return @name != @types_window.current_data[:name]
  556.     end
  557.     return @ext != @types_window.current_ext
  558.   end
  559.   
  560.   #--------------------------------------------------------------------------
  561.   # new method: types_window=
  562.   #--------------------------------------------------------------------------
  563.   def types_window=(window)
  564.     @types_window = window
  565.   end
  566.   
  567.   #--------------------------------------------------------------------------
  568.   # alias method: include?
  569.   #--------------------------------------------------------------------------
  570.   alias window_itemlist_include_aim include?
  571.   def include?(item)
  572.     if @types_window.nil?
  573.       return window_itemlist_include_aim(item)
  574.     else
  575.       return ace_item_menu_include?(item)
  576.     end
  577.   end
  578.   
  579.   #--------------------------------------------------------------------------
  580.   # new method: ace_item_menu_include?
  581.   #--------------------------------------------------------------------------
  582.   def ace_item_menu_include?(item)
  583.     case @category
  584.     #---
  585.     when :field
  586.       return false unless item.is_a?(RPG::Item)
  587.       return item.menu_ok?
  588.     when :battle
  589.       return false unless item.is_a?(RPG::Item)
  590.       return item.battle_ok?
  591.     #---
  592.     when :w_type
  593.       return false unless item.is_a?(RPG::Weapon)
  594.       return item.wtype_id == @types_window.current_ext
  595.     when :a_type
  596.       return false unless item.is_a?(RPG::Armor)
  597.       return item.atype_id == @types_window.current_ext
  598.     when :e_type
  599.       return false unless item.is_a?(RPG::Armor)
  600.       return item.etype_id == @types_window.current_ext
  601.     #---
  602.     when :all
  603.       case @types_window.current_ext
  604.       when :item
  605.         return item.is_a?(RPG::Item)
  606.       when :weapon
  607.         return item.is_a?(RPG::Weapon)
  608.       else
  609.         return item.is_a?(RPG::Armor)
  610.       end
  611.     #---
  612.     when :category
  613.       case @types_window.current_ext
  614.       when :item
  615.         return false unless item.is_a?(RPG::Item)
  616.       when :weapon
  617.         return false unless item.is_a?(RPG::Weapon)
  618.       else
  619.         return false unless item.is_a?(RPG::Armor)
  620.       end
  621.       return item.category.include?(@types_window.current_data[:name].upcase)
  622.     #---
  623.     else
  624.       return window_itemlist_include_aim(item)
  625.     end
  626.   end
  627.   
  628. end # Window_ItemList

  629. #==============================================================================
  630. # ■ Window_ItemStatus
  631. #==============================================================================

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

  984. #==============================================================================
  985. # ■ Scene_Item
  986. #==============================================================================

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

  1153. #==============================================================================
  1154. #
  1155. # ▼ End of File
  1156. #
  1157. #==============================================================================
复制代码

作者: lifujiang    时间: 2012-1-23 00:04
谢谢分享
作者: orzfly    时间: 2012-1-23 00:15
不是原创的话不能是发布的吧。
来源可是http://yanflychannel.wordpress.com
请考虑转到地球村。
作者: 越前リョーマ    时间: 2012-1-23 01:19
这样漂亮不少呢,不过不带个范例吗?
那个大图应该可以自己做的吧?
作者: xmheart    时间: 2012-1-27 10:38
大图跟物品图标是一样的…能造成不一样的吗?
作者: asdrty123    时间: 2012-1-28 03:51
xmheart 发表于 2012-1-27 10:38
大图跟物品图标是一样的…能造成不一样的吗?

可以
在物品的備註輸入
<image: string>
string號碼來自於你放在Graphics\Pictures\的圖片

範例

作者: 布里蓝    时间: 2012-4-14 14:09
请问下,怎么把物品分类?比如菜谱分到菜谱里,我把脚本里各种像样的话写到备注里也没效……


‘‘──布里蓝于2012-4-15 00:13补充以下内容

啊,摸索了半天终于懂了,原来是<category: 菜谱>而不是<category: menu>啊!
’’




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1