-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathMOG_Music_BookModifyByAXY.js
959 lines (876 loc) · 35.3 KB
/
MOG_Music_BookModifyByAXY.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
//=============================================================================
// MOG_Music_Book.js
//=============================================================================
/*:
* @plugindesc (v1.5) O plugin adiciona a cena Livro de Músicas.
* @author Moghunter
*
* @param Command Menu
* @desc Ativar o comando da cena de música.
* @default true
*
* @param Command Word
* @desc Definição do nome do comando.
* @default Music Book
*
* @param List Fade Duration
* @desc Tempo para dar fade na lista.
* @default 120
*
* @param Completion Word
* @desc Definição da palavra completado.
* @default Completion
*
* @param Meter X-Axis
* @desc Posição do medidor de tempo X-Axis
* @default 90
*
* @param Meter Y-Axis
* @desc Posição do medidor de tempo Y-Axis
* @default 0
*
* @param Point X-Axis
* @desc Posição do ponteiro do tempo X-Axis
* @default 0
*
* @param Point Y-Axis
* @desc Posição do ponteiro do tempo Y-Axis
* @default 5
*
* @param Number X-Axis
* @desc Posição do ponteiro do tempo X-Axis
* @default 350
*
* @param Number Y-Axis
* @desc Posição do ponteiro do tempo Y-Axis
* @default 16
*
* @help
* =============================================================================
* +++ MOG - Music Book (v1.5) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* =============================================================================
* O plugin adiciona uma cena onde podem ser acessadas as músicas tocadas no
* jogo.
* =============================================================================
* Para chamar o cena use o comando abaixo através do Plugin Command.
* Por padrão a cena de Música pode ser acessada pelo Menu principal.
*
* music_book
*
* =============================================================================
* As imagens correspondentes as músicas devem ser gravadas na pasta
*
* /img/musicbook/
*
* E as imagem deve ter o nome igual ao arquivo de música para aparecerem na
* tela.
* =============================================================================
* A descrição e o titulo da música devem ser feitas no arquivo
*
* Music_Titles.txt
*
* Este arquivo deve estar gravado na pasta /Data/
*
* =============================================================================
* Para configurar o script escreva estes comentários no arquivo Music_Titles.txt
* O arquivo pode ser aberto com o programa de "Bloco de Notas" comum.
*
* FILE_NAME : TITLE_OF_MUSIC : DESCRIPTION : PARTICLE_NAME : PX : PY
*
* FILE_NAME - Nome do arquivo da música.
* TITLE_OF_MUSIC - Titulo da música.
* DESCRIPTION - Descrição da música.
* PARTICLE_NAME - Nome do arquivo da partícula. (Opcional)
* PX - Velocidade da partícula horizontal.
* PY - Velocidade da partícula vertical.
*
* Exemplo
*
* Battle3:Battle For Freedom:Battle Theme 3 (Rpg Maker MV)
* Dungeon1:Empire Of Angels:Dungeon Theme 1 (Rpg Maker MV):particle_1:0:-1
* Field1:Our Destiny:FieldTheme 1 (Rpg Maker MV)
*
* =============================================================================
* HISTÓRICO
* =============================================================================
* (1.5) Correção do bug Required no modo WEB, no entanto a quantidade de músicas
* será baseado no setup do Plugin.
*/
//=============================================================================
// ** PLUGIN PARAMETERS
//=============================================================================
var Imported = Imported || {};
Imported.MOG_Music_Book = true;
var Moghunter = Moghunter || {};
Moghunter.parameters = PluginManager.parameters('MOG_Music_BookModifyByAXY');
Moghunter.musicbook_command_menu = String(Moghunter.parameters['Command Menu'] || "true");
Moghunter.musicbook_command_name = String(Moghunter.parameters['Command Word'] || "Music Book");
Moghunter.musicbook_fade_time = Number(Moghunter.parameters['List Fade Duration'] || 120);
Moghunter.musicbook_completion_word = String(Moghunter.parameters['Completion Word'] || "Completion");
Moghunter.musicbook_meter_x = Number(Moghunter.parameters['Meter X-Axis'] || 90);
Moghunter.musicbook_meter_y = Number(Moghunter.parameters['Meter Y-Axis'] || 0);
Moghunter.musicbook_point_x = Number(Moghunter.parameters['Point X-Axis'] || 0);
Moghunter.musicbook_point_y = Number(Moghunter.parameters['Point Y-Axis'] || 5);
Moghunter.musicbook_time_number_x = Number(Moghunter.parameters['Number X-Axis'] || 350);
Moghunter.musicbook_time_number_y = Number(Moghunter.parameters['Number Y-Axis'] || 16);
//=============================================================================
// ** TITLES SETTING
//=============================================================================
Moghunter.musicbook_titles = [
["001start","标题页面","门仓聪","particle_1",0,-1],
["002hunligangqinqu","婚礼进行曲","大神"],
["002name","输入名称","大神"],
["003yongshizhilian","勇士之恋","门仓聪"],
["013yuanwuqu","圆舞曲","门仓聪"],
["022liuliang","流浪","masaki"],
["033bayinheherolove","八音盒勇士之恋","门仓聪"],
["beishangsaiwaixue","悲伤塞外雪","张永","particle_1",0,-1],
["youmei8yin","优美八音","大神"],
["001hunlihuyanbin","悲伤婚礼","胡彦斌"],
["my001zgzmn","中国丈母娘","何龙雨"],
["tank1","坦克坦克,爆裂坦克","门仓聪","particle_1",0,-1]
];
//=============================================================================
// ** ImageManager
//=============================================================================
//==============================
// * Music Book
//==============================
ImageManager.loadmusicbook = function(filename) {
return this.loadBitmap('img/musicbook/', filename, 0, true);
};
//=============================================================================
// ** Game_Interpreter
//=============================================================================
//==============================
// * PluginCommand
//==============================
var _alias_mog_music_book_pluginCommand = Game_Interpreter.prototype.pluginCommand
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_alias_mog_music_book_pluginCommand.call(this,command, args)
if (command === "music_book") {$gameSystem.music_book();};
return true;
};
//=============================================================================
// ** AudioManager
//=============================================================================
//==============================
// * Play Bgm
//==============================
var _alias_mog_musicbook_aumngr_playBgm = AudioManager.playBgm
AudioManager.playBgm = function(bgm, pos) {
_alias_mog_musicbook_aumngr_playBgm.call(this,bgm,pos);
//console.log($gameSystem);
if($gameSystem != null){//by xy 2016.12.29
if ($gameSystem._music_list && bgm.name) {
for (var i = 0; i < $gameSystem._music_list.length; i++) {
if ($gameSystem._music_list[i][1] === bgm.name) {$gameSystem._music_list[i][0] = true};
};};
$gameTemp._bgmBuffer = this._bgmBuffer;
}
};
//==============================
// * Stop Bgm
//==============================
var _alias_mog_musicbook_stopBgm = AudioManager.stopBgm;
AudioManager.stopBgm = function() {
_alias_mog_musicbook_stopBgm.call(this);
//$gameTemp._bgmBuffer = null;
};
//==============================
// * Fade OutBgm
//==============================
var _alias_mog_musicbook_fadeOutBgm = AudioManager.fadeOutBgm;
AudioManager.fadeOutBgm = function(duration) {
_alias_mog_musicbook_fadeOutBgm.call(this,duration);
$gameTemp._bgmBuffer = null;
};
//=============================================================================
// ** Game_Temp
//=============================================================================
//==============================
// * Initialize
//==============================
var _alias_mog_musicbook_gtemp_initialize = Game_Temp.prototype.initialize
Game_Temp.prototype.initialize = function() {
_alias_mog_musicbook_gtemp_initialize.call(this);
this._bgmBuffer = null;
};
//=============================================================================
// ** Game_System
//=============================================================================
//==============================
// * Bgm Duration
//==============================
Game_System.prototype.bgm_duration = function(type) {
if (!$gameTemp._bgmBuffer || !$gameTemp._bgmBuffer.isReady()) {return 0};
var duration = $gameTemp._bgmBuffer._totalTime / $gameTemp._bgmBuffer._pitch
if (type === 0) {duration = Math.floor(duration);}
return duration
};
//==============================
// * Bgm pos
//==============================
Game_System.prototype.bgm_pos = function(type) {
if (!$gameTemp._bgmBuffer || !$gameTemp._bgmBuffer.isReady()) {return 0};
if (type === 0) {return Math.floor($gameTemp._bgmBuffer.seek());}
else {return $gameTemp._bgmBuffer.seek()};
};
//==============================
// * Bgm bgm_loopLength
//==============================
Game_System.prototype.bgm_loopLength = function(type) {
if (!$gameTemp._bgmBuffer || !$gameTemp._bgmBuffer.isReady()) {return 0};
return $gameTemp._bgmBuffer._loopStart
};
//==============================
// * Bgm Length Text
//==============================
Game_System.prototype.bgmLengthText = function() {
var hour = Math.floor(this.bgm_duration(0) / 60 / 60);
var min = Math.floor(this.bgm_duration(0) / 60) % 60;
var sec = this.bgm_duration(0) % 60;
return hour.padZero(1) + ':' + min.padZero(2) + ':' + sec.padZero(2);
};
//==============================
// * Bgm Pos Text
//==============================
Game_System.prototype.bgmPosText = function() {
var hour = Math.floor(this.bgm_pos(0) / 60 / 60);
var min = Math.floor(this.bgm_pos(0) / 60) % 60;
var sec = this.bgm_pos(0) % 60;
return hour.padZero(1) + ':' + min.padZero(2) + ':' + sec.padZero(2);
};
//==============================
// * Make Music List
//==============================
Game_System.prototype.make_music_list = function() {
var music_data = Moghunter.musicbook_titles;
this._music_list = [];
for (var i = 0; i < music_data.length; i++) {
var e = true;
var t = "";
var h = "";
var pn = null;
var px = 0;
var py = 0;
if (music_data[i][0] === $dataSystem.titleBgm.name) {e = true};
if (music_data[i][1]) {t = music_data[i][1]};
if (music_data[i][2]) {h = music_data[i][2]};
if (music_data[i][3]) {pn = music_data[i][3]};
if (music_data[i][4]) {px = music_data[i][4]};
if (music_data[i][5]) {py = music_data[i][5]};
this._music_list[i] = [e,music_data[i][0],t,h,pn,px,py];
};
};
//==============================
// * Music Book
//==============================
Game_System.prototype.music_book = function() {
if (!this._music_list) {return};
SoundManager.playOk();
SceneManager.push(Scene_Music_Book);
};
//=============================================================================
// ** Scene Map
//=============================================================================
//==============================
// * Initialize
//==============================
var _alias_mog_music_book_create = Scene_Map.prototype.create
Scene_Map.prototype.create = function() {
_alias_mog_music_book_create.call(this)
if (!$gameSystem._music_list) {$gameSystem.make_music_list();};
}
//=============================================================================
// ** Window Music List
//=============================================================================
function Window_MusicList() {
this.initialize.apply(this, arguments);
};
Window_MusicList.prototype = Object.create(Window_Selectable.prototype);
Window_MusicList.prototype.constructor = Window_MusicList;
//==============================
// * Initialize
//==============================
Window_MusicList.prototype.initialize = function(x, y, width, height) {
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this._ismoved = false;
this._data = $gameSystem._music_list;
this.activate();
this.select(0);
this.refresh();
};
//==============================
// * Set Top Row
//==============================
var _alias_mog_music_book_setTopRow = Window_MusicList.prototype.setTopRow;
Window_MusicList.prototype.setTopRow = function(row) {
_alias_mog_music_book_setTopRow.call(this,row);
this._ismoved = true;
};
//==============================
// * ScrollDown
//==============================
var _alias_mog_music_book_wm_scrollDown = Window_MusicList.prototype.scrollDown
Window_MusicList.prototype.scrollDown = function() {
_alias_mog_music_book_wm_scrollDown.call(this);
this._ismoved = true;
};
//==============================
// * ScrollUp
//==============================
var _alias_mog_music_book_wm_scrollUp = Window_MusicList.prototype.scrollUp
Window_MusicList.prototype.scrollUp = function() {
_alias_mog_music_book_wm_scrollUp.call(this);
this._ismoved = true;
};
//==============================
// * PageDown
//==============================
var _alias_mog_music_book_wm_cursorPagedown = Window_MusicList.prototype.cursorPagedown
Window_MusicList.prototype.cursorPagedown = function() {
_alias_mog_music_book_wm_cursorPagedown.call(this)
this._ismoved = true;
};
//==============================
// * PageUP
//==============================
var _alias_mog_music_book_wm_cursorPageup = Window_MusicList.prototype.cursorPageup
Window_MusicList.prototype.cursorPageup = function() {
_alias_mog_music_book_wm_cursorPageup.call(this)
this._ismoved = true;
};
//==============================
// * MaxCols
//==============================
Window_MusicList.prototype.maxCols = function() {
return 1;
};
//==============================
// * MaxItems
//==============================
Window_MusicList.prototype.maxItems = function() {
return this._data ? this._data.length : 1;
};
//==============================
// * IsCurrentItemEnabled
//==============================
Window_MusicList.prototype.isCurrentItemEnabled = function(i) {
return this._data[i][0];
};
//==============================
// * Refresh
//==============================
Window_MusicList.prototype.refresh = function() {
this.createContents();
this.contents.clear();
this.contents.fontItalic = true;
this.drawAllItems();
};
//==============================
// * DrawItem
//==============================
Window_MusicList.prototype.drawItem = function(i) {
if (this._data[i]) {
this.changePaintOpacity(this.isCurrentItemEnabled(i));
var rect = this.itemRect(i);
rect.width -= this.textPadding();
if (this.isCurrentItemEnabled(i)) {
if (this._data[i][2] != "") {
this.drawText(this._data[i][2] , rect.x, rect.y, this.width - 60,"center");
}
else {
this.drawText(this._data[i][1] , rect.x, rect.y, this.width - 60,"center");
};
}
else {
this.drawText("????" , rect.x, rect.y, this.width - 60,"center");
};
this.changePaintOpacity(1);
};
};
//==============================
// * Process OK
//==============================
Window_MusicList.prototype.processOk = function() {
};
//==============================
// * isOKEnable
//==============================
Window_MusicList.prototype.isOkEnabled = function() {
return true;
};
//==============================
// * processCancel
//==============================
var _alias_mog_music_book_processCancel = Window_Selectable.prototype.processCancel
Window_MusicList.prototype.processCancel = function() {
_alias_mog_music_book_processCancel.call(this);
AudioManager.stopBgm();
BattleManager.replayBgmAndBgs()
};
//=============================================================================
// ** Window_MusicComp
//=============================================================================
function Window_MusicComp() {
this.initialize.apply(this, arguments);
}
Window_MusicComp.prototype = Object.create(Window_Base.prototype);
Window_MusicComp.prototype.constructor = Window_MusicComp;
//==============================
// * Initialize
//==============================
Window_MusicComp.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, x, y, width, height);
this._data = $gameSystem._music_list;
this._data_comp = [];
for (var i = 0; i < this._data.length; i++) {
if (this._data[i][0]) {this._data_comp.push(this._data[i])};
};
this.refresh();
};
//==============================
// * Refresh
//==============================
Window_MusicComp.prototype.refresh = function() {
this.contents.clear();
var comp = Math.floor((this._data_comp.length / this._data.length) * 100)
var comp2 = "(" + this._data_comp.length + "/" + this._data.length + ")"
this.drawText(Moghunter.musicbook_completion_word + " " + comp + " % ", 0, 0, 200,"left");
this.drawText(comp2, 0, 0, (this.width - 32),"right");
};
//=============================================================================
// ** Window Help
//=============================================================================
//==============================
// * Set Text Rv
//==============================
Window_Help.prototype.setText_rv = function(text) {
if (this._text !== text) {
var words = text.split(' ');
var text1 = "";
var text2 = "";
this.textWidth(text1)
for (var i = 0; i < words.length; i++) {
if (this.textWidth(text1 + words[i]) < (this.width - 32)) {text1 += words[i] + " " }
else {text2 += words[i] + " "};
};
this._text = text;
this.contents.clear();
this.drawText(text1,0,0,(this.width - 32));
this.drawText(text2,0,this.lineHeight(),(this.width - 32));
};
};
if (String(Moghunter.musicbook_command_menu) === "true") {
//=============================================================================
// ** Window MenuCommand
//=============================================================================
//==============================
// * make Command List
//==============================
var _alias_mog_music_book_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
Window_MenuCommand.prototype.addOriginalCommands = function() {
_alias_mog_music_book_addOriginalCommands.call(this);
this.addMusicBook();
};
//==============================
// * Add Music Book
//==============================
Window_MenuCommand.prototype.addMusicBook = function() {
this.addCommand(String(Moghunter.musicbook_command_name), 'music_book', true);
};
//=============================================================================
// ** Scene Menu
//=============================================================================
//==============================
// * create Command Window
//==============================
var _alias_mog_music_book_reateCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function() {
_alias_mog_music_book_reateCommandWindow.call(this);
this._commandWindow.setHandler('music_book', this.commandMusicBook.bind(this));
this._commandWindow.height -= this._commandWindow.itemHeight();
};
//==============================
// * Music Book
//==============================
Scene_Menu.prototype.commandMusicBook = function() {
if (!$gameSystem._music_list) {return};
SceneManager.push(Scene_Music_Book);
};
};
//=============================================================================
// ** Scene Music Book
//=============================================================================
function Scene_Music_Book() {
this.initialize.apply(this, arguments);
}
Scene_Music_Book.prototype = Object.create(Scene_Base.prototype);
Scene_Music_Book.prototype.constructor = Scene_Music_Book;
//==============================
// * Initialize
//==============================
Scene_Music_Book.prototype.initialize = function() {
Scene_Base.prototype.initialize.call(this);
BattleManager.saveBgmAndBgs();
AudioManager.fadeOutBgm(1);
AudioManager.stopBgs();
this._playing_index = -1;
this._bgmPos_old = -1;
this._bgmduration_old = -1;
this._data = $gameSystem._music_list;
this._cover_fade = false;
this._fade_time = Math.max(Moghunter.musicbook_fade_time,1);
this.create_backgrounds();
this.create_particles();
this.create_position();
this.create_number_time();
this.create_window_music_list();
this.create_window_comp();
this.create_window_help();
for (var i = 0; i < this._sprite_particles.length; i++) {
this.reset_particles(i);
};
};
//==============================
// * Music
//==============================
Scene_Music_Book.prototype.music = function() {
if (!this._w_music_list) {return null}
return this._data[this._w_music_list._index];
};
//==============================
// * Create Window Music List
//==============================
Scene_Music_Book.prototype.create_backgrounds = function() {
this._background = new Sprite(ImageManager.loadmusicbook("Music_Book_A"));
this.addChild(this._background);
this._cover = new Sprite();
this._cover.anchor.x = 0.5;
this._cover.anchor.y = 0.5;
this.addChild(this._cover);
};
//==============================
// * Create Particles
//==============================
Scene_Music_Book.prototype.create_particles = function() {
this._sprite_particles = [];
this._sprite_particles_data = [];
for (i = 0; i < 30; i++) {
this._sprite_particles.push(new Sprite());
this.addChild(this._sprite_particles[i]);
this._sprite_particles_data[i] = []
this.reset_particles(i);
this._sprite_particles[i].x = Math.floor((Math.random() * Graphics.boxWidth));
this._sprite_particles[i].y = Math.floor((Math.random() * Graphics.boxHeight));
this._sprite_particles[i].opacity = 0;
this._sprite_particles[i].blendMode = 1;
};
};
//==============================
// * Refresh Particles
//==============================
Scene_Music_Book.prototype.refresh_particles = function() {
if (!this.music()[4]) {return};
for (i = 0; i < this._sprite_particles.length; i++){
this._sprite_particles[i].bitmap = ImageManager.loadmusicbook(String(this.music()[4]));
this.reset_particles(i);
this._sprite_particles[i].x = Math.floor((Math.random() * Graphics.boxWidth));
this._sprite_particles[i].y = Math.floor((Math.random() * Graphics.boxHeight));
};
};
//==============================
// * Clear Particles
//==============================
Scene_Music_Book.prototype.clear_particles = function() {
for (i = 0; i < this._sprite_particles.length; i++){
this._sprite_particles[i].bitmap = null;
};
};
//==============================
// * Reset Particles
//==============================
Scene_Music_Book.prototype.reset_particles = function(i) {
if (!this.music()) {return};
this._sprite_particles_data[i][0] = Math.floor((Math.random() * 2) * this.music()[5])
this._sprite_particles_data[i][1] = Math.floor((Math.random() * 2) * this.music()[6])
this._sprite_particles_data[i][2] = ((Math.random() * Moghunter.title_particle_a));
this._sprite_particles[i].opacity = 0;
this._sprite_particles[i].x = Math.floor((Math.random() * Graphics.boxWidth));
var pz = ((Math.random() * 0.5) * 1);
this._sprite_particles[i].scale = new PIXI.Point(0.5 + Number(pz), 0.5 + Number(pz));
if (Moghunter.title_particle_sy < 0) {
this._sprite_particles[i].y = Graphics.boxHeight + this._sprite_particles[i].height * 2;
}
else if (Moghunter.title_particle_sy > 0)
{
this._sprite_particles[i].y = -this._sprite_particles[i].height * 2;
}
else {
this._sprite_particles[i].y = Math.floor((Math.random() * Graphics.boxHeight));
}
if (this._sprite_particles_data[i][0] == 0 && this._sprite_particles_data[i][1] == 0) {
this._sprite_particles[i].x = -this._sprite_particles[i].width * 5;
this._sprite_particles_data[i][0] = 9999;
this._sprite_particles_data[i][1] = 9999;
};
};
//==============================
// * Reset Particles C
//==============================
Scene_Music_Book.prototype.reset_particles_c = function(i) {
if (!this._sprite_particles_data) {return false};
if (this._sprite_particles[i].x < -this._sprite_particles[i].width * 2 || this._sprite_particles[i].x > Graphics.boxWidth + this._sprite_particles[i].width * 2) {return true};
if (this._sprite_particles[i].y < -this._sprite_particles[i].height * 2 || this._sprite_particles[i].y > Graphics.boxHeight + this._sprite_particles[i].height * 2 ) {return true};
return false;
};
//==============================
// * Update Particles
//==============================
Scene_Music_Book.prototype.update_particles = function() {
if (!this._sprite_particles_data) {return}
for (var i = 0; i < this._sprite_particles.length; i++) {
this._sprite_particles[i].x += this._sprite_particles_data[i][0];
this._sprite_particles[i].y += this._sprite_particles_data[i][1];
this._sprite_particles[i].opacity += 2;
this._sprite_particles[i].rotation += this._sprite_particles_data[i][2];
if (this.reset_particles_c(i)) { this.reset_particles(i);};
};
};
//==============================
// * Create Number Time
//==============================
Scene_Music_Book.prototype.create_number_time = function() {
this._number_refresh = 0;
this._number_pos_data = [Moghunter.musicbook_time_number_x,Moghunter.musicbook_time_number_y];
this._sprite_number = new Sprite(new Bitmap(300,32))
this._sprite_number.x = this._number_pos_data[0];
this._sprite_number.y = this._number_pos_data[1];
this.addChild(this._sprite_number);
this.refresh_number();
};
//==============================
// * Refresh Number
//==============================
Scene_Music_Book.prototype.refresh_number = function() {
this._bgmPos_old = $gameSystem.bgm_pos(0);
this._bgmduration_old = $gameSystem.bgm_duration(0);
this._sprite_number.bitmap.clear();
var text = $gameSystem.bgmPosText() + " : " + $gameSystem.bgmLengthText();
this._sprite_number.bitmap.drawText(String(text),0,0,300,32,'center');
};
//==============================
// * Create Position
//==============================
Scene_Music_Book.prototype.create_position = function() {
this._position_data = [Moghunter.musicbook_meter_x,Moghunter.musicbook_meter_y,-1,
Moghunter.musicbook_point_x,Moghunter.musicbook_point_y,0,0,0];
this._sprite_pos_4 = new Sprite(ImageManager.loadmusicbook("Music_Book_B"))
this._sprite_pos_4.x = this._position_data[0];
this._sprite_pos_4.y = this._position_data[1];
this.addChild(this._sprite_pos_4);
this._sprite_pos_1 = new Sprite(ImageManager.loadmusicbook("Music_Book_B"))
this._sprite_pos_1.x = this._position_data[0];
this._sprite_pos_1.y = this._position_data[1];
this.addChild(this._sprite_pos_1);
this._sprite_pos_3 = new Sprite(ImageManager.loadmusicbook("Music_Book_B"))
this._sprite_pos_3.x = this._position_data[0];
this._sprite_pos_3.y = this._position_data[1];
this.addChild(this._sprite_pos_3);
this._sprite_pos_2 = new Sprite(ImageManager.loadmusicbook("Music_Book_C"))
this._position_data[5] = this._position_data[0] + this._position_data[3];
this._sprite_pos_2.x = this._position_data[5];
this._sprite_pos_2.y = this._position_data[1] + this._position_data[4];
this._sprite_pos_2.anchor.x = 0.5;
this._sprite_pos_2.anchor.y = 0.5;
this.addChild(this._sprite_pos_2);
};
//==============================
// * Create Position
//==============================
Scene_Music_Book.prototype.refresh_position_data = function() {
this._position_data[6] = this._sprite_pos_1.bitmap.height / 3;
this._position_data[2] = this._sprite_pos_1.bitmap.width;
this._position_data[1] -= this._position_data[6] + this._w_music_list.height;
this._sprite_pos_1.setFrame(0,0, this._position_data[2], this._position_data[6]);
};
//==============================
// * Update Meter
//==============================
Scene_Music_Book.prototype.update_meter = function() {
this._sprite_pos_3.setFrame(0,this._position_data[6], this.m_rate, this._position_data[6]);
var loop_range = this._position_data[2] * $gameSystem.bgm_loopLength() / $gameSystem.bgm_duration(1);
this._sprite_pos_4.setFrame(0,this._position_data[6] * 2, loop_range, this._position_data[6]);
};
//==============================
// * Set M Rate
//==============================
Scene_Music_Book.prototype.set_m_rate = function() {
return this._position_data[2] * $gameSystem.bgm_pos(1) / $gameSystem.bgm_duration(1);
};
//==============================
// * Update Position
//==============================
Scene_Music_Book.prototype.update_position = function() {
this._sprite_pos_2.x = this._position_data[5] + this.m_rate;
};
//==============================
// * Create Window Music List
//==============================
Scene_Music_Book.prototype.create_window_music_list = function() {
var w = Graphics.boxWidth;
var h = 180;
var x = 0;
var y = Graphics.boxHeight - h;
this._w_music_list = new Window_MusicList(x,y,w,h);
this._w_music_list.setHandler('cancel', this.popScene.bind(this));
this.addChild(this._w_music_list);
this._fade = [0,0,Graphics.height + 72,
Graphics.height - this._w_music_list.height];
};
//==============================
// * Create Window Comp
//==============================
Scene_Music_Book.prototype.create_window_comp = function() {
var w = Graphics.boxWidth;
var h = 72;
var x = 0;
var y = this._w_music_list.y - h
this._w_music_comp = new Window_MusicComp(x,y,w,h)
this.addChild(this._w_music_comp);
this._fade2 = [0,0,this._fade[2] - this._w_music_comp.height,
this._fade[3] - this._w_music_comp.height];
};
//==============================
// * Initialize
//==============================
Scene_Music_Book.prototype.create_window_help = function() {
this._helpWindow = new Window_Help();
this._helpWindow.contents.fontItalic = true;
this.addChild(this._helpWindow);
};
//==============================
// * Refresh Music
//==============================
Scene_Music_Book.prototype.refresh_music = function() {
this._number_refresh = 0;
if (!this.music()[0]) {this.nodata_effect();return};
SoundManager.playOk();
if (this._playing_index === this._w_music_list._index) {return;};
var text = this.music()[2] + " - " + this.music()[3];
this._helpWindow.setText_rv(text);
//this.refresh_cover();
this.play_music();
this._playing_index = this._w_music_list._index;
this.clear_particles();
this.refresh_particles();
};
//==============================
// * No Data Effect
//==============================
Scene_Music_Book.prototype.nodata_effect = function() {
SoundManager.playBuzzer();
this._cover_fade = true;
this.clear_particles();
this._helpWindow.setText_rv("");
AudioManager.stopBgm();
this._playing_index = this._w_music_list._index;
};
//==============================
// * Refresh Cover
//==============================
Scene_Music_Book.prototype.refresh_cover = function() {
var file_name = String(this.music()[1]) + ".png"
var path = "img/musicbook/"
this._cover_fade = false;
this._cover.bitmap = ImageManager.loadmusicbook(this.music()[1])
this._cover.opacity = 0;
this._cover.scale.x = 1.5;
this._cover.scale.y = this._cover.scale.x;
this._cover.x = Graphics.width / 2;
this._cover.y = Graphics.height / 2;
};
//==============================
// * Play Music
//==============================
Scene_Music_Book.prototype.play_music = function() {
var bgm = [];
bgm.name = this.music()[1]; bgm.volume = 100;bgm.pitch = 100;bgm.pan = 0;
AudioManager.playBgm(bgm,0);
};
//==============================
// * Need Refresh
//==============================
Scene_Music_Book.prototype.need_refresh = function() {
if (this._w_music_list._ismoved) {return true};
if (TouchInput.isTriggered()) {return true};
if (Input.isTriggered("ok")) {return true};
if (Input.isTriggered('up')) {return true};
if (Input.isTriggered('right')) {return true};
if (Input.isTriggered('left')) {return true};
if (Input.isTriggered('down')) {return true};
return false;
};
//==============================
// * Update Window
//==============================
Scene_Music_Book.prototype.update_window = function() {
if (this._fade[0] > 0){this._fade[0] -= 1};
if (this.need_refresh()) {this._fade[0] = this._fade_time}
if (this._fade[0] === 0) {
this._w_music_list.y += 5;
this._w_music_comp.y += 5;
this._w_music_list.opacity -= 5;
if (this._w_music_list.y > this._fade[2]) {this._w_music_list.y = this._fade[2];};
if (this._w_music_comp.y > this._fade2[2]) {this._w_music_comp.y = this._fade2[2];};
}
else {
this._w_music_list.y -= 15;
this._w_music_comp.y -= 15;
this._w_music_list.opacity += 10;
if (this._w_music_list.y < this._fade[3]) {this._w_music_list.y = this._fade[3];};
if (this._w_music_comp.y < this._fade2[3]) {this._w_music_comp.y = this._fade2[3];};
};
if (this._cover_fade ) {this._cover.opacity -= 5;}
else {this._cover.opacity += 5;};
this._w_music_list._ismoved = false;
this._w_music_list.contentsOpacity = this._w_music_list.opacity;
this._w_music_comp.opacity = this._w_music_list.opacity;
this._w_music_comp.contentsOpacity = this._w_music_list.opacity;
this._helpWindow.opacity = this._w_music_list.opacity;
if (this._cover.scale.x > 1.00) {this._cover.scale.x -= 0.01}
this._cover.scale.y = this._cover.scale.x;
this._sprite_pos_1.y = this._w_music_list.y + this._position_data[1];
this._sprite_pos_2.y = this._sprite_pos_1.y + this._position_data[4];
this._sprite_pos_3.y = this._sprite_pos_1.y;
this._sprite_pos_4.y = this._sprite_pos_3.y + this._position_data[6] / 2;
this._sprite_number.x = this._number_pos_data[0] + this._sprite_pos_1.x;
this._sprite_number.y = this._number_pos_data[1] + this._sprite_pos_1.y;
};
//==============================
// * Need Refresh Number
//==============================
Scene_Music_Book.prototype.need_refresh_number = function() {
if (this._bgmPos_old != $gameSystem.bgm_pos(0)) {return true};
if (this._bgmduration_old != $gameSystem.bgm_duration(0)) {return true};
return false;
};
//==============================
// * Update
//==============================
Scene_Music_Book.prototype.update = function() {
Scene_Base.prototype.update.call(this);
if (!this.music()) {return};
this._number_refresh += 1
this.m_rate = this.set_m_rate();
if (this.need_refresh_number()) {this.refresh_number();this._number_refresh = 0};
if (Input.isTriggered("ok") || (TouchInput.isTriggered() && this._w_music_list.isTouchedInsideFrame())) {this.refresh_music()};
if (this._position_data[2] === -1 && this._sprite_pos_1.bitmap.isReady()) {this.refresh_position_data()};
if (this._position_data[2] > -1) {this.update_position()};
this.update_particles();
this.update_meter();
this.update_window();
};