Video

This Plugin upgrades the Options Menu!
The options are placed into different categories and a description window
has been added.

Options Upgrade
Version 1.02
SumRndmDde

This Plugin upgrades the Options Menu!
The options are placed into different categories and a description window
has been added.

One may also manipulate the various positions of all the windows, and can
control the rows/colums for the category window.

==========================================================================
Setting up Categories/Descriptions
==========================================================================

By default, all of the default options have descriptions and categories
set up for them. These are all customized through the Parameters.

If an option does not have a category assigned to it, it will be placed
in the default category. If an option does not have a description, one
will not be used.

In order to assign a category or description, you'll need the symbol
for the command.

First, place the command in an Option X Symbol Parameter.

Once you do so, then the Option X Category and Option X Description will
be used with the option associated with this symbol.

==========================================================================
Window Color Customizers
==========================================================================

This plugin also adds options to change the tone of the game's windows.

You can remove these by setting the "Add Window Colors?" parameter to false.

Keep in mind that doing so may leave the "Window" category blank. Be sure
to remove the category from the list if that happens. However, you could
simply add other options to it if necessary.

==========================================================================
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,
~ SumRndmDde
var SRD = SRD || {};
SRD.OptionsUpgrade = SRD.OptionsUpgrade || {};

var Imported = Imported || {};
Imported["SumRndmDde Options Upgrade"] = 1.02;

function Window_OptionsCategory() {
	this.initialize.apply(this, arguments);
}

(function(_) {
	
"use strict";

var params = PluginManager.parameters('SRD_OptionsUpgrade');

_.categories = String(params['Categories']).split(/\s*,\s*/);
_.default = String(params['Default Category']);
_.addColors = String(params['Add Window Colors?']).trim().toLowerCase() === 'true';
_.addReset = String(params['Add Reset Option?']).trim().toLowerCase() === 'true';
_.resetName = String(params['Reset Option Name']);
_.resetSE = String(params['Reset Option SE']);


_.categoryCols = String(params['Category Window Cols']);
_.categoryRows = String(params['Category Window Rows']);
_.categoryX = String(params['Category Window X']);
_.categoryY = String(params['Category Window Y']);
_.categoryWidth = String(params['Category Window Width']);
_.categoryAlign = String(params['Category Text Align']);

_.optionsX = String(params['Options Window X']);
_.optionsY = String(params['Options Window Y']);
_.optionsWidth = String(params['Options Window Width']);

_.helpX = String(params['Help Window X']);
_.helpY = String(params['Help Window Y']);

_.windowRedText = String(params['Window Red Text'] || "Window Red");
_.windowGreenText = String(params['Window Green Text'] || "Window Green");
_.windowBlueText = String(params['Window Blue Text'] || "Window Blue");

_.commands = [];
_.comCategories = [];
_.comDescriptions = [];

for(var i = 1; i <= 50; i++) {
	var symbol = String(params['Option ' + i + ' Symbol']);
	if(symbol.trim().length > 0) {
		var category = String(params['Option ' + i + ' Category']);
		var description = String(params['Option ' + i + ' Description']).replace('\\n', '\n');
		_.commands[i - 1] = symbol;
		_.comCategories[i - 1] = category;
		_.comDescriptions[i - 1] = description;
	}
}

//-----------------------------------------------------------------------------
// Scene_Options
//-----------------------------------------------------------------------------

var _Scene_Options_create = Scene_Options.prototype.create;
Scene_Options.prototype.create = function() {
	_Scene_Options_create.apply(this, arguments);
	this.createMessageWindow();
	this._optionsWindow.deactivate();
	this._optionsWindow.deselect();
	this.createCategoryWindow();
	this.createHelpWindow();
	for(var i = 0; i < 2; i++) {
		this._helpWindow.x = eval(_.helpX);
		this._helpWindow.y = eval(_.helpY);
		this._categoryWindow.x = eval(_.categoryX);
		this._categoryWindow.y = eval(_.categoryY);
	}
	this._optionsWindow.setCategoryWindow(this._categoryWindow);
};

Scene_Options.prototype.onCategoryOk = function() {
	this._optionsWindow.activate();
	this._optionsWindow.select(0);
};

Scene_Options.prototype.onCategoryCancel = function() {
	//$gameMessage.add('Do you wish to save these settings?');
	this.popScene();
};

Scene_Options.prototype.onCategoryReset = function() {
	ConfigManager.applyData({});
	this._optionsWindow.deselect();
	this._categoryWindow.activate();
	this._helpWindow.clear();
};

Scene_Options.prototype.onOptionsCancel = function() {
	this._optionsWindow.deselect();
	this._categoryWindow.activate();
	this._helpWindow.clear();
};

var _Scene_Options_createOptionsWindow = Scene_Options.prototype.createOptionsWindow;
Scene_Options.prototype.createOptionsWindow = function() {
	_Scene_Options_createOptionsWindow.apply(this, arguments);
	this._optionsWindow.setHandler('cancel', this.onOptionsCancel.bind(this));
};

Scene_Options.prototype.createCategoryWindow = function() {
	this._categoryWindow = new Window_OptionsCategory();
	this._categoryWindow.setHandler('ok', this.onCategoryOk.bind(this));
	this._categoryWindow.setHandler('cancel', this.onCategoryCancel.bind(this));
	this._categoryWindow.setHandler('srd-reset-and-stuff', this.onCategoryReset.bind(this));
	this._categoryWindow.setOptionsWindow(this._optionsWindow);
	this.addWindow(this._categoryWindow);
};

Scene_Options.prototype.createHelpWindow = function() {
	this._helpWindow = new Window_Help();
	this._optionsWindow.setHelpWindow(this._helpWindow);
	this.addWindow(this._helpWindow);
};

Scene_Options.prototype.createMessageWindow = function() {
	this._messageWindow = new Window_Message();
	this.addWindow(this._messageWindow);
	this._messageWindow.subWindows().forEach(function(window) {
		this.addWindow(window);
	}, this);
};

//-----------------------------------------------------------------------------
// Window_OptionsCategory
//-----------------------------------------------------------------------------

Window_OptionsCategory.prototype = Object.create(Window_HorzCommand.prototype);
Window_OptionsCategory.prototype.constructor = Window_OptionsCategory;

Window_OptionsCategory.prototype.initialize = function() {
	Window_HorzCommand.prototype.initialize.call(this, 0, 0);
};

Window_OptionsCategory.prototype.windowWidth = function() {
	return eval(_.categoryWidth);
};

Window_OptionsCategory.prototype.maxCols = function() {
	return eval(_.categoryCols);
};

Window_OptionsCategory.prototype.numVisibleRows = function() {
	return eval(_.categoryRows);
};

Window_OptionsCategory.prototype.update = function() {
	Window_HorzCommand.prototype.update.call(this);
	if (this._optionsWindow && this.currentSymbol() != this._optionsWindow.getCategory()) {
		this._optionsWindow.setCategory(this.currentSymbol());
	}
};

Window_OptionsCategory.prototype.makeCommandList = function() {
	for(var i = 0; i < _.categories.length; i++) {
		this.addCommand(_.categories[i], _.categories[i]);
	}
	if(_.addReset) this.addCommand(_.resetName, 'srd-reset-and-stuff');
};

Window_OptionsCategory.prototype.setOptionsWindow = function(optionsWindow) {
	this._optionsWindow = optionsWindow;
	this.update();
};

Window_OptionsCategory.prototype.playOkSound = function() {
	if(this.currentSymbol() != 'srd-reset-and-stuff') {
		SoundManager.playOk();
	} else {
		AudioManager.playSe({"name":_.resetSE,"pan":0,"pitch":100,"volume":100});
	}
};

Window_OptionsCategory.prototype.itemTextAlign = function() {
	return _.categoryAlign;
};

//-----------------------------------------------------------------------------
// Window_Options
//-----------------------------------------------------------------------------

var _Window_Options_initialize = Window_Options.prototype.initialize;
Window_Options.prototype.initialize = function() {
	this._category = _.comCategories[0];
	_Window_Options_initialize.apply(this, arguments);
	this.refresh();
};

Window_Options.prototype.windowWidth = function() {
	return eval(_.optionsWidth);
};

Window_Options.prototype.setCategory = function(category) {
	this._category = category;
	this.refresh();
};

Window_Options.prototype.getCategory = function() {
	return this._category;
};

Window_Options.prototype.updatePlacement = function() {
	if(this._helpWindow && this._categoryWindow) {
		this.x = eval(_.optionsX);
		this.y = eval(_.optionsY);
	}
};

var _Window_Command_addCommand = Window_Command.prototype.addCommand;
Window_Options.prototype.addCommand = function(name, symbol, enabled, ext) {
	var index = _.commands.indexOf(symbol);
	if(index < 0 && this._category != _.default) return;
	if(index >= 0 && this._category != _.comCategories[index]) return;
	_Window_Command_addCommand.apply(this, arguments);
};

Window_Options.prototype.makeCommandList = function() {
	this.addGeneralOptions();
	this.addVolumeOptions();
	if(_.addColors) {
		this.addCommand(_.windowRedText, 'windowRed');
		this.addCommand(_.windowGreenText, 'windowGreen');
		this.addCommand(_.windowBlueText, 'windowBlue');
	}
};

Window_Options.prototype.updateHelp = function() {
	if(this._helpWindow) {
		var index = _.commands.indexOf(this.currentData() ? this.currentData().symbol : '');
		this._helpWindow.setText(_.comDescriptions[index]);
	}
};

Window_Options.prototype.updateHeight = function() {
	if(this.height != this.windowHeight()) {
		this.height = this.windowHeight();
	}
	if(this._list.length <= 0) {
		this.visible = false;
	} else {
		this.visible = true;
	}
};

Window_Options.prototype.setHelpWindow = function(window) {
	this._helpWindow = window;
	this.updateHelp();
};

Window_Options.prototype.setCategoryWindow = function(window) {
	this._categoryWindow = window;
	this.updatePlacement();
};

Window_Options.prototype.refresh = function() {
	this.clearCommandList();
	this.makeCommandList();
	this.updateHeight();
	this.createContents();
	this.drawAllItems();
};

if(_.addColors) {

var _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.isWindowColorSymbol(symbol)) {
		return this.windowColorStatusText(value);
	} else {
		return _Window_Options_statusText.apply(this, arguments);
	}
};

Window_Options.prototype.isWindowColorSymbol = function(symbol) {
	return symbol === 'windowRed' || symbol === 'windowGreen' || symbol === 'windowBlue';
};

Window_Options.prototype.windowColorStatusText = function(value) {
	return value;
};

var _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);
	if (this.isWindowColorSymbol(symbol)) {
		value += 5;
		if (value > 255) {
			value = 0;
		}
		value = value.clamp(-255, 255);
		this.changeValue(symbol, value);
	} else {
		_Window_Options_processOk.apply(this, arguments);
	}
};

var _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);
	if (this.isWindowColorSymbol(symbol)) {
		value += 5;
		value = value.clamp(-255, 255);
		this.changeValue(symbol, value);
	} else {
		_Window_Options_cursorRight.apply(this, arguments);
	}
};

var _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);
	if (this.isWindowColorSymbol(symbol)) {
		value -= 5;
		value = value.clamp(-255, 255);
		this.changeValue(symbol, value);
	} else {
		_Window_Options_cursorLeft.apply(this, arguments);
	}
};

//-----------------------------------------------------------------------------
// Game_System
//-----------------------------------------------------------------------------

var _Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
	_Game_System_initialize.apply(this, arguments);
	this.setWindowTone([ConfigManager._windowRed, ConfigManager._windowGreen, ConfigManager._windowBlue]);
};

//-----------------------------------------------------------------------------
// ConfigManager
//-----------------------------------------------------------------------------

ConfigManager._windowRed = 0;
ConfigManager._windowGreen = 0;
ConfigManager._windowBlue = 0;

Object.defineProperty(ConfigManager, 'windowRed', {
	get: function() {
		return $gameSystem ? $gameSystem.windowTone()[0] : this._windowRed;
	},
	set: function(value) {
		if($gameSystem) {
			$gameSystem.windowTone()[0] = value;
		} else {
			this._windowRed = value;
		}
	},
	configurable: true
});

Object.defineProperty(ConfigManager, 'windowGreen', {
	get: function() {
		return $gameSystem ? $gameSystem.windowTone()[1] : this._windowGreen;
	},
	set: function(value) {
		if($gameSystem) {
			$gameSystem.windowTone()[1] = value;
		} else {
			this._windowGreen = value;
		}
	},
	configurable: true
});

Object.defineProperty(ConfigManager, 'windowBlue', {
	get: function() {
		return $gameSystem ? $gameSystem.windowTone()[2] : this._windowBlue;
	},
	set: function(value) {
		if($gameSystem) {
			$gameSystem.windowTone()[2] = value;
		} else {
			this._windowBlue = value;
		}
	},
	configurable: true
});

var _ConfigManager_makeData = ConfigManager.makeData;
ConfigManager.makeData = function() {
	var config = _ConfigManager_makeData.apply(this, arguments);
	config.windowRed = this.windowRed;
	config.windowGreen = this.windowGreen;
	config.windowBlue = this.windowBlue;
	return config;
};

var _ConfigManager_applyData = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
	_ConfigManager_applyData.apply(this, arguments);
	this.windowRed = this.readWindowColors(config, 'windowRed');
	this.windowGreen = this.readWindowColors(config, 'windowGreen');
	this.windowBlue = this.readWindowColors(config, 'windowBlue');
};

ConfigManager.readWindowColors = function(config, name) {
	var value = config[name];
	if (value !== undefined) {
		return parseInt(value).clamp(-255, 255);
	} else {
		return 0;
	}
};

}

})(SRD.OptionsUpgrade);