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.

facesets in load/save screen?

Status
Not open for further replies.
I'm surprised I can't find this. Could someone find/make me a script that simply allows me to use pictures(facesets) for the characters in the save/load screen instead of the character's charset?
 

ccoa

Member

First, add this above Game_Temp:

Code:
module RPG
  module Cache    
    def self.face(filename)
      self.load_bitmap("Graphics/Faces/", filename)
    end
  end
end

In Scene_Save, replace these lines:

Code:
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push([actor.character_name, actor.character_hue])
    end

With:

Code:
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push(actor.name.downcase)
    end

Then, in Window_SaveFile, replace this:

Code:
      for i in 0...@characters.size
        bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
        cw = bitmap.rect.width / 4
        ch = bitmap.rect.height / 4
        src_rect = Rect.new(0, 0, cw, ch)
        x = 300 - @characters.size * 32 + i * 64 - cw / 2
        self.contents.blt(x, 68 - ch, bitmap, src_rect)
      end

With this:

Code:
      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

This is assuming that the filename of the face graphic is the same as the character name and is located in the folder Graphics/Faces. If not, be more specific about your request.
 
I keep getting a "cannot convert Array into string" error.

This occurs on:
Code:
self.load_bitmap("Graphics/Faces/", filename)

I have made a "Faces" folder in the "Graphics" folder of my project. I saved the picture as (character name).png inside that folder. I also tried it with the ID name instead, 001.png. Neither of these worked.

I wasnt sure if:
Code:
module RPG
  module Cache    
    def self.face(filename)
      self.load_bitmap("Graphics/Faces/", filename)
    end
  end
end

...should be placed at the TOP of the Game_Temp, or in a new "script" above it. I tried both of these, and I get the same error in both cases.
 
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, 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
    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, 0, 600, 32, name)
    @name_width = contents.text_size(name).width
    # If save file exists
    if @file_exist
      # Draw character
      #for i in 0...@characters.size (the following lines commented out/replaced by ImmuneEntity)
      #  bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
      #  cw = bitmap.rect.width / 4
      #  ch = bitmap.rect.height / 4
      #  src_rect = Rect.new(0, 0, cw, ch)
      #  x = 300 - @characters.size * 32 + i * 64 - cw / 2
      #  self.contents.blt(x, 68 - ch, bitmap, src_rect)
      #end
      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 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, 8, 600, 32, time_string, 2)
      # Draw timestamp
      self.contents.font.color = normal_color
      time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
      self.contents.draw_text(4, 40, 600, 32, time_string, 2)
    end
  end
  #--------------------------------------------------------------------------
  # * Set Selected
  #     selected : new selected (true = selected, false = unselected)
  #--------------------------------------------------------------------------
  def selected=(selected)
    @selected = selected
    update_cursor_rect
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @selected
      self.cursor_rect.set(0, 0, @name_width + 8, 32)
    else
      self.cursor_rect.empty
    end
  end
end
 

ccoa

Member

Works just fine for me.

You do know that you'll have to delete your old savefiles, right? Just like any script that effects what you save and load, old savefiles won't work with it.
 
No, I didn't know that. I guess I didn't even think of that because I just figured this script would simply modify the way it is displayed.

It doesn't crash anymore, but now my problem is the face simply doesn't display. Do I have to name it the character's name, or the character's ID? (I've tried both.)

Is there a specific size it needs to be? I was using 98x98 first and then i went down to 40x40 and it still doesn't work.

Any suggestions? Sorry for having so much difficulty with this.
 

ccoa

Member

Character's name, all lowercase.

The size will depend on how big your save windows are. If they're the standard size, you will have to use smaller images. How small, I don't know, sorry. This is just a direct excerpt from my own game's scripts, and I'm using large sized save windows and only displaying 3.
 

ccoa

Member

This topic has been resolved. If ImmuneEntity or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

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