/*:
* @plugindesc 全螢幕選項 SRD_FullscreenToggleOption.js
* @author SumRndmDde
*
* @param Option Name
* @desc 選項名稱
* @default 全螢幕
*
* @param Position
* @desc 選項位置
* Choices are: Top, Middle, Bottom
* @default Top
*
* @param Default Value
* @desc 預設值
* true = on false = off
* @default on
*
* @param ersist Default?
* @desc 堅持預設值 (Choices are: true, false)
* @default true
*
* @help
*/
(function() {
var parameters = PluginManager.parameters('SRD_FullscreenToggleOption');
var optionName = String(parameters['Option Name']);
var defaultValue = String(parameters['Default Value']).trim().toLowerCase() === 'true';
var position = String(parameters['Position']).toLowerCase();
var persist = String(parameters['Persist Default?']).trim().toLowerCase() === 'true';
ConfigManager.fullscreen = defaultValue;
Object.defineProperty(ConfigManager, 'fullscreen', {
get: function() {
return !Graphics._isFullScreen();
},
set: function(value) {
if (value) {
Graphics._requestFullScreen(); //執行全螢幕
} else {
Graphics._cancelFullScreen(); //視窗化
}
},
configurable: true
});
var _ConfigManager_makeData = ConfigManager.makeData;
ConfigManager.makeData = function() {
var config = _ConfigManager_makeData.call(this);
config.fullscreen = this.fullscreen;
return config;
};
var _ConfigManager_applyData = ConfigManager.applyData;
ConfigManager.applyData = function(config) {
_ConfigManager_applyData.call(this, config);
this.fullscreen = this.readFullscreen(config, 'fullscreen');
};
ConfigManager.readFullscreen = function(config, name) {
var value = config[name];
if(!persist) {
if (value !== undefined) { //假如已有定義
return value;
} else {
return defaultValue; //返回預設值
}
} else {
return defaultValue; //返回預設值
}
};
var _Window_Options_addGeneralOptions = Window_Options.prototype.addGeneralOptions;
Window_Options.prototype.addGeneralOptions = function() {
_Window_Options_addGeneralOptions.call(this);
if(position === 'middle') {
this.addCommand(optionName, 'fullscreen'); //新增全螢幕選項
}
};
var _Window_Options_makeCommandList = Window_Options.prototype.makeCommandList;
Window_Options.prototype.makeCommandList = function() {
if(position === 'top') {
this.addCommand(optionName, 'fullscreen'); //新增全螢幕選項
}
_Window_Options_makeCommandList.call(this);
};
var _Window_Options_addVolumeOptions = Window_Options.prototype.addVolumeOptions;
Window_Options.prototype.addVolumeOptions = function() {
_Window_Options_addVolumeOptions.call(this);
if(position === 'bottom') {
this.addCommand(optionName, 'fullscreen'); //新增全螢幕選項
}
};
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if(command.toLowerCase() === 'togglescreentype') { //假如切換選項
Graphics._switchFullScreen(); //執行全螢幕切換
}
};
})();