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.

Showing a loaded $game_system value in save file window

Culex

Member

Greetings. I'm editing Window_SaveFile so that each window can be a different color. The colors are based on which window skin the player has used within their saved game. Here's a rough example.

Save 1
Save 2
Save 3

Well, I have it all set up and it works so far (just trust me on this one ;D). However, I want to know how to load a $game_system value from a saved game and be able to show it. This is why: I have each window skin set to a different $game_system value (i.e. $game_system.window_color = 0 is red, 1 is yellow, 2 is green, etc.). If I can figure out how to show a loaded $game_system value, then each save file window can have the color of the window skin the player had used in game. I hope my inquiry makes sense. My thanks in advance! :)
 

khmp

Sponsor

Do you mean the text or the window_skin reflects what window skin was used at the time the file was saved? If it's the second.

Code:
#==============================================================================
# ** Window_SaveFile
#------------------------------------------------------------------------------
#  This window displays save files on the save and load screens.
#==============================================================================

class Window_SaveFile < Window_Base
  Red_Skin = 'windowskin_red.png'
  Green_Skin = 'windowskin_green.png'
  Blue_Skin = 'windowskin_blue.png'
  Yellow_Skin = 'windowskin_yellow.png'
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :filename                 # file name
  attr_reader   :selected                 # selected
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     file_index : save file index (0-3)
  #     filename   : file name
  #--------------------------------------------------------------------------
  def initialize(file_index, filename)
    super(0, 64 + file_index % 4 * 104, 640, 104)
    self.contents = Bitmap.new(width - 32, height - 32)
    @file_index = file_index
    @filename = "Save#{@file_index + 1}.rxdata"
    @time_stamp = Time.at(0)
    @file_exist = FileTest.exist?(@filename)
    if @file_exist
      file = File.open(@filename, "r")
      @time_stamp = file.mtime
      @characters = Marshal.load(file)
      @frame_count = Marshal.load(file)
      @game_system = Marshal.load(file)
      @game_switches = Marshal.load(file)
      @game_variables = Marshal.load(file)
      @total_sec = @frame_count / Graphics.frame_rate
      file.close
    end
    case $game_system.window_color
      when 0 # The color red
        @windowskin_name = Red_Skin
      when 1 # The color green
        @windowskin_name = Green_Skin
      when 2 # The color blue
        @windowskin_name = Blue_Skin
      when 3 # The color yellow
        @windowskin_name = Yellow_Skin
    end
    self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    refresh
    @selected = false
  end
end

Try something like that. Change the Constants right below the top to reflect the actual names of the window skins you are using to signify the colors. To install just create an empty section right above main and paste this code.

Good luck with it Culex! :afro:
 

Culex

Member

I tried that before and it didn't work. But I found the problem. There was a script I had found that allowed me to load the map from a saved game and show it as a background. Somehow it conflicted with what you suggested so I just removed it. I can figure out the map thing later, but the windowskin thing is more important. Thank you, khmp. No more problems here.
 

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