Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)

[RGSS3] Legacy 1-Man Menu System (Save option removed)

By: Legacy on Nov 11th, 2012  |  syntax: Ruby  |  size: 66.38 KB  |  hits: 62  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #==============================================================================
  2. # :: 1-Man Menu System ::
  3. #------------------------------------------------------------------------------
  4. # Author : Legacy
  5. #
  6. # Version History:
  7. #  v1.00 - 08.11.2012 > First release
  8. #------------------------------------------------------------------------------
  9. #  This script changes the default menu system found in RPG Maker VX Ace, it
  10. # is designed for games that only ever have a single active party member.
  11. #
  12. #------------------------------------------------------------------------------
  13. # Instructions:
  14. #  To install the script, open you script editor and paste this script on
  15. #  a new section below the Materials section.
  16. #
  17. #------------------------------------------------------------------------------
  18. # Compatibility:
  19. #   This script was designed for use with RPG Maker VX Ace, it is unlikely to
  20. # run on RPG Maker VX without adjustment.
  21. #
  22. #  This script may be incompatible with more than one party member.
  23. #
  24. #==============================================================================
  25. $imported = {} if $imported == nil
  26. $imported['Legacy_MainMenu'] = 1.00
  27.  
  28. #==============================================================================
  29. # :: Window_HorzMenuCommand
  30. #------------------------------------------------------------------------------
  31. #  This command window appears on the menu screen.
  32. #==============================================================================
  33.  
  34. class Window_HorzMenuCommand < Window_HorzCommand
  35.   #--------------------------------------------------------------------------
  36.   # ; Object Initialization
  37.   #--------------------------------------------------------------------------
  38.   def initialize
  39.     super(100, 0)
  40.     self.opacity = 180
  41.   end
  42.   #--------------------------------------------------------------------------
  43.   # ; Get Window Width
  44.   #--------------------------------------------------------------------------
  45.   def window_width
  46.     return 380
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # ; Get Digit Count
  50.   #--------------------------------------------------------------------------
  51.   def col_max
  52.     return 3
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ; Get Number of Lines to Show
  56.   #--------------------------------------------------------------------------
  57.   def visible_line_number
  58.     return 1
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ; Create Command List
  62.   #--------------------------------------------------------------------------
  63.   def make_command_list
  64.     add_main_commands
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ; Add Main Commands to List
  68.   #--------------------------------------------------------------------------
  69.   def add_main_commands
  70.     add_command(Vocab::item,   :item,   main_commands_enabled)
  71.     add_command(Vocab::skill,  :skill,  main_commands_enabled)
  72.     add_command(Vocab::equip,  :equip,  main_commands_enabled)
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ; Get Activation State of Main Commands
  76.   #--------------------------------------------------------------------------
  77.   def main_commands_enabled
  78.     $game_party.exists
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ; Processing When OK Button Is Pressed
  82.   #--------------------------------------------------------------------------
  83.   def process_ok
  84.     super
  85.   end
  86. end
  87.  
  88. #==============================================================================
  89. # ** Window_ItemCategory
  90. #------------------------------------------------------------------------------
  91. #  This window is for selecting a category of normal items and equipment
  92. # on the item screen or shop screen.
  93. #==============================================================================
  94.  
  95. class Window_ItemCategory < Window_HorzCommand
  96.   #--------------------------------------------------------------------------
  97.   # ; Public Instance Variables
  98.   #--------------------------------------------------------------------------
  99.   attr_reader   :item_window
  100.   #--------------------------------------------------------------------------
  101.   # ; Object Initialization
  102.   #--------------------------------------------------------------------------
  103.   def initialize
  104.     super(0, 0)
  105.     self.opacity = 180
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ; Get Window Width
  109.   #--------------------------------------------------------------------------
  110.   def window_width
  111.     return 380
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ; Get Digit Count
  115.   #--------------------------------------------------------------------------
  116.   def col_max
  117.     return 4
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ; Frame Update
  121.   #--------------------------------------------------------------------------
  122.   def update
  123.     super
  124.     @item_window.category = current_symbol if @item_window
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ; Create Command List
  128.   #--------------------------------------------------------------------------
  129.   def make_command_list
  130.     add_command(Vocab::item,     :item)
  131.     add_command(Vocab::weapon,   :weapon)
  132.     add_command(Vocab::armor,    :armor)
  133.     add_command(Vocab::key_item, :key_item)
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # ; Set Item Window
  137.   #--------------------------------------------------------------------------
  138.   def item_window=(item_window)
  139.     @item_window = item_window
  140.     update
  141.   end
  142. end
  143.  
  144. #==============================================================================
  145. # ** Window_ItemList
  146. #------------------------------------------------------------------------------
  147. #  This window displays a list of party items on the item screen.
  148. #==============================================================================
  149.  
  150. class Window_ItemList < Window_Selectable
  151.   #--------------------------------------------------------------------------
  152.   # * Object Initialization
  153.   #--------------------------------------------------------------------------
  154.   def initialize(x, y, width, height)
  155.     super
  156.     @category = :none
  157.     @data = []
  158.     self.opacity = 180
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # * Set Category
  162.   #--------------------------------------------------------------------------
  163.   def category=(category)
  164.     return if @category == category
  165.     @category = category
  166.     refresh
  167.     self.oy = 0
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # * Get Digit Count
  171.   #--------------------------------------------------------------------------
  172.   def col_max
  173.     return 1
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # * Get Number of Items
  177.   #--------------------------------------------------------------------------
  178.   def item_max
  179.     @data ? @data.size : 1
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # * Get Item
  183.   #--------------------------------------------------------------------------
  184.   def item
  185.     @data && index >= 0 ? @data[index] : nil
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # * Get Activation State of Selection Item
  189.   #--------------------------------------------------------------------------
  190.   def current_item_enabled?
  191.     enable?(@data[index])
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # * Include in Item List?
  195.   #--------------------------------------------------------------------------
  196.   def include?(item)
  197.     case @category
  198.     when :item
  199.       item.is_a?(RPG::Item) && !item.key_item?
  200.     when :weapon
  201.       item.is_a?(RPG::Weapon)
  202.     when :armor
  203.       item.is_a?(RPG::Armor)
  204.     when :key_item
  205.       item.is_a?(RPG::Item) && item.key_item?
  206.     else
  207.       false
  208.     end
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # * Display in Enabled State?
  212.   #--------------------------------------------------------------------------
  213.   def enable?(item)
  214.     $game_party.usable?(item)
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # * Create Item List
  218.   #--------------------------------------------------------------------------
  219.   def make_item_list
  220.     @data = $game_party.all_items.select {|item| include?(item) }
  221.     @data.push(nil) if include?(nil)
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # * Restore Previous Selection Position
  225.   #--------------------------------------------------------------------------
  226.   def select_last
  227.     select(@data.index($game_party.last_item.object) || 0)
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # * Draw Item
  231.   #--------------------------------------------------------------------------
  232.   def draw_item(index)
  233.     item = @data[index]
  234.     if item
  235.       rect = item_rect(index)
  236.       rect.width -= 2
  237.       draw_item_name(item, rect.x, rect.y, enable?(item))
  238.       rect.x += 4
  239.       draw_item_number(rect, item)
  240.     end
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # * Draw Number of Items
  244.   #--------------------------------------------------------------------------
  245.   def draw_item_number(rect, item)
  246.     draw_text(rect, sprintf("x%2d", $game_party.item_number(item)), 2)
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # * Update Help Text
  250.   #--------------------------------------------------------------------------
  251.   def update_help
  252.     @help_window.set_item(item)
  253.   end
  254.   #--------------------------------------------------------------------------
  255.   # * Refresh
  256.   #--------------------------------------------------------------------------
  257.   def refresh
  258.     make_item_list
  259.     create_contents
  260.     draw_all_items
  261.   end
  262. end
  263.  
  264. #==============================================================================
  265. # ** Window_ActorStatus
  266. #------------------------------------------------------------------------------
  267. #  This window displays party member status on the menu screen.
  268. #==============================================================================
  269.  
  270. class Window_ActorStatus < Window_Selectable
  271.   #--------------------------------------------------------------------------
  272.   # ; Public Instance Variables
  273.   #--------------------------------------------------------------------------
  274.   attr_reader   :pending_index            # Pending position (for formation)
  275.   #--------------------------------------------------------------------------
  276.   # ; Object Initialization
  277.   #--------------------------------------------------------------------------
  278.   def initialize(x, y)
  279.     super(x, y, 380, 320)
  280.     @pending_index = -1
  281.     @actor = $game_party.members[0]
  282.     self.opacity = 180
  283.     refresh
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ; Get Number of Items
  287.   #--------------------------------------------------------------------------
  288.   def item_max
  289.     return 1
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # ; Get Item Height
  293.   #--------------------------------------------------------------------------
  294.   def item_height
  295.     (height - standard_padding * 2) / 4
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # ; Draw Item
  299.   #--------------------------------------------------------------------------
  300.   def draw_item(index)
  301.     enabled = $game_party.battle_members.include?(@actor)
  302.     rect = item_rect(index)
  303.     draw_item_background(index)
  304.     draw_actor_name(@actor, x - 100, y - 50)
  305.     draw_actor_level(@actor, x + 40, y - 50)
  306.     draw_actor_class(@actor, x + 140, y - 50)
  307.     draw_actor_face(@actor, rect.x + 20, rect.y + 25, enabled)
  308.     draw_actor_icons(@actor, x - 80, y + (line_height * 2) + 28)
  309.     draw_actor_hp(@actor, x - 100 , y + (line_height * 1) + 75)
  310.     draw_actor_mp(@actor, x - 100, y + (line_height * 2) + 75)
  311.     draw_parameters(150, y - 10)
  312.     draw_exp_info(155, 200)
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ; Draw Parameters
  316.   #--------------------------------------------------------------------------
  317.   def draw_parameters(x, y)
  318.     6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  319.   end
  320.   #--------------------------------------------------------------------------
  321.   # * Draw Experience Information
  322.   #--------------------------------------------------------------------------
  323.   def draw_exp_info(x, y)
  324.     s1 = @actor.max_level? ? "-------" : @actor.exp
  325.     s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
  326.     s_next = sprintf(Vocab::ExpNext, Vocab::level)
  327.     change_color(system_color)
  328.     draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
  329.     draw_text(x, y + line_height * 2, 180, line_height, s_next)
  330.     change_color(normal_color)
  331.     draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
  332.     draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
  333.   end
  334.   #--------------------------------------------------------------------------
  335.   # ; Draw Background for Item
  336.   #--------------------------------------------------------------------------
  337.   def draw_item_background(index)
  338.     if index == @pending_index
  339.       contents.fill_rect(item_rect(index), pending_color)
  340.     end
  341.   end
  342.   #--------------------------------------------------------------------------
  343.   # ; Processing When OK Button Is Pressed
  344.   #--------------------------------------------------------------------------
  345.   def process_ok
  346.     super
  347.     $game_party.menu_actor = @actor
  348.   end
  349.   #--------------------------------------------------------------------------
  350.   # ; Restore Previous Selection Position
  351.   #--------------------------------------------------------------------------
  352.   def select_last
  353.     select($game_party.menu_actor.index || 0)
  354.   end
  355. end
  356. #==============================================================================
  357. # ** Window_MenuStatus
  358. #------------------------------------------------------------------------------
  359. #  This window displays party member status on the menu screen.
  360. #==============================================================================
  361.  
  362. class Window_Legacy_MenuStatus < Window_Selectable
  363.   #--------------------------------------------------------------------------
  364.   # * Public Instance Variables
  365.   #--------------------------------------------------------------------------
  366.   attr_reader   :pending_index            # Pending position (for formation)
  367.   #--------------------------------------------------------------------------
  368.   # * Object Initialization
  369.   #--------------------------------------------------------------------------
  370.   def initialize(x, y)
  371.     super(x, y, 150, 315)
  372.     @pending_index = -1
  373.     refresh
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # * Get Number of Items
  377.   #--------------------------------------------------------------------------
  378.   def item_max
  379.     $game_party.members.size
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # * Get Item Height
  383.   #--------------------------------------------------------------------------
  384.   def item_height
  385.     (height - standard_padding * 2) / 4
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # * Draw Item
  389.   #--------------------------------------------------------------------------
  390.   def draw_item(index)
  391.     actor = $game_party.members[index]
  392.     enabled = $game_party.battle_members.include?(actor)
  393.     rect = item_rect(index)
  394.     draw_item_background(index)
  395.     draw_actor_name(actor, x - 100, y - 50)
  396.     draw_actor_level(actor, x - 35, y - 50)
  397.     draw_actor_face(actor, rect.x + 20, rect.y + 25, enabled)
  398.     draw_actor_icons(actor, x - 80, y + (line_height * 2) + 28)
  399.     draw_actor_hp(actor, x - 100 , y + 100)
  400.     draw_actor_mp(actor, x - 100 , y + 125)
  401.   end
  402.   #--------------------------------------------------------------------------
  403.   # * Draw Background for Item
  404.   #--------------------------------------------------------------------------
  405.   def draw_item_background(index)
  406.     if index == @pending_index
  407.       contents.fill_rect(item_rect(index), pending_color)
  408.     end
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # * Processing When OK Button Is Pressed
  412.   #--------------------------------------------------------------------------
  413.   def process_ok
  414.     super
  415.     $game_party.menu_actor = $game_party.members[index]
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # * Restore Previous Selection Position
  419.   #--------------------------------------------------------------------------
  420.   def select_last
  421.     select($game_party.menu_actor.index || 0)
  422.   end
  423.   #--------------------------------------------------------------------------
  424.   # * Set Pending Position (for Formation)
  425.   #--------------------------------------------------------------------------
  426.   def pending_index=(index)
  427.     last_pending_index = @pending_index
  428.     @pending_index = index
  429.     redraw_item(@pending_index)
  430.     redraw_item(last_pending_index)
  431.   end
  432.  
  433. end
  434.  
  435. #==============================================================================
  436. # ** Legacy_Window_MenuActor
  437. #------------------------------------------------------------------------------
  438. #  This window is for selecting actors that will be the target of item or
  439. # skill use.
  440. #==============================================================================
  441.  
  442. class Window_Legacy_MenuActor < Window_Legacy_MenuStatus
  443.   #--------------------------------------------------------------------------
  444.   # * Object Initialization
  445.   #--------------------------------------------------------------------------
  446.   def initialize
  447.     super(100, 47)
  448.     self.visible = true
  449.     self.height = 320
  450.     self.opacity = 180
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # * Processing When OK Button Is Pressed
  454.   #--------------------------------------------------------------------------
  455.   def process_ok
  456.     $game_party.target_actor = $game_party.members[index]
  457.     call_ok_handler
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # * Restore Previous Selection Position
  461.   #--------------------------------------------------------------------------
  462.   def select_last
  463.     select($game_party.target_actor.index || 0)
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # * Set Position of Cursor for Item
  467.   #--------------------------------------------------------------------------
  468.   def select_for_item(item)
  469.     @cursor_fix = item.for_user?
  470.     @cursor_all = item.for_all?
  471.     if @cursor_fix
  472.       select($game_party.menu_actor.index)
  473.     elsif @cursor_all
  474.       select(0)
  475.     else
  476.       select_last
  477.     end
  478.   end
  479.   #--------------------------------------------------------------------------
  480.   # * Update Cursor
  481.   #--------------------------------------------------------------------------
  482.   def update_cursor
  483.     cursor_rect.empty
  484.   end
  485. end
  486.  
  487.  
  488. #==============================================================================
  489. # ** Window_Location
  490. #------------------------------------------------------------------------------
  491. #  This window displays the map name.
  492. #==============================================================================
  493.  
  494. class Window_Location < Window_Base
  495.   #--------------------------------------------------------------------------
  496.   # * Object Initialization
  497.   #--------------------------------------------------------------------------
  498.   def initialize
  499.     super(0, 0, 240, fitting_height(1))
  500.     self.opacity = 180
  501.     refresh
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # * Frame Update
  505.   #--------------------------------------------------------------------------
  506.   def update
  507.     super
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # * Refresh
  511.   #--------------------------------------------------------------------------
  512.   def refresh
  513.     contents.clear
  514.     draw_text(contents.rect, $game_map.display_name, 1)
  515.   end
  516. end
  517.  
  518. #==============================================================================
  519. # ** Window_HorzSkillCommand
  520. #------------------------------------------------------------------------------
  521. #  This window is for selecting commands (special attacks, magic, etc.) on the
  522. # skill screen.
  523. #==============================================================================
  524.  
  525. class Window_HorzSkillCommand < Window_HorzCommand
  526.   #--------------------------------------------------------------------------
  527.   # * Public Instance Variables
  528.   #--------------------------------------------------------------------------
  529.   attr_reader   :skill_window
  530.   #--------------------------------------------------------------------------
  531.   # * Object Initialization
  532.   #--------------------------------------------------------------------------
  533.   def initialize(x, y)
  534.     super(x, y)
  535.     @actor = nil
  536.     self.height = 48
  537.     self.opacity = 180
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # * Get Digit Count
  541.   #--------------------------------------------------------------------------
  542.   def col_max
  543.     return 2
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # * Get Spacing for Items Arranged Side by Side
  547.   #--------------------------------------------------------------------------
  548.   def spacing
  549.     return 8
  550.   end
  551.   #--------------------------------------------------------------------------
  552.   # * Set Actor
  553.   #--------------------------------------------------------------------------
  554.   def actor=(actor)
  555.     return if @actor == actor
  556.     @actor = actor
  557.     refresh
  558.     select_last
  559.   end
  560.   #--------------------------------------------------------------------------
  561.   # * Get Number of Lines to Show
  562.   #--------------------------------------------------------------------------
  563.   def visible_line_number
  564.     return 1
  565.   end
  566.   #--------------------------------------------------------------------------
  567.   # * Create Command List
  568.   #--------------------------------------------------------------------------
  569.   def make_command_list
  570.     return unless @actor
  571.     @actor.added_skill_types.sort.each do |stype_id|
  572.       name = $data_system.skill_types[stype_id]
  573.       add_command(name, :skill, true, stype_id)
  574.     end
  575.   end
  576.   #--------------------------------------------------------------------------
  577.   # * Frame Update
  578.   #--------------------------------------------------------------------------
  579.   def update
  580.     super
  581.     @skill_window.stype_id = current_ext if @skill_window
  582.   end
  583.   #--------------------------------------------------------------------------
  584.   # * Set Skill Window
  585.   #--------------------------------------------------------------------------
  586.   def skill_window=(skill_window)
  587.     @skill_window = skill_window
  588.     update
  589.   end
  590.   #--------------------------------------------------------------------------
  591.   # * Restore Previous Selection Position
  592.   #--------------------------------------------------------------------------
  593.   def select_last
  594.     skill = @actor.last_skill.object
  595.     if skill
  596.       select_ext(skill.stype_id)
  597.     else
  598.       select(0)
  599.     end
  600.   end
  601. end
  602.  
  603. #==============================================================================
  604. # ** Window_SkillStatus
  605. #------------------------------------------------------------------------------
  606. #  This window displays the skill user's status on the skill screen.
  607. #==============================================================================
  608.  
  609. class Window_SkillStatus < Window_Base
  610.   #--------------------------------------------------------------------------
  611.   # * Object Initialization
  612.   #--------------------------------------------------------------------------
  613.   def initialize(x, y)
  614.     super(x, y, 180, 320)
  615.     @actor = nil
  616.     self.opacity = 180
  617.     self.visible = true
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # * Actor Settings
  621.   #--------------------------------------------------------------------------
  622.   def actor=(actor)
  623.     return if @actor == actor
  624.     @actor = actor
  625.     refresh
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   # * Refresh
  629.   #--------------------------------------------------------------------------
  630.   def refresh
  631.     contents.clear
  632.     return unless @actor
  633.     draw_actor_name(@actor, 5, 0)
  634.     draw_actor_level(@actor, 75, 0)
  635.     draw_actor_face(@actor, 20, 25)
  636.     draw_actor_icons(@actor, 20, 125)
  637.     draw_actor_hp(@actor, 5 , 150)
  638.     draw_actor_mp(@actor, 5 , 175)
  639.   end
  640. end
  641.  
  642. #==============================================================================
  643. # ** Window_SkillList
  644. #------------------------------------------------------------------------------
  645. #  This window is for displaying a list of available skills on the skill window.
  646. #==============================================================================
  647.  
  648. class Window_SkillList < Window_Selectable
  649.   #--------------------------------------------------------------------------
  650.   # * Object Initialization
  651.   #--------------------------------------------------------------------------
  652.   def initialize(x, y, width, height)
  653.     super
  654.     @actor = nil
  655.     @stype_id = 0
  656.     @data = []
  657.     self.opacity = 180
  658.   end
  659.   #--------------------------------------------------------------------------
  660.   # * Set Actor
  661.   #--------------------------------------------------------------------------
  662.   def actor=(actor)
  663.     return if @actor == actor
  664.     @actor = actor
  665.     refresh
  666.     self.oy = 0
  667.   end
  668.   #--------------------------------------------------------------------------
  669.   # * Set Skill Type ID
  670.   #--------------------------------------------------------------------------
  671.   def stype_id=(stype_id)
  672.     return if @stype_id == stype_id
  673.     @stype_id = stype_id
  674.     refresh
  675.     self.oy = 0
  676.   end
  677.   #--------------------------------------------------------------------------
  678.   # * Get Digit Count
  679.   #--------------------------------------------------------------------------
  680.   def col_max
  681.     return 1
  682.   end
  683.   #--------------------------------------------------------------------------
  684.   # * Get Number of Items
  685.   #--------------------------------------------------------------------------
  686.   def item_max
  687.     @data ? @data.size : 1
  688.   end
  689.   #--------------------------------------------------------------------------
  690.   # * Get Skill
  691.   #--------------------------------------------------------------------------
  692.   def item
  693.     @data && index >= 0 ? @data[index] : nil
  694.   end
  695.   #--------------------------------------------------------------------------
  696.   # * Get Activation State of Selection Item
  697.   #--------------------------------------------------------------------------
  698.   def current_item_enabled?
  699.     enable?(@data[index])
  700.   end
  701.   #--------------------------------------------------------------------------
  702.   # * Include in Skill List?
  703.   #--------------------------------------------------------------------------
  704.   def include?(item)
  705.     item && item.stype_id == @stype_id
  706.   end
  707.   #--------------------------------------------------------------------------
  708.   # * Display Skill in Active State?
  709.   #--------------------------------------------------------------------------
  710.   def enable?(item)
  711.     @actor && @actor.usable?(item)
  712.   end
  713.   #--------------------------------------------------------------------------
  714.   # * Create Skill List
  715.   #--------------------------------------------------------------------------
  716.   def make_item_list
  717.     @data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
  718.   end
  719.   #--------------------------------------------------------------------------
  720.   # * Restore Previous Selection Position
  721.   #--------------------------------------------------------------------------
  722.   def select_last
  723.     select(@data.index(@actor.last_skill.object) || 0)
  724.   end
  725.   #--------------------------------------------------------------------------
  726.   # * Draw Item
  727.   #--------------------------------------------------------------------------
  728.   def draw_item(index)
  729.     skill = @data[index]
  730.     if skill
  731.       rect = item_rect(index)
  732.       rect.width -= 4
  733.       draw_item_name(skill, rect.x, rect.y, enable?(skill))
  734.       draw_skill_cost(rect, skill)
  735.     end
  736.   end
  737.   #--------------------------------------------------------------------------
  738.   # * Draw Skill Use Cost
  739.   #--------------------------------------------------------------------------
  740.   def draw_skill_cost(rect, skill)
  741.     if @actor.skill_tp_cost(skill) > 0
  742.       change_color(tp_cost_color, enable?(skill))
  743.       draw_text(rect, @actor.skill_tp_cost(skill), 2)
  744.     elsif @actor.skill_mp_cost(skill) > 0
  745.       change_color(mp_cost_color, enable?(skill))
  746.       draw_text(rect, @actor.skill_mp_cost(skill), 2)
  747.     end
  748.   end
  749.   #--------------------------------------------------------------------------
  750.   # * Update Help Text
  751.   #--------------------------------------------------------------------------
  752.   def update_help
  753.     @help_window.set_item(item)
  754.   end
  755.   #--------------------------------------------------------------------------
  756.   # * Refresh
  757.   #--------------------------------------------------------------------------
  758.   def refresh
  759.     make_item_list
  760.     create_contents
  761.     draw_all_items
  762.   end
  763. end
  764.  
  765. #==============================================================================
  766. # ** Window_EquipStatus
  767. #------------------------------------------------------------------------------
  768. #  This window displays actor parameter changes on the equipment screen.
  769. #==============================================================================
  770.  
  771. class Window_EquipStatus < Window_Base
  772.   #--------------------------------------------------------------------------
  773.   # * Object Initialization
  774.   #--------------------------------------------------------------------------
  775.   def initialize(x, y)
  776.     super(x, y, 180, 320)
  777.     @actor = nil
  778.     @temp_actor = nil
  779.     refresh
  780.   end
  781.  
  782.   #--------------------------------------------------------------------------
  783.   # * Get Number of Lines to Show
  784.   #--------------------------------------------------------------------------
  785.   def visible_line_number
  786.     return 7
  787.   end
  788.   #--------------------------------------------------------------------------
  789.   # * Set Actor
  790.   #--------------------------------------------------------------------------
  791.   def actor=(actor)
  792.     return if @actor == actor
  793.     @actor = actor
  794.     refresh
  795.   end
  796.   #--------------------------------------------------------------------------
  797.   # * Refresh
  798.   #--------------------------------------------------------------------------
  799.   def refresh
  800.     contents.clear
  801.     if !@actor.nil?
  802.       draw_actor_name(@actor, 4, 0)
  803.       draw_actor_level(@actor, 100, 0)
  804.       draw_actor_face(@actor, 25, 30)
  805.     end
  806.     6.times {|i| draw_item(0, line_height * (1 + i), 2 + i) }
  807.   end
  808.   #--------------------------------------------------------------------------
  809.   # * Set Temporary Actor After Equipment Change
  810.   #--------------------------------------------------------------------------
  811.   def set_temp_actor(temp_actor)
  812.     return if @temp_actor == temp_actor
  813.     @temp_actor = temp_actor
  814.     refresh
  815.   end
  816.   #--------------------------------------------------------------------------
  817.   # * Draw Item
  818.   #--------------------------------------------------------------------------
  819.   def draw_item(x, y, param_id)
  820.     draw_param_name(x + 4, y + 115, param_id)
  821.     draw_current_param(x + 45, y + 115, param_id) if @actor
  822.     draw_right_arrow(x + 85, y + 115)
  823.     draw_new_param(x + 115, y + 115, param_id) if @temp_actor
  824.   end
  825.   #--------------------------------------------------------------------------
  826.   # * Draw Parameter Name
  827.   #--------------------------------------------------------------------------
  828.   def draw_param_name(x, y, param_id)
  829.     change_color(system_color)
  830.     draw_text(x, y, 80, line_height, Vocab::param(param_id))
  831.   end
  832.   #--------------------------------------------------------------------------
  833.   # * Draw Current Parameter
  834.   #--------------------------------------------------------------------------
  835.   def draw_current_param(x, y, param_id)
  836.     change_color(normal_color)
  837.     draw_text(x, y, 32, line_height, @actor.param(param_id), 2)
  838.   end
  839.   #--------------------------------------------------------------------------
  840.   # * Draw Right Arrow
  841.   #--------------------------------------------------------------------------
  842.   def draw_right_arrow(x, y)
  843.     change_color(system_color)
  844.     draw_text(x, y, 22, line_height, "→", 1)
  845.   end
  846.   #--------------------------------------------------------------------------
  847.   # * Draw Post-Equipment Change Parameter
  848.   #--------------------------------------------------------------------------
  849.   def draw_new_param(x, y, param_id)
  850.     new_value = @temp_actor.param(param_id)
  851.     change_color(param_change_color(new_value - @actor.param(param_id)))
  852.     draw_text(x, y, 32, line_height, new_value, 2)
  853.   end
  854. end
  855.  
  856. #==============================================================================
  857. # ** Window_SaveFile
  858. #------------------------------------------------------------------------------
  859. #  This window displays save files on the save and load screens.
  860. #==============================================================================
  861.  
  862. class Window_SaveFile < Window_Base
  863.   #--------------------------------------------------------------------------
  864.   # * Public Instance Variables
  865.   #--------------------------------------------------------------------------
  866.   attr_reader   :selected                 # selected
  867.   #--------------------------------------------------------------------------
  868.   # * Object Initialization
  869.   #     index : index of save files
  870.   #--------------------------------------------------------------------------
  871.   def initialize(height, index)
  872.     super(90, (index * height) - 100, 360, height)
  873.     @file_index = index
  874.     refresh
  875.     @selected = false
  876.     self.opacity = 180
  877.   end
  878.   #--------------------------------------------------------------------------
  879.   # * Refresh
  880.   #--------------------------------------------------------------------------
  881.   def refresh
  882.     contents.clear
  883.     change_color(normal_color)
  884.     name = Vocab::File + " #{@file_index + 1}"
  885.     draw_text(4, 0, 200, line_height, name)
  886.     @name_width = text_size(name).width
  887.     draw_party_characters(152, 58)
  888.     draw_playtime(0, contents.height - line_height, contents.width - 4, 2)
  889.   end
  890.   #--------------------------------------------------------------------------
  891.   # * Draw Party Characters
  892.   #--------------------------------------------------------------------------
  893.   def draw_party_characters(x, y)
  894.     header = DataManager.load_header(@file_index)
  895.     return unless header
  896.     header[:characters].each_with_index do |data, i|
  897.       draw_character(data[0], data[1], x + i * 48, y)
  898.     end
  899.   end
  900.   #--------------------------------------------------------------------------
  901.   # * Draw Play Time
  902.   #--------------------------------------------------------------------------
  903.   def draw_playtime(x, y, width, align)
  904.     header = DataManager.load_header(@file_index)
  905.     return unless header
  906.     draw_text(x, y, width, line_height, header[:playtime_s], 2)
  907.   end
  908.   #--------------------------------------------------------------------------
  909.   # * Set Selected
  910.   #--------------------------------------------------------------------------
  911.   def selected=(selected)
  912.     @selected = selected
  913.     update_cursor
  914.   end
  915.   #--------------------------------------------------------------------------
  916.   # * Update Cursor
  917.   #--------------------------------------------------------------------------
  918.   def update_cursor
  919.     if @selected
  920.       cursor_rect.set(0, 0, @name_width + 8, line_height)
  921.     else
  922.       cursor_rect.empty
  923.     end
  924.   end
  925. end
  926.  
  927.  
  928. #==============================================================================
  929. # :: Scene_Menu
  930. #------------------------------------------------------------------------------
  931. #  This class performs the menu screen processing.
  932. #==============================================================================
  933. class Scene_Menu < Scene_MenuBase
  934.   #--------------------------------------------------------------------------
  935.   # ; Start Processing
  936.   #--------------------------------------------------------------------------
  937.   def start
  938.     super
  939.     create_command_window
  940.     create_location_window
  941.     create_gold_window
  942.     create_status_window
  943.   end
  944.   #--------------------------------------------------------------------------
  945.   # ; Create Command Window
  946.   #--------------------------------------------------------------------------
  947.   def create_command_window
  948.     @command_window = Window_HorzMenuCommand.new
  949.     @command_window.height = 48
  950.     @command_window.set_handler(:item,      method(:command_item))
  951.     @command_window.set_handler(:skill,     method(:command_personal))
  952.     @command_window.set_handler(:equip,     method(:command_personal))
  953.     @command_window.set_handler(:cancel,    method(:return_scene))
  954.   end
  955.   #--------------------------------------------------------------------------
  956.   # ; Create Gold Window
  957.   #--------------------------------------------------------------------------
  958.   def create_gold_window
  959.     @gold_window = Window_Gold.new
  960.     @gold_window.x = 385
  961.     @gold_window.y = Graphics.height - @gold_window.height
  962.     @gold_window.opacity = 180
  963.   end
  964.   #--------------------------------------------------------------------------
  965.   # ; Create Status Window
  966.   #--------------------------------------------------------------------------
  967.   def create_status_window
  968.     @status_window = Window_ActorStatus.new(100, 48)
  969.   end
  970.   #--------------------------------------------------------------------------
  971.   # ; Create Location  Window
  972.   #--------------------------------------------------------------------------
  973.   def create_location_window
  974.     @location_window = Window_Location.new
  975.     @location_window.x = 0
  976.     @location_window.y = Graphics.height - @location_window.height
  977.     @location_window.opacity = 180
  978.   end
  979.   #--------------------------------------------------------------------------
  980.   # ; [Item] Command
  981.   #--------------------------------------------------------------------------
  982.   def command_item
  983.     SceneManager.call(Scene_Legacy_Item)
  984.   end
  985.   #--------------------------------------------------------------------------
  986.   # ; [Skill], [Equipment] and [Status] Commands
  987.   #--------------------------------------------------------------------------
  988.   def command_personal
  989.     case @command_window.current_symbol
  990.     when :skill
  991.       SceneManager.call(Scene_Legacy_Skill)
  992.     when :equip
  993.       SceneManager.call(Scene_Equip)
  994.     end
  995.   end
  996. end
  997.  
  998. #==============================================================================
  999. # ** Scene_ItemBase
  1000. #------------------------------------------------------------------------------
  1001. #  This class performs common processing for the item screen and skill screen.
  1002. #==============================================================================
  1003.  
  1004. class Scene_Legacy_ItemBase < Scene_MenuBase
  1005.   #--------------------------------------------------------------------------
  1006.   # * Start Processing
  1007.   #--------------------------------------------------------------------------
  1008.   def start
  1009.     super
  1010.     create_actor_window
  1011.   end
  1012.   #--------------------------------------------------------------------------
  1013.   # * Create Actor Window
  1014.   #--------------------------------------------------------------------------
  1015.   def create_actor_window
  1016.     @actor_window = Window_Legacy_MenuActor.new
  1017.     @actor_window.set_handler(:ok,     method(:on_actor_ok))
  1018.     @actor_window.set_handler(:cancel, method(:on_actor_cancel))
  1019.   end
  1020.   #--------------------------------------------------------------------------
  1021.   # * Get Currently Selected Item
  1022.   #--------------------------------------------------------------------------
  1023.   def item
  1024.     @item_window.item
  1025.   end
  1026.   #--------------------------------------------------------------------------
  1027.   # * Get Item's User
  1028.   #--------------------------------------------------------------------------
  1029.   def user
  1030.     $game_party.movable_members.max_by {|member| member.pha }
  1031.   end
  1032.   #--------------------------------------------------------------------------
  1033.   # * Determine if Cursor Is in Left Column
  1034.   #--------------------------------------------------------------------------
  1035.   def cursor_left?
  1036.     @item_window.index % 1 == 0
  1037.   end
  1038.   #--------------------------------------------------------------------------
  1039.   # * Hide Subwindow
  1040.   #--------------------------------------------------------------------------
  1041.   def hide_sub_window(window)
  1042.     @viewport.rect.x = @viewport.ox = 0
  1043.     @viewport.rect.width = Graphics.width
  1044.     window.hide.deactivate
  1045.     activate_item_window
  1046.   end
  1047.   #--------------------------------------------------------------------------
  1048.   # * Actor [OK]
  1049.   #--------------------------------------------------------------------------
  1050.   def on_actor_ok
  1051.     if item_usable?
  1052.       use_item
  1053.     else
  1054.       Sound.play_buzzer
  1055.     end
  1056.   end
  1057.   #--------------------------------------------------------------------------
  1058.   # * Actor [Cancel]
  1059.   #--------------------------------------------------------------------------
  1060.   def on_actor_cancel
  1061.     activate_item_window
  1062.   end
  1063.   #--------------------------------------------------------------------------
  1064.   # * Confirm Item
  1065.   #--------------------------------------------------------------------------
  1066.   def determine_item
  1067.     if item.for_friend?
  1068.       @actor_window.show.activate
  1069.       @actor_window.select_for_item(item)
  1070.     else
  1071.       use_item
  1072.       activate_item_window
  1073.     end
  1074.   end
  1075.   #--------------------------------------------------------------------------
  1076.   # * Activate Item Window
  1077.   #--------------------------------------------------------------------------
  1078.   def activate_item_window
  1079.     @item_window.refresh
  1080.     @item_window.activate
  1081.   end
  1082.   #--------------------------------------------------------------------------
  1083.   # * Get Array of Actors Targeted by Item Use
  1084.   #--------------------------------------------------------------------------
  1085.   def item_target_actors
  1086.     if !item.for_friend?
  1087.       []
  1088.     elsif item.for_all?
  1089.       $game_party.members
  1090.     else
  1091.       [$game_party.members[@actor_window.index]]
  1092.     end
  1093.   end
  1094.   #--------------------------------------------------------------------------
  1095.   # * Determine if Item is Usable
  1096.   #--------------------------------------------------------------------------
  1097.   def item_usable?
  1098.     user.usable?(item) && item_effects_valid?
  1099.   end
  1100.   #--------------------------------------------------------------------------
  1101.   # * Determine if Item Is Effective
  1102.   #--------------------------------------------------------------------------
  1103.   def item_effects_valid?
  1104.     item_target_actors.any? do |target|
  1105.       target.item_test(user, item)
  1106.     end
  1107.   end
  1108.   #--------------------------------------------------------------------------
  1109.   # * Use Item on Actor
  1110.   #--------------------------------------------------------------------------
  1111.   def use_item_to_actors
  1112.     item_target_actors.each do |target|
  1113.       item.repeats.times { target.item_apply(user, item) }
  1114.     end
  1115.   end
  1116.   #--------------------------------------------------------------------------
  1117.   # * Use Item
  1118.   #--------------------------------------------------------------------------
  1119.   def use_item
  1120.     play_se_for_item
  1121.     user.use_item(item)
  1122.     use_item_to_actors
  1123.     check_common_event
  1124.     check_gameover
  1125.     @actor_window.refresh
  1126.   end
  1127.   #--------------------------------------------------------------------------
  1128.   # * Determine if Common Event Is Reserved
  1129.   #    Transition to the map screen if the event call is reserved.
  1130.   #--------------------------------------------------------------------------
  1131.   def check_common_event
  1132.     SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
  1133.   end
  1134. end
  1135.  
  1136.  
  1137. #==============================================================================
  1138. # ** Scene_Item
  1139. #------------------------------------------------------------------------------
  1140. #  This class performs the item screen processing.
  1141. #==============================================================================
  1142.  
  1143. class Scene_Legacy_Item < Scene_Legacy_ItemBase
  1144.   #--------------------------------------------------------------------------
  1145.   # * Start Processing
  1146.   #--------------------------------------------------------------------------
  1147.   def start
  1148.     super
  1149.     create_help_window
  1150.     create_category_window
  1151.     create_item_window
  1152.   end
  1153.   #--------------------------------------------------------------------------
  1154.   # * Frame Update
  1155.   #--------------------------------------------------------------------------
  1156.   def update
  1157.     update_basic
  1158.   end
  1159.   #--------------------------------------------------------------------------
  1160.   # * Create Help Window
  1161.   #--------------------------------------------------------------------------
  1162.   def create_help_window
  1163.     @help_window = Window_Help.new(1)
  1164.     @help_window.viewport = @viewport
  1165.     @help_window.y = 365
  1166.     @help_window.height = 50
  1167.     @help_window.opacity = 180
  1168.   end
  1169.   #--------------------------------------------------------------------------
  1170.   # * Create Category Window
  1171.   #--------------------------------------------------------------------------
  1172.   def create_category_window
  1173.     @category_window = Window_ItemCategory.new
  1174.     @category_window.viewport = @viewport
  1175.     @category_window.help_window = @help_window
  1176.     @category_window.x = 100
  1177.     @category_window.y = 0
  1178.     @category_window.width = 380
  1179.     @category_window.set_handler(:ok,     method(:on_category_ok))
  1180.     @category_window.set_handler(:cancel, method(:return_scene))
  1181.   end
  1182.   #--------------------------------------------------------------------------
  1183.   # * Create Item Window
  1184.   #--------------------------------------------------------------------------
  1185.   def create_item_window
  1186.     @item_window = Window_ItemList.new(250, 47, 230, 318)
  1187.     @item_window.viewport = @viewport
  1188.     @item_window.help_window = @help_window
  1189.     @item_window.set_handler(:ok,     method(:on_item_ok))
  1190.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  1191.     @category_window.item_window = @item_window
  1192.   end
  1193.   #--------------------------------------------------------------------------
  1194.   # * Category [OK]
  1195.   #--------------------------------------------------------------------------
  1196.   def on_category_ok
  1197.     @item_window.activate
  1198.     @item_window.select_last
  1199.   end
  1200.   #--------------------------------------------------------------------------
  1201.   # * Item [OK]
  1202.   #--------------------------------------------------------------------------
  1203.   def on_item_ok
  1204.     $game_party.last_item.object = item
  1205.     determine_item
  1206.   end
  1207.   #--------------------------------------------------------------------------
  1208.   # * Item [Cancel]
  1209.   #--------------------------------------------------------------------------
  1210.   def on_item_cancel
  1211.     @item_window.unselect
  1212.     @category_window.activate
  1213.   end
  1214.   #--------------------------------------------------------------------------
  1215.   # * Play SE When Using Item
  1216.   #--------------------------------------------------------------------------
  1217.   def play_se_for_item
  1218.     Sound.play_use_item
  1219.   end
  1220.   #--------------------------------------------------------------------------
  1221.   # * Use Item
  1222.   #--------------------------------------------------------------------------
  1223.   def use_item
  1224.     super
  1225.     @item_window.redraw_current_item
  1226.     @item_window.refresh
  1227.   end
  1228. end
  1229.  
  1230. #==============================================================================
  1231. # ** Scene_Skill
  1232. #------------------------------------------------------------------------------
  1233. #  This class performs skill screen processing. Skills are handled as items for
  1234. # the sake of process sharing.
  1235. #==============================================================================
  1236.  
  1237. class Scene_Legacy_Skill < Scene_Legacy_ItemBase
  1238.   #--------------------------------------------------------------------------
  1239.   # * Start Processing
  1240.   #--------------------------------------------------------------------------
  1241.   def start
  1242.     super
  1243.     create_help_window
  1244.     create_command_window
  1245.     create_item_window
  1246.   end
  1247.   #--------------------------------------------------------------------------
  1248.   # * Create Help Window
  1249.   #--------------------------------------------------------------------------
  1250.   def create_help_window
  1251.     @help_window = Window_Help.new(1)
  1252.     @help_window.viewport = @viewport
  1253.     @help_window.y = 367
  1254.     @help_window.height = 50
  1255.     @help_window.opacity = 180
  1256.   end
  1257.   #--------------------------------------------------------------------------
  1258.   # * Create Command Window
  1259.   #--------------------------------------------------------------------------
  1260.   def create_command_window
  1261.     @command_window = Window_HorzSkillCommand.new(100, 0)
  1262.     @command_window.width = 150
  1263.     @command_window.viewport = @viewport
  1264.     @command_window.help_window = @help_window
  1265.     @command_window.actor = @actor
  1266.     @command_window.set_handler(:skill,    method(:command_skill))
  1267.     @command_window.set_handler(:cancel,   method(:return_scene))
  1268.     @command_window.set_handler(:pagedown, method(:next_actor))
  1269.     @command_window.set_handler(:pageup,   method(:prev_actor))
  1270.   end
  1271.   #--------------------------------------------------------------------------
  1272.   # * Create Item Window
  1273.   #--------------------------------------------------------------------------
  1274.   def create_item_window
  1275.     @item_window = Window_SkillList.new(250, 0, 245, 367)
  1276.     @item_window.actor = @actor
  1277.     @item_window.viewport = @viewport
  1278.     @item_window.help_window = @help_window
  1279.     @item_window.set_handler(:ok,     method(:on_item_ok))
  1280.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  1281.     @command_window.skill_window = @item_window
  1282.   end
  1283.   #--------------------------------------------------------------------------
  1284.   # * Get Skill's User
  1285.   #--------------------------------------------------------------------------
  1286.   def user
  1287.     @actor
  1288.   end
  1289.   #--------------------------------------------------------------------------
  1290.   # * [Skill] Command
  1291.   #--------------------------------------------------------------------------
  1292.   def command_skill
  1293.     @item_window.activate
  1294.     @item_window.select_last
  1295.   end
  1296.   #--------------------------------------------------------------------------
  1297.   # * Item [OK]
  1298.   #--------------------------------------------------------------------------
  1299.   def on_item_ok
  1300.     @actor.last_skill.object = item
  1301.     determine_item
  1302.   end
  1303.   #--------------------------------------------------------------------------
  1304.   # * Item [Cancel]
  1305.   #--------------------------------------------------------------------------
  1306.   def on_item_cancel
  1307.     @item_window.unselect
  1308.     @command_window.activate
  1309.   end
  1310.   #--------------------------------------------------------------------------
  1311.   # * Play SE When Using Item
  1312.   #--------------------------------------------------------------------------
  1313.   def play_se_for_item
  1314.     Sound.play_use_skill
  1315.   end
  1316.   #--------------------------------------------------------------------------
  1317.   # * Use Item
  1318.   #--------------------------------------------------------------------------
  1319.   def use_item
  1320.     super
  1321.     @actor_window.refresh
  1322.     @item_window.refresh
  1323.   end
  1324.   #--------------------------------------------------------------------------
  1325.   # * Change Actors
  1326.   #--------------------------------------------------------------------------
  1327.   def on_actor_change
  1328.     @command_window.actor = @actor
  1329.     @actor_window.actor = @actor
  1330.     @item_window.actor = @actor
  1331.     @command_window.activate
  1332.   end
  1333. end
  1334.  
  1335. #==============================================================================
  1336. # ** Scene_Equip
  1337. #------------------------------------------------------------------------------
  1338. #  This class performs the equipment screen processing.
  1339. #==============================================================================
  1340.  
  1341. class Scene_Equip < Scene_MenuBase
  1342.   #--------------------------------------------------------------------------
  1343.   # * Start Processing
  1344.   #--------------------------------------------------------------------------
  1345.   def start
  1346.     super
  1347.     create_help_window
  1348.     create_status_window
  1349.     create_command_window
  1350.     create_slot_window
  1351.     create_item_window
  1352.   end
  1353.   #--------------------------------------------------------------------------
  1354.   # * Create Help Window
  1355.   #--------------------------------------------------------------------------
  1356.   def create_help_window
  1357.     @help_window = Window_Help.new(1)
  1358.     @help_window.viewport = @viewport
  1359.     @help_window.y = 367
  1360.     @help_window.height = 50
  1361.     @help_window.opacity = 180
  1362.   end
  1363.   #--------------------------------------------------------------------------
  1364.   # * Create Status Window
  1365.   #--------------------------------------------------------------------------
  1366.   def create_status_window
  1367.     @status_window = Window_EquipStatus.new(20, 48)
  1368.     @status_window.viewport = @viewport
  1369.     @status_window.actor = @actor
  1370.     @status_window.opacity = 180
  1371.   end
  1372.   #--------------------------------------------------------------------------
  1373.   # * Create Command Window
  1374.   #--------------------------------------------------------------------------
  1375.   def create_command_window
  1376.     @command_window = Window_EquipCommand.new(100, 0, 380)
  1377.     @command_window.opacity = 180
  1378.     @command_window.viewport = @viewport
  1379.     @command_window.help_window = @help_window
  1380.     @command_window.set_handler(:equip,    method(:command_equip))
  1381.     @command_window.set_handler(:optimize, method(:command_optimize))
  1382.     @command_window.set_handler(:clear,    method(:command_clear))
  1383.     @command_window.set_handler(:cancel,   method(:return_scene))
  1384.     @command_window.set_handler(:pagedown, method(:next_actor))
  1385.     @command_window.set_handler(:pageup,   method(:prev_actor))
  1386.   end
  1387.   #--------------------------------------------------------------------------
  1388.   # * Create Slot Window
  1389.   #--------------------------------------------------------------------------
  1390.   def create_slot_window
  1391.     @slot_window = Window_EquipSlot.new(200, 48, 320)
  1392.     @slot_window.opacity = 180
  1393.     @slot_window.viewport = @viewport
  1394.     @slot_window.help_window = @help_window
  1395.     @slot_window.status_window = @status_window
  1396.     @slot_window.actor = @actor
  1397.     @slot_window.set_handler(:ok,       method(:on_slot_ok))
  1398.     @slot_window.set_handler(:cancel,   method(:on_slot_cancel))
  1399.   end
  1400.   #--------------------------------------------------------------------------
  1401.   # * Create Item Window
  1402.   #--------------------------------------------------------------------------
  1403.   def create_item_window
  1404.     @item_window = Window_EquipItem.new(200, 192, 320, 175)
  1405.     @item_window.opacity = 180
  1406.     @item_window.viewport = @viewport
  1407.     @item_window.help_window = @help_window
  1408.     @item_window.status_window = @status_window
  1409.     @item_window.actor = @actor
  1410.     @item_window.set_handler(:ok,     method(:on_item_ok))
  1411.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  1412.     @slot_window.item_window = @item_window
  1413.   end
  1414.   #--------------------------------------------------------------------------
  1415.   # * [Change Equipment] Command
  1416.   #--------------------------------------------------------------------------
  1417.   def command_equip
  1418.     @slot_window.activate
  1419.     @slot_window.select(0)
  1420.   end
  1421.   #--------------------------------------------------------------------------
  1422.   # * [Ultimate Equipment] Command
  1423.   #--------------------------------------------------------------------------
  1424.   def command_optimize
  1425.     Sound.play_equip
  1426.     @actor.optimize_equipments
  1427.     @status_window.refresh
  1428.     @slot_window.refresh
  1429.     @command_window.activate
  1430.   end
  1431.   #--------------------------------------------------------------------------
  1432.   # * [Remove All] Command
  1433.   #--------------------------------------------------------------------------
  1434.   def command_clear
  1435.     Sound.play_equip
  1436.     @actor.clear_equipments
  1437.     @status_window.refresh
  1438.     @slot_window.refresh
  1439.     @command_window.activate
  1440.   end
  1441.   #--------------------------------------------------------------------------
  1442.   # * Slot [OK]
  1443.   #--------------------------------------------------------------------------
  1444.   def on_slot_ok
  1445.     @item_window.activate
  1446.     @item_window.select(0)
  1447.   end
  1448.   #--------------------------------------------------------------------------
  1449.   # * Slot [Cancel]
  1450.   #--------------------------------------------------------------------------
  1451.   def on_slot_cancel
  1452.     @slot_window.unselect
  1453.     @command_window.activate
  1454.   end
  1455.   #--------------------------------------------------------------------------
  1456.   # * Item [OK]
  1457.   #--------------------------------------------------------------------------
  1458.   def on_item_ok
  1459.     Sound.play_equip
  1460.     @actor.change_equip(@slot_window.index, @item_window.item)
  1461.     @slot_window.activate
  1462.     @slot_window.refresh
  1463.     @item_window.unselect
  1464.     @item_window.refresh
  1465.   end
  1466.   #--------------------------------------------------------------------------
  1467.   # * Item [Cancel]
  1468.   #--------------------------------------------------------------------------
  1469.   def on_item_cancel
  1470.     @slot_window.activate
  1471.     @item_window.unselect
  1472.   end
  1473.   #--------------------------------------------------------------------------
  1474.   # * Change Actors
  1475.   #--------------------------------------------------------------------------
  1476.   def on_actor_change
  1477.     @status_window.actor = @actor
  1478.     @slot_window.actor = @actor
  1479.     @item_window.actor = @actor
  1480.     @command_window.activate
  1481.   end
  1482. end
  1483.  
  1484. #==============================================================================
  1485. # ** Scene_File
  1486. #------------------------------------------------------------------------------
  1487. #  This class performs common processing for the save screen and load screen.
  1488. #==============================================================================
  1489.  
  1490. class Scene_File < Scene_MenuBase
  1491.   #--------------------------------------------------------------------------
  1492.   # * Start Processing
  1493.   #--------------------------------------------------------------------------
  1494.   def start
  1495.     super
  1496.     create_help_window
  1497.     create_savefile_viewport
  1498.     create_savefile_windows
  1499.     init_selection
  1500.   end
  1501.   #--------------------------------------------------------------------------
  1502.   # * Termination Processing
  1503.   #--------------------------------------------------------------------------
  1504.   def terminate
  1505.     super
  1506.     @savefile_viewport.dispose
  1507.     @savefile_windows.each {|window| window.dispose }
  1508.   end
  1509.   #--------------------------------------------------------------------------
  1510.   # * Frame Update
  1511.   #--------------------------------------------------------------------------
  1512.   def update
  1513.     super
  1514.     @savefile_windows.each {|window| window.update }
  1515.     update_savefile_selection
  1516.   end
  1517.   #--------------------------------------------------------------------------
  1518.   # * Create Help Window
  1519.   #--------------------------------------------------------------------------
  1520.   def create_help_window
  1521.     @help_window = Window_Help.new(1)
  1522.     @help_window.set_text(help_window_text)
  1523.     @help_window.y = 367
  1524.     @help_window.height = 50
  1525.     @help_window.opacity = 180
  1526.   end
  1527.   #--------------------------------------------------------------------------
  1528.   # * Get Help Window Text
  1529.   #--------------------------------------------------------------------------
  1530.   def help_window_text
  1531.     return ""
  1532.   end
  1533.   #--------------------------------------------------------------------------
  1534.   # * Create Save File Viewport
  1535.   #--------------------------------------------------------------------------
  1536.   def create_savefile_viewport
  1537.     @savefile_viewport = Viewport.new
  1538.     @savefile_viewport.rect.y = @help_window.height
  1539.     @savefile_viewport.rect.height -= @help_window.height
  1540.   end
  1541.   #--------------------------------------------------------------------------
  1542.   # * Create Save File Window
  1543.   #--------------------------------------------------------------------------
  1544.   def create_savefile_windows
  1545.     @savefile_windows = Array.new(item_max) do |i|
  1546.       Window_SaveFile.new(savefile_height, i)
  1547.     end
  1548.     @savefile_windows.each {|window| window.viewport = @savefile_viewport }
  1549.   end
  1550.   #--------------------------------------------------------------------------
  1551.   # * Initialize Selection State
  1552.   #--------------------------------------------------------------------------
  1553.   def init_selection
  1554.     @index = first_savefile_index
  1555.     @savefile_windows[@index].selected = true
  1556.     self.top_index = @index - visible_max / 2
  1557.     ensure_cursor_visible
  1558.   end
  1559.   #--------------------------------------------------------------------------
  1560.   # * Get Number of Items
  1561.   #--------------------------------------------------------------------------
  1562.   def item_max
  1563.     return 3
  1564.   end
  1565.   #--------------------------------------------------------------------------
  1566.   # * Get Number of Save Files to Show on Screen
  1567.   #--------------------------------------------------------------------------
  1568.   def visible_max
  1569.     return 4
  1570.   end
  1571.   #--------------------------------------------------------------------------
  1572.   # * Get Height of Save File Window
  1573.   #--------------------------------------------------------------------------
  1574.   def savefile_height
  1575.     return 100
  1576.   end
  1577.   #--------------------------------------------------------------------------
  1578.   # * Get File Index to Select First
  1579.   #--------------------------------------------------------------------------
  1580.   def first_savefile_index
  1581.     return 0
  1582.   end
  1583.   #--------------------------------------------------------------------------
  1584.   # * Get Current Index
  1585.   #--------------------------------------------------------------------------
  1586.   def index
  1587.     @index
  1588.   end
  1589.   #--------------------------------------------------------------------------
  1590.   # * Get Top Index
  1591.   #--------------------------------------------------------------------------
  1592.   def top_index
  1593.     @savefile_viewport.oy / savefile_height
  1594.   end
  1595.   #--------------------------------------------------------------------------
  1596.   # * Set Top Index
  1597.   #--------------------------------------------------------------------------
  1598.   def top_index=(index)
  1599.     index = 0 if index < 0
  1600.     index = item_max - visible_max if index > item_max - visible_max
  1601.     @savefile_viewport.oy = index * savefile_height
  1602.   end
  1603.   #--------------------------------------------------------------------------
  1604.   # * Get Bottom Index
  1605.   #--------------------------------------------------------------------------
  1606.   def bottom_index
  1607.     top_index + visible_max - 1
  1608.   end
  1609.   #--------------------------------------------------------------------------
  1610.   # * Set Bottom Index
  1611.   #--------------------------------------------------------------------------
  1612.   def bottom_index=(index)
  1613.     self.top_index = index - (visible_max - 1)
  1614.   end
  1615.   #--------------------------------------------------------------------------
  1616.   # * Update Save File Selection
  1617.   #--------------------------------------------------------------------------
  1618.   def update_savefile_selection
  1619.     return on_savefile_ok     if Input.trigger?(:C)
  1620.     return on_savefile_cancel if Input.trigger?(:B)
  1621.     update_cursor
  1622.   end
  1623.   #--------------------------------------------------------------------------
  1624.   # * Save File [OK]
  1625.   #--------------------------------------------------------------------------
  1626.   def on_savefile_ok
  1627.   end
  1628.   #--------------------------------------------------------------------------
  1629.   # * Save File [Cancel]
  1630.   #--------------------------------------------------------------------------
  1631.   def on_savefile_cancel
  1632.     Sound.play_cancel
  1633.     return_scene
  1634.   end
  1635.   #--------------------------------------------------------------------------
  1636.   # * Update Cursor
  1637.   #--------------------------------------------------------------------------
  1638.   def update_cursor
  1639.     last_index = @index
  1640.     cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
  1641.     cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
  1642.     cursor_pagedown   if Input.trigger?(:R)
  1643.     cursor_pageup     if Input.trigger?(:L)
  1644.     if @index != last_index
  1645.       Sound.play_cursor
  1646.       @savefile_windows[last_index].selected = false
  1647.       @savefile_windows[@index].selected = true
  1648.     end
  1649.   end
  1650.   #--------------------------------------------------------------------------
  1651.   # * Move Cursor Down
  1652.   #--------------------------------------------------------------------------
  1653.   def cursor_down(wrap)
  1654.     @index = (@index + 1) % item_max if @index < item_max - 1 || wrap
  1655.     ensure_cursor_visible
  1656.   end
  1657.   #--------------------------------------------------------------------------
  1658.   # * Move Cursor Up
  1659.   #--------------------------------------------------------------------------
  1660.   def cursor_up(wrap)
  1661.     @index = (@index - 1 + item_max) % item_max if @index > 0 || wrap
  1662.     ensure_cursor_visible
  1663.   end
  1664.   #--------------------------------------------------------------------------
  1665.   # * Move Cursor One Page Down
  1666.   #--------------------------------------------------------------------------
  1667.   def cursor_pagedown
  1668.     if top_index + visible_max < item_max
  1669.       self.top_index += visible_max
  1670.       @index = [@index + visible_max, item_max - 1].min
  1671.     end
  1672.   end
  1673.   #--------------------------------------------------------------------------
  1674.   # * Move Cursor One Page Up
  1675.   #--------------------------------------------------------------------------
  1676.   def cursor_pageup
  1677.     if top_index > 0
  1678.       self.top_index -= visible_max
  1679.       @index = [@index - visible_max, 0].max
  1680.     end
  1681.   end
  1682.   #--------------------------------------------------------------------------
  1683.   # * Scroll Cursor to Position Within Screen
  1684.   #--------------------------------------------------------------------------
  1685.   def ensure_cursor_visible
  1686.     self.top_index = index if index < top_index
  1687.     self.bottom_index = index if index > bottom_index
  1688.   end
  1689. end