-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTF_TextWindowMenu.js
145 lines (129 loc) · 4.94 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
//========================================
// TF_TextWindowMenu.js
// Version :0.4.0.0
// For : RPGツクールMZ (RPG Maker MZ)
// -----------------------------------------------
// Copyright : Tobishima-Factory 2020-2021
// Website : http://tonbi.jp
//
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
//========================================
/*:ja
* @target MZ
* @plugindesc タイトルにテキストウィンドウ表示メニューを追加。
* @author とんび@鳶嶋工房
* @url https://github.com/tonbijp/RPGMakerMZ/blob/master/TF_TextWindowMenu.js
* @base PluginCommonBase
* @orderAfter PluginCommonBase
*
* @param windowParams @text メニューとウィンドウの設定。
* @type struct<WindowParam>[]
* @default ["{\"menuLabel\":\"著作・製作\",\"contents\":\"©\\n\\n\\\\}©Gotcha Gotcha Games Inc./YOJI OJIMA 2020\\\\{\"}"]
*
* @param setTitleCommand @text タイトルに表示するか。
* @type boolean @default true
*
* @help
* タイトル画面への著作権情報や操作説明の追加を想定したプラグインです。
*
* windowParams パラメータ1行につき1メニューがタイトル画面に追加されます。
* そのメニューを選択すると、ウィンドウが1枚開きます。
*
* ウィンドウの行数は lines パラメータで指定します。
*
* contents パラメータを入力する際はコンテクストメニュー(右クリック)の
* [アイコンセットビューア]を利用して \I[n] の n の数値を入力できます。
* その他、メッセージと同じ制御文字が使えますので、ご活用ください。
*
* 利用規約 : MITライセンス
*/
/*~struct~WindowParam:ja
*
* @param menuLabel
* @desc タイトル画面でのメニュー名。
* @type string
* @default 著作・製作
*
* @param contents
* @desc ウィンドウに表示する内容(制御文字が使えます)
* @type multiline_string
* @default
* ©
*
* \}©Gotcha Gotcha Games Inc./YOJI OJIMA 2020\{
*/
( () => {
"use strict";
const HANDLER_OPEN_WINDOW = "handlerOpenWindow";
// プラグインパラメータを受け取る
const pluginParams = PluginManagerEx.createParameter( document.currentScript );
let dafaultRows = 0;
const windowParams = pluginParams.windowParams;
/*---- Window_TitleCommand ----*/
/**
* タイトルのメニューにコマンドを追加。
*/
const _Window_TitleCommand_makeCommandList = Window_TitleCommand.prototype.makeCommandList;
Window_TitleCommand.prototype.makeCommandList = function() {
_Window_TitleCommand_makeCommandList.call( this );
if( !pluginParams.setTitleCommand ) return;
dafaultRows = this.maxItems();
windowParams.forEach( e => this.addCommand( e.menuLabel, HANDLER_OPEN_WINDOW ) );
};
/*---- Scene_Title ----*/
// コマンド数に合わせて、高さを増やす。
const _Scene_Title_commandWindowRect = Scene_Title.prototype.commandWindowRect;
Scene_Title.prototype.commandWindowRect = function() {
const rect = _Scene_Title_commandWindowRect.call( this );
if( !pluginParams.setTitleCommand ) return rect;
const itemHeight = Window_TitleCommand.prototype.itemHeight();
rect.height += windowParams.length * itemHeight;
return rect;
};
// コマンドハンドラを追加。
const _Scene_Title_createCommandWindow = Scene_Title.prototype.createCommandWindow;
Scene_Title.prototype.createCommandWindow = function() {
_Scene_Title_createCommandWindow.call( this );
if( !pluginParams.setTitleCommand ) return;
this._commandWindow.setHandler( HANDLER_OPEN_WINDOW, () => {
this._commandWindow.close();
Scene_SingleInfo.contentsId = this._commandWindow.index() - dafaultRows;
SceneManager.push( Scene_SingleInfo );
} );
};
// シーン
class Scene_SingleInfo extends Scene_MenuBase {
create() {
super.create();
const wh = this.mainAreaHeight();
const rect = new Rectangle( 0, this.mainAreaTop(), Graphics.boxWidth, wh );
const infoWindow = new Window_SingleInfo( rect );
infoWindow.setHandler( "ok", this.popScene.bind( this ) );
infoWindow.setHandler( "cancel", this.popScene.bind( this ) );
if( Scene_SingleInfo.contentsId !== null ) {
infoWindow.setContents( windowParams[ Scene_SingleInfo.contentsId ].contents );
}
this.addWindow( infoWindow );
}
helpAreaHeight() { return 0; }; //ヘルプの高さを0にすることでメインの高さを広げる
}
window.Scene_SingleInfo = Scene_SingleInfo;//公開
Scene_SingleInfo.contentsId = null;
// 情報ウィンドウ
class Window_SingleInfo extends Window_Selectable {
initialize( rect ) {
super.initialize( rect );
this.activate();
}
// 画面どこをタップしても反応するように
isOkTriggered() {
return super.isOkTriggered() || TouchInput.isTriggered();
};
setContents( text ) {
this.contents.clear();
const rect = this.baseTextRect();
this.drawTextEx( text, rect.x, rect.y, rect.width );
}
}
} )();