Option Name
The name used by the Font option.
This Plugin adds a Font selector to the Options Window that allows the Player to choose a Font for the game.
Font Option
Version 1.01
SomeRanDev
This Plugin adds a Font selector to the Options Window that allows
the Player to choose a Font for the game.
==============================================================================
How to Set up the Images
==============================================================================
First place all of the Font files you wish to use in:
/fonts/
The default font file (mplus-1m-regular.ttf) should remain within the folder!
==============================================================================
How to Set up the Options
==============================================================================
Next, in order to set up the order and the names for the Fonts in the
Options Menu, you must use the Parameters.
It is manadatory that one Font at least the default font should exist!
Using the "Default Font Name" Parameter, you can give that font a specific
name when selected in the Options Menu.
Next, you can set up the choices by filling out the "Font" sections.
Using "Font # File", input the name of a Font file (including extension) from
the fonts folder!
Next, use "Font # Name", set the name of that Font that will be displayed
in the Options Menu. This will also be the name of the font that can be
accessed using other plugins, so similarly, this can be used to preload
fonts.
Once you have filled out both Parameters for one "Font" section,
it will be available in the Options Menu in game.
==============================================================================
Switches
==============================================================================
If you wish for a Font option to only be available once a Switch is turned
ON, input the Switch's ID within the "Font # Switch" Parameter.
Once done, that Switch must be turned ON for that Font to appear!
Use this to create unlockable or purchasable fonts!
==============================================================================
End of Help File
==============================================================================
Welcome to the bottom of the Help file.
Thanks for reading!
If you have questions, or if you enjoyed this Plugin, please check
out my YouTube channel!
https://www.youtube.com/c/SumRndmDde
Until next time,
~ SomeRanDev
var SRD = SRD || {};
SRD.FontOption = SRD.FontOption || {};
var Imported = Imported || {};
Imported["SumRndmDde Font Option"] = 1.01;
(function(_) {
"use strict";
//-----------------------------------------------------------------------------
// SRD.FontOption
//-----------------------------------------------------------------------------
const params = PluginManager.parameters('SRD_FontOption');
_.name = String(params['Option Name']);
_.position = String(params['Position']).trim().toLowerCase();
_.defaultName = String(params['Default Font Name']);
_.index = 0;
_.lowest = 0;
_.fonts = [""];
_.names = [_.defaultName];
_.switches = [0];
for(var i = 1; i <= 50; i++) {
var file = String(params['Font ' + i + ' File']);
var name = String(params['Font ' + i + ' Name']);
var swit = parseInt(params['Font ' + i + ' Switch']);
if(file.trim().length > 0 && name.trim().length > 0) {
_.fonts[i] = file;
_.names[i] = name;
Graphics.loadFont(name, 'fonts/' + file);
}
if(swit) _.switches[i] = swit;
}
_.fixIndex = function() {
while((_.switches[_.index] && _.switches[_.index] != 0) && (!$gameSwitches || !$gameSwitches.value(_.switches[_.index]))) {
_.index++;
if(_.index > _.fonts.length - 1) _.index = 0;
}
};
_.changeIndex = function(value) {
_.index = Number(value).clamp(_.lowest, _.fonts.length - 1);
while((_.switches[_.index] && _.switches[_.index] != 0) && (!$gameSwitches || !$gameSwitches.value(_.switches[_.index]))) {
_.index++;
if(_.index > _.fonts.length - 1) _.index = 0;
}
};
_.refreshAllWindows = function() {
const scene = SceneManager._scene;
if(scene && scene._windowLayer) {
const layer = scene._windowLayer;
if(!layer.children) return;
layer.children.forEach(function(win) {
win.resetFontSettings();
if(win.refresh) win.refresh();
})
}
};
//-----------------------------------------------------------------------------
// ConfigManager
//-----------------------------------------------------------------------------
Object.defineProperty(ConfigManager, 'fontStyle', {
get: function() {
_.fixIndex();
return _.index;
},
set: function(value) {
_.changeIndex(value);
_.refreshAllWindows();
},
configurable: true
});
_.ConfigManager_makeData = ConfigManager.makeData;
ConfigManager.makeData = function() {
var config = _.ConfigManager_makeData.call(this);
config.fontStyle = this.fontStyle;
return config;
};
_.ConfigManager_applyData = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
_.ConfigManager_applyData.call(this, config);
this.fontStyle = this.readFontStyle(config, 'fontStyle');
};
ConfigManager.readFontStyle = function(config, name) {
var value = config[name];
if (value !== undefined) {
return value;
} else {
return _.lowest;
}
};
//-----------------------------------------------------------------------------
// Window_Base
//-----------------------------------------------------------------------------
_.Window_Base_resetFontSettings = Window_Base.prototype.resetFontSettings;
Window_Base.prototype.resetFontSettings = function() {
_.Window_Base_resetFontSettings.apply(this, arguments);
this.loadOptionsFont();
};
Window_Base.prototype.loadOptionsFont = function() {
if(_.fonts[_.index]) {
this.contents.fontFace = _.names[_.index];
}
};
//-----------------------------------------------------------------------------
// Window_Options
//-----------------------------------------------------------------------------
_.Window_Options_addGeneralOptions = Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function() {
_.Window_Options_addGeneralOptions.call(this);
if(_.position === 'middle') {
this.addCommand(_.name, 'fontStyle');
}
};
_.Window_Options_makeCommandList = Window_Options.prototype.makeCommandList;
Window_Options.prototype.makeCommandList = function() {
if(_.position === 'top') {
this.addCommand(_.name, 'fontStyle');
}
_.Window_Options_makeCommandList.call(this);
};
_.Window_Options_addVolumeOptions = Window_Options.prototype.addVolumeOptions;
Window_Options.prototype.addVolumeOptions = function() {
_.Window_Options_addVolumeOptions.call(this);
if(_.position === 'bottom') {
this.addCommand(_.name, 'fontStyle');
}
};
_.Window_Options_statusText = Window_Options.prototype.statusText;
Window_Options.prototype.statusText = function(index) {
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
if(this.isFontSymbol(symbol)) {
return this.fontStyleStatusText(value);
}
return _.Window_Options_statusText.call(this, index);
};
Window_Options.prototype.isFontSymbol = function(symbol) {
return symbol === 'fontStyle';
};
Window_Options.prototype.fontStyleStatusText = function(value) {
return _.names[value];
};
_.Window_Options_processOk = Window_Options.prototype.processOk;
Window_Options.prototype.processOk = function() {
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
_.Window_Options_processOk.call(this);
if(this.isFontSymbol(symbol)) {
value += 1;
if(value >= _.fonts.length) value = _.lowest;
this.changeValue(symbol, value);
}
};
_.Window_Options_cursorRight = Window_Options.prototype.cursorRight;
Window_Options.prototype.cursorRight = function(wrap) {
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
_.Window_Options_cursorRight.call(this, wrap);
if(this.isFontSymbol(symbol)) {
value += 1;
this.changeValue(symbol, value);
}
};
_.Window_Options_cursorLeft = Window_Options.prototype.cursorLeft;
Window_Options.prototype.cursorLeft = function(wrap) {
var index = this.index();
var symbol = this.commandSymbol(index);
var value = this.getConfigValue(symbol);
_.Window_Options_cursorLeft.call(this, wrap);
if(this.isFontSymbol(symbol)) {
value -= 1;
this.changeValue(symbol, value);
}
};
})(SRD.FontOption);