RPG Maker
 

 Username:
 Password:
   Not a member? Register!



Home > RGSS Script Reference > Scene_File

Scene_File


Inherits from: None

Description: This class handles the elements on the "file selection" menu that are common to both saving and loading. This class's two child classes, Scene_Save and Scene_Load, handle the elements specific to saving and loading, respectively.

Code


class Scene_File
# ------------------------------------  
  def initialize(help_text)
    @help_text = help_text
  end
# ------------------------------------  
  def main
    @help_window = Window_Help.new
    @help_window.set_text(@help_text)
    @savefile_windows = []
    for i in 0..3
      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
    end
    @file_index = $game_temp.last_file_index
    @savefile_windows[@file_index].selected = true
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    for i in @savefile_windows
      i.dispose
    end
  end
# ------------------------------------  
  def update
    @help_window.update
    for i in @savefile_windows
      i.update
    end
    if Input.trigger?(Input::C)
      on_decision(make_filename(@file_index))
      $game_temp.last_file_index = @file_index
      return
    end
    if Input.trigger?(Input::B)
      on_cancel
      return
    end
    if Input.repeat?(Input::DOWN)
      if Input.trigger?(Input::DOWN) or @file_index < 3
        $game_system.se_play($data_system.cursor_se)
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 1) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    if Input.repeat?(Input::UP)
      if Input.trigger?(Input::UP) or @file_index > 0
        $game_system.se_play($data_system.cursor_se)
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 3) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
  end
# ------------------------------------  
  def make_filename(file_index)
    return "Save#{file_index + 1}.rxdata"
  end
end

Properties


Help_Text: The text to be displayed in the help window.

Help_Window: A Window_Help object respresenting the help window shown on the file selection menu.

SaveFile_Windows: An array of Window_SaveFile objects, one for each of the save files.

File_Index: The index of the currently selected file.

Methods


Initialize

Arguments: None
Local Variables: None

How it Works: This method sets the help text to the appropriate value.

Main

Arguments: None
Local Variables: None

How it Works: This is the main method for this class. First, the help window and help text are set up. Then, the save file windows are set up. Starting with an empty array, each of the four save file winodws are set up with their associated index and filename. The @file_index = $game_temp.last_file_index statement sets the currently selected file to the last file either saved or loaded, depending on whether the user is saving or loading. The main loop is the loop seen in pretty much every "Scene" class. It updates the graphics, checks for input, and updates the window contents repeatedly until the value of $Scene changes (the user either selects a file or cancels). Once the scene changes, the rest of the method does garbage collection on the windows.

Update

Arguments: None
Local Variables: None

How it Works: This method updates the help window, save file windows, and responds to user input. First, the contents of the help window and the save file windows are updated. Then, the method processes input from the user. If the user presses "C" (decision key), then the Scene_Save#On_Decision or Scene_Load#On_Decision method is called, depending on whether the user is saving or loading. Also, the value of $game_temp.last_file_index is set to the selected file, so that next time the user saves or loads, this file will be selected by default. If the user presses "B" (cancel key), then either Scene_Save#On_Cancel or Scene_Load#On_Cancel is called, depending on whether the user is saving or loading. If the user presses the down arrow, then the cursor sound effect is played, and the currently selected index is incremented and modded by 4 (to prevent the selection cursor from moving beyond the last file). If the user presses the up arrow, then the cursor sound effect is played, and the currently selected index is decremented and modded by 4 (to prevent the selection cursor from moving past the first file).

Make_Filename

Arguments: None
Local Variables: None

How it Works: This method constructs the filename of the save file corresponding to the currently selected save file index. This is done by starting with the string "Save#", then adding an integer equal to the index of the currently selected save file, plus 1 (because internally, the save files start from 0), and then adds ".rxdata". 
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