Make 'Disabled' Commands use Colours instead of Opacity

CriticalGames

Veteran
Veteran
Joined
Aug 8, 2014
Messages
217
Reaction score
61
First Language
English
Primarily Uses
Hi everyone,

I have a bit of an unusual question, but bear with me =P Due to the specific aesthetic of the game that I'm making, I use Victor Sant's SFont plugin (which essentially uses special pictures instead of font files to render text - https://victorenginescripts.wordpress.com/rpg-maker-mv/sfont/). Because of this aesthetic, I am also not able to use opacity effects on things like text.

Now, the way RPG Maker MV handles 'disabled' commands (e.g. the Continue button on the main menu when there's no saved games; or an item that is unusable from the menu) is that it basically halves that text's opacity - making it fade into whatever background your windows use. However, again, this doesn't fit with the aesthetic of my game.

So I need a different approach to signify to the player that a specific command is 'disabled'. I've figured out a theory of how to approach this, but as I'm awful at programming, I don't know how to actually implement it. The way the SFonts work is that they replace the various 'colours' that can be assigned to text. So if I put \c[1] in front of some text, instead of changing the text to a blue colour, it would load the SFont I have in slot 1.

And it's much the same in Javascript. Here's a line from rpg_windows.js that calls upon colour 16 - however, with the SFont system in place, this means that it will load the SFont that I have in slot 16.

Window_Base.prototype.systemColor = function() {
return this.textColor(16);
};

So what I need to do, somehow, is to make RPG Maker MV use a specific colour for disabled commands, instead of reducing the opacity. That way I can set up an SFont in a particular slot with grey colouring to represent disabled commands.

Hopefully that makes some degree of sense haha. Would this be possible or am I barking up the wrong tree?

Thanks for reading! =D
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
First Language
Czech
Primarily Uses
RMMV
I looked into the core files of the rpg maker. I think it would be better if you told us which plugin you use for show disabled choices. Because I cannot find any trace of how the game handles disabled choices in the game files and the console doesn't help either.
 
Last edited:

CriticalGames

Veteran
Veteran
Joined
Aug 8, 2014
Messages
217
Reaction score
61
First Language
English
Primarily Uses
I looked into the core files of the rpg maker. I think it would be better if you told us which plugin you use for show disabled choices. Because I cannot find any trace of how the game handles disabled choices in the game files and the console doesn't help either.
Thank you very much for responding (and the handy notification!), but I don't use any plugins for this, sorry. Just in case we're talking about different things, I'm referring to disabled 'commands' (ala the Continue button on the main menu I described in my first post) not 'choices' (I thought you might have been thinking about dialogue choices).

As far as I can tell, in the rpg_windows.js plugin, it's usually got to do with the word 'enabled' in the core files. For example, this.isContinueEnabled() on line 5756. It also seems to be in relation to something called PaintOpacity, but I'm not 100% sure on that one. I haven't been able to find where this all gets established, though =/
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
First Language
Czech
Primarily Uses
RMMV
Well, disabled commands and disabled choices react the same, so I hoped you would use a plugin for it too :D
Thanks for your insight, I was able to track it down!
In rpg_windows.js there is a function Window_Base.prototype.changePaintOpacity. If you want, you can edit it to for example
return this.textColor(xx)
 

CriticalGames

Veteran
Veteran
Joined
Aug 8, 2014
Messages
217
Reaction score
61
First Language
English
Primarily Uses
@Poryg - Ah, good eye! Thank you very much =D I'm sorry to keep asking, especially as I'm almost certainly doing something wrong, but it doesn't seem to be working. I changed it from:

Window_Base.prototype.changePaintOpacity = function(enabled) {
this.contents.paintOpacity = enabled ? 255 : this.translucentOpacity();
};
To:

Window_Base.prototype.changePaintOpacity = function(enabled) {
return this.textColor(4);
};
Did I miss a few steps? =P
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
First Language
Czech
Primarily Uses
RMMV
No, it was my idiocy :)
You need to change the value of a variable. So the function will look like this.

Code:
Window_Base.prototype.changePaintOpacity = function(enabled) {
    this.contents.paintOpacity = enabled ? 255 : this.textColor(4);
};
 

CriticalGames

Veteran
Veteran
Joined
Aug 8, 2014
Messages
217
Reaction score
61
First Language
English
Primarily Uses
@Poryg - Hmm...It still doesn't seem to be doing anything, sorry =/ I tried changing the 255 number to 150 out of curiosity, and it actually affected the opacity of all the text in the game; not just disabled functions. Maybe we need to do something with "this.translucentOpacity()"? Or change "paintOpacity" to something else?

I also tested it in a fresh project with no plugins, and the results were the same; the text colour didn't change, but all of the disabled text did become solid instead of transparent (presumably because you replaced "this.translucentOpacity"?).
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
First Language
Czech
Primarily Uses
RMMV
Ugh, I screwed the function once again. This time I'll fix it for sure!
Code:
Window_Base.prototype.changePaintOpacity = function(enabled) {
    if (enabled == false){
        this.contents.textColor = this.textColor(4)
    }
};
Earlier I combined two things that shouldn't be combined, acting on a rush. This should be correct now.
 
Last edited:

CriticalGames

Veteran
Veteran
Joined
Aug 8, 2014
Messages
217
Reaction score
61
First Language
English
Primarily Uses
@Poryg - Aha! Thank you very much =D At least...it's a step in the right direction haha. I'm just testing it all out, and it's weirdly inconsistent. On my actual project, it doesn't seem to have done anything (it hasn't changed the SFont like it should have). And then on the fresh, new test project, it did work on the Continue button on the main menu, but it hasn't worked on unusable skills and items in the in-game menu. So I'm not sure what to make of that, or where to go from here XD

But regardless, thank you very much for your help - I sincerely appreciate it =D
 

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,380
Reaction score
10,824
First Language
English
Primarily Uses
RMVXA

I've moved this thread to Javascript/Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
First Language
Czech
Primarily Uses
RMMV
That doesn't make sense to me.
Looking through the code, all functions you describe, the items and commands, use the exact same function. Window_Base.prototype.changePaintOpacity. And since it is a Boolean, it uses either true or false. Or 0/1, doesn't matter.

Edit: Now it doesn't make sense even more... Because the console throws me the right color.
 
Last edited:

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
144
First Language
English
Primarily Uses
RMMV
Firstly, best not to edit core files directly, since updating MV will then revert all your changes. Best to just make your changes in a seperate js file and import it as a plugin.

That said, I think this should work.

(Copy this into a text editor and save it as a js file, then import it as a plugin in your project):

Code:
Window_Base.prototype.changePaintOpacity = function(enabled) {
  var disabledColor = this.textColor(4);
    if (enabled) {
        this.resetTextColor();
    } else {
        this.changeTextColor(disabledColor);
    }
};
Poryg what you forgot to do was reset the text color when the function is called as false. At least that's what I think as to why it wouldn't work.
 

CriticalGames

Veteran
Veteran
Joined
Aug 8, 2014
Messages
217
Reaction score
61
First Language
English
Primarily Uses
[move]Javascript/Plugin Support[/move]
Sorry Kes - for whatever reason, I didn't think of this as a plugin problem when I posted the topic. Thank you for moving it!

That doesn't make sense to me.
Looking through the code, all functions you describe, the items and commands, use the exact same function. Window_Base.prototype.changePaintOpacity. And since it is a Boolean, it uses either true or false. Or 0/1, doesn't matter.
I agree - it doesn't make any sense to me (more on that below XD). But I really appreciate you spending all this time helping me, so thank you! It looks like you were very close haha.

Firstly, best not to edit core files directly, since updating MV will then revert all your changes. Best to just make your changes in a seperate js file and import it as a plugin.

That said, I think this should work.

(Copy this into a text editor and save it as a js file, then import it as a plugin in your project):

Code:
Window_Base.prototype.changePaintOpacity = function(enabled) {
  var disabledColor = this.textColor(4);
    if (enabled) {
        this.resetTextColor();
    } else {
        this.changeTextColor(disabledColor);
    }
};
Poryg what you forgot to do was reset the text color when the function is called as false. At least that's what I think as to why it wouldn't work.
Thank you very much for the code Naveed! =D That was another big step, as the SFont is now changing on the main menu and on the root in-game menu. So for the in-game menu, if I disable one of the options (for example, 'Save'), it will now change colour like it should, so that's really great. However, it's still not affecting unusable items or skills - they're still the same colour as everything else. I am sorry to keep asking, and this is a big improvement already, but does anyone have any ideas why this would be?
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
144
First Language
English
Primarily Uses
RMMV
So I looked through the base code and found out the problem. The engine resets the text color before drawing any item/skill name. So text color changes to the paint opacity is overwritten.

Replace what you wrote previously with this:

Code:
Window_Base.prototype.changePaintOpacity = function(enabled) {
  var disabledColor = this.textColor(4);
    if (enabled) {
        this.changeTextColor(this.normalColor());
        this._useDisabled = false;
    } else {
        this.changeTextColor(disabledColor);
        this._useDisabled = true;
    }
};

Window_Base.prototype.drawItemName = function(item, x, y, width) {
    width = width || 312;
    if (item) {
        var iconBoxWidth = Window_Base._iconWidth + 4;
        this._useDisabled = this._useDisabled || false;
        if (!this._useDisabled) this.resetTextColor();
        this.drawIcon(item.iconIndex, x + 2, y + 2);
        this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
    }
};
Note that since I didn't test it myself, it could have some undesired consequences, so I suggest you test it thoroughly.

EDIT: Changed the code a bit to lessen chances of any side effects.
 

CriticalGames

Veteran
Veteran
Joined
Aug 8, 2014
Messages
217
Reaction score
61
First Language
English
Primarily Uses
Thank you so much @Naveed - it looks like that did it! Unfortunately it didn't change the items/skills on my actual project, but it *does* work on my fresh test project, so obviously the code part is all correct and it's just a plugin or something causing me trouble. It'll probably just take a bit of fiddling to get it working haha.

Thanks so much for sorting that out for me; I really appreciate it!
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,038
Reaction score
10,250
First Language
Czech
Primarily Uses
RMMV
Maybe it would be better to separate that function and use it as a separate plugin, just being sure it is under the SFont plugin.
 

CriticalGames

Veteran
Veteran
Joined
Aug 8, 2014
Messages
217
Reaction score
61
First Language
English
Primarily Uses
@Poryg - Thanks for the idea! I just tried it, though, and it unfortunately didn't seem to make a difference. This plugin is underneath the SFont plugin though =)
 

Naveed

Veteran
Veteran
Joined
Nov 2, 2013
Messages
314
Reaction score
144
First Language
English
Primarily Uses
RMMV
Only reason then for it to not work is that some other plugin overwrites the drawItemName function.

Best way to test out specific plugin issues is to turn all plugins off and then turn them on one by one, testing between each one (you can start out testing by turning 5-6 plugins on each time and when you find the problem start narrowing down within that group)
 

CriticalGames

Veteran
Veteran
Joined
Aug 8, 2014
Messages
217
Reaction score
61
First Language
English
Primarily Uses
Well, that was simple! Just had to figure out which plugin was causing the problem and then move this new plugin above it. Looks to be working perfectly now =D Thank you very much for all your help @Naveed and @Poryg!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I am dead tired but at the same time I really wanna write a tutorial x_x
Looked out side and couldn't see the neighbor's house through the snow. That age old Christmas song started going through my head. "It's a lovely day to say the heck at home."
Last year, I planted a bunch of spinach, and one plant wasn't doing well, so I transferred it to a separate pot. All its kin died while it hibernated over winter. Now it thrives. I've named it Prince Spinach.
Scooby Doo on Zombie Island is anime and you cant change my mind.
I guess the concept of friendship has changed :") Today I saw a very quiet boy getting bullied by his 'friends' because he wasn't talking. They made a circle and made him sit in the middle and were nagging him saying hey talk, sing a song, do this tongue twister etc. etc. And I could totally see the discomfort in the boy's face. Glad I don't have 'friends' lmao

Forum statistics

Threads
93,371
Messages
911,733
Members
122,863
Latest member
muhlijem
Top