I've been writing a plugin, and it seems to work. Except there's one oddity I don't understand.
The plugin adds a new option to the Options menu, and the developer can pick what this defaults to by setting a parameter. However, if the developer wants it to default to "false", the setting is grey in the Options menu instead of white. This seems to be purely cosmetic, with everything else working as intended, but it's still annoying.
Code in spoiler:
While I'm here, are there any guides to plugin precedence, compatibility, or general best practices? I haven't been able to find much.
The plugin adds a new option to the Options menu, and the developer can pick what this defaults to by setting a parameter. However, if the developer wants it to default to "false", the setting is grey in the Options menu instead of white. This seems to be purely cosmetic, with everything else working as intended, but it's still annoying.
Code in spoiler:
//=============================================================================
// InstantText.js
//=============================================================================
/*:
@plugindesc This plugin causes text to render instantly instead of character-by-character.
@author Jatopian
@param Default
@desc Whether instant text is enabled by default in the Options menu. true / false
true - on, false - off
@default true
@help
This plugin causes text to be rendered instantly by default,
instead of one character at a time.
Player can toggle this behavior in the game's Options menu.
Developer can toggle whether the default setting is ON or OFF.
*/
(function() {
var params = PluginManager.parameters("InstantText");
var pInstantText = String(params["Default"]);
//=============================================================================
// ConfigManager
//=============================================================================
getDefaultInstantText = function() {
if (pInstantText.match(/true/i)) {
return true;
} else if (pInstantText.match(/false/i)) {
return false;
} else {
return Utils.isNwjs();
}
};
ConfigManager.instantText = getDefaultInstantText();
var alias_cm_md = ConfigManager.makeData;
ConfigManager.makeData = function() {
var config = alias_cm_md.call(this);
config.instantText = this.instantText;
return config;
};
var alias_cm_ad = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
alias_cm_ad.call(this, config);
this.instantText = this.readConfigInstantText(config, 'instantText');
};
ConfigManager.readConfigInstantText = function(config, name) {
var value = config[name];
if (value !== undefined) {
return value;
} else {
return getDefaultInstantText();
}
};
//=============================================================================
// Window_Options
//=============================================================================
var alias_wo_ago = Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function() {
alias_wo_ago.call(this);
this.addCommand("Instant Text", 'instantText', getDefaultInstantText());
console.log(getDefaultInstantText());
};
//=============================================================================
// Window Message
//=============================================================================
var alias_wm_udf = Window_Message.prototype.updateShowFast;
Window_Message.prototype.updateShowFast = function() {
alias_wm_udf.call(this);
if (ConfigManager.instantText === true) {
this._showFast = true
}
}
})();
// InstantText.js
//=============================================================================
/*:
@plugindesc This plugin causes text to render instantly instead of character-by-character.
@author Jatopian
@param Default
@desc Whether instant text is enabled by default in the Options menu. true / false
true - on, false - off
@default true
@help
This plugin causes text to be rendered instantly by default,
instead of one character at a time.
Player can toggle this behavior in the game's Options menu.
Developer can toggle whether the default setting is ON or OFF.
*/
(function() {
var params = PluginManager.parameters("InstantText");
var pInstantText = String(params["Default"]);
//=============================================================================
// ConfigManager
//=============================================================================
getDefaultInstantText = function() {
if (pInstantText.match(/true/i)) {
return true;
} else if (pInstantText.match(/false/i)) {
return false;
} else {
return Utils.isNwjs();
}
};
ConfigManager.instantText = getDefaultInstantText();
var alias_cm_md = ConfigManager.makeData;
ConfigManager.makeData = function() {
var config = alias_cm_md.call(this);
config.instantText = this.instantText;
return config;
};
var alias_cm_ad = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
alias_cm_ad.call(this, config);
this.instantText = this.readConfigInstantText(config, 'instantText');
};
ConfigManager.readConfigInstantText = function(config, name) {
var value = config[name];
if (value !== undefined) {
return value;
} else {
return getDefaultInstantText();
}
};
//=============================================================================
// Window_Options
//=============================================================================
var alias_wo_ago = Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function() {
alias_wo_ago.call(this);
this.addCommand("Instant Text", 'instantText', getDefaultInstantText());
console.log(getDefaultInstantText());
};
//=============================================================================
// Window Message
//=============================================================================
var alias_wm_udf = Window_Message.prototype.updateShowFast;
Window_Message.prototype.updateShowFast = function() {
alias_wm_udf.call(this);
if (ConfigManager.instantText === true) {
this._showFast = true
}
}
})();
Code:
//=============================================================================
// InstantText.js
//=============================================================================
/*:
@plugindesc This plugin causes text to render instantly instead of character-by-character.
@author Jatopian
@param Default
@desc Whether instant text is enabled by default in the Options menu. true / false
true - on, false - off
@default true
@help
This plugin causes text to be rendered instantly by default,
instead of one character at a time.
Player can toggle this behavior in the game's Options menu.
Developer can toggle whether the default setting is ON or OFF.
*/
(function() {
var params = PluginManager.parameters("InstantText");
var pInstantText = String(params["Default"]);
//=============================================================================
// ConfigManager
//=============================================================================
getDefaultInstantText = function() {
if (pInstantText.match(/true/i)) {
return true;
} else if (pInstantText.match(/false/i)) {
return false;
} else {
return Utils.isNwjs();
}
};
ConfigManager.instantText = getDefaultInstantText();
var alias_cm_md = ConfigManager.makeData;
ConfigManager.makeData = function() {
var config = alias_cm_md.call(this);
config.instantText = this.instantText;
return config;
};
var alias_cm_ad = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
alias_cm_ad.call(this, config);
this.instantText = this.readConfigInstantText(config, 'instantText');
};
ConfigManager.readConfigInstantText = function(config, name) {
var value = config[name];
if (value !== undefined) {
return value;
} else {
return getDefaultInstantText();
}
};
//=============================================================================
// Window_Options
//=============================================================================
var alias_wo_ago = Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function() {
alias_wo_ago.call(this);
this.addCommand("Instant Text", 'instantText', getDefaultInstantText());
console.log(getDefaultInstantText());
};
//=============================================================================
// Window Message
//=============================================================================
var alias_wm_udf = Window_Message.prototype.updateShowFast;
Window_Message.prototype.updateShowFast = function() {
alias_wm_udf.call(this);
if (ConfigManager.instantText === true) {
this._showFast = true
}
}
})();
Code:
//=============================================================================
// InstantText.js
//=============================================================================
/*:
@plugindesc This plugin causes text to render instantly instead of character-by-character.
@author Jatopian
@param Default
@desc Whether instant text is enabled by default in the Options menu. true / false
true - on, false - off
@default true
@help
This plugin causes text to be rendered instantly by default,
instead of one character at a time.
Player can toggle this behavior in the game's Options menu.
Developer can toggle whether the default setting is ON or OFF.
*/
(function() {
var params = PluginManager.parameters("InstantText");
var pInstantText = String(params["Default"]);
//=============================================================================
// ConfigManager
//=============================================================================
getDefaultInstantText = function() {
if (pInstantText.match(/true/i)) {
return true;
} else if (pInstantText.match(/false/i)) {
return false;
} else {
return Utils.isNwjs();
}
};
ConfigManager.instantText = getDefaultInstantText();
var alias_cm_md = ConfigManager.makeData;
ConfigManager.makeData = function() {
var config = alias_cm_md.call(this);
config.instantText = this.instantText;
return config;
};
var alias_cm_ad = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
alias_cm_ad.call(this, config);
this.instantText = this.readConfigInstantText(config, 'instantText');
};
ConfigManager.readConfigInstantText = function(config, name) {
var value = config[name];
if (value !== undefined) {
return value;
} else {
return getDefaultInstantText();
}
};
//=============================================================================
// Window_Options
//=============================================================================
var alias_wo_ago = Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function() {
alias_wo_ago.call(this);
this.addCommand("Instant Text", 'instantText', getDefaultInstantText());
console.log(getDefaultInstantText());
};
//=============================================================================
// Window Message
//=============================================================================
var alias_wm_udf = Window_Message.prototype.updateShowFast;
Window_Message.prototype.updateShowFast = function() {
alias_wm_udf.call(this);
if (ConfigManager.instantText === true) {
this._showFast = true
}
}
})();
While I'm here, are there any guides to plugin precedence, compatibility, or general best practices? I haven't been able to find much.