Custom options for Yanfly options core

Hey there,

as I understand correctly, you can add custom options to the yanfly plugin options core. But how I do that?
Basically, I want to add some options from SumRndmDde "Game Upgrade" plugin. This plugin provides commands like:

The following plugin commands may be used to manipulate the game window:

ForceClose
Closes the game window.

FocusWindow
Focuses on the game window.

MinimizeWindow
Minimizes the game window.

UnminimizeWindow
Unminimizes the game window.

MaximizeWindow
Maximizes the game window.

UnmaximizeWindow
Unmaximize the game window.

RequestAttention
Requests attention to the game window.

TaskBarShow
Makes the game accessable from the task bar.

TaskBarHide
Removes the game from the task bar.

EnterKioskMode
Enters kiosk mode.

LeaveKioskMode
Leaves kiosk mode.

SetProgressBar ratio
Sets the window's progress bar to the value defined by "ratio".

Let's say I want to add an option to show/hide the game in the taskbar for whatever reason. Where in yanflys plugin do I need to put the code TaskBarHide?

I really appreciate any help 🙂
*bump*
Plugin link for reference: http://sumrndm.site/game-upgrade/

Looks like SRD's plugin commands all neatly correspond to functions defined on SRD.PluginCommands. I assume you could call hide when the option is toggled off and show when it's toggled on, but I haven't really experimented with Yanfly's Options Core so I'm not sure if that's all you'd need to get it to work as expected. 😅

All the function names are in lowercase, e.g.
Code:
SRD.PluginCommands.taskbarhide();
SRD.PluginCommands.taskbarshow();
Thank you! Now at least I know the code 🙂

Next I need to know where to put it?

I tried it with process OK code cause I thought this would be the place where it decides what to do.

var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
this.changeValue(symbol, !value);
var value = config[name];
if (value !== 0) {
SRD.PluginCommands.taskbarhide();
} else {
SRD.PluginCommands.taskbarshow();
}

But it doesn't work. To be honest, I have no clue what I do here xD
👋 OK I did some experimenting and it looks like you have mostly the right idea! The value variable is true|false, not 1|0, that's probably why your attempt wasn't working. ^_^

Try this:
Spoiler
  • Process OK Code: (show/hide when toggled)
    Code:
    var index = this.index();
    var symbol = this.commandSymbol(index);
    var value = this.getConfigValue(symbol);
    this.changeValue(symbol, !value);
    if (value) {
      SRD.PluginCommands.taskbarshow();
    } else {
      SRD.PluginCommands.taskbarhide();
    }
  • Cursor Right Code: (hide window when toggled)
    Code:
    var index = this.index();
    var symbol = this.commandSymbol(index);
    var value = this.getConfigValue(symbol);
    this.changeValue(symbol, true);
    SRD.PluginCommands.taskbarhide();
  • Cursor Left Code: (show window when toggled)
    Code:
    var index = this.index();
    var symbol = this.commandSymbol(index);
    var value = this.getConfigValue(symbol);
    this.changeValue(symbol, false);
    SRD.PluginCommands.taskbarshow();
  • Load Config Code: (hide if option is on)
    Code:
    ConfigManager[symbol] = !!config[symbol];
    if (ConfigManager[symbol]) {
      SRD.PluginCommands.taskbarhide();
    }
Or here's the text version of my "Hide In Taskbar" options parameter entry:
Code:
{"Name":"Hide In Taskbar","---Settings---":"","HelpDesc":"\"Hide the window in the taskbar?\"","Symbol":"taskHide","ShowHide":"\"show = true;\"","Enable":"\"enabled = true;\"","Ext":"\"ext = 0;\"","---Functions---":"","MakeCommandCode":"\"this.addCommand(name, symbol, enabled, ext);\"","DrawItemCode":"\"var rect = this.itemRectForText(index);\\nvar statusWidth = this.statusWidth();\\nvar titleWidth = rect.width - statusWidth;\\nthis.resetTextColor();\\nthis.changePaintOpacity(this.isCommandEnabled(index));\\nthis.drawOptionsName(index);\\nthis.drawOptionsOnOff(index);\"","ProcessOkCode":"\"var index = this.index();\\nvar symbol = this.commandSymbol(index);\\nvar value = this.getConfigValue(symbol);\\nthis.changeValue(symbol, !value);\\nif (value) {\\n  SRD.PluginCommands.taskbarshow();\\n} else {\\n  SRD.PluginCommands.taskbarhide();\\n}\"","CursorRightCode":"\"var index = this.index();\\nvar symbol = this.commandSymbol(index);\\nvar value = this.getConfigValue(symbol);\\nthis.changeValue(symbol, true);\\nSRD.PluginCommands.taskbarhide();\"","CursorLeftCode":"\"var index = this.index();\\nvar symbol = this.commandSymbol(index);\\nvar value = this.getConfigValue(symbol);\\nthis.changeValue(symbol, false);\\nSRD.PluginCommands.taskbarshow();\"","DefaultConfigCode":"\"ConfigManager[symbol] = false;\"","SaveConfigCode":"\"config[symbol] = ConfigManager[symbol];\"","LoadConfigCode":"\"ConfigManager[symbol] = !!config[symbol];\\nif (ConfigManager[symbol]) {\\n  SRD.PluginCommands.taskbarhide();\\n}\""}
Yes, that's it, thank you!
My commands OFF/ON are exactly the other way round so I needed to exchange them, but now it works perfectly fine!

There is just one small thing.
Per default, I want the game to be shown in the taskbar, of course. So the option "Show in taskbar?" needs to be enabled by default.
This is an issue this script can't do.
We had the discussion here:
https://forums.rpgmakerweb.com/inde...-default-code-not-working.106969/#post-953743
This was the load config code which solved the problem:

var value = config[name];
if (value !== undefined) {
ConfigManager[name] = value;
} else {
ConfigManager[name] = true;
}

How can I combine this with your load config code?
Oh I see, looks like this works:
Spoiler
Code:
if (config[symbol] === undefined) {
  ConfigManager[symbol] = true;
} else {
  ConfigManager[symbol] = !!config[symbol];
}
if (ConfigManager[symbol]) {
  SRD.PluginCommands.taskbarhide();
}

Edit: shorter solution below! The issue is that the default value gets applied before the options are loaded from the file; you just need to check if the value is undefined before applying it:
Code:
if (config[symbol] !== undefined) {
  ConfigManager[symbol] = !!config[symbol];
}
if (ConfigManager[symbol]) {
  SRD.PluginCommands.taskbarhide();
}
You are wonderful! :kiss:
Thank you so much!
You're welcome! I just added a slightly shorter version and a little explanation of why the default value doesn't seem to work to my previous post.

Happy RPG Making~! 😂

Original thread: https://forums.rpgmakerweb.com/threads/custom-options-for-yanfly-options-core.106568/