Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Imported = Imported || {};
- Imported.Coolie_BattleTurnCount = true;
- var Coolie = Coolie || {};
- Coolie.BTW = Coolie.BTW || {};
- Coolie.BTW.version = 2.00;
- /*:
- * @plugindesc v2.00 Display a turn count window in battle
- * @author Coolie (William Couillard)
- *
- * @help
- * =============================================================================
- * ABOUT THIS PLUGIN (Coolie_BattleTurnCount)
- * =============================================================================
- * Adds a window to Scene_Battle that shows the current turn count.
- *
- * =============================================================================
- * PLUGIN PARAMETERS
- * =============================================================================
- * This window position is customizable through Plugin Parameters, as well as
- * the text string used to represent the Turn Count.
- *
- * Escape codes can be used.
- *
- * =============================================================================
- * PLUGIN COMMANDS
- * =============================================================================
- * ShowTurnCount
- *
- * The above Plugin Command will force the Turn Count window to open.
- *
- * HideTurnCount
- *
- * The above Plugin Command will force the Turn Count window to close. Both
- * Plugin Commands are case-insensitive and will only work during battle.
- *
- * =============================================================================
- * TERMS OF USE
- * =============================================================================
- * This plugin, 'Coolie_BattleTurnCount v2.00', is OK to use in commercial and
- * non-commercial projects, free of charge.
- *
- * It is prohibited to redistribute this plugin, or copy JavaScript from it for
- * use elsewhere.
- *
- * =============================================================================
- * TIPS
- * =============================================================================
- * - If you are using AB_EnemyBook plugin, place this plugin ABOVE it to avoid
- * a visual bug.
- *
- * - If you are using Nasty Replace Window With Picture plugin, the name of the
- * window to use is Window_TurnCount.
- *
- * =============================================================================
- * VERSION & UPDATE HISTORY
- * =============================================================================
- * > v2.0 : New Parameters added, Plugin Commands added, bugfixes
- * > October 6th, 2025
- *
- * > v1.0 : Initial Release
- * > September 16th, 2021
- *
- * @param General Settings
- *
- * @param Hide On Skill/Item
- * @parent General Settings
- * @type boolean
- * @desc Should the turn count window close while the skill or item window is open?
- * Default: true
- * @default true
- *
- * @param Window Settings
- *
- * @param Window Width
- * @parent Window Settings
- * @type number
- * @min 0
- * @desc The width, in pixels, of the Turn Count Window.
- * Default: 160
- * @default 160
- *
- * @param Window X Position
- * @parent Window Settings
- * @type number
- * @min 0
- * @desc The X position, in pixels, of the Turn Count Window.
- * Default: 0
- * @default 0
- *
- * @param Window Y Position
- * @parent Window Settings
- * @type number
- * @min 0
- * @desc The Y position, in pixels, of the Turn Count Window.
- * Default: 372
- * @default 372
- *
- * @param Window Opacity
- * @parent Window Settings
- * @type number
- * @min 0
- * @max 255
- * @desc The window's overall opacity (0 = fully transparent, 255 = fully opaque)
- * @default 255
- *
- * @param Window Back Opacity
- * @parent Window Settings
- * @type number
- * @min 0
- * @max 255
- * @desc The window's background opacity (0 = fully transparent, 255 = fully opaque)
- * @default 192
- *
- * @param Use Battlelog Style
- * @parent Window Settings
- * @type boolean
- * @desc If true, the window will use the same style as the BattleLog window (faded black bar, no frame)
- * @default false
- *
- * @param Text Settings
- *
- * @param Window Text
- * @parent Text Settings
- * @type text
- * @desc The label to show before the turn number. Escape codes can be used.
- * Default: Turn
- * @default Turn
- */
- // =============================================================================
- // Plugin Parameters
- // =============================================================================
- Coolie.Parameters = PluginManager.parameters('Coolie_BattleTurnCount');
- Coolie.Param = Coolie.Param || {};
- Coolie.Param.BTWHideOnSkillItem = String(Coolie.Parameters['Hide On Skill/Item']).toLowerCase() === 'true';
- Coolie.Param.BTWWindowWidth = Number(Coolie.Parameters['Window Width']);
- Coolie.Param.BTWWindowX = Number(Coolie.Parameters['Window X Position']);
- Coolie.Param.BTWWindowY = Number(Coolie.Parameters['Window Y Position']);
- Coolie.Param.BTWWindowOpacity = Number(Coolie.Parameters['Window Opacity'] || 255);
- Coolie.Param.BTWWindowBackOpacity = Number(Coolie.Parameters['Window Back Opacity'] || 192);
- Coolie.Param.BTWUseBattleLogStyle = String(Coolie.Parameters['Use Battlelog Style']).toLowerCase() === 'true';
- Coolie.Param.BTWWindowText = String(Coolie.Parameters['Window Text']);
- // =============================================================================
- // Window_TurnCount
- // =============================================================================
- function Window_TurnCount() {
- this.initialize.apply(this, arguments);
- }
- Window_TurnCount.prototype = Object.create(Window_Selectable.prototype);
- Window_TurnCount.prototype.constructor = Window_TurnCount;
- // =============================================================================
- // Window_TurnCount (initialize)
- // =============================================================================
- Window_TurnCount.prototype.initialize = function() {
- var x = Coolie.Param.BTWWindowX;
- var y = Coolie.Param.BTWWindowY;
- var width = Coolie.Param.BTWWindowWidth;
- var height = this.fittingHeight(1);
- Window_Selectable.prototype.initialize.call(this, x, y, width, height);
- // Opacity
- this.opacity = Coolie.Param.BTWWindowOpacity;
- this.backOpacity = Coolie.Param.BTWWindowBackOpacity;
- // BattleLog Style
- if (Coolie.Param.BTWUseBattleLogStyle) {
- this.opacity = 0;
- this.backOpacity = 0;
- this._battleLogStyle = true;
- } else {
- this._battleLogStyle = false;
- }
- this.refresh();
- };
- // =============================================================================
- // Window_TurnCount (refresh)
- // =============================================================================
- Window_TurnCount.prototype.refresh = function() {
- var x = 0;
- var y = 0;
- var text = Coolie.Param.BTWWindowText;
- var turnNum = Math.floor($gameTroop.turnCount() + 1).toString();
- this.contents.clear();
- this.drawBackground();
- this.drawTextEx(text + ' ' + turnNum, x + 4, y);
- };
- // =============================================================================
- // Window_TurnCount (open)
- // =============================================================================
- Window_TurnCount.prototype.open = function() {
- this.refresh();
- Window_Selectable.prototype.open.call(this);
- };
- // =============================================================================
- // Window_TurnCount (drawBackground)
- // =============================================================================
- Window_TurnCount.prototype.drawBackground = function() {
- if (this._battleLogStyle) {
- var rect = this.contents.rect;
- var x = 0;
- var y = 0;
- var width = this.contentsWidth();
- var height = this.contentsHeight();
- this.contents.paintOpacity = 160;
- this.contents.fillRect(x, y, width, height, '#000000');
- this.contents.paintOpacity = 255;
- }
- };
- // =============================================================================
- // Scene_Battle (createAllWindows)
- // =============================================================================
- var alias_Coolie_BattleTurnCount_createAllWindows = Scene_Battle.prototype.createAllWindows;
- Scene_Battle.prototype.createAllWindows = function() {
- alias_Coolie_BattleTurnCount_createAllWindows.call(this);
- this.createTurnsWindow();
- };
- // =============================================================================
- // Scene_Battle (createTurnsWindow)
- // =============================================================================
- Scene_Battle.prototype.createTurnsWindow = function() {
- this._turnsWindow = new Window_TurnCount();
- this.addWindow(this._turnsWindow);
- this._turnsWindow.open();
- };
- // =============================================================================
- // Scene_Battle (refreshTurnCount)
- // =============================================================================
- Scene_Battle.prototype.refreshTurnCount = function() {
- this._turnsWindow.refresh();
- };
- // =============================================================================
- // Scene_Battle (startPartyCommandSelection)
- // =============================================================================
- var alias_Coolie_BattleTurnCount_startPartyCommandSelection = Scene_Battle.prototype.startPartyCommandSelection;
- Scene_Battle.prototype.startPartyCommandSelection = function() {
- alias_Coolie_BattleTurnCount_startPartyCommandSelection.call(this);
- this.refreshTurnCount();
- };
- // =============================================================================
- // Scene_Battle (terminate)
- // =============================================================================
- var alias_Coolie_BattleTurnCount_terminate = Scene_Battle.prototype.terminate;
- Scene_Battle.prototype.terminate = function() {
- if (this._turnsWindow) this._turnsWindow.close();
- alias_Coolie_BattleTurnCount_terminate.call(this);
- };
- // =============================================================================
- // Scene_Battle (commandSkill)
- // =============================================================================
- var _Coolie_BTW_commandSkill = Scene_Battle.prototype.commandSkill;
- Scene_Battle.prototype.commandSkill = function() {
- if (Coolie.Param.BTWHideOnSkillItem && this._turnsWindow) this._turnsWindow.close();
- _Coolie_BTW_commandSkill.apply(this, arguments);
- };
- // =============================================================================
- // Scene_Battle (commandItem)
- // =============================================================================
- var _Coolie_BTW_commandItem = Scene_Battle.prototype.commandItem;
- Scene_Battle.prototype.commandItem = function() {
- if (Coolie.Param.BTWHideOnSkillItem && this._turnsWindow) this._turnsWindow.close();
- _Coolie_BTW_commandItem.apply(this, arguments);
- };
- // =============================================================================
- // Scene_Battle (onSkillCancel)
- // =============================================================================
- var _Coolie_BTW_onSkillCancel = Scene_Battle.prototype.onSkillCancel;
- Scene_Battle.prototype.onSkillCancel = function() {
- _Coolie_BTW_onSkillCancel.apply(this, arguments);
- if (Coolie.Param.BTWHideOnSkillItem && this._turnsWindow) this._turnsWindow.open();
- };
- // =============================================================================
- // Scene_Battle (onItemCancel)
- // =============================================================================
- var _Coolie_BTW_onItemCancel = Scene_Battle.prototype.onItemCancel;
- Scene_Battle.prototype.onItemCancel = function() {
- _Coolie_BTW_onItemCancel.apply(this, arguments);
- if (Coolie.Param.BTWHideOnSkillItem && this._turnsWindow) this._turnsWindow.open();
- };
- // =============================================================================
- // Scene_Battle (startActorCommandSelection)
- // =============================================================================
- var _Coolie_BTW_startActorCommandSelection = Scene_Battle.prototype.startActorCommandSelection;
- Scene_Battle.prototype.startActorCommandSelection = function() {
- _Coolie_BTW_startActorCommandSelection.apply(this, arguments);
- if (Coolie.Param.BTWHideOnSkillItem && this._turnsWindow) this._turnsWindow.open();
- };
- // =============================================================================
- // Plugin Command: ShowTurnCount / HideTurnCount
- // =============================================================================
- var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- _Game_Interpreter_pluginCommand.apply(this, arguments);
- if (!SceneManager._scene || !SceneManager._scene._turnsWindow) return;
- switch (command.toLowerCase()) {
- case 'showturncount':
- SceneManager._scene._turnsWindow.open();
- break;
- case 'hideturncount':
- SceneManager._scene._turnsWindow.close();
- break;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment