Advertisement
Legacy

[RGSS3] Legacy 1-Man Menu System

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