-
Notifications
You must be signed in to change notification settings - Fork 1
/
TF_DashControl.js
89 lines (78 loc) · 3.02 KB
/
TF_DashControl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//========================================
// TF_DashControl
// Version :1.0.0.0
// For : RPGツクールMV (RPG Maker MV)
// -----------------------------------------------
// Copyright : Tobishima-Factory 2018
// Website : http://tonbi.jp
//
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
//========================================
/*:
* @plugindesc ダッシュ可・不可制御と、その状態のセーブファイルへの保存
* @author とんび@鳶嶋工房
*
* @param Show AlwaysDash menu
* @desc [オプション] メニューに[常時ダッシュ]を表示させるか
* 表示 : true | 消す : false
* @default true
*
* @help プラグインコマンド
* ・TF_DASH_ENABLED 真偽値
* ダッシュ可能状態を設定します
* true : ダッシュ可
* false : ダッシュ不可
*
* JavaScriptから使う場合は
* $GameSystem.TF_DashEnabled( true ); // ダッシュ可
* $GameSystem.TF_DashEnabled( false );// ダッシュ不可
*
* 利用規約 : MITライセンス
*/
( function() {
'use strict';
const PLUGIN_NAME = 'TF_DashControl';
const SHOW_MENU = 'Show AlwaysDash menu';
const PLUGIN_COMMAND = 'TF_DASH_ENABLED';
/**
* 初期化イベント(的なアレ)
*/
const _Game_System_initialize = Game_System.prototype.initialize;
Game_System.prototype.initialize = function() {
_Game_System_initialize.call( this );
this.TF_dashEnabled = true; // セーブ用変数を用意
};
/**
* プラグインコマンドの実行
*/
const _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function( command, args ) {
_Game_Interpreter_pluginCommand.call( this, command, args );
if( command.toUpperCase() !== PLUGIN_COMMAND ) return;
const dashEnabled = ( args[ 0 ].toLowerCase() === 'true' );
$gameSystem.TF_DashEnabled( dashEnabled );
};
/**
* ダッシュ可能状態の設定
* @param {Boolean} dashEnabled 注:isDashDisabledとは真偽逆
*/
Game_System.prototype.TF_DashEnabled = function( dashEnabled ) {
this.TF_dashEnabled = ( dashEnabled == 'false' );
};
/**
* @returns {Boolean} ダッシュ不可か
*/
const _Game_Map_isDashDisabled = Game_Map.prototype.isDashDisabled;
Game_Map.prototype.isDashDisabled = function() {
return !$gameSystem.TF_dashEnabled || _Game_Map_isDashDisabled.call( this );
};
// [常時ダッシュ]メニューの表示・非表示の設定
const showAlwaysDashMenu = PluginManager.parameters( PLUGIN_NAME )[ SHOW_MENU ];
if( showAlwaysDashMenu.toLowerCase() === 'true' ) return;
const _Window_Command_addCommand = Window_Command.prototype.addCommand;
Window_Options.prototype.addCommand = function( name, symbol, enabled, ext ) {
if( symbol === 'alwaysDash' ) return;
_Window_Command_addCommand.call( this, name, symbol, enabled, ext );
};
} )();