151 lines
5.1 KiB
JavaScript
151 lines
5.1 KiB
JavaScript
//=============================================================================
|
||
// RPG Maker MZ - FpsOptionPlus
|
||
//=============================================================================
|
||
|
||
/*:
|
||
* @target MZ
|
||
* @plugindesc 最大FPSを変更するオプション項目を追加します。
|
||
* @author econa(ecoddr)
|
||
*
|
||
* @param OptionName
|
||
* @type string
|
||
* @default FPS 調整
|
||
* @desc オプションに表示する項目テキストを設定します。
|
||
*
|
||
* @help FpsOptionPlus.js
|
||
*
|
||
* このプラグインは、オプションに最大FPSを変更する項目を追加します。
|
||
*
|
||
* 機能をオンにすると、オプション画面の末尾に
|
||
* 最大FPSを「60Fps」「30Fps」「15Fps」の3通りに変更する項目が追加されます。
|
||
*
|
||
*/
|
||
|
||
(() => {
|
||
const _FpsConfigSymbol = 'fpsChanger';
|
||
ConfigManager[_FpsConfigSymbol] = 0;
|
||
|
||
const _Graphics_onTick = Graphics._onTick;
|
||
Graphics._onTick = function (deltaTime) {
|
||
if (ConfigManager[_FpsConfigSymbol] != null) {
|
||
if (Graphics.frameCount % (ConfigManager[_FpsConfigSymbol] * 2) > 0) {
|
||
if (this._tickHandler) {
|
||
this._tickHandler(deltaTime);
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
_Graphics_onTick.apply(this, arguments);
|
||
};
|
||
|
||
// const _Window_Options_makeCommandList = Window_Options.prototype.makeCommandList;
|
||
// Window_Options.prototype.makeCommandList = function () {
|
||
// _Window_Options_makeCommandList.apply(this, arguments);
|
||
// this.addFpsOptions();
|
||
// };
|
||
|
||
// Window_Options.prototype.addFpsOptions = function () {
|
||
// this.addCommand(this.fpsConfigName(), "fpsChanger");
|
||
// }
|
||
|
||
Window_Options.prototype.fpsConfigName = function () {
|
||
const option = PluginManager.parameters('FpsOptionPlus');
|
||
if (option) {
|
||
const optionName = PluginManager.parameters('FpsOptionPlus').OptionName;
|
||
if (optionName) {
|
||
return optionName;
|
||
}
|
||
}
|
||
console.debug("FpsOptionPlusのOptionNameプロパティがない");
|
||
return "";
|
||
};
|
||
|
||
const _Window_Options_statusText = Window_Options.prototype.statusText;
|
||
Window_Options.prototype.statusText = function (index) {
|
||
const symbol = this.commandSymbol(index);
|
||
const value = this.getConfigValue(symbol);
|
||
if (symbol == _FpsConfigSymbol) {
|
||
return this.fpsText(value);
|
||
}
|
||
return _Window_Options_statusText.apply(this, arguments);
|
||
};
|
||
|
||
Window_Options.prototype.fpsText = function (type) {
|
||
switch (type) {
|
||
case 0: // 60
|
||
return '60Fps';
|
||
case 1: // 30
|
||
return '60Fps';
|
||
case 2: // 15
|
||
return '60Fps';
|
||
}
|
||
}
|
||
|
||
const Window_Options_changeValue = Window_Options.prototype.changeValue;
|
||
Window_Options.prototype.changeValue = function (symbol, value) {
|
||
if (symbol == _FpsConfigSymbol) {
|
||
const lastValue = this.getConfigValue(symbol);
|
||
if (lastValue !== value) {
|
||
const isChanged = this.setFpsConfigValue(symbol, value);
|
||
if (isChanged) {
|
||
this.redrawItem(this.findSymbol(symbol));
|
||
this.playCursorSound();
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
Window_Options_changeValue.apply(this, arguments);
|
||
};
|
||
|
||
Window_Options.prototype.setFpsConfigValue = function (symbol, value) {
|
||
let isChanged = false;
|
||
if (value && ConfigManager[symbol] < 2) {
|
||
ConfigManager[symbol] += 1;
|
||
isChanged = true;
|
||
} else if (value == false && ConfigManager[symbol] > 0) {
|
||
ConfigManager[symbol] -= 1;
|
||
isChanged = true;
|
||
}
|
||
if (isChanged) {
|
||
ConfigManager[symbol] = ConfigManager[symbol].clamp(0, 2);
|
||
}
|
||
return isChanged;
|
||
}
|
||
|
||
const _Scene_Options_maxCommands = Scene_Options.prototype.maxCommands;
|
||
Scene_Options.prototype.maxCommands = function () {
|
||
let length = _Scene_Options_maxCommands.apply(this, arguments);
|
||
// Increase this value when adding option items.
|
||
return length + 1;
|
||
};
|
||
|
||
const _ConfigManager_makeData = ConfigManager.makeData;
|
||
ConfigManager.makeData = function() {
|
||
const config = {};
|
||
config.alwaysDash = this.alwaysDash;
|
||
config.commandRemember = this.commandRemember;
|
||
config.touchUI = this.touchUI;
|
||
config.bgmVolume = this.bgmVolume;
|
||
config.bgsVolume = this.bgsVolume;
|
||
config.meVolume = this.meVolume;
|
||
config.seVolume = this.seVolume;
|
||
config[_FpsConfigSymbol] = ConfigManager[_FpsConfigSymbol];
|
||
return config;
|
||
};
|
||
|
||
const _ConfigManager_applyData = ConfigManager.applyData;
|
||
ConfigManager.applyData = function(config) {
|
||
_ConfigManager_applyData.apply(this, arguments);
|
||
|
||
ConfigManager[_FpsConfigSymbol] = this.readFpsValue(config);
|
||
};
|
||
|
||
ConfigManager.readFpsValue = function(config) {
|
||
const fpsValue = config[_FpsConfigSymbol];
|
||
if (fpsValue) {
|
||
return fpsValue;
|
||
} else {
|
||
return 0;
|
||
}
|
||
}
|
||
})();
|