Advertisement
DizzyFoxkit

Scene_Menu Attraction

May 24th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.75 KB | None | 0 0
  1. class Scene_Menu
  2.   #--------------------------------------------------------------------------
  3.   # * Object Initialization
  4.   #     menu_index : command cursor's initial position
  5.   #--------------------------------------------------------------------------
  6.   def initialize(menu_index = 0)
  7.     @menu_index = menu_index
  8.   end
  9.   #--------------------------------------------------------------------------
  10.   # * Main Processing
  11.   #--------------------------------------------------------------------------
  12.   def main
  13.     # Make command window
  14.     s1 = $data_system.words.item
  15.     s2 = $data_system.words.skill
  16.     s3 = $data_system.words.equip
  17.     s4 = "Status"
  18.     s5 = "Save"
  19.     s6 = "End Game"
  20.     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
  21.         @command_window.x = -160
  22.         @command_window.y = 0
  23.     @command_window.index = @menu_index
  24.     # If number of party members is 0
  25.     if $game_party.actors.size == 0
  26.       # Disable items, skills, equipment, and status
  27.       @command_window.disable_item(0)
  28.       @command_window.disable_item(1)
  29.       @command_window.disable_item(2)
  30.       @command_window.disable_item(3)
  31.     end
  32.     # If save is forbidden
  33.     if $game_system.save_disabled
  34.       # Disable save
  35.       @command_window.disable_item(4)
  36.     end
  37.     # Make gold window
  38.     @gold_window = Window_Gold.new
  39.     @gold_window.x = 0
  40.     @gold_window.y = 480
  41.     # Make status window
  42.     @status_window = Window_MenuStatus.new
  43.     @status_window.x = 160
  44.     @status_window.y = -480
  45.         @gold_window.start(0, 416)
  46.         @command_window.start(0, 0)
  47.     # Execute transition
  48.     Graphics.transition
  49.     # Main loop
  50.     loop do
  51.       # Update game screen
  52.       Graphics.update
  53.       # Update input information
  54.       Input.update
  55.       # Frame update
  56.       update
  57.       # Abort loop if screen is changed
  58.       if $scene != self
  59.         break
  60.       end
  61.     end
  62.     # Prepare for transition
  63.     Graphics.freeze
  64.     # Dispose of windows
  65.     @command_window.dispose
  66.     @gold_window.dispose
  67.     @status_window.dispose
  68.   end
  69.   #--------------------------------------------------------------------------
  70.   # * Frame Update
  71.   #--------------------------------------------------------------------------
  72.   def update
  73.     # Update windows
  74.     @command_window.update
  75.     @gold_window.update
  76.     @status_window.update
  77.     # If command window is active: call update_command
  78.     if @command_window.active
  79.       update_command
  80.       return
  81.     end
  82.     # If status window is active: call update_status
  83.     if @status_window.active
  84.       update_status
  85.       return
  86.     end
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # * Frame Update (when command window is active)
  90.   #--------------------------------------------------------------------------
  91.   def update_command
  92.     # If B button was pressed
  93.     if Input.trigger?(Input::B)
  94.             # Move both the command window and gold window back
  95.             @command_window.start(-160,0)
  96.             @gold_window.start(0, 480)
  97.       # Play cancel SE
  98.       $game_system.se_play($data_system.cancel_se)
  99.       # Switch to map screen
  100.       $scene = Scene_Map.new
  101.       return
  102.     end
  103.     # If C button was pressed
  104.     if Input.trigger?(Input::C)
  105.       # If command other than save or end game, and party members = 0
  106.       if $game_party.actors.size == 0 and @command_window.index < 4
  107.         # Play buzzer SE
  108.         $game_system.se_play($data_system.buzzer_se)
  109.         return
  110.       end
  111.       # Branch by command window cursor position
  112.       case @command_window.index
  113.       when 0  # item
  114.                 @command_window.start(-160, 0)
  115.         # Play decision SE
  116.         $game_system.se_play($data_system.decision_se)
  117.         # Switch to item screen
  118.         $scene = Scene_Item.new
  119.       when 1  # skill
  120.         # Play decision SE
  121.         $game_system.se_play($data_system.decision_se)
  122.         # Make status window active
  123.         @command_window.active = false
  124.                 @status_window.start(160,0)
  125.         @status_window.active = true
  126.         @status_window.index = 0
  127.       when 2  # equipment
  128.         # Play decision SE
  129.         $game_system.se_play($data_system.decision_se)
  130.         # Make status window active
  131.         @command_window.active = false
  132.                 @status_window.start(160,0)
  133.         @status_window.active = true
  134.         @status_window.index = 0
  135.       when 3  # status
  136.         # Play decision SE
  137.         $game_system.se_play($data_system.decision_se)
  138.         # Make status window active
  139.         @command_window.active = false
  140.                 @status_window.start(160,0)
  141.         @status_window.active = true
  142.         @status_window.index = 0
  143.       when 4  # save
  144.         # If saving is forbidden
  145.         if $game_system.save_disabled
  146.           # Play buzzer SE
  147.           $game_system.se_play($data_system.buzzer_se)
  148.           return
  149.         end
  150.         # Play decision SE
  151.         $game_system.se_play($data_system.decision_se)
  152.         # Switch to save screen
  153.         $scene = Scene_Save.new
  154.       when 5  # end game
  155.         # Play decision SE
  156.         $game_system.se_play($data_system.decision_se)
  157.         # Switch to end game screen
  158.         $scene = Scene_End.new
  159.       end
  160.       return
  161.     end
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * Frame Update (when status window is active)
  165.   #--------------------------------------------------------------------------
  166.   def update_status
  167.     # If B button was pressed
  168.     if Input.trigger?(Input::B)
  169.       # Play cancel SE
  170.       $game_system.se_play($data_system.cancel_se)
  171.       # Make command window active & move status window
  172.             @status_window.start(160,-480)
  173.       @command_window.active = true
  174.       @status_window.active = false
  175.       @status_window.index = -1
  176.       return
  177.     end
  178.     # If C button was pressed
  179.     if Input.trigger?(Input::C)
  180.       # Branch by command window cursor position
  181.       case @command_window.index
  182.       when 1  # skill
  183.         # If this actor's action limit is 2 or more
  184.         if $game_party.actors[@status_window.index].restriction >= 2
  185.           # Play buzzer SE
  186.           $game_system.se_play($data_system.buzzer_se)
  187.           return
  188.         end
  189.         # Play decision SE
  190.         $game_system.se_play($data_system.decision_se)
  191.         # Switch to skill screen
  192.         $scene = Scene_Skill.new(@status_window.index)
  193.       when 2  # equipment
  194.         # Play decision SE
  195.         $game_system.se_play($data_system.decision_se)
  196.         # Switch to equipment screen
  197.         $scene = Scene_Equip.new(@status_window.index)
  198.       when 3  # status
  199.         # Play decision SE
  200.         $game_system.se_play($data_system.decision_se)
  201.         # Switch to status screen
  202.         $scene = Scene_Status.new(@status_window.index)
  203.       end
  204.       return
  205.     end
  206.   end
  207. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement