Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Jereth on January 04, 2016, 01:07:38 am

Title: Problem changin fonts in game.
Post by: Jereth on January 04, 2016, 01:07:38 am
I know fonts have been an issue for a while, so I figured I'd ask this here and move on to something else. On some maps I'm trying to change the font during messages. The image changes take no problem, but it's just the font that won't change. this is a direct edit to Window_Message:
class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # ● Object Initialization
  #--------------------------------------------------------------------------
  def initialize
     super(80+64, 356, 580, 198)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.windowskin = RPG::Cache.windowskin("001-Blue01")
   
    #Check For Alternate Maps
    if @map_id == 5
      self.contents.font.name = "Small Sana"
      self.contents.font.size = 28
    elsif @map_id == 6
      self.contents.font.name = "Curley Font"
      self.contents.font.size = 16
    else
      self.contents.font.name = "Monotype Corsiva"
      self.contents.font.size = 22
    end
   
    self.visible = false
    self.z = 9998
    @fade_in = false
    @fade_out = false
    @contents_showing = false
    @cursor_width = 0
    self.active = false
    self.index = -1
  end


I know for a fact that the font names are correct. What ever one I place in the else case is the font the systems uses for all messages regardless of which map I'm on. I also know "if @map_id == X" works as I'm using it as a conditional in an event for altering the frame of the message window. Can anyone see what I'm doing wrong here or if the font change should be put else where?
Title: Re: Problem changin fonts in game.
Post by: winkio on January 04, 2016, 01:19:45 am
just because it works in an event doesn't mean it will work anywhere in a script.

The Interpreter (which runs events) has @map_id defined, but Window_Message does not.  You have to get the id from $game_map instead (I think it's $game_map.id, but you might need to check).
Title: Re: Problem changin fonts in game.
Post by: KK20 on January 04, 2016, 02:53:49 am
^
This.

Happens to be $game_map.map_id that you want to use.
Also would suggest using a "case" rather than a series of if-else's.
Title: Re: Problem changin fonts in game.
Post by: Jereth on January 04, 2016, 03:18:49 am
Thanks for the replies.
Quote from: KK20 on January 04, 2016, 02:53:49 am
Happens to be $game_map.map_id that you want to use.
Also would suggest using a "case" rather than a series of if-else's.

Yep, while I was waiting I was doing close to the same thing in Scene_Map and figured out the whole $game_map.map_id instead of @map_id. Still though, at the end of the day the fonts simply won't change.
class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # ● Object Initialization
  #--------------------------------------------------------------------------
  def initialize
     super(80+64, 356, 580, 198)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.windowskin = RPG::Cache.windowskin("001-Blue01")
   
    #Check For Alternate Maps
    case $game_map.map_id
    when 5
      self.contents.font.name = "Small Sana"
      self.contents.font.size = 28
    when 6
      self.contents.font.name = "Curley Font"
      self.contents.font.size = 16
    else
      self.contents.font.name = "Monotype Corsiva"
      self.contents.font.size = 22
    end

The change here is now it always uses the first font instead of the last whichever font is loaded first, eg; if I start the game on map 6 it uses that font everywhere. It's just mildly frustrating because I use several fonts all over menus and combat depending on what actor is in what position in the party, yet this is a problem I've been coming back to once a week for 2 months. This for example took 2 minutes and worked first shot and it's almost identical.
Spoiler: ShowHide
    case $game_map.map_id
    when 5
      if $game_party.actors[0].id == 002 #Am I Cha2 in Slot #0?
        Information.show("\N[2] Affinity Boost.")
        $game_actors[002].add_state(50)
      end
    when 6
      if $game_party.actors[0].id == 003 #Am I Cha3 in Slot #0?
        Information.show("\N[3] Affinity Boost.")
        $game_actors[003].add_state(51)
      end
    else
      $game_actors[002].remove_state(50)
      $game_actors[003].remove_state(51)
    end

Anywho, I'll keep pecking at it. Thanks again.
Title: Re: Problem changin fonts in game.
Post by: Zexion on January 04, 2016, 09:25:21 am
Honestly i would just stick that same code into the refresh method >.> might not be the cool way to do it but it should work
Title: Re: Problem changin fonts in game.
Post by: KK20 on January 04, 2016, 11:56:11 am
Actually, forget modifying initialize and only modify refresh.

A new instance of Window_Message is only created at the start of Scene_Map or Scene_Battle, thus your initialize method will only be called ONCE per scene. It won't be until you, say, open the menu then close it to see your font change. Moving your code to refresh will help as this method is called every time you are displaying the message window.

Also, you don't need to do '002' for character IDs, or anything in the database for that matter. Just a simiple '2' is enough as the prior zeroes are ignored.
Title: Re: Problem changin fonts in game.
Post by: Jereth on January 04, 2016, 07:07:00 pm
Quote from: Zexion on January 04, 2016, 09:25:21 am
Honestly i would just stick that same code into the refresh method >.> might not be the cool way to do it but it should work

I'm really enjoying the fact that when I come back here the advice you guys give is exactly what I tried before coming back and seeing if anyone had an idea lol.
Quote from: KK20 on January 04, 2016, 11:56:11 am
Actually, forget modifying initialize and only modify refresh.

A new instance of Window_Message is only created at the start of Scene_Map or Scene_Battle, thus your initialize method will only be called ONCE per scene. It won't be until you, say, open the menu then close it to see your font change. Moving your code to refresh will help as this method is called every time you are displaying the message window.

Also, you don't need to do '002' for character IDs, or anything in the database for that matter. Just a simiple '2' is enough as the prior zeroes are ignored.

I interchange '002' and '2' format. I'm really used to using 3 digit format in code to create alignment in arrays or console outputs so I just tend to do it automatically.
The only location was was able to get this to work was within the super of "update", for some reason refresh will only change the actual text but not the format. But at least talking about it gave me new thoughts.

So to close off, I did get it to work and the only place it would was in update, I placed it directly above the @fade_in check.

Thanks for bouncing ideas, folks.
Title: Re: Problem changin fonts in game.
Post by: KK20 on January 05, 2016, 03:27:49 am
Quote from: Jereth on January 04, 2016, 07:07:00 pm
The only location was was able to get this to work was within the super of "update", for some reason refresh will only change the actual text but not the format.

I'll be sure to check this one out too. This doesn't sound right at all.

EDIT:

class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias rerefresh refresh
  def refresh
    case $game_variables[50]
    when 0
      self.contents.font.name = "Times New Roman"
      self.contents.font.size = 28
    when 1
      self.contents.font.name = "Calibri"
      self.contents.font.size = 16
    else
      self.contents.font.name = "Arial"
      self.contents.font.size = 20
    end
    rerefresh
  end
end

(http://puu.sh/mkePp/f30be28d9a.gif)
Title: Re: Problem changin fonts in game.
Post by: Blizzard on January 05, 2016, 04:13:35 am
He is most likely using a script that overrides his change.
Title: Re: Problem changin fonts in game.
Post by: Jereth on January 05, 2016, 09:19:57 am
Quote from: Blizzard on January 05, 2016, 04:13:35 am
He is most likely using a script that overrides his change.

Last question, what should I be more embarrassed about:

-or-
Title: Re: Problem changin fonts in game.
Post by: Blizzard on January 05, 2016, 10:25:38 am
LMAO! xD
Don't worry about it, it happens.