How are windowskins applied to a window?

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I wrote a script for changing window skins dynamically, but I found that existing windows do not change.


So I went and destroyed the window and created a new one, but this is not a good solution for many reasons.


Does anyone know how to window skin is applied?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Maybe try redrawing/refreshing the contents bitmap of the window instead? It might also be worth checking window_base...
 
Last edited by a moderator:

Kaelan

Veteran
Veteran
Joined
May 14, 2012
Messages
797
Reaction score
537
First Language
Portuguese
Primarily Uses
RMMV
Have you tried just calling

contents.clearcreate_contents?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
No, I hadn't tried it, as I didn't think it was related to the contents of the window.


But after trying, it didn't seem to change anything, so unfortunately it didn't work :(


A quick test would be showing a text message, changing the windowskin, and then showing another message.
 

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
453
Reaction score
211
First Language
English
Primarily Uses
RMMV
What about putting an if statement under the frame update in window_base?

So

Code:
class Window_Base < Windowdef update    super    update_tone    update_open if @opening    update_close if @closing    if SceneManager.scene_is?(Scene_Menu)       self.windowskin = Cache.system($game_system.windowskin) #what ever you want your window skin to be called    else       self.windowskin = Cache.system("Window") #if your if statement is not met return to default skin    endendend
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
If this is related to your script, I'm wondering where the scene.refresh_windowskin which you call from the SceneManager.refresh_windowskin lies... It's nowhere on the script so I assume that's on the default Scene_Base? I'm not on my RM right now so I cannot check...

The only thing I saw there that would change the windowskin was the self.windowskin set-up on the initialize call, which is only run when the window is made which makes sense as to why it's only changing when you create the window and not if you alter it when the window is already made... In which case, you might wanna call the self.windowskin = blahblah manually for each window during update or when you use the skin changer method of your script
 
Last edited by a moderator:

Kaelan

Veteran
Veteran
Joined
May 14, 2012
Messages
797
Reaction score
537
First Language
Portuguese
Primarily Uses
RMMV
Are you sure there's nothing setting your windowskin on refresh or recreating the window or something? I have windows that change windowskins depending on what they're displaying and the only thing I have to do is make a refresh call.

Code:
  #--------------------------------------------------------------------------  # * Set Data  #--------------------------------------------------------------------------  def data=(data)    return if @data == data    @data = data       actor = @data.battler    if actor.is_a?(Game_Actor) || actor.is_friendly?      self.windowskin = Cache.system("Window_Ally")    elsif actor.is_a?(KDEA_Creature)      self.windowskin = Cache.system("Window_Enemy")    else      self.windowskin = Cache.system("Window_Neutral")    end    self.back_opacity = 255    refresh  end    #--------------------------------------------------------------------------  # refresh  #--------------------------------------------------------------------------  def refresh     contents.clear    create_contents    reset_font_settings    draw_data  end
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
@Kaelan - I'm assuming this is about Hime's script http://forums.rpgmakerweb.com/index.php?/topic/33796-windowskin-changer/

In which case, the only time I saw it calling self.windowskin was during initialization of the window... which is exactly why it doesn't change unless the window is recreated after the script call that Hime made for changing the windowskin...

@Hime

This worked fine for me, you just need to call the self.windowskin = operator upon changing the windowskin value

Code:
class Game_System    attr_accessor :window_skin end class Scene_Base    def modify_window_skin(skin)    $game_system.window_skin = skin    instance_variables.each do |varname|      ivar = instance_variable_get(varname)      ivar.windowskin = Cache.system($game_system.window_skin) if ivar.is_a?(Window)    end  end  end class Window_Base    alias initialize_windowskin initialize  def initialize(x, y, width, height)    initialize_windowskin(x, y, width, height)    self.windowskin = Cache.system($game_system.window_skin) unless $game_system.window_skin.nil?  endend
 
Last edited by a moderator:

Nathan Frost

... only the world's greatest Secret Agent.
Veteran
Joined
Sep 23, 2014
Messages
243
Reaction score
74
First Language
English
Primarily Uses
What about applying what scene_base handles as an instance variable, it already updates and disposes them so why not apply the window skin property?

Code:
#==============================================================================# ** Scene_Base#------------------------------------------------------------------------------#  This is a superclass of all scenes in the game.#==============================================================================class Scene_Base  #--------------------------------------------------------------------------  # * Set Windowskin  #--------------------------------------------------------------------------  def set_windowskin(name)        instance_variables.each do |varname|      ivar = instance_variable_get(varname)      ivar.windowskin = Cache.system(name) if ivar.is_a?(Window)    end  endend
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Lol you guys are right I'm not sure what I was thinking. Just putting it in the update method worked.

There is currently a compatibility issue with the contents of the window.

As Kaelan mentions, after changing the skin, the contents must be re-drawn.

This is because windowskins also hold information about font colours.

The default scripts use a "refresh" method for almost every window, so this is nice: I can just call that method if it exists.

If your window does not have a refresh method, and instead draws things on their own, then you won't be able to dynamically change the contents of the window (which means the skin would change, but the fonts are still the old one until you re-create the window)

What about applying what scene_base handles as an instance variable, it already updates and disposes them so why not apply the window skin property?

#==============================================================================# ** Scene_Base#------------------------------------------------------------------------------# This is a superclass of all scenes in the game.#==============================================================================class Scene_Base #-------------------------------------------------------------------------- # * Set Windowskin #-------------------------------------------------------------------------- def set_windowskin(name) instance_variables.each do |varname| ivar = instance_variable_get(varname) ivar.windowskin = Cache.system(name) if ivar.is_a?(Window) end endend
This is the solution I would prefer, because ideally you only want to set the windowskin when you actually call a method that changes the windowskin. I've designed it so that any access to $game_system.windowskin= should trigger the change.

However, I am aware of several scripts that define their own scene classes...that don't inherit from Scene_Base for some reason. Currently I've placed it in the Window's update method, under the assumption that no one is creating their own window that doesn't inherit from it.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
@Nathan - It's just that that doesn't save the new windowskin on a save file... Which I think is why Hime used an instance variable of $game_system to save the windowskin name, which is why I did  that too on my post. :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top