Advertisement
leequangson

Menu siêu gọn!!!

Aug 29th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.80 KB | None | 0 0
  1. #==============================================================================
  2. # ** Window_MenuCommand
  3. #------------------------------------------------------------------------------
  4. #  This command window appears on the menu screen.
  5. #==============================================================================
  6.  
  7. class Window_MenuCommand < Window_Command
  8.   #--------------------------------------------------------------------------
  9.   # * Initialize Command Selection Position (Class Method)
  10.   #--------------------------------------------------------------------------
  11.   def self.init_command_position
  12.     @@last_command_symbol = nil
  13.   end
  14.   #--------------------------------------------------------------------------
  15.   # * Object Initialization
  16.   #--------------------------------------------------------------------------
  17.   def initialize
  18.     super(0, 0)
  19.     select_last
  20.   end
  21.   #--------------------------------------------------------------------------
  22.   # * Get Window Width
  23.   #--------------------------------------------------------------------------
  24.   def window_width
  25.     return 160
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # * Get Number of Lines to Show
  29.   #--------------------------------------------------------------------------
  30.   def visible_line_number
  31.     item_max
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # * Create Command List
  35.   #--------------------------------------------------------------------------
  36.   def make_command_list
  37.     add_main_commands
  38.     #add_formation_command
  39.     add_original_commands
  40.     add_save_command
  41.     add_game_end_command
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # * Add Main Commands to List
  45.   #--------------------------------------------------------------------------
  46.   def add_main_commands
  47.     add_command(Vocab::item,   :item,   main_commands_enabled)
  48.     #add_command(Vocab::skill,  :skill,  main_commands_enabled)
  49.     #add_command(Vocab::equip,  :equip,  main_commands_enabled)
  50.     #add_command(Vocab::status, :status, main_commands_enabled)
  51.   end
  52.   #--------------------------------------------------------------------------
  53.   # * Add Formation to Command List
  54.   #--------------------------------------------------------------------------
  55.   def add_formation_command
  56.     add_command(Vocab::formation, :formation, formation_enabled)
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # * For Adding Original Commands
  60.   #--------------------------------------------------------------------------
  61.   def add_original_commands
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # * Add Save to Command List
  65.   #--------------------------------------------------------------------------
  66.   def add_save_command
  67.     add_command(Vocab::save, :save, save_enabled)
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # * Add Exit Game to Command List
  71.   #--------------------------------------------------------------------------
  72.   def add_game_end_command
  73.     add_command(Vocab::game_end, :game_end)
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # * Get Activation State of Main Commands
  77.   #--------------------------------------------------------------------------
  78.   def main_commands_enabled
  79.     $game_party.exists
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Get Activation State of Formation
  83.   #--------------------------------------------------------------------------
  84.   def formation_enabled
  85.     $game_party.members.size >= 2 && !$game_system.formation_disabled
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # * Get Activation State of Save
  89.   #--------------------------------------------------------------------------
  90.   def save_enabled
  91.     !$game_system.save_disabled
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Processing When OK Button Is Pressed
  95.   #--------------------------------------------------------------------------
  96.   def process_ok
  97.     @@last_command_symbol = current_symbol
  98.     super
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # * Restore Previous Selection Position
  102.   #--------------------------------------------------------------------------
  103.   def select_last
  104.     select_symbol(@@last_command_symbol)
  105.   end
  106. end
  107.  
  108. #==============================================================================
  109. # ** Scene_Menu
  110. #------------------------------------------------------------------------------
  111. #  This class performs the menu screen processing.
  112. #==============================================================================
  113.  
  114. class Scene_Menu < Scene_MenuBase
  115.   #--------------------------------------------------------------------------
  116.   # * Start Processing
  117.   #--------------------------------------------------------------------------
  118.   def start
  119.     super
  120.     create_command_window
  121.     #create_gold_window
  122.     #create_status_window
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # * Create Command Window
  126.   #--------------------------------------------------------------------------
  127.   def create_command_window
  128.     @command_window = Window_MenuCommand.new
  129.     @command_window.set_handler(:item,      method(:command_item))
  130.     @command_window.set_handler(:skill,     method(:command_personal))
  131.     @command_window.set_handler(:equip,     method(:command_personal))
  132.     @command_window.set_handler(:status,    method(:command_personal))
  133.     @command_window.set_handler(:formation, method(:command_formation))
  134.     @command_window.set_handler(:save,      method(:command_save))
  135.     @command_window.set_handler(:game_end,  method(:command_game_end))
  136.     @command_window.set_handler(:cancel,    method(:return_scene))
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # * Create Gold Window
  140.   #--------------------------------------------------------------------------
  141.   def create_gold_window
  142.     @gold_window = Window_Gold.new
  143.     @gold_window.x = 0
  144.     @gold_window.y = Graphics.height - @gold_window.height
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # * Create Status Window
  148.   #--------------------------------------------------------------------------
  149.   def create_status_window
  150.     @status_window = Window_MenuStatus.new(@command_window.width, 0)
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # * [Item] Command
  154.   #--------------------------------------------------------------------------
  155.   def command_item
  156.     SceneManager.call(Scene_Item)
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * [Skill], [Equipment] and [Status] Commands
  160.   #--------------------------------------------------------------------------
  161.   def command_personal
  162.     @status_window.select_last
  163.     @status_window.activate
  164.     @status_window.set_handler(:ok,     method(:on_personal_ok))
  165.     @status_window.set_handler(:cancel, method(:on_personal_cancel))
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # * [Formation] Command
  169.   #--------------------------------------------------------------------------
  170.   def command_formation
  171.     @status_window.select_last
  172.     @status_window.activate
  173.     @status_window.set_handler(:ok,     method(:on_formation_ok))
  174.     @status_window.set_handler(:cancel, method(:on_formation_cancel))
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # * [Save] Command
  178.   #--------------------------------------------------------------------------
  179.   def command_save
  180.     SceneManager.call(Scene_Save)
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * [Exit Game] Command
  184.   #--------------------------------------------------------------------------
  185.   def command_game_end
  186.     SceneManager.call(Scene_End)
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * [OK] Personal Command
  190.   #--------------------------------------------------------------------------
  191.   def on_personal_ok
  192.     case @command_window.current_symbol
  193.     when :skill
  194.       SceneManager.call(Scene_Skill)
  195.     when :equip
  196.       SceneManager.call(Scene_Equip)
  197.     when :status
  198.       SceneManager.call(Scene_Status)
  199.     end
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # * [Cancel] Personal Command
  203.   #--------------------------------------------------------------------------
  204.   def on_personal_cancel
  205.     @status_window.unselect
  206.     @command_window.activate
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # * Formation [OK]
  210.   #--------------------------------------------------------------------------
  211.   def on_formation_ok
  212.     if @status_window.pending_index >= 0
  213.       $game_party.swap_order(@status_window.index,
  214.                              @status_window.pending_index)
  215.       @status_window.pending_index = -1
  216.       @status_window.redraw_item(@status_window.index)
  217.     else
  218.       @status_window.pending_index = @status_window.index
  219.     end
  220.     @status_window.activate
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # * Formation [Cancel]
  224.   #--------------------------------------------------------------------------
  225.   def on_formation_cancel
  226.     if @status_window.pending_index >= 0
  227.       @status_window.pending_index = -1
  228.       @status_window.activate
  229.     else
  230.       @status_window.unselect
  231.       @command_window.activate
  232.     end
  233.   end
  234. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement