135 lines
5 KiB
JavaScript
135 lines
5 KiB
JavaScript
//===========================================================================
|
||
// MpiDisableGamePad.js
|
||
//===========================================================================
|
||
|
||
/*:
|
||
* @target MZ
|
||
* @plugindesc ゲームパッドを無効化できるオプションを追加します。
|
||
* @author 奏ねこま(おとぶき ねこま)
|
||
*
|
||
* @param Option Name
|
||
* @desc オプション画面に項目名として表示するテキストを指定してください。
|
||
* @default ゲームパッド
|
||
*
|
||
* @param Value Text
|
||
* @desc オプション画面に設定値として表示するテキストを指定してください。(カンマ区切りで、有効時,無効時)
|
||
* @default ON,OFF
|
||
*
|
||
* @param Option Index
|
||
* @desc オプション画面の何番目に表示するかを指定してください。(先頭は1)
|
||
* @default 7
|
||
*
|
||
* @help
|
||
* [説明]
|
||
* ゲームパッドを無効化できるオプションを追加します。
|
||
*
|
||
* [利用規約] ..................................................................
|
||
* - 本プラグインの利用は、RPGツクールMV/RPGMakerMVの正規ユーザーに限られます。
|
||
* - 商用、非商用、有償、無償、一般向け、成人向けを問わず、利用可能です。
|
||
* - 利用の際、連絡や報告は必要ありません。また、製作者名の記載等も不要です。
|
||
* - プラグインを導入した作品に同梱する形以外での再配布、転載はご遠慮ください。
|
||
* - 本プラグインにより生じたいかなる問題についても、一切の責任を負いかねます。
|
||
* [改訂履歴] ..................................................................
|
||
* Version 1.00 2017/05/22 First edition.
|
||
* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||
* Web Site: http://makonet.sakura.ne.jp/rpg_tkool/
|
||
* Twitter : https://twitter.com/koma_neko
|
||
* Copylight (c) 2017 Nekoma Otobuki
|
||
*/
|
||
|
||
var Imported = Imported || {};
|
||
var Makonet = Makonet || {};
|
||
|
||
(function(){
|
||
'use strict';
|
||
|
||
var plugin = 'MpiDisableGamePad';
|
||
|
||
Imported[plugin] = true;
|
||
Makonet[plugin] = {};
|
||
|
||
var $mpi = Makonet[plugin];
|
||
$mpi.parameters = PluginManager.parameters(plugin);
|
||
|
||
$mpi.command_name = $mpi.parameters['Option Name'];
|
||
$mpi.value_text = $mpi.parameters['Value Text'].trim().split(/ *, */);
|
||
$mpi.option_index = (+$mpi.parameters['Option Index'] || 1) - 1;
|
||
|
||
var _ = plugin;
|
||
var __ = `$${_}`;
|
||
|
||
//==============================================================================
|
||
// Input
|
||
//==============================================================================
|
||
|
||
(function(o,p){
|
||
var f=o[p];o[p]=function(gamepad){
|
||
if (!ConfigManager.gamePad) return;
|
||
f.apply(this,arguments);
|
||
};
|
||
}(Input,'_updateGamepadState'));
|
||
|
||
//==============================================================================
|
||
// ConfigManager
|
||
//==============================================================================
|
||
|
||
ConfigManager.gamePad = true;
|
||
|
||
(function(o,p){
|
||
var f=o[p];o[p]=function(){
|
||
var config = f.apply(this,arguments);
|
||
config.gamePad = this.gamePad;
|
||
return config;
|
||
};
|
||
}(ConfigManager,'makeData'));
|
||
|
||
(function(o,p){
|
||
var f=o[p];o[p]=function(config){
|
||
f.apply(this,arguments);
|
||
this.gamePad = this.readFlag(config, 'gamePad');
|
||
};
|
||
}(ConfigManager,'applyData'));
|
||
|
||
(function(o,p){
|
||
var f=o[p];o[p]=function(config, name){
|
||
if ((name === 'gamePad') && !config.hasOwnProperty('gamePad')) {
|
||
config[name] = true;
|
||
}
|
||
return f.apply(this,arguments);
|
||
};
|
||
}(ConfigManager,'readFlag'));
|
||
|
||
//==============================================================================
|
||
// Window_Options
|
||
//==============================================================================
|
||
|
||
Object.defineProperty(Window_Options.prototype,_,{
|
||
get:function(){return this[__]=this[__]||{}},
|
||
set:function(value){this[__]=value},
|
||
configurable: true
|
||
});
|
||
|
||
(function(o,p){
|
||
var f=o[p];o[p]=function(){
|
||
f.apply(this,arguments);
|
||
var command = { name: $mpi.command_name, symbol: 'gamePad', enabled: true, ext: null };
|
||
this._list.splice($mpi.option_index, 0, command);
|
||
};
|
||
}(Window_Options.prototype,'makeCommandList'));
|
||
|
||
(function(o,p){
|
||
var f=o[p];o[p]=function(index){
|
||
this[_].draw_index = index;
|
||
f.apply(this,arguments);
|
||
};
|
||
}(Window_Options.prototype,'drawItem'));
|
||
|
||
(function(o,p){
|
||
var f=o[p];o[p]=function(value){
|
||
var symbol = this.commandSymbol(this[_].draw_index);
|
||
var on = $mpi.value_text[0];
|
||
var off = $mpi.value_text[1];
|
||
return (symbol === 'gamePad') ? (value ? on : off) : f.apply(this,arguments);
|
||
};
|
||
}(Window_Options.prototype,'booleanStatusText'));
|
||
}());
|