[SCRIPTING] [RMVX] BITMAP LOADING AND UPDATING WINDOWSKINS
Posts
Pages:
1
Alright, I'm beating my head against a wall with this one, because as far as I can tell this should be working and it isn't. But it also is, just not properly.
What I'm trying to do is create a windowskin color changer in RPG Maker VX. I've got it mostly working, the problem is that it doesn't update in real time.
This is the bit of code that I'm using.

Elsewhere in this script, you can adjust the window variable to anywhere between 1 and 64. Essentially what this does is it pulls the colors of two pixels from a modified window skin I created where I added a color palette in some of what is technically dead space. Those colors are then used to create a gradient, filling in the top left part of the window skin (what is normally used as the background for the window itself).
This is the window skin.

So here's the problem. When you select the color, it does update the windowskin, but only when you close the window. I make sure to run this method every time the window variable is adjusted, but it doesn't actually change the color of the window as you're adjusting the variable.
I was using a slightly different bit of code that did update the window in the moment that you changed it, but it used several different image files. Here I'm updating one bitmap, not loading a whole new file. I know that certain methods (such as gradient_fill_rect) can be time consuming, and I suspect that the bitmap isn't fully loading before trying to process this, but I honestly don't know. I'm wondering if there's a way to have the window skin actually update in real time, not just when closing the window (and subsequently loading a new one). I feel like I'm missing something completely obvious, but I can't for the life of me figure it out.
I kind of consider myself an amateur when it comes to Ruby, everything I've learned has just been through trial and error. So I may have missed some fundamentals when learning how to code. Any help is greatly appreciated, and please let me know if this makes no sense. I'll try to explain it better if I can.
What I'm trying to do is create a windowskin color changer in RPG Maker VX. I've got it mostly working, the problem is that it doesn't update in real time.
This is the bit of code that I'm using.

Elsewhere in this script, you can adjust the window variable to anywhere between 1 and 64. Essentially what this does is it pulls the colors of two pixels from a modified window skin I created where I added a color palette in some of what is technically dead space. Those colors are then used to create a gradient, filling in the top left part of the window skin (what is normally used as the background for the window itself).
This is the window skin.

So here's the problem. When you select the color, it does update the windowskin, but only when you close the window. I make sure to run this method every time the window variable is adjusted, but it doesn't actually change the color of the window as you're adjusting the variable.
I was using a slightly different bit of code that did update the window in the moment that you changed it, but it used several different image files. Here I'm updating one bitmap, not loading a whole new file. I know that certain methods (such as gradient_fill_rect) can be time consuming, and I suspect that the bitmap isn't fully loading before trying to process this, but I honestly don't know. I'm wondering if there's a way to have the window skin actually update in real time, not just when closing the window (and subsequently loading a new one). I feel like I'm missing something completely obvious, but I can't for the life of me figure it out.
I kind of consider myself an amateur when it comes to Ruby, everything I've learned has just been through trial and error. So I may have missed some fundamentals when learning how to code. Any help is greatly appreciated, and please let me know if this makes no sense. I'll try to explain it better if I can.
I no longer have access to VX, so I dunno how much I can actually help. However, let's take a look at Ace's processes in regards to it's initialization method...
...as well as it's update method.
The sub-thought in my head is that the tone object might be the variable to manipulate if you want to set the window color background, rather than using the windowskin variable to create a gradient rectangle. Of course, I don't necessarily know/remember if VX windows even have a tone variable/object to keep track of window color (though, it seems likely given the windowskin bitmap format), so it's largely a guess on my part.
class Window_Base < Window #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y, width, height) super self.windowskin = Cache.system("Window") update_padding update_tone create_contents @opening = @closing = false end end
...as well as it's update method.
class Window_Base < Window #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super update_tone update_open if @opening update_close if @closing end #-------------------------------------------------------------------------- # * Update Open Processing #-------------------------------------------------------------------------- def update_open self.openness += 48 @opening = false if open? end #-------------------------------------------------------------------------- # * Update Close Processing #-------------------------------------------------------------------------- def update_close self.openness -= 48 @closing = false if close? end #-------------------------------------------------------------------------- # * Update Tone #-------------------------------------------------------------------------- def update_tone self.tone.set($game_system.window_tone) end end
The sub-thought in my head is that the tone object might be the variable to manipulate if you want to set the window color background, rather than using the windowskin variable to create a gradient rectangle. Of course, I don't necessarily know/remember if VX windows even have a tone variable/object to keep track of window color (though, it seems likely given the windowskin bitmap format), so it's largely a guess on my part.
I had actually studied those methods as well, and I don't remember seeing anything relating to tone. Unfortunately, even if VX did support that, it wouldn't work either. I wanted to keep the default skin black, so changing the tone (I might be thinking of hue, actually) wouldn't have the same effect. Also, unless changing the tone only affected a selected portion, then it would also change text colors, as the palette in the bottom right would be similarly affected.
I think I managed to make it work by creating a separate bitmap for the new window skin, loading a different one, then reloading the new one. That seems to work, but I am worried about caching issues. I'm completely unfamiliar with cached resources and whether or not I'm actually clearing them properly. I'll share my code when I get back to my computer.
EDIT: Double checked, it doesn't look like RGSS2 has a method of changing the tone of a window. I'm starting to realize how limited VX was in the beginning, although it can still accomplish a lot with some creative solutions.
This is what I managed to put together, and it seems to work!

I used the original method that loaded a whole new window skin from a Windows folder within the Graphics folder. It looks like modifying the existing bitmap doesn't update it, but loading a whole new one does. Regardless, now the script manages to create 64 unique window skins from one single image (minus the placeholder to reload the skin). Still a little worried about caching though, it should be fine but I'm not certain.
I think I managed to make it work by creating a separate bitmap for the new window skin, loading a different one, then reloading the new one. That seems to work, but I am worried about caching issues. I'm completely unfamiliar with cached resources and whether or not I'm actually clearing them properly. I'll share my code when I get back to my computer.
EDIT: Double checked, it doesn't look like RGSS2 has a method of changing the tone of a window. I'm starting to realize how limited VX was in the beginning, although it can still accomplish a lot with some creative solutions.
This is what I managed to put together, and it seems to work!

I used the original method that loaded a whole new window skin from a Windows folder within the Graphics folder. It looks like modifying the existing bitmap doesn't update it, but loading a whole new one does. Regardless, now the script manages to create 64 unique window skins from one single image (minus the placeholder to reload the skin). Still a little worried about caching though, it should be fine but I'm not certain.
Pages:
1















