Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

New Save/Load screen please ?

Jason

Awesome Bro

Okay, well I've had this idea for a new Save/Load menu but can't get it to work:

When you highlight a save, the background of the save menu shows the part where you saved it at, just like the transparent menu how you can see the map in the background, I was hoping someone could do this with the Save/Load menu as it would be a nice effect for the game and people would be able to clarify easier which save they are using by looking at the background and seeing their location.

I hope I explained this easy enough and that someone can do it, thankyou.
 

poccil

Sponsor

In the script section Scene_File, make these changes:

Method "initialize":

Code:
  def initialize(help_text)
    @currentChoice=-1
    @spriteset=nil
    @help_text = help_text
  end

Beginning of method "main":

Code:
  def main
    # Make help window
    @help_window = Window_Help.new
    @help_window.set_text(@help_text)
    @help_window.opacity=200
    @help_window.z=20000
    # Make save file window
    @savefile_windows = []
    for i in 0..3
      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
      @savefile_windows[i].opacity=200
      @savefile_windows[i].z=20000
    end

End of method "main":
Code:
    # Dispose of windows
    @help_window.dispose
    @spriteset.dispose if @spriteset
    for i in @savefile_windows
      i.dispose
    end
  end

Beginning of the method "update":

Code:
  def update
     if @file_index != @currentChoice
      @spriteset.dispose if @spriteset
      @spriteset=nil
      filename=make_filename(@file_index)
      if FileTest.exist?(filename)
        file = File.open(filename, "rb")
        read_save_data(file)
        file.close
        @spriteset=Spriteset_Map.new
      end
      @currentChoice=@file_index
    end
    # Update windows
    @help_window.update
    for i in @savefile_windows
      i.update
 

poccil

Sponsor

The script code is below:

Code:
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This is a superclass for the save screen and load screen.
#==============================================================================

class Scene_File
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     help_text : text string shown in the help window
  #--------------------------------------------------------------------------
  def initialize(help_text)
    @currentChoice=-1
    @spriteset=nil
    @help_text = help_text
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window
    @help_window = Window_Help.new
    @help_window.set_text(@help_text)
    @help_window.opacity=200
    @help_window.z=20000
    # Make save file window
    @savefile_windows = []
    for i in 0..3
      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
      @savefile_windows[i].opacity=200
      @savefile_windows[i].z=20000
    end
    # Select last file to be operated
    @file_index = $game_temp.last_file_index
    @savefile_windows[@file_index].selected = true
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @spriteset.dispose if @spriteset
    for i in @savefile_windows
      i.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
     if @file_index != @currentChoice
      @spriteset.dispose if @spriteset
      @spriteset=nil
      filename=make_filename(@file_index)
      if FileTest.exist?(filename)
        file = File.open(filename, "rb")
        read_save_data(file)
        file.close
        @spriteset=Spriteset_Map.new
      end
      @currentChoice=@file_index
    end
    # Update windows
    @help_window.update
    for i in @savefile_windows
      i.update
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Call method: on_decision (defined by the subclasses)
      on_decision(make_filename(@file_index))
      $game_temp.last_file_index = @file_index
      return
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Call method: on_cancel (defined by the subclasses)
      on_cancel
      return
    end
    # If the down directional button was pressed
    if Input.repeat?(Input::DOWN)
      # If the down directional button pressed down is not a repeat,
      # or cursor position is more in front than 3
      if Input.trigger?(Input::DOWN) or @file_index < 3
        # Play cursor SE
        $game_system.se_play($data_system.cursor_se)
        # Move cursor down
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 1) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    # If the up directional button was pressed
    if Input.repeat?(Input::UP)
      # If the up directional button pressed down is not a repeatã€
 

poccil

Sponsor

Oh...  Add the following as a new script section:

Code:
class Scene_File
  def read_save_data(file)
    # Read character data for drawing save file
    characters = Marshal.load(file)
    # Read frame count for measuring play time
    Graphics.frame_count = Marshal.load(file)
    # Read each type of game object
    $game_system        = Marshal.load(file)
    $game_switches      = Marshal.load(file)
    $game_variables     = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_screen        = Marshal.load(file)
    $game_actors        = Marshal.load(file)
    $game_party         = Marshal.load(file)
    $game_troop         = Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    # If magic number is different from when saving
    # (if editing was added with editor)
    if $game_system.magic_number != $data_system.magic_number
      # Load map
      $game_map.setup($game_map.map_id)
      $game_player.center($game_player.x, $game_player.y)
    end
    # Refresh party members
    $game_party.refresh
  end
end
 

poccil

Sponsor

Okay...  Here's the new change.  Add the following to a new script section:

Code:
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This is a superclass for the save screen and load screen.
#==============================================================================

class Scene_File
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     help_text : text string shown in the help window
  #--------------------------------------------------------------------------
  def initialize(help_text)
    @currentChoice=-1
    @spriteset=nil
    @help_text = help_text
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window
    @help_window = Window_Help.new
    @help_window.set_text(@help_text)
    @help_window.opacity=200
    @help_window.z=20000
    # Make save file window
    @savefile_windows = []
    for i in 0..3
      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
      @savefile_windows[i].opacity=200
      @savefile_windows[i].z=20000
    end
    # Select last file to be operated
    @file_index = $game_temp.last_file_index
    @savefile_windows[@file_index].selected = true
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @spriteset.dispose if @spriteset
    for i in @savefile_windows
      i.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
     if @file_index != @currentChoice
      @spriteset.dispose if @spriteset
      @spriteset=nil
      filename=make_filename(@file_index)
      if FileTest.exist?(filename)
        file = File.open(filename, "rb")
        readTempSaveData(file)
        file.close
        @spriteset=Spriteset_Map.new
      end
      @currentChoice=@file_index
    end
    # Update windows
    @help_window.update
    for i in @savefile_windows
      i.update
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Call method: on_decision (defined by the subclasses)
      on_decision(make_filename(@file_index))
      $game_temp.last_file_index = @file_index
      return
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Call method: on_cancel (defined by the subclasses)
      on_cancel
      return
    end
    # If the down directional button was pressed
    if Input.repeat?(Input::DOWN)
      # If the down directional button pressed down is not a repeat,
      # or cursor position is more in front than 3
      if Input.trigger?(Input::DOWN) or @file_index < 3
        # Play cursor SE
        $game_system.se_play($data_system.cursor_se)
        # Move cursor down
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 1) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
    # If the up directional button was pressed
    if Input.repeat?(Input::UP)
      # If the up directional button pressed down is not a repeat、
      # or cursor position is more in back than 0
      if Input.trigger?(Input::UP) or @file_index > 0
        # Play cursor SE
        $game_system.se_play($data_system.cursor_se)
        # Move cursor up
        @savefile_windows[@file_index].selected = false
        @file_index = (@file_index + 3) % 4
        @savefile_windows[@file_index].selected = true
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Make File Name
  #     file_index : save file index (0-3)
  #--------------------------------------------------------------------------
  def make_filename(file_index)
    return "Save#{file_index + 1}.rxdata"
  end
  def readTempSaveData(file)
    # Read character data for drawing save file
    characters = Marshal.load(file)
    # Read frame count for measuring play time
    Marshal.load(file)
    # Read each type of game object
    Marshal.load(file)
    Marshal.load(file)
    Marshal.load(file)
    Marshal.load(file)
    $game_screen        = Marshal.load(file)
    Marshal.load(file)
    Marshal.load(file)
    Marshal.load(file)
    $game_map           = Marshal.load(file)
    $game_player        = Marshal.load(file)
    $game_map.setup($game_map.map_id)
    $game_player.center($game_player.x, $game_player.y)
  end
end
class Scene_Save
  def main
    @oldvars=[$game_map,$game_player,$game_screen]
    super
    $game_map=@oldvars[0]
    $game_player=@oldvars[1]
    $game_screen=@oldvars[2]
  end
  def on_decision(filename)
    # Play save SE
    $game_system.se_play($data_system.save_se)
    # Write save data
    file = File.open(filename, "wb")
    $game_map=@oldvars[0]
    $game_player=@oldvars[1]
    $game_screen=@oldvars[2]
    write_save_data(file)
    file.close
    # If called from event
    if $game_temp.save_calling
      # Clear save call flag
      $game_temp.save_calling = false
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # Switch to menu screen
    $scene = Scene_Menu.new(4)
  end
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top