Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*:
- * @plugindesc v1.00 Extends the ingame options menu with some optional entries regarding the minimap.
- * <Iavra Minimap Menu>
- * @author Iavra
- *
- * @param Label Zoom
- * @desc Label to be used for the minimaps zoom. Leave empty to disable this option.
- * @default
- *
- * @param Label Opacity
- * @desc Label to be used for the minimaps opacity. Leave empty to disable this option.
- * @default
- *
- * @help
- * Make minimap zoom and/or opacity configurable via the ingame Options menu by specifying the label texts to be
- * shown. Leave a label empty to disable the option.
- */
- (function($, undefined) {
- "use strict";
- /**
- * Basic helper function to extend objects. Mainly used for inheritance and other prototype-related operations.
- */
- $._extend || ($._extend = function(b, e) { for(var k in e) { b[k] = e[k]; } return b; });
- /**
- * Reading plugin parameters.
- */
- var _params = $plugins.filter(function(p) { return p.description.contains('<Iavra Minimap Menu>'); })[0].parameters;
- var _label_zoom = _params['Label Zoom'];
- var _label_opacity = _params['Label Opacity'];
- //=============================================================================
- // ConfigManager
- //=============================================================================
- /**
- * Store minimap data in the persistent configuration data.
- */
- var _configManager_makeData = ConfigManager.makeData;
- ConfigManager.makeData = function() {
- var config = _configManager_makeData.call(this);
- config._iavra_minimap_zoom = this._iavra_minimap_zoom;
- config._iavra_minimap_opacity = this._iavra_minimap_opacity;
- };
- /**
- * Read configuration data and extract minimap data, if present.
- */
- var _configManager_applyData = ConfigManager.applyData;
- ConfigManager.applyData = function(config) {
- _configManager_applyData.call(this, config);
- if(config._iavra_minimap_zoom !== undefined) { this._iavra_minimap_zoom = config._iavra_minimap_zoom; }
- if(config._iavra_minimap_opacity !== undefined) { this._iavra_minimap_opacity = config._iavra_minimap_opacity; }
- };
- /**
- * Add new properties to the ConfigManager.
- */
- Object.defineProperties(ConfigManager, {
- _iavra_minimap_zoom: {
- get: function() { return $.MINIMAP.zoom; },
- set: function(value) { $.MINIMAP.zoom = value; }
- },
- _iavra_minimap_opacity: {
- get: function() { return $.MINIMAP.opacity; },
- set: function(value) { $.MINIMAP.opacity = value; }
- }
- });
- //=============================================================================
- // Window_Options
- //=============================================================================
- /**
- * If the labels for minimap zoom and/or opacity are given, add new entries in the Options window.
- */
- var _windowOptions_makeCommandList = Window_Options.prototype.makeCommandList;
- Window_Options.prototype.makeCommandList = function() {
- _windowOptions_makeCommandList.call(this);
- if(_label_zoom) { this.addCommand(_label_zoom, '_iavra_minimap_zoom'); }
- if(_label_opacity) { this.addCommand(_label_opacity, '_iavra_minimap_opacity'); }
- };
- /**
- * Convert the minimap configuration data to percent, cutting off decimal in case rounding errors.
- */
- var _windowOptions_statusText = Window_Options.prototype.statusText;
- Window_Options.prototype.statusText = function(index) {
- var s = this.commandSymbol(index), v = this.getConfigValue(s);
- if(s === '_iavra_minimap_zoom' || s === '_iavra_minimap_opacity') { return (v * 100).toFixed(0) + "%"; }
- return _windowOptions_statusText.call(this, index);
- };
- /**
- * On enter, increase the data by 10%.
- */
- var _windowOptions_processOk = Window_Options.prototype.processOk;
- Window_Options.prototype.processOk = function() {
- return this._iavra_minimap_changeValue(0.1) || _windowOptions_processOk.call(this);
- };
- /**
- * On right, increase the data by 10%.
- */
- var _windowOptions_cursorRight = Window_Options.prototype.cursorRight;
- Window_Options.prototype.cursorRight = function(wrap) {
- return this._iavra_minimap_changeValue(0.1) || _windowOptions_cursorRight.call(this, wrap);
- };
- /**
- * On left, decrease the data by 10%.
- */
- var _windowOptions_cursorLeft = Window_Options.prototype.cursorLeft;
- Window_Options.prototype.cursorLeft = function(wrap) {
- return this._iavra_minimap_changeValue(-0.1) || _windowOptions_cursorLeft.call(this, wrap);
- };
- /**
- * Apply the requested change to minimap configuration data.
- */
- Window_Options.prototype._iavra_minimap_changeValue = function(offset) {
- var s = this.commandSymbol(this.index()), v = this.getConfigValue(s);
- if(s === '_iavra_minimap_zoom') { this.changeValue(s, v + offset); return true; }
- if(s === '_iavra_minimap_opacity') { this.changeValue(s, v + offset); return true; }
- };
- })(this.IAVRA || (this.IAVRA = {}));
Add Comment
Please, Sign In to add comment