DizzyFoxkit

Druidia Menu

May 21st, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.00 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.         @gold_window.win_move
  47.         @command_window.start(0, 0)
  48.         @command_window.win_move
  49.     # Execute transition
  50.     Graphics.transition
  51.     # Main loop
  52.     loop do
  53.       # Update game screen
  54.       Graphics.update
  55.       # Update input information
  56.       Input.update
  57.       # Frame update
  58.       update
  59.       # Abort loop if screen is changed
  60.       if $scene != self
  61.         break
  62.       end
  63.     end
  64.     # Prepare for transition
  65.     Graphics.freeze
  66.     # Dispose of windows
  67.     @command_window.dispose
  68.     @gold_window.dispose
  69.     @status_window.dispose
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # * Frame Update
  73.   #--------------------------------------------------------------------------
  74.   def update
  75.     # Update windows
  76.     @command_window.update
  77.     @gold_window.update
  78.     @status_window.update
  79.     # If command window is active: call update_command
  80.     if @command_window.active
  81.       update_command
  82.       return
  83.     end
  84.     # If status window is active: call update_status
  85.     if @status_window.active
  86.       update_status
  87.       return
  88.     end
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # * Frame Update (when command window is active)
  92.   #--------------------------------------------------------------------------
  93.   def update_command
  94.     # If B button was pressed
  95.     if Input.trigger?(Input::B)
  96.             # Move both the command window and gold window back
  97.             @command_window.start(-160,0)
  98.             @gold_window.start(0, 480)
  99.             @command_window.win_move
  100.             @gold_window.win_move
  101.       # Play cancel SE
  102.       $game_system.se_play($data_system.cancel_se)
  103.       # Switch to map screen
  104.       $scene = Scene_Map.new
  105.       return
  106.     end
  107.     # If C button was pressed
  108.     if Input.trigger?(Input::C)
  109.       # If command other than save or end game, and party members = 0
  110.       if $game_party.actors.size == 0 and @command_window.index < 4
  111.         # Play buzzer SE
  112.         $game_system.se_play($data_system.buzzer_se)
  113.         return
  114.       end
  115.       # Branch by command window cursor position
  116.       case @command_window.index
  117.       when 0  # item
  118.                 @command_window.start(-160, 0)
  119.                 @command_window.win_move
  120.         # Play decision SE
  121.         $game_system.se_play($data_system.decision_se)
  122.         # Switch to item screen
  123.         $scene = Scene_Item.new
  124.       when 1  # skill
  125.         # Play decision SE
  126.         $game_system.se_play($data_system.decision_se)
  127.         # Make status window active
  128.         @command_window.active = false
  129.                 @status_window.start(160,0)
  130.                 @status_window.win_move
  131.         @status_window.active = true
  132.         @status_window.index = 0
  133.       when 2  # equipment
  134.         # Play decision SE
  135.         $game_system.se_play($data_system.decision_se)
  136.         # Make status window active
  137.         @command_window.active = false
  138.                 @status_window.start(160,0)
  139.                 @status_window.win_move
  140.         @status_window.active = true
  141.         @status_window.index = 0
  142.       when 3  # status
  143.         # Play decision SE
  144.         $game_system.se_play($data_system.decision_se)
  145.         # Make status window active
  146.         @command_window.active = false
  147.                 @status_window.start(160,0)
  148.                 @status_window.win_move
  149.         @status_window.active = true
  150.         @status_window.index = 0
  151.       when 4  # save
  152.         # If saving is forbidden
  153.         if $game_system.save_disabled
  154.           # Play buzzer SE
  155.           $game_system.se_play($data_system.buzzer_se)
  156.           return
  157.         end
  158.         # Play decision SE
  159.         $game_system.se_play($data_system.decision_se)
  160.         # Switch to save screen
  161.         $scene = Scene_Save.new
  162.       when 5  # end game
  163.         # Play decision SE
  164.         $game_system.se_play($data_system.decision_se)
  165.         # Switch to end game screen
  166.         $scene = Scene_End.new
  167.       end
  168.       return
  169.     end
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # * Frame Update (when status window is active)
  173.   #--------------------------------------------------------------------------
  174.   def update_status
  175.     # If B button was pressed
  176.     if Input.trigger?(Input::B)
  177.       # Play cancel SE
  178.       $game_system.se_play($data_system.cancel_se)
  179.       # Make command window active & move status window
  180.             @status_window.start(160,-480)
  181.             @status_window.win_move
  182.       @command_window.active = true
  183.       @status_window.active = false
  184.       @status_window.index = -1
  185.       return
  186.     end
  187.     # If C button was pressed
  188.     if Input.trigger?(Input::C)
  189.       # Branch by command window cursor position
  190.       case @command_window.index
  191.       when 1  # skill
  192.         # If this actor's action limit is 2 or more
  193.         if $game_party.actors[@status_window.index].restriction >= 2
  194.           # Play buzzer SE
  195.           $game_system.se_play($data_system.buzzer_se)
  196.           return
  197.         end
  198.         # Play decision SE
  199.         $game_system.se_play($data_system.decision_se)
  200.         # Switch to skill screen
  201.         $scene = Scene_Skill.new(@status_window.index)
  202.       when 2  # equipment
  203.         # Play decision SE
  204.         $game_system.se_play($data_system.decision_se)
  205.         # Switch to equipment screen
  206.         $scene = Scene_Equip.new(@status_window.index)
  207.       when 3  # status
  208.         # Play decision SE
  209.         $game_system.se_play($data_system.decision_se)
  210.         # Switch to status screen
  211.         $scene = Scene_Status.new(@status_window.index)
  212.       end
  213.       return
  214.     end
  215.   end
  216. end
Advertisement
Add Comment
Please, Sign In to add comment