-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSceneSoundTest_with_comments.js
1535 lines (1370 loc) · 57.9 KB
/
SceneSoundTest_with_comments.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//=============================================================================
// SceneSoundTest.js(Ver.2.3.0) + コメントウィンドウ
// ----------------------------------------------------------------------------
// SceneSoundTestの音量/ピッチ/位相ウィンドウを、楽曲コメント欄に変更するプラグインです。
// 変更履歴
// 2021/6/21
// Ver.0.4 Ver.2.3.0に合わせた。
// 2017/12/30
// Ver.0.3
// @helpに改行を付加した。「コメントを消す」オプションの追加。
// 2017/8/15
// Ver.0.2
// バージョン2.1.0にコードを合わせた。
// 2017/5/22
// Ver.0.1
// コマンドウィンドウ使うの止めた。
// Ver.0.0
// 初版。
// ----------------------------------------------------------------------------
// 22番目の素数(NAK)
// [GitHub] : https://github.com/DICE2000
//=============================================================================
//
// 以下は SceneSoundTest.jsの履歴です。
//
//=============================================================================
// SceneSoundTest.js
// ----------------------------------------------------------------------------
// (C)2016 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 2.3.0 2020/05/17 ヘルプウィンドウに曲名を表示するかどうかの設定を追加
// 2.2.0 2020/05/04 データファイルのtype指定が大文字の場合でも正常に動作するよう修正
// プラグインの型指定機能に対応
// 2.1.0 2017/06/21 BGMが一曲も存在しないデータリストを読み込んで再生しようとするとエラーになる問題を修正
// リストウィンドウでの操作タイプを2パターン用意しました。
// 2.0.0 2017/06/18 BGS、ME、SEの演奏機能を追加
// 1.1.1 2017/05/27 競合の可能性のある記述(Objectクラスへのプロパティ追加)をリファクタリング
// 1.1.0 2017/01/25 同一サーバで同プラグインを適用した複数のゲームを公開する際に、設定が重複するのを避けるために管理番号を追加
// RPGアツマール等CSVが使えない環境のためデータファイルとしてJSON形式をサポート
// 1.0.3 2016/10/10 設定項目をすべて非表示にした場合、リストから選択後、ゲームが止まってしまう問題を修正
// 1.0.2 2016/05/11 ウィンドウの位置指定方法を少し変更(見た目上はそのまま)
// 1.0.1 2016/02/07 改行コード(CR+LF)に対応
// 英語対応
// 1.0.0 2016/01/29 初版
// ----------------------------------------------------------------------------
// [Blog] : https://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub] : https://github.com/triacontane/
//=============================================================================
/*:
* @plugindesc Sound test plugin(Ver.2.3.0) + Comment Window
* @author triacontane (modified by NAK)
*
* @param CommandName
* @desc Command name
* @default Sound Test
*
* @param AddCommandTitle
* @desc Add command at title scene(ON/OFF)
* @default true
* @type boolean
*
* @param AddCommandMenu
* @desc Add command at menu scene(ON/OFF)
* @default true
* @type boolean
*
* @param NameVolume
* @desc Name volume for Bgm setting window
* @default Volume
*
* @param NamePitch
* @desc Name pitch for Bgm setting window
* @default Pitch
*
* @param NamePan
* @desc Name pan for Bgm setting window
* @default Pan
*
* @param BackPicture
* @desc Back ground picture(/img/pictures/)
* @default
*
* @param ReadFormat
* @desc read data format(CSV or JSON)
* @type select
* @option CSV
* @option JSON
*
* @param ManageNumber
* @desc 同一サーバ内に複数のゲームを配布する場合のみ、ゲームごとに異なる値を設定してください。(RPGアツマールは対象外)
* @default
*
* @param ListControlType
* @desc リストウィンドウでの操作タイプです。(1, 2)
* @type select
* @option 1[OK:演奏+音量調整][Shift:演奏停止]
* @value 1
* @option 2[OK:演奏][Shift:音量調整])
* @value 2
*
* @param ShowAudioNameDesc
* @desc BGMの説明ウィンドウに曲名を表示します。
* @default true
* @type boolean
*
* @param CommentWindow
* @desc Change BGM setting window to comment window
* @default false
* @type boolean
*
* @param コメントを消す
* @desc カーソルが他の項目に当たった場合、コメントを消します。
* @default false
* @type boolean
*
* @help Add a comment window on sound test screen.
* make the following item in a CSV file.
*
* filename : in detail below.
* displayName : in detail below.
* description : in detail below.
* type : in detail below.
* comment : comments on BGM. word wrap is automatically done. insert \n if you want a new line manually.
*
* ex :
* fileName,displayName,description,comment
* aaa,bbb,ccc,hogehoge
*
* ------ The following is original help text of SceneSoundTest.js ------
*
* Add sound test screen.
*
* Preparation
* Make [/data/SoundTest.csv] UFT-8
*
* COLUMN : DESCRIPTION
* fileName : Audio File name
* displayName : Audio Display name
* description : Audio Description
* type : Audio Type(bgm or bgs or me or se)
*
* ex :
* fileName,displayName,description,type
* aaa,bbb,ccc,bgm
*
* CSV Sample
* https://raw.githubusercontent.com/triacontane/RPGMakerMV/master/SoundTest.csv
*
* Plugin Command
*
* SOUND_TEST_CALL
* Call sound test scene
* ex : SOUND_TEST_CALL
*
* SOUND_TEST_LIBERATE_ALL
* All BGM liberate
* ex : SOUND_TEST_LIBERATE_ALL
*
* SOUND_TEST_TITLE_VALID
* Add command at title scene
* ex : SOUND_TEST_TITLE_VALID
*
* SOUND_TEST_MENU_VALID
* Add command at menu scene
* 例:SOUND_TEST_MENU_VALID
*
* This plugin is released under the MIT License.
*/
/*:ja
* @plugindesc サウンドテストプラグイン(Ver.2.3.0)+コメントウィンドウ
* @author トリアコンタン/改造:22番目の素数(NAK)
*
* @param コマンド名称
* @desc タイトルやメニュー画面に表示されるコマンド名です。
* @default サウンドテスト
*
* @param タイトルに追加
* @desc タイトル画面にサウンドテストを追加します。(ON/OFF)
* OFFにした場合もコマンドで後から有効にできます。
* @default true
* @type boolean
*
* @param メニューに追加
* @desc メニュー画面にサウンドテストを追加します。(ON/OFF)
* OFFにした場合もコマンドで後から有効にできます。
* @default true
* @type boolean
*
* @param 音量名称
* @desc BGMの設定項目「音量」のゲーム内での名称です。
* 空にすると、設定ウィンドウに音量が表示されなくなります。
* @default 音量
*
* @param ピッチ名称
* @desc BGMの設定項目「ピッチ」のゲーム内での名称です。
* 空にすると、設定ウィンドウにピッチが表示されなくなります。
* @default ピッチ
*
* @param 位相名称
* @desc BGMの設定項目「位相」のゲーム内での名称です。
* 空にすると、設定ウィンドウに位相が表示されなくなります。
* @default 位相
*
* @param 背景ピクチャ
* @desc 背景として表示するピクチャ(/img/pictures/)を指定できます。
* サイズは画面サイズに合わせて拡縮されます。拡張子、パス不要。
* @default
* @require 1
* @dir img/pictures/
* @type file
*
* @param 読込形式
* @desc データファイルの読み込み形式です。
* CSV形式およびJSON形式をサポートしています。
* @default
* @type select
* @option CSV
* @option JSON
*
* @param 管理番号
* @desc 同一サーバ内に複数のゲームを配布する場合のみ、ゲームごとに異なる値を設定してください。(RPGアツマールは対象外)
* @default
*
* @param リスト操作タイプ
* @desc リストウィンドウでの操作タイプです。
* @default 1
* @type select
* @option 1[OK:演奏+音量調整][Shift:演奏停止]
* @value 1
* @option 2[OK:演奏][Shift:音量調整])
* @value 2
*
* @param 説明文に曲名表示
* @desc BGMの説明ウィンドウに曲名を表示します。
* @default true
* @type boolean
*
* @param コメントウィンドウ
* @desc BGMの設定項目をコメントウィンドウに変えます。
* @default false
* @type boolean
*
* @param コメントを消す
* @desc カーソルが他の項目に当たった場合、コメントを消します。
* @default false
* @type boolean
*
* @help サウンドテストにコメント欄を付けます。
* CSV/JSONに以下の項目を追加してください。
*
* comment : コメントです。自動改行されます。
* 改行したい場合は\nを入れてください。
*
* CSVの場合
* fileName,displayName,description,comment
* ファイル名,表示名,説明,コメント
*
* JSONの場合
* [
* {"fileName":"BGMファイル名", "displayName":"BGM表示名", "description":"説明", "comment":"コメント"},
* {"fileName":"BGMファイル名", "displayName":"BGM表示名", "description":"説明", "comment":"コメント" }
* ]
*
* 「コメントを消す」オプションは、試しにやってみたら実装できたけれども
* どっちが良いのか自分でもよく分からなくなったので
* とりあえず残してみました。お好みでどうぞ。
*
* ------↓以下はオリジナルのヘルプテキストです↓------
*
* ゲーム中のオーディオを視聴できるサウンドテスト画面を実装します。
* タイトル画面、メニュー画面およびプラグインコマンドから専用画面に遷移します。
* ゲーム中に一度でも再生したことのあるオーディオを視聴できるようになります。
*
* 準備
* 1.CSV形式の場合
* 以下の書式で「SoundTest.csv」を用意し、「/data/」以下に配置します。
* カンマ区切りのCSV形式で、データ中にカンマは使用できません。
* また、文字コードは「UTF-8」で保存してください。
* 特にExcel等で編集した後は注意してください。
*
* 項目名 : 説明
* fileName : BGMのファイル名です。拡張子不要。
* displayName : BGMリストに表示される曲名です。
* description : ヘルプウィンドウに表示される説明です。\nと記述すると改行します。
* type : オーディオ種別(bgm or bgs or me or se)
*
* なお、別プラグイン「バッチ処理プラグイン」(BatchProcessManager.js)
* を使えば現在のBGMフォルダを解析して上記書式のひな形CSVを自動生成できます。
*
* 「バッチ処理プラグイン」配布先
* https://raw.githubusercontent.com/triacontane/RPGMakerMV/master/BatchProcessManager.js
*
* こちらにCSVのサンプルをあげています。
* https://raw.githubusercontent.com/triacontane/RPGMakerMV/master/SoundTest.csv
*
* 2.JSON形式の場合
* RPGアツマール等のCSV形式が使用できない環境の場合、
* こちらのJSON形式を選択してください。
* 以下の書式で「SoundTest.json」を用意し、「/data/」以下に配置します。
* 文字コードは「UTF-8」で保存してください。
*
* [
* {"fileName":"BGMファイル名", "displayName":"BGM表示名", "description":"説明", "type":"BGM"},
* {"fileName":"BGMファイル名", "displayName":"BGM表示名", "description":"説明", "type":"BGS""}
* ]
*
* CSV→JSON変換ツールを使用した場合、末尾のカンマ等が正しく記述されていないと
* エラーが発生するので注意してください。
*
* プラグインコマンド詳細
* イベントコマンド「プラグインコマンド」から実行。
* (パラメータの間は半角スペースで区切る)
*
* SOUND_TEST_CALL or
* サウンドテスト画面の呼び出し
* サウンドテスト画面を呼び出します。
* 例:SOUND_TEST_CALL
*
* SOUND_TEST_LIBERATE_ALL or
* サウンドテスト全開放
* サウンドテスト画面で???となっている曲目を全開放します。
* 例:SOUND_TEST_LIBERATE_ALL
*
* SOUND_TEST_TITLE_VALID or
* タイトル画面のサウンドテスト有効化
* タイトル画面の項目にサウンドテストが追加されます。
* 例:SOUND_TEST_TITLE_VALID
*
* SOUND_TEST_MENU_VALID or
* メニュー画面のサウンドテスト有効化
* メニュー画面の項目にサウンドテストが追加されます。
* 例:SOUND_TEST_MENU_VALID
*
* 利用規約:
* 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
* についても制限はありません。
* このプラグインはもうあなたのものです。
*/
//=============================================================================
// グローバル変数
// サウンドテストデータファイルとゲームファイル
//=============================================================================
var $gameSoundTest = null;
var $dataSoundTest = null;
function Game_SoundTest() {
this.initialize.apply(this, arguments);
}
function Game_AudioSelector() {
this.initialize.apply(this, arguments);
}
function Scene_SoundTest() {
this.initialize.apply(this, arguments);
}
(function() {
'use strict';
var pluginName = 'SceneSoundTest_with_comments';
var getParamString = function(paramNames) {
var value = getParamOther(paramNames);
return value === null ? '' : value;
};
var getParamBoolean = function(paramNames) {
var value = getParamString(paramNames).toUpperCase();
return value === 'TRUE';
};
var getParamNumber = function(paramNames, min, max) {
var value = getParamString(paramNames);
if (arguments.length < 2) min = -Infinity;
if (arguments.length < 3) max = Infinity;
return (parseInt(value) || 0).clamp(min, max);
};
var getParamBoolean = function(paramNames) {
var value = (getParamOther(paramNames) || '').toUpperCase();
return value === 'ON' || value === 'TRUE';
};
var getParamOther = function(paramNames) {
if (!Array.isArray(paramNames)) paramNames = [paramNames];
for (var i = 0; i < paramNames.length; i++) {
var name = PluginManager.parameters(pluginName)[paramNames[i]];
if (name) return name;
}
return null;
};
var getCommandName = function(command) {
return (command || '').toUpperCase();
};
var iterate = function(that, handler) {
Object.keys(that).forEach(function(key, index) {
handler.call(that, key, that[key], index);
});
};
var paramReadFormat = getParamString(['読込形式', 'ReadFormat']).toUpperCase();
var paramManageNumber = getParamString(['管理番号', 'ManageNumber']);
var paramListControlType = getParamNumber(['リスト操作タイプ', 'ListControlType'], 1, 2);
var paramShowAudioName = getParamBoolean(['説明文に曲名表示', 'ShowAudioNameDesc']);
//=============================================================================
// DataManager
// CSV読み込み処理を定義します。
//=============================================================================
DataManager._dataSeparater = ',';
DataManager.soundTestFiles = [];
DataManager.loadCsvFiles = function() {
this.soundTestFiles.forEach(function(file) {
this._loadCsvFile(file.name, file.src);
}.bind(this));
};
DataManager._loadCsvFile = function(name, src) {
var xhr = new XMLHttpRequest();
var url = 'data/' + src;
xhr.open('GET', url);
xhr.onload = function() {
if (xhr.status < 400) {
window[name] = this._loadSoundData(xhr.responseText);
} else {
window[name] = [];
}
}.bind(this);
xhr.onerror = function() {
window[name] = [];
}.bind(this);
window[name] = null;
xhr.send();
};
DataManager._loadSoundData = function(responseText) {
switch (paramReadFormat) {
case 'JSON':
return JSON.parse(responseText);
default :
return this._loadCsvData(responseText);
}
};
DataManager._loadCsvData = function(responseText) {
var dataList = [null];
var dataArray = responseText.replace(/\r\n?/g, '\n').split('\n');
var columns = dataArray.shift().split(this._dataSeparater);
dataArray.forEach(function(line) {
if (line === '') return;
var dataObject = {};
dataObject.id = dataList.length;
iterate(line.split(this._dataSeparater), function(key, data) {
dataObject[columns[key]] = data.replace(/^\s*\"?(.*?)\"?\s*$/, function() {
return arguments[1];
});
}.bind(this));
dataList[dataObject.id] = dataObject;
}.bind(this));
return dataList;
};
DataManager.isLoadedCsv = function() {
return this.soundTestFiles.every(function(file) {
return window[file.name];
}.bind(this));
};
DataManager.getSoundTestFileName = function() {
switch (paramReadFormat) {
case 'JSON':
return 'SoundTest.json';
default :
return 'SoundTest.csv';
}
};
DataManager.soundTestFiles.push({name: '$dataSoundTest', src: DataManager.getSoundTestFileName()});
//=============================================================================
// StorageManager
// サウンドテスト設定ファイルのパス取得処理を追加定義します。
//=============================================================================
var _StorageManager_localFilePath = StorageManager.localFilePath;
StorageManager.localFilePath = function(saveFileId) {
if (saveFileId === SoundTestManager.saveId) {
return this.localFileDirectoryPath() + 'SoundTest.rpgsave';
} else {
return _StorageManager_localFilePath.apply(this, arguments);
}
};
var _StorageManager_webStorageKey = StorageManager.webStorageKey;
StorageManager.webStorageKey = function(saveFileId) {
if (saveFileId === SoundTestManager.saveId) {
return 'RPG SoundTest' + paramManageNumber;
} else {
return _StorageManager_webStorageKey.apply(this, arguments);
}
};
//=============================================================================
// AudioManager
// 演奏時にプレイリストに追加します。
//=============================================================================
var _AudioManager_playBgm = AudioManager.playBgm;
AudioManager.playBgm = function(bgm, pos) {
_AudioManager_playBgm.apply(this, arguments);
SoundTestManager.addPlayListIfNeed(bgm, 0);
};
var _AudioManager_playBgs = AudioManager.playBgs;
AudioManager.playBgs = function(bgs, pos) {
_AudioManager_playBgs.apply(this, arguments);
SoundTestManager.addPlayListIfNeed(bgs, 1);
};
var _AudioManager_playMe = AudioManager.playMe;
AudioManager.playMe = function(me) {
_AudioManager_playMe.apply(this, arguments);
SoundTestManager.addPlayListIfNeed(me, 2);
};
var _AudioManager_playSe = AudioManager.playSe;
AudioManager.playSe = function(se) {
_AudioManager_playSe.apply(this, arguments);
SoundTestManager.addPlayListIfNeed(se, 3);
};
var _AudioManager_playStaticSe = AudioManager.playStaticSe;
AudioManager.playStaticSe = function(se) {
_AudioManager_playStaticSe.apply(this, arguments);
SoundTestManager.addPlayListIfNeed(se, 3);
};
//=============================================================================
// Game_Interpreter
// プラグインコマンドを追加定義します。
//=============================================================================
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.apply(this, arguments);
this.pluginCommandSceneSoundTest(command, args);
};
Game_Interpreter.prototype.pluginCommandSceneSoundTest = function(command) {
switch (getCommandName(command)) {
case 'SOUND_TEST_CALL' :
case 'サウンドテスト画面の呼び出し' :
SceneManager.push(Scene_SoundTest);
break;
case 'SOUND_TEST_LIBERATE_ALL':
case 'サウンドテスト全開放':
$gameSoundTest.addPlayListAll();
SoundTestManager.saveGame();
break;
case 'SOUND_TEST_TITLE_VALID' :
case 'タイトル画面のサウンドテスト有効化' :
$gameSoundTest.titleCommandVisible = true;
SoundTestManager.saveGame();
break;
case 'SOUND_TEST_MENU_VALID' :
case 'メニュー画面のサウンドテスト有効化' :
$gameSoundTest.menuCommandVisible = true;
SoundTestManager.saveGame();
break;
}
};
//=============================================================================
// Scene_Boot
// サウンドテスト設定ファイルを読み込んでからゲームを開始します。
//=============================================================================
var _Scene_Boot_create = Scene_Boot.prototype.create;
Scene_Boot.prototype.create = function() {
_Scene_Boot_create.apply(this, arguments);
DataManager.loadCsvFiles();
if (!SoundTestManager.loadGame()) {
SoundTestManager.makeGame();
}
};
var _Scene_Boot_isReady = Scene_Boot.prototype.isReady;
Scene_Boot.prototype.isReady = function() {
return _Scene_Boot_isReady.apply(this, arguments) && DataManager.isLoadedCsv();
};
var _Scene_Boot_start = Scene_Boot.prototype.start;
Scene_Boot.prototype.start = function() {
_Scene_Boot_start.apply(this, arguments);
SoundTestManager.saveGame();
};
//=============================================================================
// Scene_Title
// サウンドテスト画面の呼び出しを追加します。
//=============================================================================
var _Scene_Title_createCommandWindow = Scene_Title.prototype.createCommandWindow;
Scene_Title.prototype.createCommandWindow = function() {
_Scene_Title_createCommandWindow.apply(this, arguments);
if ($gameSoundTest.titleCommandVisible)
this._commandWindow.setHandler('soundTest', this.commandSoundTest.bind(this));
};
Scene_Title.prototype.commandSoundTest = function() {
this._commandWindow.close();
SceneManager.push(Scene_SoundTest);
};
//=============================================================================
// Scene_Menu
// サウンドテスト画面の呼び出しを追加します。
//=============================================================================
var _Scene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function() {
_Scene_Menu_createCommandWindow.apply(this, arguments);
if ($gameSoundTest.menuCommandVisible)
this._commandWindow.setHandler('soundTest', this.commandSoundTest.bind(this));
};
Scene_Menu.prototype.commandSoundTest = function() {
SceneManager.push(Scene_SoundTest);
};
//=============================================================================
// Window_TitleCommand
// サウンドテスト画面の呼び出しの選択肢を追加定義します。
//=============================================================================
var _Window_TitleCommand_makeCommandList = Window_TitleCommand.prototype.makeCommandList;
Window_TitleCommand.prototype.makeCommandList = function() {
_Window_TitleCommand_makeCommandList.apply(this, arguments);
if ($gameSoundTest.titleCommandVisible)
this.addCommand(getParamString(['コマンド名称', 'CommandName']), 'soundTest');
};
var _Window_TitleCommand_updatePlacement = Window_TitleCommand.prototype.updatePlacement;
Window_TitleCommand.prototype.updatePlacement = function() {
_Window_TitleCommand_updatePlacement.apply(this, arguments);
if ($gameSoundTest.titleCommandVisible) this.y += this.height / 8;
};
//=============================================================================
// Window_MenuCommand
// サウンドテスト画面の呼び出しの選択肢を追加定義します。
//=============================================================================
var _Window_MenuCommand_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
Window_MenuCommand.prototype.addOriginalCommands = function() {
_Window_MenuCommand_addOriginalCommands.apply(this, arguments);
var enabled = this.isSoundTestEnabled();
if ($gameSoundTest.menuCommandVisible)
this.addCommand(getParamString(['コマンド名称', 'CommandName']), 'soundTest', enabled);
};
Window_MenuCommand.prototype.isSoundTestEnabled = function() {
return true;
};
//=============================================================================
// Scene_SoundTest
// サウンドテスト画面を扱うクラスです。
//=============================================================================
Scene_SoundTest.prototype = Object.create(Scene_MenuBase.prototype);
Scene_SoundTest.prototype.constructor = Scene_SoundTest;
Scene_SoundTest.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
$gameSoundTest.refresh();
this._backgroundLoading = false;
};
Scene_SoundTest.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createHelpWindow();
this.createAudioCategoryWindow();
this.createAudioListWindow();
this.createAudioSettingWindow();
this.activateAudioList();
this.changeAudioCategory();
};
var _Scene_SoundTest_createBackground = Scene_SoundTest.prototype.createBackground;
Scene_SoundTest.prototype.createBackground = function() {
var background = getParamString(['背景ピクチャ', 'BackPicture']);
if (background) {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = ImageManager.loadPicture(background, 0);
this.addChild(this._backgroundSprite);
this._backgroundLoading = true;
} else {
_Scene_SoundTest_createBackground.apply(this, arguments);
}
};
Scene_SoundTest.prototype.update = function() {
Scene_MenuBase.prototype.update.call(this);
if (this._backgroundLoading && this._backgroundSprite.bitmap.isReady()) {
this._backgroundSprite.scale.x = Graphics.boxWidth / this._backgroundSprite.width;
this._backgroundSprite.scale.y = Graphics.boxHeight / this._backgroundSprite.height;
this._backgroundLoading = false;
}
};
Scene_SoundTest.prototype.createAudioCategoryWindow = function() {
var y = this._helpWindow.y + this._helpWindow.height;
this._audioCategoryWindow = new Window_AudioCategory(0, y);
this._audioCategoryWindow.setHandler('touchInside', this.onTouchCategory.bind(this));
this.addWindow(this._audioCategoryWindow);
};
Scene_SoundTest.prototype.createAudioListWindow = function() {
var upperWindow = this._audioCategoryWindow.isCommandExist() ? this._audioCategoryWindow : this._helpWindow;
var y = upperWindow.y + upperWindow.height;
var height = Graphics.boxHeight - y;
this._audioListWindow = new Window_AudioList(0, y, 320, height, this._audioCategoryWindow);
this._audioListWindow.setHelpWindow(this._helpWindow);
this._audioListWindow.setHandler('ok', this.onListOk.bind(this));
this._audioListWindow.setHandler('cancel', this.escapeScene.bind(this));
this._audioListWindow.setHandler('change', this.changeAudioCategory.bind(this));
this._audioListWindow.setHandler('shift', this.onListShift.bind(this));
this._audioListWindow.setHandler('touchInside', this.activateAudioList.bind(this));
this.addWindow(this._audioListWindow);
};
Scene_SoundTest.prototype.createAudioSettingWindow = function() {
this._audioSettingWindow = new Window_AudioSetting(this._audioCategoryWindow.width, this._audioCategoryWindow.y);
this._audioSettingWindow.setHandler('cancel', this.activateAudioList.bind(this));
this._audioSettingWindow.setHandler('touchInside', this.activateAudioSetting.bind(this));
this.addWindow(this._audioSettingWindow);
if (SoundTestManager.isSettingEmpty()) this._audioSettingWindow.hide();
};
Scene_SoundTest.prototype.onListOk = function() {
if (!this._audioListWindow.isCurrentItemEnabled()) return;
this.playAudio();
if (paramListControlType === 1) {
this.activateAudioSetting();
} else {
this.activateAudioList();
}
};
Scene_SoundTest.prototype.onListShift = function() {
if (!this._audioListWindow.isCurrentItemEnabled()) return;
if (paramListControlType === 1) {
this.stopAudio();
} else {
this.activateAudioSetting();
}
};
Scene_SoundTest.prototype.playAudio = function() {
$gameSoundTest.setNameAndPlay(this._audioListWindow.item().fileName);
};
Scene_SoundTest.prototype.stopAudio = function() {
$gameSoundTest.setNameAndPlay('');
AudioManager.stopAll();
};
Scene_SoundTest.prototype.escapeScene = function() {
$gameSoundTest.restoreAudio();
this.popScene();
};
Scene_SoundTest.prototype.activateAudioSetting = function() {
if (!SoundTestManager.isSettingEmpty()) {
this._audioListWindow.deactivate();
this._audioSettingWindow.activate();
this._audioSettingWindow.select(0);
this._audioCategoryWindow.deactivate();
this.changeAudioName();
} else {
this.activateAudioList();
}
};
Scene_SoundTest.prototype.onTouchCategory = function() {
this._audioCategoryWindow.selectForTouch();
this.changeAudioCategory();
this.activateAudioList();
};
Scene_SoundTest.prototype.activateAudioList = function() {
this._audioSettingWindow.deselect();
this._audioSettingWindow.deactivate();
this._audioListWindow.activate();
};
Scene_SoundTest.prototype.changeAudioCategory = function() {
var type = this._audioCategoryWindow.getAudioType();
$gameSoundTest.setAudioType(type);
this._audioListWindow.setup(type);
this.changeAudioName();
};
Scene_SoundTest.prototype.changeAudioName = function() {
$gameSoundTest.setName(this._audioListWindow.item().fileName);
};
//=============================================================================
// Window_Selectable
// サウンドテスト画面のウィンドウ共通処理です。
//=============================================================================
var _Window_Selectable_processTouch = Window_Selectable.prototype.processTouch;
Window_Selectable.prototype.processTouch = function() {
_Window_Selectable_processTouch.apply(this, arguments);
if (this._soundTestWindow) {
this.processTouchNonActive();
}
};
Window_Selectable.prototype.processTouchNonActive = function() {
if (this.isOpen() && !this.active && this.isTouchedInsideFrame() &&
this.isHandled('touchInside') && TouchInput.isTriggered()) {
this.callHandler('touchInside');
this.selectForTouch();
}
};
var _Window_Selectable_processHandling = Window_Selectable.prototype.processHandling;
Window_Selectable.prototype.processHandling = function() {
_Window_Selectable_processHandling.apply(this, arguments);
if (!this._soundTestWindow) return;
if (this.isOpenAndActive()) {
if (this.isShiftEnabled() && this.isShiftTriggered()) {
this.processShift();
}
}
};
Window_Selectable.prototype.isShiftEnabled = function() {
return this.isHandled('shift');
};
Window_Selectable.prototype.isShiftTriggered = function() {
return Input.isRepeated('shift');
};
Window_Selectable.prototype.processShift = function() {
this.callHandler('shift');
};
Window_Selectable.prototype.selectForTouch = function() {
var lastIndex = this.index();
var x = this.canvasToLocalX(TouchInput.x);
var y = this.canvasToLocalY(TouchInput.y);
var hitIndex = this.hitTest(x, y);
if (hitIndex >= 0) {
this.select(hitIndex);
}
if (this.index() !== lastIndex) {
SoundManager.playCursor();
}
};
//=============================================================================
// Window_AudioSetting
// オーディオカテゴリウィンドウです。
//=============================================================================
function Window_AudioCategory() {
this.initialize.apply(this, arguments);
}
Window_AudioCategory._audioTypeNames = {
bgm: 'BGM',
bgs: 'BGS',
me : 'ME',
se : 'SE'
};
Window_AudioCategory.prototype = Object.create(Window_HorzCommand.prototype);
Window_AudioCategory.prototype.constructor = Window_AudioCategory;
Window_AudioCategory.prototype.initialize = function(x, y) {
Window_Command.prototype.initialize.call(this, x, y);
this._soundTestWindow = true;
this.select(0);
this.deactivate();
};
Window_AudioCategory.prototype.getAudioType = function() {
return this.commandSymbol(this.index());
};
Window_AudioCategory.prototype.makeCommandList = function() {
SoundTestManager.types.forEach(function(type) {
if ($gameSoundTest.isExistAudio(type)) {
this.addCommand(Window_AudioCategory._audioTypeNames[type], type);
}
}, this);
this.updateVisibility();
};
Window_AudioCategory.prototype.maxCols = function() {
return 4;
};
Window_AudioCategory.prototype.windowWidth = function() {
return 320;
};
Window_AudioCategory.prototype.updateVisibility = function() {
if (!this.isCommandExist()) {
this.visible = false;
}
};
Window_AudioCategory.prototype.isCommandExist = function() {
return this._list.length > 1;
};
//=============================================================================
// Window_AudioList
// オーディオリストウィンドウです。
//=============================================================================
function Window_AudioList() {
this.initialize.apply(this, arguments);
this._soundTestWindow = true;
}
Window_AudioList.prototype = Object.create(Window_Selectable.prototype);
Window_AudioList.prototype.constructor = Window_AudioList;
Window_AudioList.prototype.initialize = function(x, y, width, height, categoryWindow) {
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this._data = [];
this._categoryWindow = categoryWindow;
this.setup(categoryWindow.getAudioType());
this.select(0);
};
Window_AudioList.prototype.maxCols = function() {
return 1;
};
Window_AudioList.prototype.spacing = function() {
return 0;
};
Window_AudioList.prototype.maxItems = function() {
return this._data ? this._data.length : 1;
};
Window_AudioList.prototype.item = function() {
var index = this.index();
return this._data && index >= 0 ? this._data[index] : null;
};
Window_AudioList.prototype.isEnabled = function(item) {
return item ? $gameSoundTest.isPlayAlready(item.fileName, this._audioType) : false;
};
Window_AudioList.prototype.isCurrentItemEnabled = function() {
return this.isEnabled(this._data[this.index()]);
};
Window_AudioList.prototype.makeItemList = function() {
this._data = $gameSoundTest.getAudioDataList(this._audioType);
};
Window_AudioList.prototype.drawItem = function(index) {
var item = this._data[index];
if (item) {
var rect = this.itemRect(index);
rect.width -= this.textPadding();
this.changePaintOpacity(this.isEnabled(item));
this.drawItemName(item, rect.x, rect.y, rect.width);
this.changePaintOpacity(1);
}
};
Window_AudioList.prototype.drawItemName = function(item, x, y, width) {
this.resetTextColor();
this.drawText(this.isEnabled(item) ? item.displayName : '???', x, y, width);
};
Window_AudioList.prototype.updateHelp = function() {
var item = this.item();
this._helpWindow.setText(item ? this.getDescription(item) : '');
};
Window_AudioList.prototype.getDescription = function(item) {
var name = paramShowAudioName ? '【' + item.displayName + '】\n' : '';
return this.isEnabled(item) ? name + item.description.replace('\\n', '\n') : '???';
};
Window_AudioList.prototype.setup = function(audioType) {
if (this._audioType === audioType) return;
this._audioType = audioType;
this.refresh();
this.select(0);