Change icons with variables

Padramyr

Veteran
Veteran
Joined
May 22, 2017
Messages
95
Reaction score
75
First Language
German
Primarily Uses
RMMV
Hey there! :)

I'm not sure if it's even possible what I'm asking. I need a plugin that changes icons depending on a variable.
I'm using Iavra Localization. At the start of the game I ask the player which language should be used and change a variable depending on the choice (besides changing the ingame language with the plugin commands). That's because the title screen, tutorial pictures and such will be in the corresponding language using conditional branches and I couldn't find another way to achieve this.
What I would like to accomplish also is that I can change some icons with that variable as well. For example the icons for status (de-)buffs. While it should be an icon with "DEF" (for "Defence") in it in English it should be an icon with "VER" (for the german word "Verteidigung") in it in German.

I was thinking about having multiple icons for the same buff in different languages in one sheet or having multiple sheets with a plugin changing which sheet is used. Whatever is easier to accomplish.

If anyone can point me to a existing plugin that would be great :)
Or maybe someone is willing to help me out and make a plugin for that if it's even possible :)
 
Last edited:

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
147
Reaction score
166
First Language
Danish
Primarily Uses
RMMV
Hi, I made this plugin for you. If you have any questions or request regarding this plugin feel free to ask.
Just put this after Iavra Localization. You need to name the IconSet images like this:
Code:
IconSet_[LOCALIZATION NAME]
E.g. IconSet_en (img/system/IconSet_en.png)
Code:
//=============================================================================
// Localization Icons
// MRP_LocalizationIcons.js
// By Magnus0808 || Magnus Rubin Peterson
//=============================================================================

/*:
 * @plugindesc Extension to Iavra Localization Core. Icons use localization.
 * @author Magnus0808
 *
 * @help Put this after Iavra Localization Core.
 * Save the different IconSets in the img/system folder with the following
 * nameing: 'IconSet_[LOCALIZATION NAME]'
 * E.g. IconSet_en (img/system/IconSet_en.png)
 *
 */

(function(){
    var Iavra_languages = IAVRA.I18N.languages();
    
    Window_Base.prototype.drawIcon = function(iconIndex, x, y) {
        var bitmap = ImageManager.loadSystem('IconSet_' + IAVRA.I18N.language);
        var pw = Window_Base._iconWidth;
        var ph = Window_Base._iconHeight;
        var sx = iconIndex % 16 * pw;
        var sy = Math.floor(iconIndex / 16) * ph;
        this.contents.blt(bitmap, sx, sy, pw, ph, x, y);
    };
    
    Sprite_StateIcon.prototype.loadBitmap = function() {
        var bitmap = ImageManager.loadSystem('IconSet_' + IAVRA.I18N.language);
        this.setFrame(0, 0, 0, 0);
    };
    
    Scene_Boot.loadSystemImages = function() {
        ImageManager.reserveSystem('Balloon');
        ImageManager.reserveSystem('Shadow1');
        ImageManager.reserveSystem('Shadow2');
        ImageManager.reserveSystem('Damage');
        ImageManager.reserveSystem('States');
        ImageManager.reserveSystem('Weapons1');
        ImageManager.reserveSystem('Weapons2');
        ImageManager.reserveSystem('Weapons3');
        ImageManager.reserveSystem('ButtonSet');
        
        for(var i = 0; i < Iavra_languages.length; i++){
            ImageManager.reserveSystem('IconSet_' + Iavra_languages[i]);
        }       
    };
    
})();
 

Attachments

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
@Magnus0808 Nice! I was going to pick up this request but you beat me to it.

It would be best if you could alias the Scene_Boot.loadSystemImages function instead of overwriting for compatibility with other plugins that load system images :)
 

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
147
Reaction score
166
First Language
Danish
Primarily Uses
RMMV
It would be best if you could alias the Scene_Boot.loadSystemImages function instead of overwriting for compatibility with other plugins that load system images :)
I thought about doing that. However, I had to remove the first line of the function:
ImageManager.reserveSystem('IconSet').
If I did alias the function that line would be run which would require there to be a file called IconSet. However, since I made the naming convention different this is not really optimal. I did plan to alias it if it turned out to be any problems and just note that there should be a file with the IconSet name.
 

Padramyr

Veteran
Veteran
Joined
May 22, 2017
Messages
95
Reaction score
75
First Language
German
Primarily Uses
RMMV
Thank you very much, @Magnus0808 :)
I'll test it out later on. I'm not quite sure if I have any other plugin that loads system images. As soon as I'm at home I'll check that xD
 

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

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top