/*:
* @target MZ
* @plugindesc Adds map name, variable, and playtime displays to the pause menu.
* @author Caethyril
* @url https://forums.rpgmakerweb.com/index.php?threads/140600/
* @help Leave a format string blank to hide that window.
*
* Free to use and/or modify for any project, no credit required.
*
* @param Format: Map Name
* @type string
* @desc Format string for the map name display.
* %1 = map display name, %2 = map ID.
* @default %1
*
* @param Format: Variable
* @type string
* @desc Format string for the variable display.
* %1 = variable name, %2 = variable value.
* @default \c[4]%1\c[0]: %2
*
* @param Variable ID
* @parent Format: Variable
* @type variable
* @desc The game variable to display.
* @default 0
*
* @param Format: Playtime
* @type string
* @desc Format string for the playtime display.
* %1 = play time (as shown on save screen).
* @default %1
*/
void (() => {
'use strict';
// Get plugin params.
const PLUGIN_NAME = 'PauseMenuInfos';
const P = PluginManager.parameters(PLUGIN_NAME);
// Parse/store params.
const [fA, fB, iB, fC] = [
P['Format: Map Name'],
P['Format: Variable'],
parseInt(P['Variable ID'], 10) || 0,
P['Format: Playtime']
];
// Validity checks.
const [hA, hB, hC] = [
fA ? 1 : 0,
fB && iB ? 1 : 0,
fC ? 1 : 0
];
const hTotal = hA + hB + hC;
// Inheritance base for new windows.
const _BASE = Window_Gold.prototype;
// ===== Map Name ===== //
const A = globalThis.Window_MenuMapName_Cae = function() {
this.initialize(...arguments);
};
const Ap = A.prototype = Object.create(_BASE);
Ap.constructor = A;
Ap.refresh = function() {
const rect = this.itemLineRect(0);
this.contents.clear();
this.drawTextEx(this.value(), rect.x, rect.y, rect.width);
};
Ap.value = function() {
return fA.format($gameMap?.displayName(), $gameMap.mapId());
};
// ===== Variable ===== //
const B = globalThis.Window_MenuMapVar_Cae = function() {
this.initialize(...arguments);
};
const Bp = B.prototype = Object.create(_BASE);
Bp.constructor = B;
Bp.refresh = Ap.refresh;
Bp.value = function() {
return fB.format($dataSystem.variables[iB], $gameVariables.value(iB));
};
// ===== Playtime ===== //
const C = globalThis.Window_MenuMapPlaytime_Cae = function() {
this.initialize(...arguments);
};
const Cp = C.prototype = Object.create(_BASE);
Cp.constructor = C;
// Auto-refresh.
Cp.update = function() {
_BASE.update.apply(this, arguments);
if ($gameSystem.playtime() !== this._cache)
this.refresh();
};
Cp.refresh = function() {
Ap.refresh.apply(this, arguments);
this._cache = $gameSystem.playtime();
};
Cp.value = function() {
return fC.format($gameSystem.playtimeText());
};
// ======= Menu ======= //
// Patch - add new windows.
void (alias => {
Scene_Menu.prototype.create = function() {
alias.apply(this, arguments);
const rect = this.goldWindowRect();
if (hC) {
rect.y -= rect.height;
this.addWindow(this._playtimeWindowCae = new C(rect));
}
if (hB) {
rect.y -= rect.height;
this.addWindow(this._varWindowCae = new B(rect));
}
if (hA) {
rect.y -= rect.height;
this.addWindow(this._mapNameWindowCae = new A(rect));
}
};
})(Scene_Menu.prototype.create);
// Patch - reduce command window height.
void (alias => {
Scene_Menu.prototype.commandWindowRect = function() {
const rect = alias.apply(this, arguments);
rect.height -= hTotal * this.goldWindowRect().height;
return rect;
};
})(Scene_Menu.prototype.commandWindowRect);
})();