MV Replace IconSet dynamically in-game (for gamepad/keyboard button prompts)

Good evening, everyone!

This time, I would like to ask for a plugin that can do something special during the gameplay: change in real time the IconSet while using the keyboard or the gamepad. Let me explain...

In some games for PC, the use of gamepad controllers and keyboards is greatly implemented in a way that, when you are playing with with a gamepad, it shows the button icons of such gamepad (modern games can also show different buttons for different controllers, such as XBox, PlayStation or even Switch); and when you change back to the keyboard and mouse, it automatically changes the icons shown in the menus for those of a keyboard.

Thanks to the VisuStella Core Engine plugin, the MZ projects can already have a window that shows the button prompts, with texts or icons from the IconSet graphics.

But for the RPG Maker MV projects, I would like to request an specific plugin to make a game to switch (through the Options menu) between two different IconSet graphics depending on which kind of controller you are using (XBOX controllers, PlayStation 4/5 controllers, or keyboard).

It is something to be considered QoL improvements for our projects, since they can be played both with keyboard and gamepad.

Could this be possible? And if it is, can I have some help to get it done? It would be much appreciated.

Thanks in advance. Cheers!
I would like to bump this, I really would like to find an answer for this request.
Bump, sounds interesting.
Bumping this again.
I know EXACTLY what you mean, and I was thinking the same thing only this morning!
I think, rather than switching between two icon sets, it would be better to have a plugin that switches the actual icons used for the prompts, and have all the icons on one set.

Alas, I do not have one to offer.

The reason why I say this is, for example, my icon set has well over 10,000 icons on it. I wouldn't like the game to be switching that .png out and in again every time I wanted a button press to appear.

If a plugin for something like that does exist, i.e. one that dynamically detects whether the last button press came from a keyboard / controller, I'd love to find it. I'm sure a more talented person than I could find a way to script it. All you'd need is to be able to fetch the most recently returned value of the device last used.

As a last resort, I suppose you could add an option in the menu:
"Display prompts as: [Keyboard] [Controller]" kind of thing. And then set a switch to be ON or OFF depending on the choice, and build a common event for each prompt which checks the switch, and displays the correct icon ID dependent on the switches status.

Of course, then you'd need to look into how to add your own option to the in game menu to implement that.

I realise I've given you ideas without any way to execute them, but I thought you'd appreciate someone actually taking the time to help you think through this 🙂
@Oscar92player Why the sad response? I did my absolute best to be helpful!
Bumping this, because I still need a plugin for this.

PS.: Also, sorry for not answering before, @C64_Mat. I thank you for your answer, but it's not what I'm looking for, since I use a lot of icon instance in system texts inside the menus or tutorials, so I can't make an option to turn ON or OFF switches or variables, and also, I do not have enough knowledge to program all of that.
Yes, it is definitely possible, as my games do feature dynamic button prompts for xbox, ps, and switch pro controllers as well as keyboard (obviously). The problem here is likely just the fact that you're posting in plugin requests.

Such a thing doesn't usually come for free, so I suggest putting aside some money and making a post in classifieds to pay someone to make it for you. (Or, of course, learning to code it yourself is also viable.)
Yes, it is definitely possible, as my games do feature dynamic button prompts for xbox, ps, and switch pro controllers as well as keyboard (obviously). The problem here is likely just the fact that you're posting in plugin requests.

Such a thing doesn't usually come for free, so I suggest putting aside some money and making a post in classifieds to pay someone to make it for you. (Or, of course, learning to code it yourself is also viable.)

I understand that things like this could come with a cost.

However, I would like to mantain my post here because... this is the Plugin Request forum, so it is fitting for what I ask for, which is a plugin that can add an option the Options menu to switch between IconSet files, and allowing a project in RPG Maker MV to do so.
Of course you can maintain this thread, I just figure I'd let you know that you're probably not going to have a lot of luck with a request like this on the free side, seeing as you had already bumped it quite a bit. Best of luck tho!
Here's short plugin to dynamically change the iconset that is used across your game

Code:
(function() {
const _loadSystem = ImageManager.loadSystem;
ImageManager.loadSystem = function(filename) {
  
    return _loadSystem.call(
        this,
        filename.toLowerCase() == 'iconset' && $gameSystem._iconSetOverride
            ? $gameSystem._iconSetOverride
            : filename
    );
}
})()
Include it as a plugin with any name you like.

To override the icon set, use this call
Code:
$gameSystem._iconSetOverride = "IconSet2"
and to reset, use
Code:
$gameSystem._iconSetOverride = undefined
.
Here's short plugin to dynamically change the iconset that is used across your game

Code:
(function() {
const _loadSystem = ImageManager.loadSystem;
ImageManager.loadSystem = function(filename) {
  
    return _loadSystem(
        filename.toLowerCase() == 'iconset' && $gameSystem._iconSetOverride
            ? $gameSystem._iconSetOverride
            : filename
    );
}
})()
Include it as a plugin with any name you like.

To override the icon set, use this call
Code:
$gameSystem._iconSetOverride = "IconSet2"
and to reset, use
Code:
$gameSystem._iconSetOverride = undefined
.

Thank you very much! I'll try it shortly.

P.S.: By any chance, and if it is not much asking... do you know how could I create an option in the Options menu with the YEP Options Core plugin enabled? It will be very helpful to have that option there, giving the players at least two or three different options to choose from (XBOX, PS4/5, or keyboard).

EDIT: Got this error while trying your plugin, @Aerosys

1755239098712.png
I updated my last post, please try again.

Sorry, haven't dealt with YEP Options, but as soon as you have a working icon-set switch, it's much easier to ask around for help. There should be some people here that can tell you how to add a new item to YEP Options.

EDIT:
Edited it yet another time
I updated my last post, please try again.

Sorry, haven't dealt with YEP Options, but as soon as you have a working icon-set switch, it's much easier to ask around for help. There should be some people here that can tell you how to add a new item to YEP Options.

EDIT:
Edited it yet another time

Thank you very much for your answer, and your editions to make the plugin to work.

I tested it, and it works partially. It seems that there's an issue, after calling for the new IconSet image, and the icon images do not appear the first time you open, for example, the equipment menu (as if the image didn't load). At the second time you open the menu, the icons work properly.

Maybe do I need to add a command or script line to make the other IconSet to load?

EDIT: Apparently, I had to edit the script call:

Code:
$gameSystem._iconSetOverride = "IconSet_KB"

So it looked like this, and it did the trick:

Code:
$gameSystem._iconSetOverride = "IconSet_KB"

ImageManager.loadSystem('IconSet_KB');
this.setWaitMode('image');

Not sure if I should be doing the same for the code to reset the original IconSet, though.
Hello @Oscar92player

Is there a particular reason why you prefer to change the entire iconset for inputs instead of putting all inputs on the same iconset and dynamically modifying the iconIDs of the buttons displayed depending on the device used?

For my game, I went with this approach:

1) an option in YEP_option_core that lets you choose between an Xbox-type controller or a PS-type controller.

Here is the option configuration:

1755251055457.png


Make Option Code :
Code:
this.addCommand(name, symbol, enabled, ext);

Draw Option Code :

Code:
var rect = this.itemRectForText(index);
var statusWidth = this.statusWidth();
var quarterWidth = statusWidth / 2;
var titleWidth = rect.width - statusWidth;
this.resetTextColor();
this.changePaintOpacity(this.isCommandEnabled(index));
this.drawOptionsName(index);
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);

this.changePaintOpacity(value === 0);
var text = "Joypad type 1";
this.drawText(text, titleWidth, rect.y, quarterWidth, 'center');
this.changePaintOpacity(value === 1);
var text = "Joypad type 2";
this.drawText(text, titleWidth + quarterWidth, rect.y, quarterWidth, 'center');


Process OK Code + cursor right + cursor left :

Code:
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
value += 1;
if (value > 1) value = 0;
this.changeValue(symbol, value);
$gameVariables.setValue(2000, value);
I use a game variable to store which controller is being used, here variable 2000, but you can of course change that. I will also use this variable in the plugin part below.

Default config code :

Code:
ConfigManager[symbol] = 0;

Save config code :

Code:
config[symbol] = ConfigManager[symbol];

Load config code :

Code:
ConfigManager[symbol] = config[symbol];



2) Then a plugin that will detect the player's inputs and modify a predefined icon list:

Here is an excerpt from the code. I didn't include the entire plugin because it's a large plugin that reorganizes all my menus, creates a HelpButton window, etc.

But if you tinker with JS a bit, this piece of code might be useful to you:

JavaScript:
const CONTROL_MODE = { KEYBOARD: "keyboard", GAMEPAD: "gamepad" };
  let _lastControlMode = CONTROL_MODE.KEYBOARD;
  // ============================ ICON LIST =============================================================
  function getIcons() {
    const padType = $gameVariables.value(2000); // 0 = XB, 1 = PS
    if (_lastControlMode === CONTROL_MODE.KEYBOARD) {
      return {
        validate: "\\I[5330]",
        cancel: "\\I[5292]",
        prev: "\\I[5296]",
        next: "\\I[5297]",
        up: "\\I[5301]",
        down: "\\I[5302]",
        left: "\\I[5303]",
        right: "\\I[5304]"
      };
    } else if (padType === 1) {
      return {
        validate: "\\I[4759]",
        cancel: "\\I[4750]",
        prev: "\\I[5333]",
        next: "\\I[5334]",
        up: "\\I[4764]",
        down: "\\I[4765]",
        left: "\\I[4762]",
        right: "\\I[4763]"
      };
    } else {
      return {
        validate: "\\I[4928]",
        cancel: "\\I[4833]",
        prev: "\\I[5335]",
        next: "\\I[5336]",
        up: "\\I[4764]",
        down: "\\I[4765]",
        left: "\\I[4762]",
        right: "\\I[4763]"
      };
    }
  }

  // ========================= Keyboard/Mouse or Joypad detect =========================
  const _Input_onKeyDown = Input._onKeyDown;
  Input._onKeyDown = function(event) {
    _lastControlMode = CONTROL_MODE.KEYBOARD;
    _Input_onKeyDown.call(this, event);
  };

  const _TouchInput_onMouseDown = TouchInput._onMouseDown;
  TouchInput._onMouseDown = function(event) {
    _lastControlMode = CONTROL_MODE.KEYBOARD;
    _TouchInput_onMouseDown.call(this, event);
  };

  const _TouchInput_onTouchStart = TouchInput._onTouchStart;
  TouchInput._onTouchStart = function(event) {
    _lastControlMode = CONTROL_MODE.KEYBOARD;
    _TouchInput_onTouchStart.call(this, event);
  };

  const _Input_update = Input.update;
    Input.update = function() {
        _Input_update.call(this);
            const pads = navigator.getGamepads ? navigator.getGamepads() : [];
            for (let i = 0; i < pads.length; i++) {
              const pad = pads[i];
              if (pad && pad.connected && pad.buttons.some(function(btn) { return btn.pressed; })) {
                _lastControlMode = CONTROL_MODE.GAMEPAD;
              }
            }
    };

With this, the icons change in real time depending on whether you touch a button on the controller or a key on the keyboard.

I don't know if everything will be useful to you, but in any case, the configuration section of Yep_OptionCore will certainly be.
Thank you very much for your answer, and your editions to make the plugin to work.

I tested it, and it works partially. It seems that there's an issue, after calling for the new IconSet image, and the icon images do not appear the first time you open, for example, the equipment menu (as if the image didn't load). At the second time you open the menu, the icons work properly.

Maybe do I need to add a command or script line to make the other IconSet to load?

What my plugin is doing is basically, "when the core code or any plugin is loading the iconset, it receives an alternative one". The problem is, this does not include "refresh UI/HUD/whatever". The core code or a plugin can load the iconset when opening a menu, but then it will simply not react while you are browsing it.

And I can't change that because that would mean that we must change every line of code in the core code or any plugin to update changes instantly.
another way without the option menu (require his core) is
Gimmer_ControllerType which allows to auto detect gamepad or keyboard
and swap to the one you use.

you just need to configure this in the parameter and its easy to go.
Hello @Oscar92player

Is there a particular reason why you prefer to change the entire iconset for inputs instead of putting all inputs on the same iconset and dynamically modifying the iconIDs of the buttons displayed depending on the device used?

For my game, I went with this approach:

1) an option in YEP_option_core that lets you choose between an Xbox-type controller or a PS-type controller.

Here is the option configuration:

View attachment 347419

Make Option Code :
Code:
this.addCommand(name, symbol, enabled, ext);

Draw Option Code :

Code:
var rect = this.itemRectForText(index);
var statusWidth = this.statusWidth();
var quarterWidth = statusWidth / 2;
var titleWidth = rect.width - statusWidth;
this.resetTextColor();
this.changePaintOpacity(this.isCommandEnabled(index));
this.drawOptionsName(index);
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);

this.changePaintOpacity(value === 0);
var text = "Joypad type 1";
this.drawText(text, titleWidth, rect.y, quarterWidth, 'center');
this.changePaintOpacity(value === 1);
var text = "Joypad type 2";
this.drawText(text, titleWidth + quarterWidth, rect.y, quarterWidth, 'center');


Process OK Code + cursor right + cursor left :

Code:
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
value += 1;
if (value > 1) value = 0;
this.changeValue(symbol, value);
$gameVariables.setValue(2000, value);
I use a game variable to store which controller is being used, here variable 2000, but you can of course change that. I will also use this variable in the plugin part below.

Default config code :

Code:
ConfigManager[symbol] = 0;

Save config code :

Code:
config[symbol] = ConfigManager[symbol];

Load config code :

Code:
ConfigManager[symbol] = config[symbol];



2) Then a plugin that will detect the player's inputs and modify a predefined icon list:

Here is an excerpt from the code. I didn't include the entire plugin because it's a large plugin that reorganizes all my menus, creates a HelpButton window, etc.

But if you tinker with JS a bit, this piece of code might be useful to you:

JavaScript:
const CONTROL_MODE = { KEYBOARD: "keyboard", GAMEPAD: "gamepad" };
  let _lastControlMode = CONTROL_MODE.KEYBOARD;
  // ============================ ICON LIST =============================================================
  function getIcons() {
    const padType = $gameVariables.value(2000); // 0 = XB, 1 = PS
    if (_lastControlMode === CONTROL_MODE.KEYBOARD) {
      return {
        validate: "\\I[5330]",
        cancel: "\\I[5292]",
        prev: "\\I[5296]",
        next: "\\I[5297]",
        up: "\\I[5301]",
        down: "\\I[5302]",
        left: "\\I[5303]",
        right: "\\I[5304]"
      };
    } else if (padType === 1) {
      return {
        validate: "\\I[4759]",
        cancel: "\\I[4750]",
        prev: "\\I[5333]",
        next: "\\I[5334]",
        up: "\\I[4764]",
        down: "\\I[4765]",
        left: "\\I[4762]",
        right: "\\I[4763]"
      };
    } else {
      return {
        validate: "\\I[4928]",
        cancel: "\\I[4833]",
        prev: "\\I[5335]",
        next: "\\I[5336]",
        up: "\\I[4764]",
        down: "\\I[4765]",
        left: "\\I[4762]",
        right: "\\I[4763]"
      };
    }
  }

  // ========================= Keyboard/Mouse or Joypad detect =========================
  const _Input_onKeyDown = Input._onKeyDown;
  Input._onKeyDown = function(event) {
    _lastControlMode = CONTROL_MODE.KEYBOARD;
    _Input_onKeyDown.call(this, event);
  };

  const _TouchInput_onMouseDown = TouchInput._onMouseDown;
  TouchInput._onMouseDown = function(event) {
    _lastControlMode = CONTROL_MODE.KEYBOARD;
    _TouchInput_onMouseDown.call(this, event);
  };

  const _TouchInput_onTouchStart = TouchInput._onTouchStart;
  TouchInput._onTouchStart = function(event) {
    _lastControlMode = CONTROL_MODE.KEYBOARD;
    _TouchInput_onTouchStart.call(this, event);
  };

  const _Input_update = Input.update;
    Input.update = function() {
        _Input_update.call(this);
            const pads = navigator.getGamepads ? navigator.getGamepads() : [];
            for (let i = 0; i < pads.length; i++) {
              const pad = pads[i];
              if (pad && pad.connected && pad.buttons.some(function(btn) { return btn.pressed; })) {
                _lastControlMode = CONTROL_MODE.GAMEPAD;
              }
            }
    };

With this, the icons change in real time depending on whether you touch a button on the controller or a key on the keyboard.

I don't know if everything will be useful to you, but in any case, the configuration section of Yep_OptionCore will certainly be.

Thank you very much for the detailed answer, I will follow your tips to create the YEP Options setting, as well as @Aerosys plugin to make it work.

Answering to your question about why deciding to change the entire iconset... I find that method easier than having to setup variables or switches depending on the used device. Also, I prefer to allow players to choose their desired device, instead of having it change automatically.

That said, I will need extra advice on how to make the YEP Options setting to work with the script calls provided by Aerosys, that are the next in order to change the IconSet.

The script call that allows to change for the IconSet with the Keyboard icons:
Code:
$gameSystem._iconSetOverride = "IconSet_KB" #Calls for the IconSet image.

ImageManager.loadSystem('IconSet_KB'); #Loads the image to avoid issues.
this.setWaitMode('image');

The script call that allows to reset the original IconSet image with the Gamepad icons:
Code:
$gameSystem._iconSetOverride = undefined

I suppose these need to be setup with the Process OK Code, but it is not clear to me how could I do so, and I still need to figure out a Symbol for the setting, or how to properly show the two different options to choose from (Gamepad or Keyboard).

It would be appreciated if you could provide me with further instructions on how to create the YEP Options setting that could work with Aerosys plugin (I would only need two options for the players: Gamepad icons "IconSet.png" (the default one) or Keyboard icons "IconSet_KB.png").

Thank you very much in advance.

Original thread: https://forums.rpgmakerweb.com/threads/replace-iconset-dynamically-in-game-for-gamepad-keyboard-button-prompts.144907/