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.

Two quick questions...

1) How do I get the cursor on Scene_File to disappear? I still want the other contents to appear, but I can't figure out where to toss the opacity tag.

2) How do I get the map name and hero name to appear on the Scene_File? I had it working once, but only if you were saving.

Thanks
 

Anonymous

Guest

This is how I did it. Right after this line in Scene_Save

Marshal.dump(characters, file)

I added

Marshal.dump([$game_party.actors[0].name, $game_party.actors[0].level, $game_map.name], file)

And then in Scene_Load, right after this line

characters = Marshal.load(file)

I added

lead = Marshal.load(file)

Finally, Window_SaveFile:

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

class Window_SaveFile < Window_Base
  #--------------------------------------------------------------------------
  # * 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, 52 + file_index % 3 * 111, 640, 140)
    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)
      @lead = 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
    
    self.opacity = 0
    @background_sprite = Sprite.new
    @background_sprite.bitmap = RPG::Cache.picture("file")
    @background_sprite.z = self.z - 1
    @background_sprite.x = self.x + 4
    @background_sprite.y = self.y + 16
    
    refresh
    @selected = false
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # Draw file number
    self.contents.font.color = normal_color
    name = "File#{@file_index + 1}"
    self.contents.draw_text(4, 8, 600, 32, name)
    @name_width = contents.text_size(name).width
    # If save file exists
    if @file_exist
      self.contents.draw_text(64, 8, 600, 32, @lead[0].to_s)
      self.contents.draw_text(64, 40, 600, 32, "Lv  " + @lead[1].to_s)
      # Draw character
      for i in 0...@characters.size
        bitmap = RPG::Cache.face(@characters[i])
        x = 400 - @characters.size * bitmap.width + i * bitmap.width
        self.contents.blt(x, 4, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
      end
      
      # Draw map name
      self.contents.draw_text(4, 8, 600, 32, @lead[2].to_s, 2)
      
      # Draw play time
      hour = @total_sec / 60 / 60
      min = @total_sec / 60 % 60
      sec = @total_sec % 60
      time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 64, 600, 32, time_string, 2)
     
    end
  end

  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @selected
      self.cursor_rect.set(0, 8, @name_width + 8, 32)
    else
      self.cursor_rect.empty
    end
  end
  
  def dispose
    @background_sprite.dispose
    super
  end
end

Ignore the part that draws the faces on it.

To get the cursor to disapear, just change this

Code:
def update_cursor_rect
    if @selected
      self.cursor_rect.set(0, 8, @name_width + 8, 32)
    else
      self.cursor_rect.empty
    end
  end

to this

Code:
def update_cursor_rect
      self.cursor_rect.empty
  end
 
I don't think a "Thanks" works here... your quick response just ended what I'd call a 3 hour marathon or writing, editing, and rewriting my scripts. Behold the (almost finished Save/Load screen, complete with overwrite protection:
http://img109.imageshack.us/img109/2631/savescreenshotmt1.jpg[/img]
Thanks again! Now I can move on to the more important things, like fixing Trick's script so that I can actually go into battle and writing my class system.
 

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