How are windowskins applied to a window?

● ARCHIVED · READ-ONLY
Started by Tsukihime 11 posts View original ↗
  1. 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?
  2. Maybe try redrawing/refreshing the contents bitmap of the window instead? It might also be worth checking window_base...
  3. Have you tried just calling

    contents.clearcreate_contents?
  4. 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.
  5. 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
  6. 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
  7. 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
  8. @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
  9. 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
  10. 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)

    Nathan Frost said:
    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.
  11. @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. :)