Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 52.30 KB | None | 0 0
  1. #=============================================================================#
  2. #   Extended Equipment Comparison Info                                        #
  3. #   Version: 1.0.0                                                            #  
  4. #   Author: Compeador                                                         #  
  5. #   Last update: 2018.10.21                                                   #  
  6. #=============================================================================#
  7. $imported = {} if $imported.nil?
  8. $imported["COMP_EECI"] = true
  9. #=============================================================================#
  10. #                               ** Update log **                              #
  11. #-----------------------------------------------------------------------------#
  12. #                                                                             #
  13. # -- 2018.10.21: First release                                                #
  14. #                                                                             #
  15. #=============================================================================#
  16. #                       ** End-User License Agreement **                      #
  17. #-----------------------------------------------------------------------------#
  18. #  1. Copyright and Redistribution:                                           #
  19. #       All codes were written by me(Compeador), and you(the user) may edit   #
  20. #  the code for your own need without permission (duh).                       #
  21. #  Redistribute this script must agreed by VaiJack8, who commissioned this    #
  22. #  script, and you must share the original version released by the author     #
  23. #  without edits.                                                             #
  24. #                                                                             #
  25. # 2. Service Information:                                                     #
  26. #       I only responsible for the edits requested by VaiJack8(the client).   #
  27. # If you got this script from the redistribution, I'm not responsible for any #
  28. # bug and malfunction occurred in your project.                               #
  29. #                                                                             #
  30. # *You can still try to request me tho, but I won't 100% guaranteed for reply #
  31. #=============================================================================#
  32. #                              ** User Manual **                              #
  33. #-----------------------------------------------------------------------------#
  34. # > Introduction:                                                             #
  35. #       This script will change the display of original parameter comparison  #
  36. # in Equip Scene when changing the equipments, instead of showing default     #
  37. # paramters, this script will only show changed parameters, including crit.   #
  38. # evasion...etc.                                                              #
  39. #=============================================================================#
  40. #                            ** Compatibility **                              #
  41. #-----------------------------------------------------------------------------#
  42. #   > Compatible with YEA Equip Engine                                        #
  43. #   > Support comparison with 'Equipment Set Bonuses' by Modern Algebra       #
  44. #                                                                             #
  45. #       ** Place this script below the scripts mentioned above **             #
  46. #=============================================================================#
  47.  
  48. # Enable this script?
  49. COMP_EECI_Enable = true
  50.  
  51. if COMP_EECI_Enable
  52. #=============================================================================
  53. # * Module of this script
  54. #=============================================================================
  55. module COMP
  56.   #-------------------------------------------------------------------------
  57.   # Abbr. of Extended Equipment Comparison Information
  58.   module EECI
  59.     #--------------------------------------------------------------------------
  60.     # * Constants (Features) from Game_BattlerBase
  61.     # * Don't edit this unless you know what you're doing
  62.     #--------------------------------------------------------------------------
  63.     FEATURE_ELEMENT_RATE    =   Game_BattlerBase::FEATURE_ELEMENT_RATE    # Element Rate
  64.     FEATURE_DEBUFF_RATE     =   Game_BattlerBase::FEATURE_DEBUFF_RATE     # Debuff Rate
  65.     FEATURE_STATE_RATE      =   Game_BattlerBase::FEATURE_STATE_RATE      # State Rate
  66.     FEATURE_STATE_RESIST    =   Game_BattlerBase::FEATURE_STATE_RESIST    # State Resist
  67.     FEATURE_PARAM           =   Game_BattlerBase::FEATURE_PARAM           # Parameter
  68.     FEATURE_XPARAM          =   Game_BattlerBase::FEATURE_XPARAM          # Ex-Parameter
  69.     FEATURE_SPARAM          =   Game_BattlerBase::FEATURE_SPARAM          # Sp-Parameter
  70.     FEATURE_ATK_ELEMENT     =   Game_BattlerBase::FEATURE_ATK_ELEMENT     # Atk Element
  71.     FEATURE_ATK_STATE       =   Game_BattlerBase::FEATURE_ATK_STATE       # Atk State
  72.     FEATURE_ATK_SPEED       =   Game_BattlerBase::FEATURE_ATK_SPEED       # Atk Speed
  73.     FEATURE_ATK_TIMES       =   Game_BattlerBase::FEATURE_ATK_TIMES       # Atk Times+
  74.     FEATURE_STYPE_ADD       =   Game_BattlerBase::FEATURE_STYPE_ADD       # Add Skill Type
  75.     FEATURE_STYPE_SEAL      =   Game_BattlerBase::FEATURE_STYPE_SEAL      # Disable Skill Type
  76.     FEATURE_SKILL_ADD       =   Game_BattlerBase::FEATURE_SKILL_ADD       # Add Skill
  77.     FEATURE_SKILL_SEAL      =   Game_BattlerBase::FEATURE_SKILL_SEAL      # Disable Skill
  78.     FEATURE_EQUIP_WTYPE     =   Game_BattlerBase::FEATURE_EQUIP_WTYPE     # Equip Weapon
  79.     FEATURE_EQUIP_ATYPE     =   Game_BattlerBase::FEATURE_EQUIP_ATYPE     # Equip Armor
  80.     FEATURE_EQUIP_FIX       =   Game_BattlerBase::FEATURE_EQUIP_FIX       # Lock Equip
  81.     FEATURE_EQUIP_SEAL      =   Game_BattlerBase::FEATURE_EQUIP_SEAL      # Seal Equip
  82.     FEATURE_SLOT_TYPE       =   Game_BattlerBase::FEATURE_SLOT_TYPE       # Slot Type
  83.     FEATURE_ACTION_PLUS     =   Game_BattlerBase::FEATURE_ACTION_PLUS     # Action Times+
  84.     FEATURE_SPECIAL_FLAG    =   Game_BattlerBase::FEATURE_SPECIAL_FLAG    # Special Flag
  85.     FEATURE_COLLAPSE_TYPE   =   Game_BattlerBase::FEATURE_COLLAPSE_TYPE   # Collapse Effect
  86.     FEATURE_PARTY_ABILITY   =   Game_BattlerBase::FEATURE_PARTY_ABILITY   # Party Ability
  87.     # ---Feature Flags---
  88.     FLAG_ID_AUTO_BATTLE     =   Game_BattlerBase::FLAG_ID_AUTO_BATTLE     # auto battle
  89.     FLAG_ID_GUARD           =   Game_BattlerBase::FLAG_ID_GUARD           # guard
  90.     FLAG_ID_SUBSTITUTE      =   Game_BattlerBase::FLAG_ID_SUBSTITUTE      # substitute
  91.     FLAG_ID_PRESERVE_TP     =   Game_BattlerBase::FLAG_ID_PRESERVE_TP     # preserve TP
  92.     #=====================================================================#
  93.     # *                     v Free to Edit v                              #
  94.     #=====================================================================#
  95.     # * The next/last page keybind, edit the value for your own need.
  96.     #=====================================================================
  97.     Key_nextpage  = :RIGHT
  98.     Key_lastpage  = :LEFT
  99.     #---------------------------------------------------------------------
  100.     # * Text displayed when showing the comparison of set equipment bonus
  101.     SetEquipmentTextStem = "Set bonus"
  102.     SetEquipmentText = SetEquipmentTextStem + " [%s]:"
  103.     #---------------------------------------------------------------------
  104.     # * Id for standard param
  105.     FeatureNormalParam = -1
  106.     #---------------------------------------------------------------------
  107.     # * The param/feature considered to compare
  108.     ComparisonTable = {        
  109.       #    better not touch      edit the text for your need
  110.       #    ↓              ↓                 ↓      
  111.       # symbol        => [id,  display group text showed in comparison]
  112.       :param          => [FeatureNormalParam, ''],                  # Basic parameter
  113.       :xparam         => [FEATURE_XPARAM, ''],                      # Ex-Parameter
  114.       :sparam         => [FEATURE_SPARAM, ''],                      # Sp-Parameter
  115.  
  116.       :param_rate     => [FEATURE_PARAM, 'Param multipler'],        # Parameter
  117.       :special_flag   => [FEATURE_SPECIAL_FLAG, 'Special'],         # Special feature flag
  118.       :element_rate   => [FEATURE_ELEMENT_RATE, 'Element Rate'],    # Element Rate
  119.       :debuff_rate    => [FEATURE_DEBUFF_RATE, 'Debuff Rate'],      # Debuff Rate
  120.       :state_rate     => [FEATURE_STATE_RATE, 'State Rate'],        # State Rate
  121.       :state_resist   => [FEATURE_STATE_RESIST, 'State Resist'],    # State Resist
  122.       :atk_element    => [FEATURE_ATK_ELEMENT, 'Atk Element'],      # Atk Element
  123.       :atk_state      => [FEATURE_ATK_STATE, 'Atk State'],          # Atk State
  124.       :atk_speed      => [FEATURE_ATK_SPEED, 'Feature'],            # Atk Speed
  125.       :atk_times      => [FEATURE_ATK_TIMES, 'Feature'],            # Atk Times+
  126.       :stype_add      => [FEATURE_STYPE_ADD, 'Add Skill Type'],     # Add Skill Type
  127.       :stype_seal     => [FEATURE_STYPE_SEAL, 'Disable Skill Type'],# Disable Skill Type
  128.       :skill_add      => [FEATURE_SKILL_ADD, 'Add Skill'],          # Add Skill
  129.       :skill_seal     => [FEATURE_SKILL_SEAL, 'Disable Skill'],     # Disable Skill
  130.       :equip_wtype    => [FEATURE_EQUIP_WTYPE, 'Equip Weapon'],     # Equip Weapon
  131.       :equip_atype    => [FEATURE_EQUIP_ATYPE, 'Equip Armor'],      # Equip Armor
  132.       :equip_fix      => [FEATURE_EQUIP_FIX, 'Lock Equip'],         # Lock Equip
  133.       :equip_seal     => [FEATURE_EQUIP_SEAL, 'Seal Equip'],        # Seal Equip
  134.       :slot_type      => [FEATURE_SLOT_TYPE, 'Slot Type'],          # Slot Type
  135.       :action_plus    => [FEATURE_ACTION_PLUS, 'Action Times+'],    # Action Times+
  136.       :party_ability  => [FEATURE_PARTY_ABILITY, 'Party ability'],  # Party ability
  137.     }
  138.     #---------------------------------------------------------------------
  139.     # * Id for equipment set
  140.     FeatureEquipSet = -2
  141.     #---------------------------------------------------------------------
  142.     # * Compare with MA's equipment set diff
  143.     if $imported[:MA_EquipmentSetBonuses]
  144.       ComparisonTable[:equipset_plus] = [FeatureEquipSet, SetEquipmentText]
  145.     end
  146.     #---------------------------------------------------------------------
  147.     MISC_text = 'Other' # the group text not in this order list
  148.     #---------------------------------------------------------------------
  149.     # * Display order of comparison group text, upper one displayed first
  150.     TextDisplayOrder = [
  151.       '',         # suggestion: better not touch this line
  152.       'Feature',
  153.       'Special',
  154.       'Param multipler',
  155.       'Element Rate',
  156.       'Debuff Rate',
  157.       'State Rate',
  158.       'State Resist',
  159.       'Atk Element',
  160.       'Atk State',
  161.       'Atk Speed',
  162.       'Atk Times+',
  163.       'Add Skill Type',
  164.       'Disable Skill Type',
  165.       'Add Skill',
  166.       'Disable Skill',
  167.       'Equip Weapon',
  168.       'Equip Armor',
  169.       'Lock Equip',
  170.       'Seal Equip',
  171.       'Slot Type',
  172.       'Action Times+',
  173.       'Party ability',
  174.       MISC_text,
  175.       SetEquipmentText,
  176.     ]
  177.     #---------------------------------------------------------------------
  178.     # * Name display for each xparam
  179.     XParamName = {
  180.       0   => "HIT",  # HIT rate
  181.       1   => "EVA",  # EVAsion rate
  182.       2   => "CRI",  # CRItical rate
  183.       3   => "CEV",  # Critical EVasion rate
  184.       4   => "MEV",  # Magic EVasion rate
  185.       5   => "MRF",  # Magic ReFlection rate
  186.       6   => "CNT",  # CouNTer attack rate
  187.       7   => "HRG",  # Hp ReGeneration rate
  188.       8   => "MRG",  # Mp ReGeneration rate
  189.       9   => "TRG",  # Tp ReGeneration rate
  190.     }
  191.     #---------------------------------------------------------------------
  192.     # * Name display for each sparam
  193.     SParamName = {
  194.       0   => "TGR",  # TarGet Rate
  195.       1   => "GRD",  # GuaRD effect rate
  196.       2   => "REC",  # RECovery effect rate
  197.       3   => "PHA",  # PHArmacology
  198.       4   => "MCR",  # Mp Cost Rate
  199.       5   => "TCR",  # Tp Charge Rate
  200.       6   => "PDR",  # Physical Damage Rate
  201.       7   => "MDR",  # Magical Damage Rate
  202.       8   => "FDR",  # Floor Damage Rate
  203.       9   => "EXR",  # EXperience Rate
  204.     }
  205.     #---------------------------------------------------------------------
  206.     # * Name display for party ability
  207.     PartyAbilityName = {
  208.       0   => "Encounter Half",          # halve encounters
  209.       1   => "Encounter None",          # disable encounters
  210.       2   => "Cancel Surprise",         # disable surprise
  211.       3   => "Raise Preemptive",        # increase preemptive strike rate
  212.       4   => "Gold Double",             # double money earned
  213.       5   => "Item Drop Rate Double",   # double item acquisition rate
  214.     }
  215.     #---------------------------------------------------------------------
  216.     # * Name display for special feature
  217.     SpecialFeatureName = {
  218.       0 => "Auto Battle",
  219.       1 => "Guard",
  220.       2 => "Substitute",
  221.       3 => "Preserve TP",
  222.     }
  223.     #--------------------------------------------------------------------------
  224.     # * Feature name displayed at first of the line, before value comparison
  225.     OtherFeatureName = {
  226.       # feature id        => display name
  227.       FEATURE_ATK_SPEED   => 'ASP',
  228.       FEATURE_ATK_TIMES   => 'ATS+',
  229.       FEATURE_ACTION_PLUS => '+%d:',
  230.     }
  231.     #---------------------------------------------------------------------
  232.     # * prefix of single feature comparison
  233.     FeatureAddText     = "+" + " %s"
  234.     FeatureRemoveText  = "-" + " %s"
  235.     FeatureEnableText  = "√" + " %s"
  236.     FeatureDisableText = "X" + " %s"
  237.     #---------------------------------------------------------------------
  238.     # * The feature id that is actually not good
  239.     InverseColorFeature = [FEATURE_STYPE_SEAL, FEATURE_SKILL_SEAL]
  240.     #---------------------------------------------------------------------
  241.     # * The value of given feature id will disaply as percent
  242.     PercentageFeaure = [
  243.       FEATURE_ELEMENT_RATE, FEATURE_DEBUFF_RATE, FEATURE_STATE_RATE,
  244.       FEATURE_PARAM, FEATURE_XPARAM, FEATURE_SPARAM, FEATURE_ATK_STATE,
  245.       FEATURE_ACTION_PLUS,
  246.     ]
  247.     #--------------------------------------------------------------------------
  248.     # * Features that shows in status window when not comparing stuff
  249.     CurFeatureShow = [
  250.       FeatureNormalParam, FEATURE_PARTY_ABILITY, FEATURE_SKILL_ADD, FeatureEquipSet,
  251.     ]
  252.     #=====================================================================#
  253.     # Please don't edit anything below unless you know what you're doing! #
  254.     #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
  255.  
  256.     # Strcuture holds compare result of each difference
  257.     DiffInfo = Struct.new(:feature_id, :data_id, :value, :display_str, :group_text)
  258.     # :feature_id  > what do you expect me to say?
  259.     # :data_id     > data id in grouped feature, such as param
  260.     # :delta       > value changed of that feature, in certain feature id is:
  261.     #   true/false = add/remove after equip
  262.     #
  263.     # :display_str > Other text displayed
  264.     # :group_text  > even need to explain?
  265.  
  266.     DummyInfo = DiffInfo.new(nil, nil, nil, '')
  267.     #--------------------------------------------------------------------------
  268.     # * Mapping table for easier query
  269.     StringTable  = {}   # feature_id   => display_text
  270.     FeatureIdTable = {} # display_text => feature_id
  271.     DisplayOrder = {}   # display_text => order
  272.     DisplayIdOrder = {} # feature_id   => order
  273.     ComparisonTable.each do |symbol, info|
  274.       StringTable[info[0]] = info[1]
  275.       FeatureIdTable[info[1]] = info[0]
  276.     end
  277.     TextDisplayOrder.each_with_index do |str, i|
  278.       DisplayOrder[str] = i
  279.       DisplayIdOrder[FeatureIdTable[str]] = i
  280.     end
  281.   end
  282. end
  283.  
  284. #==========================================================================
  285. # ** RPG::BaseItem
  286. #--------------------------------------------------------------------------
  287. #   This class is the super class of all database classes
  288. #==========================================================================
  289. class RPG::BaseItem
  290.   FEATURE_ACTION_PLUS   = 61              # Action Times+
  291.   FEATURE_SPECIAL_FLAG  = 62              # Special Flag
  292.   FEATURE_PARTY_ABILITY = 64              # Party Ability
  293.   #--------------------------------------------------------------------------
  294.   # * Get Feature Object Array (Feature Codes Limited)
  295.   #--------------------------------------------------------------------------
  296.   def features(code = nil)
  297.     return @features if code.nil?
  298.     @features.select {|ft| ft.code == code }
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # * Get Feature Object Array (Feature Codes and Data IDs Limited)
  302.   #--------------------------------------------------------------------------
  303.   def features_with_id(code, id)
  304.     @features.select {|ft| ft.code == code && ft.data_id == id }
  305.   end
  306.   #--------------------------------------------------------------------------
  307.   # * Calculate Complement of Feature Values
  308.   #--------------------------------------------------------------------------
  309.   def features_pi(code, id)
  310.     result = features_with_id(code, id).inject(1.0) {|r, ft| r *= ft.value }
  311.   end
  312.   #--------------------------------------------------------------------------
  313.   # * Calculate Sum of Feature Values (Specify Data ID)
  314.   #--------------------------------------------------------------------------
  315.   def features_sum(code, id)
  316.     features_with_id(code, id).inject(0.0) {|r, ft| r += ft.value }
  317.   end
  318.   #--------------------------------------------------------------------------
  319.   # * Calculate Sum of Feature Values (Data ID Unspecified)
  320.   #--------------------------------------------------------------------------
  321.   def features_sum_all(code)
  322.     features(code).inject(0.0) {|r, ft| r += ft.value }
  323.   end
  324.   #--------------------------------------------------------------------------
  325.   # * Calculate Set Sum of Features
  326.   #--------------------------------------------------------------------------
  327.   def features_set(code)
  328.     features(code).inject([]) {|r, ft| r |= [ft.data_id] }
  329.   end
  330.   #--------------------------------------------------------------------------
  331.   # * Get Array of Additional Action Time Probabilities
  332.   #--------------------------------------------------------------------------
  333.   def action_plus_set
  334.     features(FEATURE_ACTION_PLUS).collect {|ft| ft.value }
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # * Determine if Special Flag
  338.   #--------------------------------------------------------------------------
  339.   def special_flag(flag_id)
  340.     features(FEATURE_SPECIAL_FLAG).any? {|ft| ft.data_id == flag_id }
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # * Determine Party Ability
  344.   #--------------------------------------------------------------------------
  345.   def party_ability(ability_id)
  346.     features(FEATURE_PARTY_ABILITY).any? {|ft| ft.data_id == ability_id }
  347.   end
  348.   #--------------------------------------------------------------------------
  349. end
  350. #==============================================================================
  351. # ** RPG::EquipItem
  352. #==============================================================================
  353. class RPG::EquipItem < RPG::BaseItem
  354.   #---------------------------------------------------------------------------
  355.   def param(id)
  356.     return @params[id]
  357.   end
  358.   #---------------------------------------------------------------------------
  359. end
  360.  
  361. module COMP::EECI
  362.   #--------------------------------------------------------------------------
  363.   # * Dummy equipment for optimaztion
  364.   Dummy = RPG::Weapon.new
  365.   Dummy.features.clear
  366. end
  367. #==============================================================================
  368. # ** Scene_Equip
  369. #==============================================================================
  370. class Scene_Equip < Scene_MenuBase
  371.   #--------------------------------------------------------------------------
  372.   # * alias: slot [OK]
  373.   #--------------------------------------------------------------------------
  374.   alias on_slot_ok_eeci on_slot_ok
  375.   def on_slot_ok
  376.     item = @actor.equips.at(@slot_window.index)
  377.     item = COMP::EECI::Dummy if item.nil?
  378.     @status_window.set_template_item(item)
  379.     on_slot_ok_eeci
  380.   end
  381. end
  382. #==============================================================================
  383. # ** Window_EquipItem
  384. #==============================================================================
  385. class Window_EquipItem < Window_ItemList
  386.   #--------------------------------------------------------------------------
  387.   # * alias: update help
  388.   #--------------------------------------------------------------------------
  389.   alias update_help_eeci update_help
  390.   def update_help
  391.     @status_window.set_compare_item(item) if @actor && @status_window
  392.     update_help_eeci
  393.   end
  394. end
  395. #==============================================================================
  396. # ** Window_EquipSlot
  397. #==============================================================================
  398. class Window_EquipSlot < Window_Selectable
  399.   #---------------------------------------------------------------------------
  400.   # * alias: refresh
  401.   #---------------------------------------------------------------------------
  402.   alias refresh_eeci refresh
  403.   def refresh
  404.     refresh_eeci
  405.     return unless @status_window
  406.     @status_window.set_base_actor(@actor)
  407.     @status_window.collect_current_feature
  408.     @status_window.draw_current_feature
  409.   end
  410. end
  411. #==============================================================================
  412. # ** Window_EquipStatus
  413. #==============================================================================
  414. class Window_EquipStatus < Window_Base
  415.   include COMP::EECI
  416.   EQS_Enable = $imported[:MA_EquipmentSetBonuses]
  417.   #---------------------------------------------------------------------------
  418.   # * Instance variables
  419.   #---------------------------------------------------------------------------
  420.   attr_reader :template_item, :compare_item, :base_actor, :feature_cache
  421.   attr_reader :difference, :pages, :page_index
  422.   attr_reader :equipset_diff, :base_equipset if EQS_Enable
  423.   #---------------------------------------------------------------------------
  424.   # * Alias method: initialize
  425.   #---------------------------------------------------------------------------
  426.   alias init_eeci initialize
  427.   def initialize(*args)
  428.     @line_max       = 0
  429.     @difference     = {}
  430.     @equipset_diff  = {} if EQS_Enable
  431.     @base_equipset  = {} if EQS_Enable
  432.     @feature_cache  = {}
  433.     @pages          = []
  434.     @base_pages     = []
  435.     @page_index     = 0
  436.     @base_actor     = nil
  437.     @fiber          = nil
  438.     @line_max       = nil
  439.     @cw = nil
  440.     collect_compare_priority
  441.     init_eeci(*args)
  442.     @ori_contents_width = width - standard_padding * 2
  443.     @visible_height = height
  444.   end
  445.   #---------------------------------------------------------------------------
  446.   def collect_compare_priority
  447.     @compare_quque = []
  448.     @compare_quque = ComparisonTable.sort_by{|k, dar|
  449.       DisplayOrder[StringTable[dar.first]] ? DisplayOrder[StringTable[dar.first]] : DisplayOrder[MISC_text]
  450.     }.collect{|p| p[0]}
  451.   end
  452.   #---------------------------------------------------------------------------
  453.   # * Dummy method, does nothing
  454.   #---------------------------------------------------------------------------
  455.   def pass(*args, &block)
  456.   end
  457.   #---------------------------------------------------------------------------
  458.   def line_max
  459.     return @line_max if @line_max
  460.     return @line_max = contents_height / line_height
  461.   end
  462.   #---------------------------------------------------------------------------
  463.   # * Alias method: update
  464.   #---------------------------------------------------------------------------
  465.   alias update_eeci update
  466.   def update
  467.     update_eeci
  468.     update_page
  469.   end
  470.   #---------------------------------------------------------------------------
  471.   # * New method: update scroll
  472.   #---------------------------------------------------------------------------
  473.   def update_page
  474.     current_pages = @temp_actor.nil? ? @base_pages : @pages
  475.     if Input.trigger?(Key_nextpage)
  476.       next_page = @page_index + 1
  477.       resume_comparison if current_pages[next_page * line_max].nil? && !compare_over?
  478.       if current_pages[next_page * line_max]
  479.         resume_comparison unless compare_over?
  480.         @page_index = next_page
  481.         update_arrows(current_pages)
  482.         draw_page(@temp_actor.nil?, @page_index)
  483.       end
  484.     elsif Input.trigger?(Key_lastpage) && @page_index > 0
  485.       @page_index -= 1
  486.       update_arrows(current_pages)
  487.       draw_page(@temp_actor.nil?, @page_index)
  488.     end
  489.   end
  490.   #---------------------------------------------------------------------------
  491.   def contents_width
  492.     return super if @cw.nil?
  493.     return @cw
  494.   end
  495.   #---------------------------------------------------------------------------
  496.   def update_arrows(current_pages)
  497.     @dx = 0
  498.     self.ox = 0
  499.     offset = standard_padding * 4
  500.     @cw = @ori_contents_width
  501.     lv = true if @page_index > 0
  502.     rv = current_pages[(@page_index + 1) * line_max].nil? ? false : true
  503.     if lv
  504.       @cw += offset
  505.       @dx     = offset
  506.       self.ox = offset
  507.     end
  508.     @cw += offset if rv
  509.     create_contents
  510.   end
  511.   #---------------------------------------------------------------------------
  512.   def compare_over?
  513.     @fiber == nil
  514.   end
  515.   #---------------------------------------------------------------------------
  516.   def resume_comparison
  517.     return if @fiber.nil?
  518.     begin
  519.       @fiber.resume
  520.     rescue FiberError => e
  521.       @fiber = nil
  522.     end
  523.   end
  524.   #---------------------------------------------------------------------------
  525.   def set_template_item(item)
  526.     return if @template_item == item
  527.     @template_item = item
  528.     @template_item = item.nil? ? Dummy : item
  529.   end
  530.   #---------------------------------------------------------------------------
  531.   def set_compare_item(item)
  532.     return if @compare_item == item
  533.     @compare_item = item.nil? ? Dummy : item
  534.   end
  535.   #---------------------------------------------------------------------------
  536.   def set_base_actor(actor)
  537.     return if @base_actor == actor
  538.     @feature_cache.clear
  539.     @base_actor = actor
  540.   end
  541.   #---------------------------------------------------------------------------
  542.   # * Overwrite method: actor=
  543.   #---------------------------------------------------------------------------
  544.   def actor=(actor)
  545.     return if @actor == actor
  546.     @actor = actor
  547.     collect_current_feature
  548.     refresh
  549.   end
  550.   #---------------------------------------------------------------------------
  551.   # * Overwrite method: refresh
  552.   #---------------------------------------------------------------------------
  553.   def refresh
  554.     contents.clear
  555.     @cw = nil
  556.     @pages      = []
  557.     @page_index =  0
  558.     return unless @actor
  559.     start_compare(:diff) if @temp_actor
  560.     stage = (@temp_actor) ? :diff : :current
  561.     resume_comparison
  562.     draw_compare_result(stage == :current)
  563.   end
  564.   #---------------------------------------------------------------------------
  565.   def collect_current_feature
  566.     return unless @actor
  567.     start_compare(:current, true)
  568.   end
  569.   #---------------------------------------------------------------------------
  570.   def start_compare(stage = :diff, restart = false)
  571.     if stage == :diff
  572.       save_fiber if !compare_over?
  573.       @fiber = Fiber.new{compare_diffs(stage)}
  574.     elsif stage == :current
  575.       if restart
  576.         release_fiber
  577.         @current_feature = {}
  578.         @base_pages      = []
  579.         @fiber = Fiber.new{compare_diffs(stage)}
  580.       elsif @saved_fiber
  581.         load_fiber
  582.       end
  583.     else
  584.       raise ArgumentError, "Invalid stage symbol (#{stage})"
  585.     end
  586.     resume_comparison
  587.   end
  588.   #---------------------------------------------------------------------------
  589.   def save_fiber
  590.     @saved_fiber = @fiber
  591.   end
  592.   #---------------------------------------------------------------------------
  593.   def load_fiber
  594.     @fiber = @saved_fiber
  595.     release_fiber
  596.   end
  597.   #---------------------------------------------------------------------------
  598.   def release_fiber
  599.     @saved_fiber = nil
  600.   end
  601.   #---------------------------------------------------------------------------
  602.   def process_compare_break(stage)
  603.     @current_line_number = 0
  604.     @draw_break = true
  605.     @showed_group = {}
  606.     Fiber.yield
  607.   end
  608.   #---------------------------------------------------------------------------
  609.   def compare_diffs(stage = :diff)
  610.     return if line_max < 2
  611.     set_compare_item(Dummy) if @compare_item.nil? && stage != :current
  612.     en_prefix   = [FeatureDisableText, FeatureEnableText]  
  613.     @current_line_number = 0 unless stage == :eqset
  614.     last_id = nil
  615.     @showed_group = {}
  616.     @compare_quque.each do |symbol|
  617.       feature_id  = ComparisonTable[symbol].at(0)
  618.       @current_group_text = ComparisonTable[symbol].at(1) || ''
  619.       case symbol
  620.       when :param;        compare_param(stage);
  621.       when :param_rate;   compare_valued_feature(stage,feature_id, true)
  622.       when :xparam;       compare_features_sum(stage,feature_id);
  623.       when :sparam;       compare_features_pi(stage,feature_id);
  624.       when :skill_add;    compare_features_set(stage,feature_id);
  625.       when :skill_seal;   compare_features_set(stage,feature_id, en_prefix.reverse);
  626.       when :element_rate; compare_features_pi(stage,feature_id);
  627.       when :atk_element;  compare_features_set(stage,feature_id);
  628.       when :atk_state;    compare_valued_feature(stage,feature_id, false);
  629.       when :state_rate;   compare_valued_feature(stage,feature_id, true);
  630.       when :state_resist; compare_features_set(stage,feature_id);
  631.       when :stype_seal;   compare_features_set(stage,feature_id, en_prefix.reverse);
  632.       when :stype_add;    compare_features_set(stage,feature_id, en_prefix);
  633.       when :atk_speed;    compare_features_sum(stage,feature_id);
  634.       when :atk_times;    compare_features_sum(stage,feature_id);
  635.       when :action_plus;  compare_action_plus(stage,feature_id);
  636.       when :special_flag; compare_special_flag(stage,feature_id);
  637.       when :party_ability;compare_party_ability(stage,feature_id);
  638.       when :equip_fix;    compare_features_set(stage, feature_id, en_prefix.reverse);
  639.       when :equip_seal;   compare_features_set(stage, feature_id, en_prefix.reverse);
  640.       when :equip_wtype;  compare_features_set(stage, feature_id);
  641.       when :equip_atype;  compare_features_set(stage, feature_id);
  642.       end
  643.       process_compare_break(stage) if @current_line_number >= line_max && !@draw_break
  644.       if EQS_Enable && stage != :eqset && feature_id == FeatureEquipSet
  645.         collect_equipment_set_diff(stage == :current)
  646.       end
  647.       last_id = feature_id
  648.       @draw_break = false
  649.       process_compare_break(stage) if @current_line_number >= line_max && !@draw_break
  650.     end # ComparisonTable.each
  651.   end
  652.   #---------------------------------------------------------------------------
  653.   def get_cache_feature(id, method, *args, &block)
  654.     return @feature_cache[id] if @feature_cache[id]
  655.     return unless @base_actor
  656.     return (@feature_cache[id] = @base_actor.send(method, *args, &block))
  657.   end
  658.   #---------------------------------------------------------------------------
  659.   def hash_feature_idx(feature_id, index = 0)
  660.     return index * 10000 + feature_id
  661.   end
  662.   #---------------------------------------------------------------------------
  663.   def push_new_comparison(stage, info)
  664.     push_group_info(stage, info)
  665.     if stage == :current || (stage == :eqset && @last_stage == :current)
  666.       @base_pages << info
  667.     else
  668.       @pages << info
  669.     end
  670.     @current_line_number += 1
  671.     if @current_line_number >= line_max
  672.       process_compare_break(stage)
  673.     end
  674.   end
  675.   #---------------------------------------------------------------------------
  676.   def push_group_info(stage, info)
  677.     str = []
  678.     str.push(sprintf(SetEquipmentText, @set_bonus_item.name)) if @set_bonus_item
  679.     str.push(@current_group_text)
  680.     ori_group = str.dup
  681.     str.select!{|s| !@showed_group[s]}
  682.  
  683.     reserve_line = str.size
  684.     if @current_line_number + reserve_line > line_max
  685.       (reserve_line - 1).times do |_|
  686.         if stage == :current || (stage == :eqset && @last_stage == :current)
  687.           @base_pages.push(DummyInfo)
  688.         else
  689.           @pages.push(DummyInfo)
  690.         end
  691.       end
  692.       process_compare_break(stage)
  693.       str = ori_group
  694.     end
  695.  
  696.     str.select{|s| s.length > 0}.each do |s|
  697.       @showed_group[s] = true
  698.       @current_line_number += 1
  699.       duminfo = DummyInfo.dup; duminfo.group_text = s;
  700.       if stage == :current || (stage == :eqset && @last_stage == :current)
  701.         @base_pages.push(duminfo)
  702.       else
  703.         @pages.push(duminfo)
  704.       end
  705.     end # each group text
  706.   end
  707.   #---------------------------------------------------------------------------
  708.   def compare_param(stage)
  709.     feature_id = FeatureNormalParam
  710.     ar = get_feature_array(feature_id)
  711.     len = ar.size
  712.     len.times do |i|
  713.       str = get_feature_name(feature_id, i)
  714.       # Show current actor feature status
  715.       if stage == :current
  716.         v = @actor.param(i)
  717.         push_new_comparison(stage, DiffInfo.new(feature_id,i,[v,v],str))
  718.         next
  719.       # Comparison
  720.       else
  721.         a = @compare_item.param(i)
  722.         b = @template_item.param(i)
  723.         next if a - b == 0
  724.         base = (get_cache_feature(i, :param, i) || 0)
  725.         a += base
  726.         b += base
  727.         push_new_comparison(stage, DiffInfo.new(feature_id, i, [a,b], str))
  728.       end
  729.     end
  730.   end
  731.   #---------------------------------------------------------------------------
  732.   def compare_features_sum(stage,feature_id)
  733.     ar = get_feature_array(feature_id); len = ar.size;
  734.     if len == 0
  735.       str = get_feature_name(feature_id)
  736.       # Show current actor feature status
  737.       if stage == :current
  738.         return unless CurFeatureShow.include?(feature_id)
  739.         v = @actor.features_sum_all(feature_id)
  740.         return if v == 0
  741.         push_new_comparison(stage, DiffInfo.new(feature_id,0,[v,v],str))
  742.         return
  743.       else
  744.         # Comparison
  745.         a = @compare_item.features_sum_all(feature_id)
  746.         b = @template_item.features_sum_all(feature_id)
  747.         delta = (a - b)
  748.         delta = delta.round(2) if delta.is_a?(Float)
  749.         return if delta == 0
  750.         base = (get_cache_feature(feature_id, :features_sum_all, feature_id) || 0)
  751.         a += base
  752.         b += base
  753.         push_new_comparison(stage, DiffInfo.new(feature_id, 0, [a,b], str))
  754.       end
  755.     else
  756.       len.times do |i|
  757.         str = get_feature_name(feature_id, i)
  758.         # Show current actor feature status
  759.         if stage == :current
  760.           return unless CurFeatureShow.include?(feature_id)
  761.           v = @actor.features_sum(feature_id, i)
  762.           next if v == 0
  763.           push_new_comparison(stage, DiffInfo.new(feature_id,i,[v,v],str))
  764.           next
  765.         else
  766.           # Comparison
  767.           a = @compare_item.features_sum(feature_id, i)
  768.           b = @template_item.features_sum(feature_id, i)
  769.           delta = (a - b)
  770.           delta = delta.round(2) if delta.is_a?(Float)
  771.           next if delta == 0
  772.           base = (get_cache_feature(hash_feature_idx(feature_id, i), :features_sum, feature_id, i) || 0)
  773.           a += base
  774.           b += base
  775.           push_new_comparison(stage, DiffInfo.new(feature_id, i, [a,b], str))
  776.         end
  777.       end # len.times
  778.     end # if len ==0
  779.   end
  780.   #---------------------------------------------------------------------------
  781.   def compare_features_pi(stage, feature_id)
  782.     ar = get_feature_array(feature_id); len = ar.size;
  783.     len.times do |i|
  784.       str = get_feature_name(feature_id, i)
  785.       # Show current actor feature status
  786.       if stage == :current
  787.         return unless CurFeatureShow.include?(feature_id)
  788.         v = @actor.features_pi(feature_id, i)
  789.         next if v == 1.0
  790.         push_new_comparison(stage, DiffInfo.new(feature_id,i,[v,v],str))
  791.         next
  792.       else
  793.         # Comparison
  794.         a = @compare_item.features_pi(feature_id, i)
  795.         b = @template_item.features_pi(feature_id, i)
  796.         delta = (a - b)
  797.         delta = delta.round(2) if delta.is_a?(Float)
  798.         next if delta == 0
  799.         base = get_cache_feature(hash_feature_idx(feature_id, i), :features_pi, feature_id, i)
  800.         base = 1 if base.nil?
  801.         a *= base
  802.         b *= base
  803.         push_new_comparison(stage, DiffInfo.new(feature_id, i, [a,b], str))
  804.       end
  805.     end
  806.   end
  807.   #---------------------------------------------------------------------------
  808.   def compare_features_set(stage, feature_id, prefix = [FeatureRemoveText, FeatureAddText])
  809.     # Show current actor feature status
  810.     if stage == :current
  811.       return unless CurFeatureShow.include?(feature_id)
  812.       feats = @actor.features_set(feature_id)
  813.       feats.each do |i|
  814.         str = sprintf(prefix[1], get_feature_name(feature_id, i))
  815.         push_new_comparison(stage, DiffInfo.new(feature_id,i,true,str))
  816.       end
  817.       return
  818.     else
  819.       # Comparison
  820.       after  = @compare_item.features_set(feature_id)
  821.       before = @template_item.features_set(feature_id)
  822.      
  823.       diffs = []
  824.       after.select{|id| !before.include?(id)}.each do |id|
  825.         str = sprintf(prefix[1], get_feature_name(feature_id, id))
  826.         diffs << DiffInfo.new(feature_id, id,  true, str)
  827.       end
  828.      
  829.       before.select{|id| !after.include?(id)}.each do |id|
  830.         str = sprintf(prefix[0], get_feature_name(feature_id, id))
  831.         diffs << DiffInfo.new(feature_id, id, false, str)
  832.       end
  833.  
  834.       diffs.each do |info|
  835.         push_new_comparison(stage, info)
  836.       end
  837.  
  838.     end
  839.   end
  840.   #---------------------------------------------------------------------------
  841.   def compare_valued_feature(stage,feature_id, pi)
  842.     # Show current actor feature status
  843.     if stage == :current
  844.       return unless CurFeatureShow.include?(feature_id)
  845.       feats = @actor.features_set(feature_id)
  846.       feats.each do |i|
  847.         str = get_feature_name(feature_id, i)
  848.         if pi
  849.           v = @actor.features_pi(feature_id, i)
  850.           next if v == 1
  851.         else
  852.           v = @actor.features_sum(feature_id, i)
  853.           next if v == 0
  854.         end
  855.         push_new_comparison(stage, DiffInfo.new(feature_id,i,[v,v],str))
  856.       end # each feat
  857.       return
  858.     else
  859.       # Comparison
  860.       after  = @compare_item.features_set(feature_id)
  861.       before = @template_item.features_set(feature_id)
  862.       prefix = [FeatureRemoveText, FeatureAddText]
  863.       (after + before).uniq.sort.each do |id|
  864.         if pi
  865.           a = @compare_item.features_pi(feature_id, id)
  866.           b = @template_item.features_pi(feature_id, id)
  867.           method_symbol = :features_pi
  868.         else
  869.           a = @compare_item.features_sum(feature_id, id)
  870.           b = @template_item.features_sum(feature_id, id)
  871.           method_symbol = :features_sum
  872.         end
  873.         next if a - b == 0
  874.         base = (get_cache_feature(hash_feature_idx(feature_id, id), method_symbol, feature_id, id) || 0)
  875.         a += base
  876.         b += base
  877.         str = get_feature_name(feature_id, id)
  878.         push_new_comparison(stage, DiffInfo.new(feature_id, id, [a,b], str))
  879.       end
  880.     end
  881.   end
  882.   #---------------------------------------------------------------------------
  883.   def compare_action_plus(stage,feature_id)
  884.     # Show current actor feature status
  885.     if stage == :current
  886.       return unless CurFeatureShow.include?(feature_id)
  887.       ar = @actor.action_plus_set.sort{|a,b| b <=> a}
  888.       ar.each_with_index do |v,i|
  889.         str = sprintf(get_feature_name(feature_id), i+1)
  890.         push_new_comparison(stage, DiffInfo.new(feature_id,i,[v,v],str))
  891.       end
  892.       return
  893.     else
  894.       # Comparison
  895.       after  = @compare_item.action_plus_set.sort{|a,b| b <=> a}
  896.       before = @template_item.action_plus_set.sort{|a,b| b <=> a}
  897.       return if after.size == 0 && before.size == 0
  898.       n = [after.size, before.size].max
  899.       n.times do |i|
  900.         a = (after[i]  || 0)
  901.         b = (before[i] || 0)
  902.         str = sprintf(get_feature_name(feature_id), i+1)
  903.         push_new_comparison(stage, DiffInfo.new(feature_id, 0, [a,b], str))
  904.       end
  905.     end
  906.   end
  907.   #---------------------------------------------------------------------------
  908.   def compare_special_flag(stage,feature_id, prefix = [FeatureRemoveText, FeatureAddText])
  909.     ar = SpecialFeatureName
  910.     ar.each do |i, str|
  911.       # Show current actor feature status
  912.       if stage == :current
  913.         return unless CurFeatureShow.include?(feature_id)
  914.         en = @actor.special_flag(i)
  915.         next unless en
  916.         str = sprintf(prefix[1], str)
  917.         push_new_comparison(stage, DiffInfo.new(feature_id,i,true,str))
  918.         next
  919.       else
  920.         # Comparison
  921.         before = @template_item.special_flag(i)
  922.         after  = @compare_item.special_flag(i)
  923.         next if before == after
  924.         enabled = after ? 1 : 0
  925.         str = sprintf(prefix[enabled], str)
  926.         push_new_comparison(stage, DiffInfo.new(feature_id, i, after, str))
  927.       end
  928.     end
  929.   end
  930.   #---------------------------------------------------------------------------
  931.   def compare_party_ability(stage,feature_id, prefix = [FeatureRemoveText, FeatureAddText])
  932.     ar = PartyAbilityName
  933.     ar.each do |i, str|
  934.       # Show current actor feature status
  935.       if stage == :current
  936.         return unless CurFeatureShow.include?(feature_id)
  937.         en = @actor.party_ability(i)
  938.         next unless en
  939.         str = sprintf(prefix[1], str)
  940.         push_new_comparison(stage, DiffInfo.new(feature_id,i,true,str))
  941.         next
  942.       else
  943.         # Comparison
  944.         before = @template_item.party_ability(i)
  945.         after  = @compare_item.party_ability(i)
  946.         next if before == after
  947.         enabled = after ? 1 : 0
  948.         str = sprintf(prefix[enabled], str)
  949.         push_new_comparison(stage, DiffInfo.new(feature_id, i, after, str))
  950.       end
  951.     end
  952.   end
  953.   #--------------------------------------------------------------------------
  954.   # * Get Equipment Slot Name
  955.   #--------------------------------------------------------------------------
  956.   def slot_name(index)
  957.     @actor ? Vocab::etype(@actor.equip_slots[index]) : ""
  958.   end
  959.   #---------------------------------------------------------------------------
  960.   def get_group_text(feature_id)
  961.     return StringTable[feature_id]
  962.   end
  963.   #---------------------------------------------------------------------------
  964.   def get_feature_name(feature_id, index = nil)
  965.     name = ''
  966.     case feature_id
  967.     when FeatureNormalParam;    name = Vocab.param(index);
  968.     when FEATURE_ATK_ELEMENT;   name = $data_system.elements[index];
  969.     when FEATURE_ELEMENT_RATE;  name = $data_system.elements[index];
  970.     when FEATURE_PARAM;         name = Vocab.param(index);
  971.     when FEATURE_XPARAM;        name = XParamName[index];
  972.     when FEATURE_SPARAM;        name = SParamName[index];
  973.     when FEATURE_SKILL_ADD;     name = ($data_skills[index].name rescue '');
  974.     when FEATURE_SKILL_SEAL;    name = ($data_skills[index].name rescue '');
  975.     when FEATURE_STATE_RATE;    name = ($data_states[index].name rescue '');
  976.     when FEATURE_STATE_RESIST;  name = ($data_states[index].name rescue '');
  977.     when FEATURE_ATK_STATE;     name = ($data_states[index].name rescue '');
  978.     when FEATURE_EQUIP_WTYPE;   name = $data_system.weapon_types[index];
  979.     when FEATURE_EQUIP_ATYPE;   name = $data_system.armor_types[index];
  980.     when FEATURE_STYPE_ADD;     name = $data_system.skill_types[index];
  981.     when FEATURE_STYPE_SEAL;    name = $data_system.skill_types[index];
  982.     when FEATURE_PARTY_ABILITY; name = PartyAbilityName[index];
  983.     when FEATURE_SPECIAL_FLAG;  name = SpecialFeatureName[index];
  984.     when FEATURE_EQUIP_FIX;     name = slot_name(index);
  985.     when FEATURE_EQUIP_SEAL;    name = slot_name(index);
  986.     else
  987.       return OtherFeatureName[feature_id] || ""
  988.     end
  989.     return name  || ''
  990.   end
  991.   #---------------------------------------------------------------------------
  992.   def get_feature_array(feature_id)
  993.     case feature_id
  994.     when FeatureNormalParam;    return Array.new($data_system.terms.params.size);
  995.     when FEATURE_ATK_ELEMENT;   return $data_system.elements;
  996.     when FEATURE_ELEMENT_RATE;  return $data_system.elements;
  997.     when FEATURE_PARAM;         return Array.new($data_system.terms.params.size);
  998.     when FEATURE_XPARAM;        return Array.new(XParamName.size);
  999.     when FEATURE_SPARAM;        return Array.new(SParamName.size);
  1000.     when FEATURE_SKILL_ADD;     return $data_skills;
  1001.     when FEATURE_SKILL_SEAL;    return $data_skills;
  1002.     when FEATURE_STATE_RATE;    return $data_states;
  1003.     when FEATURE_STATE_RESIST;  return $data_states;
  1004.     when FEATURE_ATK_STATE;     return $data_states;
  1005.     when FEATURE_EQUIP_WTYPE;   return $data_system.weapon_types;
  1006.     when FEATURE_EQUIP_WTYPE;   return $data_system.armor_types;
  1007.     when FEATURE_STYPE_ADD;     return $data_system.skill_types;
  1008.     when FEATURE_STYPE_SEAL;    return $data_system.skill_types;
  1009.     when FEATURE_PARTY_ABILITY; return PartyAbilityName;
  1010.     when FEATURE_SPECIAL_FLAG;  return SpecialFeatureName;
  1011.     when FEATURE_EQUIP_FIX;     return $data_system.terms.etypes;
  1012.     when FEATURE_EQUIP_SEAL;    return $data_system.terms.etypes;
  1013.     else
  1014.       return []
  1015.     end
  1016.   end
  1017.   #---------------------------------------------------------------------------
  1018.   def draw_current_feature
  1019.     resume_comparison
  1020.     draw_compare_result(true)
  1021.   end
  1022.   #---------------------------------------------------------------------------
  1023.   def draw_page(cur_feat, index)
  1024.     head = index * line_max
  1025.     rear = (index + 1) * line_max - 1
  1026.     list = cur_feat ? @base_pages[head..[@base_pages.size-1, rear].min] : @pages[head..[@pages.size, rear].min]
  1027.     return if list.nil?
  1028.     contents.clear
  1029.     last_display_group = ''
  1030.     @comparing = !cur_feat
  1031.  
  1032.     dy = 0
  1033.     list.each_with_index do |info, i|
  1034.       feature_id = info.feature_id
  1035.       if (info.group_text || '').length > 0
  1036.         if EQS_Enable && info.group_text.match(SetEquipmentTextStem)
  1037.           draw_equipset_title(@dx, dy, info.group_text || '')
  1038.           dy += line_height
  1039.         elsif last_display_group != info.group_text
  1040.           last_display_group = info.group_text
  1041.           rect = Rect.new(@dx, dy, @ori_contents_width, line_height)
  1042.           draw_text(rect, info.group_text)
  1043.           dy += line_height
  1044.         end
  1045.       end
  1046.       next if info.feature_id.nil?
  1047.       draw_item(@dx, dy, info)
  1048.       dy += line_height
  1049.     end
  1050.   end
  1051.   #---------------------------------------------------------------------------
  1052.   def draw_compare_result(cur_feat = false)
  1053.     resume_comparison
  1054.     update_arrows(cur_feat ? @base_pages : @pages)
  1055.     draw_page(cur_feat, 0)
  1056.   end
  1057.   #---------------------------------------------------------------------------
  1058.   def draw_equipset_title(dx, dy, str)
  1059.     return if str.length == 0
  1060.     change_color(crisis_color)
  1061.     draw_text(dx, dy, @ori_contents_width, line_height, str)
  1062.     change_color(normal_color)
  1063.   end
  1064.   #---------------------------------------------------------------------------
  1065.   # * Overwrite: draw_item
  1066.   #---------------------------------------------------------------------------
  1067.   def draw_item(dx, dy, info)
  1068.     # YEA Equip Engine code
  1069.     if $imported["YEA-AceEquipEngine"]
  1070.       self.contents.font.size = YEA::EQUIP::STATUS_FONT_SIZE
  1071.       draw_background_colour(dx, dy)
  1072.     end
  1073.  
  1074.     # Draw feature add/remove
  1075.     if info.value == true || info.value == false
  1076.       a = (info.value ? 1 : 0)
  1077.       b = (info.value ? 0 : 1)
  1078.       # Inverse the color effect if feature is not good
  1079.       inverse = InverseColorFeature.include?(info.feature_id)
  1080.      
  1081.       if inverse
  1082.         a ^= 1; b ^= 1;
  1083.       end
  1084.      
  1085.       change_color(param_change_color(a - b))
  1086.  
  1087.       # draw skill change with the icon
  1088.       if [FEATURE_SKILL_ADD, FEATURE_SKILL_SEAL].include?(info.feature_id)
  1089.         draw_skill_change(dx + 2, dy, info)
  1090.       else
  1091.         draw_info_change(dx, dy, info.display_str)
  1092.       end
  1093.       change_color(normal_color)
  1094.     else
  1095.       draw_info_name(dx + 4, dy, info.display_str)
  1096.       draw_info_diff(dx, dy, info.value, PercentageFeaure.include?(info.feature_id))
  1097.     end
  1098.     reset_font_settings if $imported["YEA-AceEquipEngine"]
  1099.   end
  1100.   #---------------------------------------------------------------------------
  1101.   def draw_info_change(dx, dy, str)
  1102.     rect = Rect.new(dx, dy, @ori_contents_width-4, line_height)
  1103.     draw_text(rect, str, 2)
  1104.   end
  1105.   #---------------------------------------------------------------------------
  1106.   def draw_skill_change(dx, dy, info)
  1107.     str = info.display_str
  1108.     return draw_info_change(dx, dy, str) unless (info.data_id || 0) > 0
  1109.     text_width = self.contents.text_size(str).width
  1110.     dx = dx + @ori_contents_width - text_width - 34
  1111.     prefix = str[0]; str = str[1...str.length];
  1112.     rect = Rect.new(dx, dy, self.contents.text_size(prefix).width + 3, line_height)
  1113.     draw_text(rect, prefix)
  1114.     offset = rect.width + 24
  1115.     draw_icon($data_skills[info.data_id].icon_index, dx + rect.width, dy)
  1116.     rect.x += offset; rect.width = text_width;
  1117.     draw_text(rect, str)
  1118.   end
  1119.   #---------------------------------------------------------------------------
  1120.   def draw_info_name(dx, dy, str)
  1121.     change_color(system_color)
  1122.     draw_text(dx, dy, @ori_contents_width, line_height, str)
  1123.     change_color(normal_color)
  1124.   end
  1125.   #---------------------------------------------------------------------------
  1126.   def draw_info_diff(dx, dy, value, is_percent = false)
  1127.     dw = (@ori_contents_width + 22) / 2
  1128.     crect = Rect.new(dx, dy, dw, line_height)
  1129.     nrect = Rect.new(dx, dy, @ori_contents_width - 8, line_height)
  1130.     drx = dx + (@ori_contents_width + 22) / 2
  1131.     draw_diff_value(crect, value[1], is_percent) if @comparing
  1132.     draw_right_arrow(drx, dy)                    if @comparing
  1133.     change_color(param_change_color(value[0] - value[1]))
  1134.     draw_diff_value(nrect, value[0], is_percent)
  1135.     change_color(normal_color)
  1136.   end
  1137.   #---------------------------------------------------------------------------
  1138.   def draw_diff_value(rect, value, is_percent)
  1139.     str = value.to_s
  1140.     str = sprintf("%s\%", (value * 100).to_i) if is_percent
  1141.     draw_text(rect, str, 2)
  1142.   end
  1143.   #--------------------------------------------------------------------------
  1144.   def draw_background_colour(dx, dy)
  1145.     colour = Color.new(0, 0, 0, translucent_alpha/2)
  1146.     rect = Rect.new(dx+1, dy+1, @ori_contents_width - 2, line_height - 2)
  1147.     contents.fill_rect(rect, colour)
  1148.   end
  1149.   #--------------------------------------------------------------------------
  1150. #-#
  1151.   #---------------------------------------------------------------------------
  1152.   # * Compare the equipment set bonus, written by Modern Algebra
  1153.   #---------------------------------------------------------------------------
  1154. if $imported[:MA_EquipmentSetBonuses]
  1155.   #---------------------------------------------------------------------------
  1156.   # * Collect equipment set difference, current_only: collect currently
  1157.   #   activated equipment set.
  1158.   def collect_equipment_set_diff(current_only = false)
  1159.     return unless @actor
  1160.     before = @actor.maesb_sets || []
  1161.     feature_id = FeatureEquipSet
  1162.     return if current_only && before.size == 0
  1163.     btmp_item = @template_item ? @template_item.dup : nil
  1164.     @last_stage = current_only ? :current : :diff
  1165.     if current_only
  1166.       start_index = @base_pages.size
  1167.       bcmp_item = @compare_item ? @compare_item.dup : nil
  1168.       @template_item = Dummy
  1169.       before.each do |obj|
  1170.         @compare_item = obj
  1171.         @set_bonus_item = obj
  1172.         compare_diffs(:eqset)
  1173.       end
  1174.     else
  1175.       return unless @temp_actor
  1176.       after  = @temp_actor.maesb_sets || []
  1177.       bcmp_item = @compare_item ? @compare_item.dup : nil
  1178.       start_index = @pages.size
  1179.       @template_item = Dummy
  1180.       after.select{|obj| !before.include?(obj)}.each do |obj|
  1181.         @compare_item = obj
  1182.         @set_bonus_item = obj
  1183.         compare_diffs(:eqset)
  1184.       end
  1185.       @compare_item = Dummy
  1186.       before.select{|obj| !after.include?(obj)}.each do |obj|
  1187.         @pages << DummyInfo
  1188.         @template_item = obj
  1189.         @set_bonus_item = obj
  1190.         compare_diffs(:eqset)
  1191.       end
  1192.     end
  1193.     @last_stage = nil
  1194.     @set_bonus_item = nil
  1195.     @template_item = btmp_item
  1196.     @compare_item = bcmp_item
  1197.   end
  1198. end
  1199.   #---------------------------------------------------------------------------
  1200. #-#
  1201. end # class Window_EQ status
  1202. end # enable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement