-
Notifications
You must be signed in to change notification settings - Fork 1
/
TF_TextWindowMenu.js
179 lines (161 loc) · 5.24 KB
/
TF_TextWindowMenu.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//========================================
// TF_TextWindowMenu.js
// Version :0.4.0.0
// For : RPGツクールMV (RPG Maker MV)
// -----------------------------------------------
// Copyright : Tobishima-Factory 2020
// Website : http://tonbi.jp
//
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
//========================================
/**
*
*/
/*:ja
* @plugindesc タイトルにテキストウィンドウ表示メニューを追加。
* @author とんび@鳶嶋工房
*
* @param windowParams
* @desc メニューとウィンドウの設定。
* @type struct<WindowParamJa>[]
* @default ["{\"menuLabel\":\"著作・製作\",\"lines\":\"12\",\"contents\":\"\\\"\\\\\\\\}(c)KADOKAWA CORPORATION\\\\\\\\{\\\"\"}"]
*
* @param isAnimate
* @desc 開閉アニメーションをするか。
* @type boolean
* @default true
*
* @help
* タイトル画面への著作権情報や操作説明の追加を想定したプラグインです。
*
* windowParams パラメータ1行につき1メニューがタイトル画面に追加されます。
* そのメニューを選択すると、ウィンドウが1枚開きます。
*
* ウィンドウの行数は lines パラメータで指定します。
*
* contents パラメータを入力する際はコンテクストメニュー(右クリック)の
* [アイコンセットビューア]を利用して \I[n] の n の数値を入力できます。
* その他、メッセージと同じ制御文字が使えますので、ご活用ください。
*
* 利用規約 : MITライセンス
*/
/*~struct~WindowParamJa:
*
* @param menuLabel
* @desc タイトル画面でのメニュー名。
* @type string
* @default 著作・製作
*
* @param lines
* @desc ウィンドウの行数。
* @type number
* @default 12
*
* @param contents
* @desc ウィンドウに表示する内容(制御文字が使えます)
* @type note
* @default "\\}(c)KADOKAWA CORPORATION\\{"
*/
( function() {
'use strict';
const TF_OPEN_WINDOW_COMMAND = 'TF_OPEN_WINDOW_COMMAND';
const TRIGGER_OK = 'ok';
const TRIGGER_CANCEL = 'cancel';
/**
* パラメータを受け取る
*/
const pluginParams = PluginManager.parameters( 'TF_TextWindowMenu' );
const TF = JSON.parse( JSON.stringify(
pluginParams,
( key, value ) => {
try { return JSON.parse( value ); } catch( e ) { }
return value;
}
) );
TF.topRows = null;
TF.itemIndex = null;
/*---- Window_TitleCommand ----*/
/**
* タイトルのメニューにコマンドを追加。
*/
const _Window_TitleCommand_makeCommandList = Window_TitleCommand.prototype.makeCommandList;
Window_TitleCommand.prototype.makeCommandList = function() {
_Window_TitleCommand_makeCommandList.call( this );
TF.topRows = this.maxItems();
TF.windowParams.forEach( e => this.addCommand( e.menuLabel, TF_OPEN_WINDOW_COMMAND ) );
};
// 選択中の項目を記録
const _Window_TitleCommand_processOk = Window_TitleCommand.prototype.processOk;
Window_TitleCommand.prototype.processOk = function() {
_Window_TitleCommand_processOk.call( this );
TF.itemIndex = this.index();
};
const _Window_TitleCommand_selectLast = Window_TitleCommand.prototype.selectLast;
Window_TitleCommand.prototype.selectLast = function() {
if( TF.itemIndex ) {
this.select( TF.itemIndex );
} else {
_Window_TitleCommand_selectLast.call( this );
}
};
/*---- Scene_Title ----*/
/**
* コマンドハンドラを追加。
*/
const _Scene_Title_createCommandWindow = Scene_Title.prototype.createCommandWindow;
Scene_Title.prototype.createCommandWindow = function() {
_Scene_Title_createCommandWindow.call( this );
this._commandWindow.setHandler( TF_OPEN_WINDOW_COMMAND, () => {
this._commandWindow.close();
SceneManager.push( Scene_TF_SingleWindow );
} );
};
/*---- Scene_TF_SingleWindow ----*/
class Scene_TF_SingleWindow extends Scene_MenuBase {
create() {
super.create();
const lines = parseInt( TF.windowParams[ TF.itemIndex - TF.topRows ].lines, 10 );
this._singleWindow = new Window_Help( lines );
this.addWindow( this._singleWindow );
this._singleWindow.y = ( Graphics.boxHeight - this._singleWindow.height ) / 2;
this._singleWindow.pause = true;
if( TF.isAnimate ) {
this._singleWindow.openness = 0;
this._singleWindow.open();
}
}
getTriggerType() {
if( TouchInput.isTriggered() || Input.isTriggered( TRIGGER_OK ) ) return TRIGGER_OK;
if( TouchInput.isCancelled() || Input.isTriggered( TRIGGER_CANCEL ) ) return TRIGGER_CANCEL;
return '';
}
exitScene( triggerType ) {
if( triggerType === '' ) return;
if( triggerType == TRIGGER_OK ) {
SoundManager.playOk();
} else {
SoundManager.playCancel();
}
if( TF.isAnimate ) {
this._singleWindow.close();
} else {
SceneManager.pop();
}
}
setContents() {
if( this._singleWindow._text ) return;
this._singleWindow.setText( TF.windowParams[ TF.itemIndex - TF.topRows ].contents );
}
update() {
super.update();
if( this._singleWindow.isOpen() ) {
this.setContents();
// 入力のチェック(Window_Help は addHandler を持たないので)
this.exitScene( this.getTriggerType() );
} else if( this._singleWindow.isClosed() ) {
SceneManager.pop();
}
}
}
} )();