Submit Your Article Guild Wars 2 Forum RPG Maker VX.com
 
RPG Maker
 

 Username:
 Password:
   Not a member? Register!



Home > RGSS Script Reference > Scene_Menu

Scene_Menu


Inherits from: None

Description: This class updates the main menu and processes user input for the main command menu and when selecting a character from the status menu.

Code


class Scene_Menu
# ------------------------------------
def initialize(menu_index = 0)
    @menu_index = menu_index
  end  
# ------------------------------------
  def main
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Save"
    s6 = "Quit Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    if $game_party.actors.size == 0
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    if $game_system.save_disabled
      @command_window.disable_item(4)
    end
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 224
    @steps_window = Window_Steps.new
    @steps_window.x = 0
    @steps_window.y = 320
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @playtime_window.dispose
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end
# ------------------------------------  
  def update
    @command_window.update
    @playtime_window.update
    @steps_window.update
    @gold_window.update
    @status_window.update
    if @command_window.active
      update_command
      return
    end
    if @status_window.active
      update_status
      return
    end
  end
# ------------------------------------  
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.actors.size == 0 and @command_window.index < 4
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new
      when 1
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when 5
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      end
      return
    end
  end
# ------------------------------------  
  def update_status
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 1
        if $game_party.actors[@status_window.index].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Skill.new(@status_window.index)
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@status_window.index)
      when 3
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end 

Properties


Menu_Index: The index of the command currently selected on the command menu (the top command is index 0, with each command below that having an index 1 higher than the last command)

Command_Window: A Window_Command object that holds the main menu commands.

Playtime_Window: A Window_PlayTime object that shows the amount of time played.

Steps_Window: A Window_Steps object that shows the number of steps taken.

Gold_Window: A Window_Gold object that shows the amount of money possessed by the party.

Status_Window: A Window_MenuStatus object that shows the current status of the party members.

Methods


Initialize

Arguments:
Menu_Index: The index of the initial selected item on the command menu (0 = the first item on the menu, with the number increasing by one for each command below the top command)
Local Variables: None

How it Works: This method initializes the menu index to the value passed to this method.

Main

Arguments: None
Local Variables: None

How it Works: This method sets up the menu, processes the user's actions in the main loop, and then disposes of the objects. The first part of the method sets up each command in the menu command window. The command window is then set up, and the item selected in the command menu is set. If the party has no characters in it, then the "Item", "Skill", "Equip", and "Status" commands can't be selected, so these are disabled if the party is empty. If the "Allow/Disallow Saving" event command has been used to disallow saving, then the "Save" command is disabled. The next few commands set up the other windows on the menu screen. The next part of the method is the main loop common to all "Scene" classes. It updates the graphics, checks the input, and updates the window contents in response to the user's actions until the value of $Scene changes (in this case, because the user has selected a menu choice, or exited the menu). Once the scene changes, the rest of this method disposes of each of the windows.

Update

Arguments: None
Local Variables: None

How it Works: This method updates the contents of all five windows on the main menu. Then, depending on whether the user is selecting a command from the main menu or selecting a character who will use a skill, be equipped, or whose status will be shown, either the Update_Command or Update_Status method will be called to process user input from that window.

Update_Command

Arguments: None
Local Variables: None

How it Works: This method updates the menu command window in response to user input. If the user's input is "B" (cancel key), then the cancel sound effect is played, and control is transferred back to the map. If the user's input is "C" (decision key), then the method first checks to see if the party's size is 0 and the command selected was either "Item", "Skill", "Equip", or "Status". If this is true, then the buzzer sound effect is played. The case statement that makes up the rest of this method processes what happens when the user selects each command. If the index of the selected command is 0 (Item), then the decision sound effect is played and control is transferred to the item menu. If the index of the selected command is 1 (Skill), 2 (Equip), or 3 (Status), then the decision sound effect is played, and the active window switches from the command window to the status window. If the index of the selected command is 4 (Save), then the method checks to see if the "Allow/Disallow Saving" event command has been used to disallow saving. If it has, then the buzzer sound effect is played. If saving is allowed, then the decision sound effect is played and control is transferred to the save menu. If the selected command is 5 (Quit Game), then the decision sound effect is played and control is transferred to the Quit Game menu.

Update_Status

Arguments: None
Local Variables: None

How it Works: This method responds to user input from the party status window when the user is selecting a party member who will use a skill, be equipped, or whose status will be shown. If the user's input is "B" (cancel key), then the cancel sound effect is played and the active window becomes the command window. The index of the status window is set to -1 (invisible). If the user's input is "C" (decision key), then what happens depends on which command was selected from the command window and the status of the party member selected. If the command window index is 1 (Skill), then the method first checks to see if the character's restriction is 2 or more (Attack Enemies Randomly, Attack Allies Randomly, or No Action Allowed). If the character's restriction isn't 2 or greater, the decision sound effect is played and control is transferred to the skill menu. If the command menu index is 2 (Equip), then the decision sound effect is played and control is transferred to the equip menu. If the command menu index is 3 (Status), then the decision sound effect is played and control is transferred to the status screen. 
Syntax
@
@@
$
alias
[array index]
attr_accessor
attr_reader
attr_writer
class
def
do
ensure
for
if
[iterator]
key => value
new
next
nil
redo
require
return
rescue
self
super
undef
unless
until
while
yield

Classes
Arrow_Actor
Arrow_Base
Arrow_Enemy
Game_Actor
Game_Actors
Game_BattleAct
Game_Battler
Game_Character
Game_Common
Game_Enemy
Game_Event
Game_Map
Game_Party
Game_Picture
Game_Player
Game_Screen
Game_SlfSwitch
Game_Switches
Game_System
Game_Troop
Game_Variables
Interpreter
Scene_Debug
Scene_End
Scene_Equip
Scene_File
Scene_Gameover
Scene_Item
Scene_Load
Scene_Map
Scene_Menu
Scene_Name
Scene_Save
Scene_Shop
Scene_Skill
Scene_Status
Scene_Title
Sprite_Battler
Sprite_Character
Sprite_Picture
Sprite_Timer
Spriteset_Battle
Spriteset_Map
Window_Base
Window_Battleresult
Window_Battlestatus
Window_Command
Window_DebugLeft
Window_DebugRight
Window_EquipItem
Window_EquipLeft
Window_EquipRight
Window_Gold
Window_Help
Window_InputNumb
Window_Item
Window_MenuStatus
Window_Message
Window_NameEdit
Window_NameInput
Window_PartyCom
Window_PlayTime
Window_SaveFile
Window_Selectable
Window_ShopBuy
Window_ShopCom
Window_ShopNum
Window_ShopSell
Window_ShopStatus
Window_Skill
Window_SkillStatus
Window_Status
Window_Steps
Window_Target

Other
Class Hierarchy
Global Variables


RPG RPG Revolution
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.

RPG RPG Revolution is an Privacy Policy and Legal