RMMV Trying to make MZ Style Window_Selectable for MV

Raphael Lourenço

Infinity Door Studio's Lead Designer
Member
Joined
Mar 30, 2017
Messages
20
Reaction score
26
First Language
Portuguese
Primarily Uses
RMMV
I'm trying to make the MZ Button Style Interface for MV.
I am trying to replicate the interface style of Rpg Maker MZ, where Window_Selectable looks very good with tight buttons, being more friendly for a mobile conversion.

I noticed that in the MV, you create a Background behind each Rect, where that background will always be behind the information. I got good results in the Menu Interface in general.
1600881974889.png
1600882032445.png
1600882055782.png

However, in the Actors Status window in the Battle Scene , the background ends up over the information for some reason.
In the combat window the bug is more visible, as the background is alternating its position whenever it enters an actor's combat turn.
1600882133570.png
The changes I made were directly in Window Selectable, where I added and modified the following lines:
JavaScript:
Window_Selectable.prototype.drawAllItems = function() {
    var topIndex = this.topIndex();
    for (var i = 0; i < this.maxPageItems(); i++) {
        var index = topIndex + i;
        if (index < this.maxItems()) {
            this.drawItemBackground(index);
            this.drawItem(index);
        }
    }
};

Window_Selectable.prototype.drawItem = function(index) {
};

Window_Selectable.prototype.clearItem = function(index) {
    var rect = this.itemRect(index);
    this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);

};

Window_Selectable.prototype.drawItemBackground = function(index) {
    var rect = this.itemRect(index);
    this.drawBackgroundRect(rect);
};

Window_Selectable.prototype.drawBackgroundRect = function(rect) {
    var c1 = 'ffffff';
    var c2 = '000000';
    var x = rect.x;
    var y = rect.y;
    var w = rect.width;
    var h = rect.height;
    this.contents.paintOpacity = 64;
    this.contents.fillRect(x+2, y+2, w-4, h-4, c1);
    this.contents.paintOpacity = 64;
    this.contents.fillRect(x+3, y+3, w-6, h-6, c2, c2, true);

};

Window_Selectable.prototype.redrawItem = function(index) {
    if (index >= 0) {
        this.clearItem(index);
        this.drawItemBackground(index);
        this.drawItem(index);
    }
};

Window_Selectable.prototype.redrawCurrentItem = function() {
    this.redrawItem(this.index());
};

Window_Selectable.prototype.refresh = function() {
    if (this.contents) {
        this.contents.clear();
        this.drawAllItems();
    }
};
What could this problem be? It remains even when I don't use any plugin.
 

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
142
Reaction score
91
First Language
English
Primarily Uses
This is the problem:
Code:
    this.contents.paintOpacity = 64;
    this.contents.fillRect(x+2, y+2, w-4, h-4, c1);
    this.contents.paintOpacity = 64;
    this.contents.fillRect(x+3, y+3, w-6, h-6, c2, c2, true);
You changed the paintOpacity to 64 and never changed it back.

The other menus just happened to call changePaintOpacity whenever they are doing their drawing and reset it to normal, but Window_BattleStatus (and Window_BattleActor and Window_BattleEnemy) simply don't.

So when they draw their text, they are drawing it with the same opacity you changed it to for drawing the background, which is 64.
 

Raphael Lourenço

Infinity Door Studio's Lead Designer
Member
Joined
Mar 30, 2017
Messages
20
Reaction score
26
First Language
Portuguese
Primarily Uses
RMMV
This is the problem:
Code:
    this.contents.paintOpacity = 64;
    this.contents.fillRect(x+2, y+2, w-4, h-4, c1);
    this.contents.paintOpacity = 64;
    this.contents.fillRect(x+3, y+3, w-6, h-6, c2, c2, true);
You changed the paintOpacity to 64 and never changed it back.

The other menus just happened to call changePaintOpacity whenever they are doing their drawing and reset it to normal, but Window_BattleStatus (and Window_BattleActor and Window_BattleEnemy) simply don't.

So when they draw their text, they are drawing it with the same opacity you changed it to for drawing the background, which is 64.
Okay! I put a third line changing the opacity to 255 after the second concents.fillRect and resolve my problem! Thank You! <3

EDIT: How I put a condition to not show this background in the Battle Status Window?
They show and dissapear during the battle, causing a strange effect during command selection.
 
Last edited:

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
142
Reaction score
91
First Language
English
Primarily Uses
How I put a condition to not show this background in the Battle Status Window?
They show and dissapear during the battle, causing a strange effect during command selection.
I'm guessing you're using some other plugins as well, because I don't see any show/disappear or strange effects happening when testing with a fresh project, I cannot help you with that issue.

If you want your background not to show up in Window_BattleStatus or other specific windows, you will have to specifically make those windows NOT draw the background. Window_Selectable is their prototype, so by default they will automatically run all the code that is in Window_Selectable when they initialize.

So you would need to manually overwrite your background drawing functions again for every individual type of Window that uses Window_Selectable but that you don't want drawing the background.

EDIT: And of course, if you are using other plugins that modify BattleStatus and similar windows, you will need to check them and make sure your changes don't also overwrite whatever they are doing or that they don't overwrite yours, if you are getting "strange effects" happening due to your plugins, it is likely they are actually already doing this somewhere. Otherwise you shouldn't be getting some of your bars and numbers being drawn with full paint opacity like in your screenshot, I'm guessing from the thickness of the bars and your menu screens you're using Yanfly plugins which already make a lot of visual edits to the windows.
 
Last edited:

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

Latest Threads

Latest Profile Posts

Took a break from spriting dinosaurs to carve a dinosaur pumpkin.

Little early but to all of you that celebrate it :

Tomorrow is Halloween! I can't wait to go to Boxi Park and show off my costume! Also one of Dad's friends is staying the night, so he might get to see the show.
Here's the title-screen for the game I'm working on: :LZSgrin:
Oh man I've been struggling with event spawners and Qmovement compatibility for quite a while- went as far as to use a tool just to pick crops :kaocry: but Ritter got their spawner to work with Qmove and I'm screeing! It's still in testing period but just- the feeling of getting over a large gameplay hurdle is a HUGE relief, I'm so thankful to Ritter! It's a cheap paid plugin but totally worth it!

Forum statistics

Threads
104,661
Messages
1,007,919
Members
136,149
Latest member
Tarashi
Top