R3EXS 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +260 -260
- data/README_EN.md +260 -260
- data/bin/R3EXS +9 -19
- data/ext/rgss3a_rvdata2/rgss3a_rvdata2.c +616 -616
- data/lib/R3EXS/RGSS3.rb +1456 -1456
- data/lib/R3EXS/RGSS3_R3EXS.rb +18 -11
- data/lib/R3EXS/ast.rb +12 -17
- data/lib/R3EXS/error.rb +1 -18
- data/lib/R3EXS/extract_strings.rb +76 -79
- data/lib/R3EXS/inject_strings.rb +36 -43
- data/lib/R3EXS/json_rvdata2.rb +115 -104
- data/lib/R3EXS/rvdata2_json.rb +47 -17
- data/lib/R3EXS/utils.rb +1080 -970
- data/lib/R3EXS/version.rb +1 -1
- metadata +5 -5
data/lib/R3EXS/utils.rb
CHANGED
@@ -1,971 +1,1081 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'oj'
|
4
|
-
require_relative 'RGSS3_R3EXS'
|
5
|
-
|
6
|
-
module R3EXS
|
7
|
-
|
8
|
-
# 工具模块
|
9
|
-
# 主要用来提供一些读取,写入,转换等功能
|
10
|
-
module Utils
|
11
|
-
|
12
|
-
# 用来匹配读取的 rvdata2 文件名
|
13
|
-
RVDATA2_FILE_NAME =
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# 用来匹配读取的 JSON 文件名
|
34
|
-
JSON_FILE_NAME =
|
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
|
-
|--[int:1(Variable)]---[int(Variable ID)]--|
|
130
|
-
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
142
|
-
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
151
|
-
|--[int:
|
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
|
-
|--[int:
|
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
|
-
|--[int:
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|--[int:
|
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
|
-
|--[int:0(
|
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
|
-
|--[int:0(
|
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
|
-
|--[int:
|
508
|
-
|
509
|
-
|--[int:0(
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
| |--[int:
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|--[int:
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|--[int:
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|--[int:
|
548
|
-
|
549
|
-
|--[int:0(
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
| |--[int:
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|--[int:
|
567
|
-
|
568
|
-
|--[int:0(
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
| |--[int:
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|--[int:
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|--[int:
|
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
|
-
|--[int:
|
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
|
-
|--[int
|
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
|
-
# @param
|
761
|
-
# @param
|
762
|
-
# @param
|
763
|
-
#
|
764
|
-
#
|
765
|
-
# @raise [
|
766
|
-
# @raise [
|
767
|
-
# @raise [
|
768
|
-
#
|
769
|
-
#
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
matched_class
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
matched_class
|
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
|
-
# @param
|
818
|
-
# @param
|
819
|
-
#
|
820
|
-
#
|
821
|
-
# @raise [
|
822
|
-
#
|
823
|
-
#
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
#
|
832
|
-
# 如果 object
|
833
|
-
# 如果 object
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
obj_r3exs
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
#
|
856
|
-
#
|
857
|
-
#
|
858
|
-
# - 如果 object
|
859
|
-
#
|
860
|
-
# @param target_dir [
|
861
|
-
#
|
862
|
-
# @yieldparam object [Object] rvdata2 文件反序列化后的对象
|
863
|
-
# @yieldparam file_basename [String] 文件名(不包含扩展名)
|
864
|
-
# @
|
865
|
-
#
|
866
|
-
#
|
867
|
-
# @raise [
|
868
|
-
#
|
869
|
-
#
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
# 如果文件名不是 'Scripts',则检查 object 的类型是否正确
|
884
|
-
unless file_basename == 'Scripts'
|
885
|
-
# 检查 object 的类型是否正确
|
886
|
-
# 这里的类型检查要用紧凑模式,因为 rvdata2 文件中可能存在 nil 元素,必须忽略
|
887
|
-
begin
|
888
|
-
check_type(object, file_basename, true, :RPG)
|
889
|
-
rescue RPGTypeError
|
890
|
-
raise Rvdata2FileError.new(file_path), "Invalid rvdata2 file: #{file_path}"
|
891
|
-
end
|
892
|
-
end
|
893
|
-
|
894
|
-
yield object, file_basename
|
895
|
-
end
|
896
|
-
end
|
897
|
-
|
898
|
-
# 读取 target_dir
|
899
|
-
#
|
900
|
-
# @note 注意传入 block 的 object
|
901
|
-
# - 在 module_name 为 RPG 时,如果 object 是数组或哈希,则其中可能存在 nil 元素。如果 object 是单独一个对象,则不可能为 nil
|
902
|
-
# - 在 module_name 为 R3EXS 时,object 不会为 nil
|
903
|
-
#
|
904
|
-
# @param
|
905
|
-
#
|
906
|
-
#
|
907
|
-
# @yieldparam
|
908
|
-
# @
|
909
|
-
#
|
910
|
-
# @
|
911
|
-
#
|
912
|
-
# @raise [
|
913
|
-
# @raise [
|
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
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'oj'
|
4
|
+
require_relative 'RGSS3_R3EXS'
|
5
|
+
|
6
|
+
module R3EXS
|
7
|
+
|
8
|
+
# 工具模块
|
9
|
+
# 主要用来提供一些读取,写入,转换等功能
|
10
|
+
module Utils
|
11
|
+
|
12
|
+
# 用来匹配读取的 rvdata2 文件名
|
13
|
+
RVDATA2_FILE_NAME =
|
14
|
+
[
|
15
|
+
/\AActors\z/,
|
16
|
+
/\AAnimations\z/,
|
17
|
+
/\AArmors\z/,
|
18
|
+
/\AClasses\z/,
|
19
|
+
/\ACommonEvents\z/,
|
20
|
+
/\AEnemies\z/,
|
21
|
+
/\AItems\z/,
|
22
|
+
/\AMap\d{3}\z/,
|
23
|
+
/\AMapInfos\z/,
|
24
|
+
/\AScripts\z/,
|
25
|
+
/\ASkills\z/,
|
26
|
+
/\AStates\z/,
|
27
|
+
/\ASystem\z/,
|
28
|
+
/\ATilesets\z/,
|
29
|
+
/\ATroops\z/,
|
30
|
+
/\AWeapons\z/
|
31
|
+
]
|
32
|
+
|
33
|
+
# 用来匹配读取的 JSON 文件名
|
34
|
+
JSON_FILE_NAME =
|
35
|
+
[
|
36
|
+
/\AActors\z/,
|
37
|
+
/\AAnimations\z/,
|
38
|
+
/\AArmors\z/,
|
39
|
+
/\AClasses\z/,
|
40
|
+
/\AEnemies\z/,
|
41
|
+
/\AItems\z/,
|
42
|
+
/\AMap\d{3}\z/,
|
43
|
+
/\AMapInfos\z/,
|
44
|
+
/\ASkills\z/,
|
45
|
+
/\AStates\z/,
|
46
|
+
/\ASystem\z/,
|
47
|
+
/\ATilesets\z/,
|
48
|
+
/\ATroops\z/,
|
49
|
+
/\AWeapons\z/
|
50
|
+
]
|
51
|
+
|
52
|
+
# 用来匹配读取的文件名到对应的R3EXS的类
|
53
|
+
FILE_BASENAME_TO_CLASS_R3EXS = {
|
54
|
+
/\AActors\z/ => R3EXS::Actor,
|
55
|
+
/\AAnimations\z/ => R3EXS::Animation,
|
56
|
+
/\AArmors\z/ => R3EXS::Armor,
|
57
|
+
/\AClasses\z/ => R3EXS::Class,
|
58
|
+
/\ACommonEvents\z/ => R3EXS::CommonEvent,
|
59
|
+
/\AEnemies\z/ => R3EXS::Enemy,
|
60
|
+
/\AItems\z/ => R3EXS::Item,
|
61
|
+
/\AMap\d{3}\z/ => R3EXS::Map,
|
62
|
+
/\AMapInfos\z/ => R3EXS::MapInfo,
|
63
|
+
/\ASkills\z/ => R3EXS::Skill,
|
64
|
+
/\AStates\z/ => R3EXS::State,
|
65
|
+
/\ASystem\z/ => R3EXS::System,
|
66
|
+
/\ATilesets\z/ => R3EXS::Tileset,
|
67
|
+
/\ATroops\z/ => R3EXS::Troop,
|
68
|
+
/\AWeapons\z/ => R3EXS::Weapon
|
69
|
+
}
|
70
|
+
|
71
|
+
# 用来匹配读取的文件名到对应的RPG的类
|
72
|
+
FILE_BASENAME_TO_CLASS_RPG = {
|
73
|
+
/\AActors\z/ => RPG::Actor,
|
74
|
+
/\AAnimations\z/ => RPG::Animation,
|
75
|
+
/\AArmors\z/ => RPG::Armor,
|
76
|
+
/\AClasses\z/ => RPG::Class,
|
77
|
+
/\ACommonEvents\z/ => RPG::CommonEvent,
|
78
|
+
/\AEnemies\z/ => RPG::Enemy,
|
79
|
+
/\AItems\z/ => RPG::Item,
|
80
|
+
/\AMap\d{3}\z/ => RPG::Map,
|
81
|
+
/\AMapInfos\z/ => RPG::MapInfo,
|
82
|
+
/\ASkills\z/ => RPG::Skill,
|
83
|
+
/\AStates\z/ => RPG::State,
|
84
|
+
/\ASystem\z/ => RPG::System,
|
85
|
+
/\ATilesets\z/ => RPG::Tileset,
|
86
|
+
/\ATroops\z/ => RPG::Troop,
|
87
|
+
/\AWeapons\z/ => RPG::Weapon
|
88
|
+
}
|
89
|
+
|
90
|
+
# 事件指令的命令名称
|
91
|
+
EVENT_COMMANDS = {
|
92
|
+
0 => 'Empty',
|
93
|
+
|
94
|
+
=begin
|
95
|
+
[string(Face Graphic name)]---[int(Face Graphic index)]---[int:{0:Normal Window, 1:Dim Background, 2:Transparent}]---[int:{0:Top, 1:Middle, 2:Bottom}]---END
|
96
|
+
=end
|
97
|
+
101 => 'ShowTextAttributes',
|
98
|
+
|
99
|
+
=begin
|
100
|
+
[Array<string>(Choices Array)]---[int:{0:Disallow, 1:Choice 1, 2:Choice 2, 3:Choice 3, 4:Choice 4, 5:Branch}(When Cancel)]---END
|
101
|
+
=end
|
102
|
+
102 => 'ShowChoices',
|
103
|
+
|
104
|
+
=begin
|
105
|
+
[int(Variable for Number)]---[int:{1~8}(Digits)]---END
|
106
|
+
=end
|
107
|
+
103 => 'InputNumber',
|
108
|
+
|
109
|
+
=begin
|
110
|
+
[int(Variable for Item ID)]---END
|
111
|
+
=end
|
112
|
+
104 => 'SelectKeyItem',
|
113
|
+
|
114
|
+
=begin
|
115
|
+
[int:{1~8}(Speed)]---[bool(No Fast Forward)]---END
|
116
|
+
=end
|
117
|
+
105 => 'ShowScrollingTextAttributes',
|
118
|
+
|
119
|
+
=begin
|
120
|
+
[string]---END
|
121
|
+
=end
|
122
|
+
108 => 'Comment',
|
123
|
+
|
124
|
+
=begin
|
125
|
+
|--[int:0(Switch)]---[int(Switch ID)]---[int{0:ON, 1:OFF}]---END
|
126
|
+
|
|
127
|
+
| |--[int:0(Compare to Constant)]---[int(Number)]-------|
|
128
|
+
|--[int:1(Variable)]---[int(Variable ID)]--| |--[int{0:==, 1:>=, 2:<=, 3:>, 4:<, 5:!=}]---END
|
129
|
+
| |--[int:1(Compare to Variable)]---[int(Variable ID)]--|
|
130
|
+
|
|
131
|
+
|--[int:2(Self Switch)]---[string{'A', 'B', 'C', 'D'}]---[int{0:ON, 1:OFF}]---END
|
132
|
+
|
|
133
|
+
|--[int:3(Timer)]---[int:{0~5999}(sec)]---[int{0:>=, 1:<=}]---END
|
134
|
+
|
|
135
|
+
| |--[int:0(In the Party)]---END
|
136
|
+
| |
|
137
|
+
| |--[int:1(Name)]---[string]---END
|
138
|
+
| |
|
139
|
+
| |--[int:2(Class)]---[int(Class ID)]---END
|
140
|
+
| |
|
141
|
+
|--[int:4(Actor)]---[int(Actor ID)]--------|--[int:3(Skill)]---[int(Skill ID)]---END
|
142
|
+
| |
|
143
|
+
| |--[int:4(Weapon)]---[int(Wwapon ID)]---END
|
144
|
+
| |
|
145
|
+
| |--[int:5(Armor)]---[int(Armor ID)]---END
|
146
|
+
| |
|
147
|
+
| |--[int:6(State)]---[int(State ID)]---END
|
148
|
+
|
|
149
|
+
| |--[int:0(Appeared)---END
|
150
|
+
|--[int:5(Enemy)]---[int(Enemy ID)]--------|
|
151
|
+
| |--[int:1(State)]---[int(State ID)]---END
|
152
|
+
|
|
153
|
+
|--[int:6(Character)]---[int:{-1:Player, 0:This event, 1:EV001, ...}]---[int:{2:Down, 4:Left, 6:Right, 8:Up}]---END
|
154
|
+
|
|
155
|
+
|--[int:7(Gold)]---[int(Money)]---[int{0:>=, 1:<=, 2:<}]---END
|
156
|
+
|
|
157
|
+
|--[int:8(Item)]---[int(Item ID)]---END
|
158
|
+
|
|
159
|
+
|--[int:9(Weapon)]---[int(Weapon ID)]---[bool(Include Equipments)]---END
|
160
|
+
|
|
161
|
+
|--[int:10(Armor)]---[int(Armor ID)]---[bool(Include Equipments)]---END
|
162
|
+
|
|
163
|
+
|--[int:11(Button)]---[int:{2:Down, 4:Left, 6:Right, 8:Up, 11:A, 12:B, 13:C, 14:X, 15:Y, 16:Z, 17:L, 18:R}]---END
|
164
|
+
|
|
165
|
+
|--[int:12(Script)]---[string]---END
|
166
|
+
|
|
167
|
+
|--[int:13(Vehicle)]---[int:{0:Boat, 1:Ship, 2:Airship}]---END
|
168
|
+
=end
|
169
|
+
111 => 'ConditionalBranch',
|
170
|
+
112 => 'Loop',
|
171
|
+
113 => 'BreakLoop',
|
172
|
+
115 => 'ExitEventProcessing',
|
173
|
+
|
174
|
+
=begin
|
175
|
+
[int(Common Event ID)]---END
|
176
|
+
=end
|
177
|
+
117 => 'CallCommonEvent',
|
178
|
+
|
179
|
+
=begin
|
180
|
+
[string]---END
|
181
|
+
=end
|
182
|
+
118 => 'Label',
|
183
|
+
|
184
|
+
=begin
|
185
|
+
|
186
|
+
[string]---END
|
187
|
+
=end
|
188
|
+
119 => 'JumpToLabel',
|
189
|
+
|
190
|
+
=begin
|
191
|
+
[int(Switch Begin ID)]---[int(Switch End ID)]---[int:{0:ON, 1:OFF}]---END
|
192
|
+
=end
|
193
|
+
121 => 'ControlSwitches',
|
194
|
+
|
195
|
+
=begin
|
196
|
+
|--[int:0(Constant)]---[int(Number)]---END
|
197
|
+
|
|
198
|
+
|--[int:1(Variable)]---[int(Variable ID)]---END
|
199
|
+
|
|
200
|
+
|--[int:2(Random)]---[int(Min)]---[int(Max)]---END
|
201
|
+
|
|
202
|
+
| |--[int:{0:Item, 1:Weapon, 2:Armor}]---[int(Corresponded Item ID)]---[int:0]---END
|
203
|
+
| |
|
204
|
+
[int(Variable Begin ID)]---[int(Variable End ID)]---[int:{0:Set, 1:Add, 2:Sub, 3:Mul, 4:Div, 5:Mod}]--| |--[int:3(Actor)]---[int:(Actor ID)]---[int:{0:Level, 1:EXP, 2:HP, 3:MP, 4:MHP, 5:MMP, 6:ATK, 7:DEF, 8:MAT, 9:MDF, 10:AGI, 11:LUK}]---END
|
205
|
+
| |
|
206
|
+
| |--[int:4(Enemy)]---[int:(Enemy ID)]---[int:{0:HP, 1:MP, 2:MHP, 3:MMP, 4:ATK, 5:DEF, 6:MAT, 7:MDF, 8:AGI, 9:LUK}]---END
|
207
|
+
|--[int:3(Game Data)]--|
|
208
|
+
| |--[int:5(Character)]---[int:{-1:Player, 0:This Event, 1:EV001, ...}]---[int:{0:Map X, 1:Map Y, 2:Direction, 3:Screen X ,4:Screen Y}]---END
|
209
|
+
| |
|
210
|
+
| |--[int:6(Party)]---[int:{0~7}(Member ID)]---[int:0]---END('s Actor ID)
|
211
|
+
| |
|
212
|
+
| |--[int:7(Other)]---[int:{0(Map ID), 1(Party Members), 2(Gold), 3(Steps), 4(Play Time), 5(Timer), 6(Save Count), 7(Battle Count)}]---[int:0]---END
|
213
|
+
|
|
214
|
+
|--[int:4(Scripts)]---[string]---END
|
215
|
+
=end
|
216
|
+
122 => 'ControlVariables',
|
217
|
+
|
218
|
+
=begin
|
219
|
+
[string:{'A', 'B', 'C', 'D'}(Self Switch Name)]---[int:{0:ON, 1:OFF}]---END
|
220
|
+
=end
|
221
|
+
123 => 'ControlSelfSwitch',
|
222
|
+
|
223
|
+
=begin
|
224
|
+
[int:{0:Start, 1:Stop}]---[int:{0~5999}(sec)]---END
|
225
|
+
=end
|
226
|
+
124 => 'ControlTimer',
|
227
|
+
|
228
|
+
=begin
|
229
|
+
|--[int:0(Constant)]---[int:{0~9999999}(Number)]---END
|
230
|
+
[int:{0:Increase, 1:Decrease}]--|
|
231
|
+
|--[int:1(Variable)]---[int(Variable ID)]---END
|
232
|
+
=end
|
233
|
+
125 => 'ChangeGold',
|
234
|
+
|
235
|
+
=begin
|
236
|
+
|--[int:0(Constant)]---[int:{0~9999999}(Number)]---END
|
237
|
+
[int(Item ID)]---[int:{0:Increase, 1:Decrease}]--|
|
238
|
+
|--[int:1(Variable)]---[int(Variable ID)]---END
|
239
|
+
=end
|
240
|
+
126 => 'ChangeItems',
|
241
|
+
|
242
|
+
=begin
|
243
|
+
|--[int:0(Constant)]---[int:{0~9999999}(Number)]--|
|
244
|
+
|--[int:0(Increase)]--| |--[bool:false(Include Equipment)]---END
|
245
|
+
| |--[int:1(Variable)]---[int(Variable ID)]---------|
|
246
|
+
[int(Weapon ID)]--|
|
247
|
+
| |--[int:0(Constant)]---[int:{0~9999999}(Number)]--|
|
248
|
+
|--[int:1(Decrease)]--| |--[bool(Include Equipment)]---END
|
249
|
+
|--[int:1(Variable)]---[int(Variable ID)]---------|
|
250
|
+
=end
|
251
|
+
127 => 'ChangeWeapons',
|
252
|
+
|
253
|
+
=begin
|
254
|
+
|--[int:0(Constant)]---[int:{0~9999999}(Number)]--|
|
255
|
+
|--[int:0(Increase)]--| |--[bool:false(Include Equipment)]---END
|
256
|
+
| |--[int:1(Variable)]---[int(Variable ID)]---------|
|
257
|
+
[int(Armor ID)]--|
|
258
|
+
| |--[int:0(Constant)]---[int:{0~9999999}(Number)]--|
|
259
|
+
|--[int:1(Decrease)]--| |--[bool(Include Equipment)]---END
|
260
|
+
|--[int:1(Variable)]---[int(Variable ID)]---------|
|
261
|
+
=end
|
262
|
+
128 => 'ChangeArmor',
|
263
|
+
|
264
|
+
=begin
|
265
|
+
[int(Actor ID)]---[int:{0:Add, 1:Remove}]---[int:{0:NO, 1:YES}(Initialize)]---END
|
266
|
+
=end
|
267
|
+
129 => 'ChangePartyMember',
|
268
|
+
|
269
|
+
=begin
|
270
|
+
[RPG::BGM]---END
|
271
|
+
=end
|
272
|
+
132 => 'ChangeBattleBGM',
|
273
|
+
|
274
|
+
=begin
|
275
|
+
[RPG::ME]---END
|
276
|
+
=end
|
277
|
+
133 => 'ChangeBattleEndME',
|
278
|
+
|
279
|
+
=begin
|
280
|
+
[int:{0:Disable, 1:Enable}]---END
|
281
|
+
=end
|
282
|
+
134 => 'ChangeSaveAccess',
|
283
|
+
|
284
|
+
=begin
|
285
|
+
[int:{0:Disable, 1:Enable}]---END
|
286
|
+
=end
|
287
|
+
135 => 'ChangeMenuAccess',
|
288
|
+
|
289
|
+
=begin
|
290
|
+
[int:{0:Disable, 1:Enable}]---END
|
291
|
+
=end
|
292
|
+
136 => 'ChangeEncounter',
|
293
|
+
|
294
|
+
=begin
|
295
|
+
[int:{0:Disable, 1:Enable}]---END
|
296
|
+
=end
|
297
|
+
137 => 'ChangeFormationAccess',
|
298
|
+
|
299
|
+
=begin
|
300
|
+
[RPG::Tone]---END
|
301
|
+
=end
|
302
|
+
138 => 'ChangeWindowColor',
|
303
|
+
|
304
|
+
=begin
|
305
|
+
|--[int:0(Direct Designation)]---[int(Map ID)]---[int(Map X)]---[int(Map Y)]-------------------------------------------------------------------------------------|
|
306
|
+
| |--[int:{0:Retain, 2:Down, 4:Left, 6:Right, 8:Up}(Direction)]---[int:{0:Normal, 1:White, 2:None}(Fade)]---END
|
307
|
+
|--[int:1(Designation with Variables)]---[int(Map ID Corresponded Variable ID)]---[int(Map X Corresponded Variable ID)]---[int(Map Y Corresponded Variable ID)]--|
|
308
|
+
=end
|
309
|
+
201 => 'TransferPlayer',
|
310
|
+
|
311
|
+
=begin
|
312
|
+
|--[int:0(Direct Designation)]---[int(Map ID)]---[int(Map X)]---[int(Map Y)]---END
|
313
|
+
[int:{0:Boat, 1:Ship, 2:Airship}]--|
|
314
|
+
|--[int:1(Designation with Variables)]---[int(Map ID Corresponded Variable ID)]---[int(Map X Corresponded Variable ID)]---[int(Map Y Corresponded Variable ID)]---END
|
315
|
+
=end
|
316
|
+
202 => 'SetVehicleLocation',
|
317
|
+
|
318
|
+
=begin
|
319
|
+
|--[int:0(Direct Designation)]---[int(Map X)]---[int(Map Y)]------------------------------------------------------------|
|
320
|
+
| |
|
321
|
+
[int:{0:This Event, 1:EV001, ...}]----------|--[int:1(Designation with Variables)]---[int(Map X Corresponded Variable ID)]---[int(Map Y Corresponded Variable ID)]--|--[int:{0:Retain, 2:Down, 4:Left, 6:Right, 8:Up}(Direction)]---END
|
322
|
+
| |
|
323
|
+
|--[int:2(Exchange with Another Event)]---[int(Exchanged Event ID)]---[int:0]----------------------------------------- |
|
324
|
+
=end
|
325
|
+
203 => 'SetEventLocation',
|
326
|
+
|
327
|
+
=begin
|
328
|
+
[int:{2:Down, 4:Left, 6:Right, 8:Up}]---[int:{0~100}(Distance)]---[int:{1:1/8 Speed, 2:1/4 Speed, 3:1/2 Speed, 4:Normal, 5:2 Speed, 6:4 Speed}]---END
|
329
|
+
=end
|
330
|
+
204 => 'ScrollMap',
|
331
|
+
|
332
|
+
=begin
|
333
|
+
[int:{-1:Player, 0:This Event, 1:EV001, ...}]---[RPG::MoveRoute(45 is Script)]---END
|
334
|
+
=end
|
335
|
+
205 => 'SetMoveRoute',
|
336
|
+
|
337
|
+
=begin
|
338
|
+
END
|
339
|
+
=end
|
340
|
+
206 => 'GetSwitchVehicle',
|
341
|
+
|
342
|
+
=begin
|
343
|
+
[int:{0:ON, 1:OFF}]---END
|
344
|
+
=end
|
345
|
+
211 => 'ChangeTransparency',
|
346
|
+
|
347
|
+
=begin
|
348
|
+
[int:{-1:Player, 0:This Event, 1:EV001, ...}]---[int(Animation ID)]---[bool(Wait for Completion)]---END
|
349
|
+
=end
|
350
|
+
212 => 'ShowAnimation',
|
351
|
+
|
352
|
+
=begin
|
353
|
+
[int:{-1:Player, 0:This Event, 1:EV001, ...}]---[int(Ballon Icon ID)]---[bool(Wait for Completion)]---END
|
354
|
+
=end
|
355
|
+
213 => 'ShowBalloonIcon',
|
356
|
+
214 => 'EraseEvent',
|
357
|
+
|
358
|
+
=begin
|
359
|
+
[int:{0:ON, 1:OFF}]---END
|
360
|
+
=end
|
361
|
+
216 => 'ChangePlayerFollowers',
|
362
|
+
217 => 'GatherFollowers',
|
363
|
+
221 => 'FadeoutScreen',
|
364
|
+
222 => 'FadeinScreen',
|
365
|
+
|
366
|
+
=begin
|
367
|
+
[RPG::Tone]---[int:{0~600}(Time 1/60 sec)]---[bool(Wait for Completion)]---END
|
368
|
+
=end
|
369
|
+
223 => 'TintScreen',
|
370
|
+
|
371
|
+
=begin
|
372
|
+
[RPG::Color]---[int:{0~600}(Time 1/60 sec)]---[bool(Wait for Completion)]---END
|
373
|
+
=end
|
374
|
+
224 => 'FlashScreen',
|
375
|
+
|
376
|
+
=begin
|
377
|
+
[int:{1~9}(Power)]---[int:{1~9}(Speed)]---[int:{0~600}(Time 1/60 sec)]---[bool(Wait for Completion)]---END
|
378
|
+
=end
|
379
|
+
225 => 'ShakeScreen',
|
380
|
+
|
381
|
+
=begin
|
382
|
+
[int:{0~999}(Time 1/60 sec)]---END
|
383
|
+
=end
|
384
|
+
230 => 'Wait',
|
385
|
+
|
386
|
+
=begin
|
387
|
+
|--[int:0(Constant)]---[int:{-9999~9999}(Map X)]---[int:{-9999~9999}(Map Y)]--------------------------|
|
388
|
+
[int:{1~100}(Number)]---[string(Picture Graphic Name)]---[int:{0:Upper Left, 1:Center}(Origin)]--| |--[int:{0~2000}(Width %)]---[int:{0~2000}(Height %)]---[int:{0~255}(Opacity)]---[int:{0:Normal, 1:Add, 2:Sub}]---END
|
389
|
+
|--[int:1(Variable)]---[int(Map X Corresponded Variable ID)]---[int(Map Y Corresponded Variable ID)]--|
|
390
|
+
=end
|
391
|
+
231 => 'ShowPicture',
|
392
|
+
|
393
|
+
=begin
|
394
|
+
|--[int:0(Constant)]---[int:{-9999~9999}(Map X)]---[int:{-9999~9999}(Map Y)]--------------------------|
|
395
|
+
[int:{1~100}(Number)]---[int:{0:Upper Left, 1:Center}(Origin)]--| |--[int:{0~2000}(Width %)]---[int:{0~2000}(Height %)]---[int:{0~255}(Opacity)]---[int:{0:Normal, 1:Add, 2:Sub}]---[int:{0~600}(Time 1/60 sec)]---[bool(Wait for Completion)]---END
|
396
|
+
|--[int:1(Variable)]---[int(Map X Corresponded Variable ID)]---[int(Map Y Corresponded Variable ID)]--|
|
397
|
+
=end
|
398
|
+
232 => 'MovePicture',
|
399
|
+
|
400
|
+
=begin
|
401
|
+
[int:{1~100}(Number)]-[int:{-90~90}(Speed)]--END
|
402
|
+
=end
|
403
|
+
233 => 'RotatePicture',
|
404
|
+
|
405
|
+
=begin
|
406
|
+
[int:{1~100}(Number)]---[RPG::Tone]---[int:{0~600}(Time 1/60 sec)]---[bool(Wait for Completion)]---END
|
407
|
+
=end
|
408
|
+
234 => 'TintPicture',
|
409
|
+
|
410
|
+
=begin
|
411
|
+
[int:{1~100}(Number)]---END
|
412
|
+
=end
|
413
|
+
235 => 'ErasePicture',
|
414
|
+
|
415
|
+
=begin
|
416
|
+
[string:{":none", ":rain", ":storm", ":snow"}]---[int:{0~9}(Power)]---[int:{0~600}(Time 1/60 sec)]---[bool(Wait for Completion)]---END
|
417
|
+
=end
|
418
|
+
236 => 'SetWeatherEffects',
|
419
|
+
|
420
|
+
=begin
|
421
|
+
[RPG::BGM]---END
|
422
|
+
=end
|
423
|
+
241 => 'PlayBGM',
|
424
|
+
|
425
|
+
=begin
|
426
|
+
[int:{1~60}(Time sec)]---END
|
427
|
+
=end
|
428
|
+
242 => 'FadeoutBGM',
|
429
|
+
243 => 'SaveBGM',
|
430
|
+
244 => 'ReplayBGM',
|
431
|
+
|
432
|
+
=begin
|
433
|
+
[RPG::BGM]---END
|
434
|
+
=end
|
435
|
+
245 => 'PlayBGS',
|
436
|
+
|
437
|
+
=begin
|
438
|
+
[int:{1~60}(Time sec)]---END
|
439
|
+
=end
|
440
|
+
246 => 'FadeoutBGS',
|
441
|
+
|
442
|
+
=begin
|
443
|
+
[RPG::ME]---END
|
444
|
+
=end
|
445
|
+
249 => 'PlayME',
|
446
|
+
|
447
|
+
=begin
|
448
|
+
[RPG::SE]---END
|
449
|
+
=end
|
450
|
+
250 => 'PlaySE',
|
451
|
+
251 => 'StopSE',
|
452
|
+
|
453
|
+
=begin
|
454
|
+
[string(Movie Name)]---END
|
455
|
+
=end
|
456
|
+
261 => 'PlayMovie',
|
457
|
+
|
458
|
+
=begin
|
459
|
+
[int:{0:ON, 1:OFF}]---END
|
460
|
+
=end
|
461
|
+
281 => 'ChangeMapNameDisplay',
|
462
|
+
|
463
|
+
=begin
|
464
|
+
[int(Tileset ID)]---END
|
465
|
+
=end
|
466
|
+
282 => 'ChangeTileset',
|
467
|
+
|
468
|
+
=begin
|
469
|
+
[string(Floor Picture)]---[string(Wall Picture)]---END
|
470
|
+
=end
|
471
|
+
283 => 'ChangeBattleBack',
|
472
|
+
|
473
|
+
=begin
|
474
|
+
[string(Distant view Picture)]---[bool(Loop Horizontal)]---[bool(Loop Vertical)]---[int(-32~32)(Horizontal Scroll)]---[int(-32~32)(Vertical Scrool)]---END
|
475
|
+
=end
|
476
|
+
284 => 'ChangeParallaxBack',
|
477
|
+
|
478
|
+
=begin
|
479
|
+
|--[int:0(Direct Designation)]---[int(Map X)]---[int(Map Y)]---END
|
480
|
+
[int(Variable for Info)]---[int:{0:Terrain, 1:Event ID, 2:Tile ID(Layer 1), 3:Tile ID(Layer 2), 4:Tile ID(Layer 3), 5:Region ID}(Info Type)]--|
|
481
|
+
|--[int:1(Designation with Variables)]---[int(Map X Corresponded Variable ID)]---[int(Map Y Corresponded Variable ID)]---END
|
482
|
+
=end
|
483
|
+
285 => 'GetLocationInfo',
|
484
|
+
|
485
|
+
=begin
|
486
|
+
|--[int:0(Direct Designation)]---[int(Enemy ID)]-----------------------------------|
|
487
|
+
| |--[bool(Can Escape)]---[bool(Continue Even When Loser)]---END
|
488
|
+
|--[int:1(Designation with Variables)]---[int(Enemy ID Corresponded Variable ID)]--|
|
489
|
+
=end
|
490
|
+
301 => 'BattleProcessing',
|
491
|
+
|
492
|
+
=begin
|
493
|
+
|--[int:0(Price: Standard)]---[int:0]------------------|
|
494
|
+
[int:{0:Item, 1:Weapon, 2:Armor}]---[int(Corresponded Item ID)]--| |--[bool(Purchase Only)]---END
|
495
|
+
|--[int:1(Price: Specify)]---[int:{0~9999999}(Price)]--|
|
496
|
+
=end
|
497
|
+
302 => 'ShopProcessing',
|
498
|
+
|
499
|
+
=begin
|
500
|
+
[int(Actor ID)]---[int:{1~16}(Max Characters)]---END
|
501
|
+
=end
|
502
|
+
303 => 'NameInputProcessing',
|
503
|
+
|
504
|
+
=begin
|
505
|
+
|--[int:0(Constant)]---[int:{1~9999}(Number)]--|
|
506
|
+
|--[int:0(Increase)]--| |--[bool:false(Allow Knockout)]---END
|
507
|
+
| |--[int:1(Variable)]---[int(Variable ID)]------|
|
508
|
+
|--[int:0(Fixed)]---[int:{0:Entire Party, 1:Actor 001, ...}]--|
|
509
|
+
| | |--[int:0(Constant)]---[int:{1~9999}(Number)]--|
|
510
|
+
| |--[int:1(Decrease)]--| |--[bool(Allow Knockout)]---END
|
511
|
+
| |--[int:1(Variable)]---[int(Variable ID)]------|
|
512
|
+
|
|
513
|
+
| |--[int:0(Constant)]---[int:{1~9999}(Number)]--|
|
514
|
+
| |--[int:0(Increase)]--| |--[bool:false(Allow Knockout)]---END
|
515
|
+
| | |--[int:1(Variable)]---[int(Variable ID)]------|
|
516
|
+
|--[int:1(Variable)]---[int(Variable ID)]-----------------------|
|
517
|
+
| |--[int:0(Constant)]---[int:{1~9999}(Number)]--|
|
518
|
+
|--[int:1(Decrease)]--| |--[bool(Allow Knockout)]---END
|
519
|
+
|--[int:1(Variable)]---[int(Variable ID)]------|
|
520
|
+
=end
|
521
|
+
311 => 'ChangeHP',
|
522
|
+
|
523
|
+
=begin
|
524
|
+
|--[int:0(Fixed)]---[int:{0:Entire Party, 1:Actor 001, ...}]--| |--[int:0(Constant)]---[int:{1~9999}(Number)]---END
|
525
|
+
| |--[int:{0:Increase, 1:Decrease}]--|
|
526
|
+
|--[int:1(Variable)]---[int(Variable ID)]---------------------| |--[int:1(Variable)]---[int(Variable ID)]---END
|
527
|
+
=end
|
528
|
+
312 => 'ChangeMP',
|
529
|
+
|
530
|
+
=begin
|
531
|
+
|--[int:0(Fixed)]---[int:{0:Entire Party, 1:Actor 001, ...}]--|
|
532
|
+
| |--[int:{0:Add, 1:Remove}]---[int(State ID)]---END
|
533
|
+
|--[int:1(Variable)]---[int(Variable ID)]---------------------|
|
534
|
+
=end
|
535
|
+
313 => 'ChangeState',
|
536
|
+
|
537
|
+
=begin
|
538
|
+
|--[int:0(Fixed)]---[int:{0:Entire Party, 1:Actor 001, ...}]---END
|
539
|
+
|
|
540
|
+
|--[int:1(Variable)]---[int(Variable ID)]---END
|
541
|
+
=end
|
542
|
+
314 => 'RecoverAll',
|
543
|
+
|
544
|
+
=begin
|
545
|
+
|--[int:0(:Constant)]---[int:{1~9999999}(Number)]--|
|
546
|
+
|--[int:0(Increase)]--| |--[bool(Show Level Up Message)]---END
|
547
|
+
| |--[int:1(Variable)]---[int(Variable ID)]----------|
|
548
|
+
|--[int:0(Fixed)]---[int:{0:Entire Party, 1:Actor 001, ...}]--|
|
549
|
+
| | |--[int:0(Constant)]---[int:{1~9999999}(Number)]--|
|
550
|
+
| |--[int:1(Decrease)]--| |--[bool:false(Show Level Up Message)]---END
|
551
|
+
| |--[int:1(Variable)]------------------------------|
|
552
|
+
|
|
553
|
+
| |--[int:0(Constant)]---[int:{1~9999999}(Number)]--|
|
554
|
+
| |--[int:0(Increase)]--| |--[bool(Show Level Up Message)]---END
|
555
|
+
| | |--[int:1(Variable)]---[int(Variable ID)]---------|
|
556
|
+
|--[int:1(Variable)]---[int(Variable ID)]---------------------|
|
557
|
+
| |--[int:0(Constant)]---[int:{1~9999999}(Number)]--|
|
558
|
+
|--[int:1(Decrease)]--| |--[bool:false(Show Level Up Message)]---END
|
559
|
+
|--[int:1(Variable)]---[int(Variable ID)]---------|
|
560
|
+
=end
|
561
|
+
315 => 'ChangeEXP',
|
562
|
+
|
563
|
+
=begin
|
564
|
+
|--[int:0(Constant)]---[int:{1~98}(Number)]--|
|
565
|
+
|--[int:0(Increase)]--| |--[bool(Show Level Up Message)]---END
|
566
|
+
| |--[int:1(Variable)]---[int(Variable ID)]----|
|
567
|
+
|--[int:0(Fixed)]---[int:{0:Entire Party, 1:Actor 001, ...}]--|
|
568
|
+
| | |--[int:0(Constant)]---[int:{1~98}(Number)]--|
|
569
|
+
| |--[int:1(Decrease)]--| |--[bool:false(Show Level Up Message)]---END
|
570
|
+
| |--[int:1(Variable)]---[int(Variable ID)]----|
|
571
|
+
|
|
572
|
+
| |--[int:0(Constant)]---[int:{1~98}(Number)]--|
|
573
|
+
| |--[int:0(Increase)]--| |--[bool(Show Level Up Message)]---END
|
574
|
+
| | |--[int:1(Variable)]---[int(Variable ID)]----|
|
575
|
+
|--[int:1(Variable)]---[int(Variable ID)]---------------------|
|
576
|
+
| |--[int:0(Constant)]---[int:{1~98}(Number)]--|
|
577
|
+
|--[int:1(Decrease)]--| |--[bool:false(Show Level Up Message)]---END
|
578
|
+
|--[int:1(Variable)]---[int(Variable ID)]------|
|
579
|
+
=end
|
580
|
+
316 => 'ChangeLevel',
|
581
|
+
|
582
|
+
=begin
|
583
|
+
|--[int:0(Fixed)]---[int:{0:Entire Party, 1:Actor 001, ...}]--| |--[int:0(Constant)]---[int:{0~9999999}(Number)]---END
|
584
|
+
| |--[int:{0:MHP, 1:MMP, 2:ATK, 3:DEF, 4:MAT, 5:MDF, 6:AGI, 7:LUK}]---[int:{0:Increase, 1:Decrease}]--|
|
585
|
+
|--[int:1(Variable)]---[int(Variable ID)]---------------------| |--[int:1(Variable)]---[int(Variable ID)]---END
|
586
|
+
=end
|
587
|
+
317 => 'ChangeParameters',
|
588
|
+
|
589
|
+
=begin
|
590
|
+
|--[int:0(Fixed)]---[int:{0:Entire Party, 1:Actor 001, ...}]--|
|
591
|
+
| |--[int:{0:Learn, 1:Forget}]---[int(Skill ID)]---END
|
592
|
+
|--[int:1(Variable)]---[int(Variable ID)]---------------------|
|
593
|
+
=end
|
594
|
+
318 => 'ChangeSkills',
|
595
|
+
|
596
|
+
=begin
|
597
|
+
[int(Actor ID)]---[int:{0:Weapon, 1:Shield, 2:Head, 3:Boby, 4:Accessory}]---[int:{0:None, 1:Equipment 001, ...}(Equipment ID)]---END
|
598
|
+
=end
|
599
|
+
319 => 'ChangeEquipment',
|
600
|
+
|
601
|
+
=begin
|
602
|
+
[int(Actor ID)]---[string(New Actor Name)]---END
|
603
|
+
=end
|
604
|
+
320 => 'ChangeActorName',
|
605
|
+
|
606
|
+
=begin
|
607
|
+
[int(Actor ID)]---[int(New Class ID)]---END
|
608
|
+
=end
|
609
|
+
321 => 'ChangeActorClass',
|
610
|
+
|
611
|
+
=begin
|
612
|
+
[int(Actor ID)]---[string(New Actor walking Picture Name)]---[int(New Actor Walking Picture Index)]---[string(New Actor Portrait Picture Name)]---[int(New Actor Portrait Picture Index)]---END
|
613
|
+
=end
|
614
|
+
322 => 'ChangeActorGraphic',
|
615
|
+
|
616
|
+
=begin
|
617
|
+
[int:{0:Boat, 1:Ship, 2:Airship}]---[string(New Vehicle Picture Name)]---[int(New Vehicle Picture Index)]---END
|
618
|
+
=end
|
619
|
+
323 => 'ChangeVehicleGraphic',
|
620
|
+
|
621
|
+
=begin
|
622
|
+
[int(Actor ID)]---[string(New Actor Nickname)]---END
|
623
|
+
=end
|
624
|
+
324 => 'ChangeActorNickname',
|
625
|
+
|
626
|
+
=begin
|
627
|
+
|--[int:0(Constant)]---[int:{1~999999}(Number)]--|
|
628
|
+
|--[int:0(Increase)]--| |--[bool:false(Allow Knockout)]---END
|
629
|
+
| |--[int:1(Variable)]---[int(Variable ID)]--------|
|
630
|
+
[int:{-1:Entire Troop, 0:Troop 001, ...}]--|
|
631
|
+
| |--[int:0(Constant)]---[int:{1~999999}(Number)]--|
|
632
|
+
|--[int:1(Decrease)]--| |--[bool(Allow Knockout)]---END
|
633
|
+
|--[int:1(Variable)]---[int(Variable ID)]--------|
|
634
|
+
|
635
|
+
=end
|
636
|
+
331 => 'ChangeEnemyHP',
|
637
|
+
|
638
|
+
=begin
|
639
|
+
|--[int:0(Constant)]---[int:{1~9999}(Number)]---END
|
640
|
+
[int:{-1:Entire Troop, 0:Troop 001, ...}]---[int:{0:Increase, 1:Decrease}]--|
|
641
|
+
|--[int:1(Variable)]---[int(Variable ID)]---END
|
642
|
+
=end
|
643
|
+
332 => 'ChangeEnemyMP',
|
644
|
+
|
645
|
+
=begin
|
646
|
+
[int:{-1:Entire Troop, 0:Troop 001, ...}]---[int:{0:Add, 1:Remove}]---[int(State ID)]---END
|
647
|
+
=end
|
648
|
+
333 => 'ChangeEnemyState',
|
649
|
+
|
650
|
+
=begin
|
651
|
+
[int:{-1:Entire Troop, 0:Troop 001, ...}]---END
|
652
|
+
=end
|
653
|
+
334 => 'EnemyRecoverAll',
|
654
|
+
|
655
|
+
=begin
|
656
|
+
[int:{-1:Entire Troop, 0:Troop 001, ...}]---END
|
657
|
+
=end
|
658
|
+
335 => 'EnemyAppear',
|
659
|
+
|
660
|
+
=begin
|
661
|
+
[int(Troop ID)]---[int(Enemy ID)]---END
|
662
|
+
=end
|
663
|
+
336 => 'EnemyTransform',
|
664
|
+
|
665
|
+
=begin
|
666
|
+
[int:{-1:Entire Troop, 0:Troop 001, ...}]---[int(Animation ID)]---END
|
667
|
+
=end
|
668
|
+
337 => 'ShowBattleAnimation',
|
669
|
+
|
670
|
+
=begin
|
671
|
+
|--[int:0(Enemy)]---[int(Troop ID)]--|
|
672
|
+
| |--[int(Skill ID)]---[int:{-2:Last Target, -1:Random, 0:Index 1,...}]---END
|
673
|
+
|--[int:1(Actor)]---[int(Actor ID)]--|
|
674
|
+
=end
|
675
|
+
339 => 'ForceAction',
|
676
|
+
340 => 'AbortBattle',
|
677
|
+
351 => 'OpenMenuScreen',
|
678
|
+
352 => 'OpenSaveScreen',
|
679
|
+
353 => 'GameOver',
|
680
|
+
354 => 'ReturnToTitleScreen',
|
681
|
+
|
682
|
+
=begin
|
683
|
+
[string]---END
|
684
|
+
=end
|
685
|
+
355 => 'Script',
|
686
|
+
|
687
|
+
=begin
|
688
|
+
[string]---END
|
689
|
+
=end
|
690
|
+
401 => 'ShowText',
|
691
|
+
|
692
|
+
=begin
|
693
|
+
[int(Choice Index)]---[string(Choice Name)]---END
|
694
|
+
=end
|
695
|
+
402 => 'When',
|
696
|
+
403 => 'WhenCancel',
|
697
|
+
404 => 'ChoicesEnd',
|
698
|
+
|
699
|
+
=begin
|
700
|
+
[string]---END
|
701
|
+
=end
|
702
|
+
405 => 'ShowScrollingText',
|
703
|
+
|
704
|
+
=begin
|
705
|
+
[string]---END
|
706
|
+
=end
|
707
|
+
408 => 'CommentMore',
|
708
|
+
411 => 'Else',
|
709
|
+
412 => 'BranchEnd',
|
710
|
+
413 => 'RepeatAbove',
|
711
|
+
|
712
|
+
=begin
|
713
|
+
[RPG::MoveCommand(45 is script)]---END
|
714
|
+
=end
|
715
|
+
505 => 'MoveRoute',
|
716
|
+
601 => 'IfWin',
|
717
|
+
602 => 'IfEscape',
|
718
|
+
603 => 'IfLose',
|
719
|
+
604 => 'BattleProcessingEnd',
|
720
|
+
|
721
|
+
=begin
|
722
|
+
|--[int:0(Price: Standard)]---[int:0]---END
|
723
|
+
[int:{0:Item, 1:Weapon, 2:Armor}]---[int(Corresponded Item ID)]--|
|
724
|
+
|--[int:1(Price: Specify)]---[int:{0~9999999}(Price)]---END
|
725
|
+
=end
|
726
|
+
605 => 'ShopItem',
|
727
|
+
|
728
|
+
=begin
|
729
|
+
[string]---END
|
730
|
+
=end
|
731
|
+
655 => 'ScriptMore' }
|
732
|
+
|
733
|
+
# 红色
|
734
|
+
RED_COLOR = "\e[31m"
|
735
|
+
|
736
|
+
# 绿色
|
737
|
+
GREEN_COLOR = "\e[32m"
|
738
|
+
|
739
|
+
# 黄色
|
740
|
+
YELLOW_COLOR = "\e[33m"
|
741
|
+
|
742
|
+
# 蓝色
|
743
|
+
BLUE_COLOR = "\e[34m"
|
744
|
+
|
745
|
+
# 紫色
|
746
|
+
MAGENTA_COLOR = "\e[35m"
|
747
|
+
|
748
|
+
# 青色
|
749
|
+
CYAN_COLOR = "\e[36m"
|
750
|
+
|
751
|
+
# 重置颜色
|
752
|
+
RESET_COLOR = "\e[0m"
|
753
|
+
|
754
|
+
# 清除行
|
755
|
+
ESCAPE = "\e[2K"
|
756
|
+
|
757
|
+
# 根据 file_basename 检查 object 的类型在 module_name 中是否正确
|
758
|
+
#
|
759
|
+
# @param object [Object] 待检查的对象
|
760
|
+
# @param file_basename [String] 文件名(不包含扩展名)
|
761
|
+
# @param is_compact [Boolean] 是否为紧凑模式
|
762
|
+
# @param module_name [Symbol] 模块名
|
763
|
+
#
|
764
|
+
# @raise [RPGTypeError] object 的类型不在 RPG 模块中
|
765
|
+
# @raise [R3EXSTypeError] object 的类型不在 R3EXS 模块中
|
766
|
+
# @raise [ModuleNameError] module_name 不是 :RPG 或 :R3EXS
|
767
|
+
# @raise [FileBaseNameError] file_basename 无法匹配到对应的类
|
768
|
+
#
|
769
|
+
# @return [void]
|
770
|
+
def Utils.check_type(object, file_basename, is_compact, module_name)
|
771
|
+
case module_name
|
772
|
+
when :RPG
|
773
|
+
matched_class = FILE_BASENAME_TO_CLASS_RPG.find { |pattern, _| file_basename =~ pattern }&.last
|
774
|
+
matched_class or raise FileBaseNameError.new(file_basename), "Invalid file basename: #{file_basename}"
|
775
|
+
if object.is_a?(Array)
|
776
|
+
if is_compact
|
777
|
+
object.compact.all? { |item| item.is_a?(matched_class) } or raise RPGTypeError.new(object), "Invalid Object: #{object}, it's not an Array<#{matched_class}>"
|
778
|
+
else
|
779
|
+
object.all? { |item| item.is_a?(matched_class) } or raise RPGTypeError.new(object), "Invalid Object: #{object}, it's not an Array<#{matched_class}>"
|
780
|
+
end
|
781
|
+
elsif object.is_a?(Hash)
|
782
|
+
if is_compact
|
783
|
+
object.compact.values.all? { |item| item.is_a?(matched_class) } or raise RPGTypeError.new(object), "Invalid Object: #{object}, it's not a Hash<#{matched_class}>"
|
784
|
+
else
|
785
|
+
object.values.all? { |item| item.is_a?(matched_class) } or raise RPGTypeError.new(object), "Invalid Object: #{object}, it's not a Hash<#{matched_class}>"
|
786
|
+
end
|
787
|
+
else
|
788
|
+
object.is_a?(matched_class) or raise RPGTypeError.new(object), "Invalid Object: #{object}, it's not a #{matched_class}"
|
789
|
+
end
|
790
|
+
when :R3EXS
|
791
|
+
matched_class = FILE_BASENAME_TO_CLASS_R3EXS.find { |pattern, _| file_basename =~ pattern }&.last
|
792
|
+
matched_class or raise FileBaseNameError.new(file_basename), "Invalid file basename: #{file_basename}"
|
793
|
+
if object.is_a?(Array)
|
794
|
+
if is_compact
|
795
|
+
object.compact.all? { |item| item.is_a?(matched_class) } or raise R3EXSTypeError.new(object), "Invalid object: #{object}, it's not an Array<#{matched_class}>"
|
796
|
+
else
|
797
|
+
object.all? { |item| item.is_a?(matched_class) } or raise R3EXSTypeError.new(object), "Invalid object: #{object}, it's not an Array<#{matched_class}>"
|
798
|
+
end
|
799
|
+
elsif object.is_a?(Hash)
|
800
|
+
if is_compact
|
801
|
+
object.compact.values.all? { |item| item.is_a?(matched_class) } or raise R3EXSTypeError.new(object), "Invalid object: #{object}, it's not a Hash<#{matched_class}>"
|
802
|
+
else
|
803
|
+
object.values.all? { |item| item.is_a?(matched_class) } or raise R3EXSTypeError.new(object), "Invalid object: #{object}, it's not a Hash<#{matched_class}>"
|
804
|
+
end
|
805
|
+
else
|
806
|
+
object.is_a?(matched_class) or raise R3EXSTypeError.new(object), "Invalid object: #{object}, it's not #{matched_class}"
|
807
|
+
end
|
808
|
+
else
|
809
|
+
raise ModuleNameError.new(module_name), "Invalid module name: #{module_name}"
|
810
|
+
end
|
811
|
+
|
812
|
+
end
|
813
|
+
|
814
|
+
# 将 RPG 中的对象转化为 R3EXS 对象
|
815
|
+
#
|
816
|
+
# @param object [Object] 待转化的 RPG 对象
|
817
|
+
# @param file_basename [String] 文件名(不包含扩展名)
|
818
|
+
# @param with_notes [Boolean] 是否包含注释
|
819
|
+
#
|
820
|
+
# @raise [RPGTypeError] object 的类型不在 RPG 模块中
|
821
|
+
# @raise [FileBaseNameError] file_basename 无法匹配到对应的类
|
822
|
+
#
|
823
|
+
# @return [Object]
|
824
|
+
def Utils.rpg_r3exs(object, file_basename, with_notes)
|
825
|
+
check_type(object, file_basename, true, :RPG)
|
826
|
+
|
827
|
+
# 首先根据 file_basename 找到对应的类
|
828
|
+
matched_class = Utils::FILE_BASENAME_TO_CLASS_R3EXS.find { |pattern, _| file_basename =~ pattern }.last
|
829
|
+
|
830
|
+
# 然后根据 object 的类型进行处理
|
831
|
+
# 如果 object 是数组,则遍历数组,对每个元素进行处理
|
832
|
+
# 如果 object 是哈希,则遍历哈希,对每个值进行处理
|
833
|
+
# 如果 object 是其他类型,则直接处理
|
834
|
+
if object.is_a?(Array)
|
835
|
+
temp = []
|
836
|
+
object.each_with_index do |obj, index|
|
837
|
+
next if obj.nil?
|
838
|
+
obj_r3exs = matched_class.new(obj, index, with_notes)
|
839
|
+
temp << obj_r3exs unless obj_r3exs.empty?
|
840
|
+
end
|
841
|
+
elsif object.is_a?(Hash) # 只有 RPG::MapInfo 是 Hash,且 key 为整数
|
842
|
+
temp = []
|
843
|
+
object.each do |key, obj|
|
844
|
+
next if obj.nil?
|
845
|
+
temp << matched_class.new(obj, key, with_notes)
|
846
|
+
end
|
847
|
+
else
|
848
|
+
# 只有 RPG::Map 和 RPG::System 是单独一个对象,且不可能为 nil
|
849
|
+
temp = matched_class.new(object, with_notes)
|
850
|
+
end
|
851
|
+
temp
|
852
|
+
end
|
853
|
+
|
854
|
+
# 读取 target_dir 下的所有 rvdata2 文件,将其反序列化为对象,并调用 block
|
855
|
+
#
|
856
|
+
# @note 注意传入 block 的 object
|
857
|
+
# - 如果 object 是数组或哈希,则其中可能存在 nil 元素
|
858
|
+
# - 如果 object 是单独一个对象,则不可能为 nil
|
859
|
+
#
|
860
|
+
# @param target_dir [Pathname] 目标目录
|
861
|
+
#
|
862
|
+
# @yieldparam object [Object] rvdata2 文件反序列化后的对象
|
863
|
+
# @yieldparam file_basename [String] 文件名(不包含扩展名)
|
864
|
+
# @yieldparam parent_relative_dir [Pathname] 文件所在目录的相对路径
|
865
|
+
# @yieldreturn [void]
|
866
|
+
#
|
867
|
+
# @raise [Rvdata2FileError] rvdata2 文件可能损坏
|
868
|
+
# @raise [Rvdata2DirError] target_dir 不存在
|
869
|
+
#
|
870
|
+
# @return [void]
|
871
|
+
def Utils.all_rvdata2_files(target_dir)
|
872
|
+
# 检查 target_dir 目录是否存在
|
873
|
+
target_dir.exist? && target_dir.directory? or raise Rvdata2DirError.new(target_dir.to_s), "rvdata2 directory not found: #{target_dir}"
|
874
|
+
# 递归获取 target_dir 下的所有 *.rvdata2 文件
|
875
|
+
target_dir.glob('**/*.rvdata2').each do |file_path|
|
876
|
+
file_basename = file_path.basename('.rvdata2').to_s
|
877
|
+
# 检查文件名是否在 RVDATA2_FILE_NAME 中与其正则表达式匹配
|
878
|
+
next unless RVDATA2_FILE_NAME.any? { |pattern| file_basename =~ pattern }
|
879
|
+
|
880
|
+
print "#{ESCAPE}#{BLUE_COLOR}Reading and Deserializing from #{RESET_COLOR}#{file_path}...\r" if $global_options[:verbose]
|
881
|
+
object = Marshal.load(file_path.binread)
|
882
|
+
|
883
|
+
# 如果文件名不是 'Scripts',则检查 object 的类型是否正确
|
884
|
+
unless file_basename == 'Scripts'
|
885
|
+
# 检查 object 的类型是否正确
|
886
|
+
# 这里的类型检查要用紧凑模式,因为 rvdata2 文件中可能存在 nil 元素,必须忽略
|
887
|
+
begin
|
888
|
+
check_type(object, file_basename, true, :RPG)
|
889
|
+
rescue RPGTypeError
|
890
|
+
raise Rvdata2FileError.new(file_path.to_s), "Invalid rvdata2 file: #{file_path}"
|
891
|
+
end
|
892
|
+
end
|
893
|
+
|
894
|
+
yield object, file_basename, file_path.dirname.relative_path_from(target_dir)
|
895
|
+
end
|
896
|
+
end
|
897
|
+
|
898
|
+
# 读取 target_dir 下的所有常规 JSON 文件,将其反序列化为对象,并调用 block
|
899
|
+
#
|
900
|
+
# @note 注意传入 block 的 object
|
901
|
+
# - 在 module_name 为 RPG 时,如果 object 是数组或哈希,则其中可能存在 nil 元素。如果 object 是单独一个对象,则不可能为 nil
|
902
|
+
# - 在 module_name 为 R3EXS 时,object 不会为 nil
|
903
|
+
#
|
904
|
+
# @param target_dir [Pathname] 目标目录
|
905
|
+
# @param module_name [Symbol] 模块名
|
906
|
+
#
|
907
|
+
# @yieldparam object [Object] JSON 文件反序列化后的对象
|
908
|
+
# @yieldparam file_basename [String] 文件名(不包含扩展名)
|
909
|
+
# @yieldparam parent_relative_dir [Pathname] 文件所在目录的相对路径
|
910
|
+
# @yieldreturn [void]
|
911
|
+
#
|
912
|
+
# @raise [RPGJsonFileError] json 文件不是 RPG 模块中的对象
|
913
|
+
# @raise [R3EXSJsonFileError] json 文件不是 R3EXS 模块中的对象
|
914
|
+
# @raise [ModuleNameError] module_name 不是 :RPG 或 :R3EXS
|
915
|
+
# @raise [JsonDirError] target_dir 不存在
|
916
|
+
#
|
917
|
+
# @return [void]
|
918
|
+
def Utils.all_json_files(target_dir, module_name)
|
919
|
+
# 检查 target_dir 目录是否存在
|
920
|
+
target_dir.exist? && target_dir.directory? or raise JsonDirError.new(target_dir.to_s), "JSON directory not found: #{target_dir}"
|
921
|
+
# 递归获取 target_dir 下的所有 *.json 文件
|
922
|
+
target_dir.glob('**/*.json').each do |file_path|
|
923
|
+
file_basename = file_path.basename('.json').to_s
|
924
|
+
# 检查文件名是否在 JSON_FILE_NAME 中与其正则表达式匹配
|
925
|
+
next unless JSON_FILE_NAME.any? { |pattern| file_basename =~ pattern }
|
926
|
+
|
927
|
+
print "#{ESCAPE}#{BLUE_COLOR}Reading and Deserializing #{RESET_COLOR}#{file_path}...\r" if $global_options[:verbose]
|
928
|
+
object = Oj.load_file(file_path.to_s)
|
929
|
+
|
930
|
+
case module_name
|
931
|
+
when :RPG
|
932
|
+
# 这里的类型检查要用紧凑模式,因为这是从 rvdata2 文件直接全部序列化后的 JSON 文件中读取的 object,其中可能存在 nil 元素
|
933
|
+
begin
|
934
|
+
check_type(object, file_basename, true, module_name)
|
935
|
+
rescue RPGTypeError
|
936
|
+
raise RPGJsonFileError.new(file_path.to_s), "Invalid RPG JSON file: #{file_path}"
|
937
|
+
end
|
938
|
+
when :R3EXS
|
939
|
+
# 这里的类型检查不能用紧凑模式,因为这是从 R3EXS 模块的类序列化后的 JSON 文件中读取的 object,程序设计中不应该存在 nil 元素
|
940
|
+
begin
|
941
|
+
check_type(object, file_basename, false, module_name)
|
942
|
+
rescue R3EXSTypeError
|
943
|
+
raise R3EXSJsonFileError.new(file_path.to_s), "Invalid R3EXS JSON file: #{file_path}"
|
944
|
+
end
|
945
|
+
else
|
946
|
+
raise ModuleNameError.new(module_name), "Invalid module name: #{module_name}"
|
947
|
+
end
|
948
|
+
|
949
|
+
yield object, file_basename, file_path.dirname.relative_path_from(target_dir)
|
950
|
+
end
|
951
|
+
end
|
952
|
+
|
953
|
+
# 读取 target_dir 下的所有 CommonEvent JSON 文件,将其反序列化为对象数组,并调用 block
|
954
|
+
#
|
955
|
+
# @note 注意传入 block 的 object
|
956
|
+
# - 在 module_name 为 RPG 时,object 可能存在 nil 元素
|
957
|
+
# - 在 module_name 为 R3EXS 时,object 不可能存在 nil 元素
|
958
|
+
#
|
959
|
+
# @param target_dir [Pathname] 目标目录
|
960
|
+
# @param module_name [Symbol] 模块名
|
961
|
+
#
|
962
|
+
# @yieldparam commonevents [Array<Object>] CommonEvent JSON 文件反序列化后的数组
|
963
|
+
# @yieldparam commonevents_basenames [String] CommonEvent JSON 文件名数组(不包含扩展名)
|
964
|
+
# @yieldparam parent_relative_dir [Pathname] 文件所在目录的相对路径
|
965
|
+
# @yieldreturn [void]
|
966
|
+
#
|
967
|
+
# @raise [RPGJsonFileError] json 文件不是 RPG 模块中的对象
|
968
|
+
# @raise [R3EXSJsonFileError] json 文件不是 R3EXS 模块中的对象
|
969
|
+
# @raise [ModuleNameError] module_name 不是 :RPG 或 :R3EXS
|
970
|
+
# @raise [JsonDirError] target_dir 不存在
|
971
|
+
#
|
972
|
+
# @return [void]
|
973
|
+
def Utils.all_commonevent_json_files(target_dir, module_name)
|
974
|
+
# 检查 target_dir 目录是否存在
|
975
|
+
target_dir.exist? && target_dir.directory? or raise JsonDirError.new(target_dir.to_s), "JSON directory not found: #{target_dir}"
|
976
|
+
|
977
|
+
# 用两个个Hash来存储每一个父目录下的所有的 CommonEvent_\d{5}.json 文件的反序列化后的对象数组以及其文件名数组
|
978
|
+
# Hash 的键是父目录的路径,值是一个数组,存储该目录下的所有 CommonEvent_\d{5}.json 文件的反序列化后的对象数组以及其文件名数组
|
979
|
+
commonevents_hash = Hash.new { |h, k| h[k] = [] }
|
980
|
+
commonevents_basenames_hash = Hash.new { |h, k| h[k] = [] }
|
981
|
+
|
982
|
+
# 递归获取 target_dir 下的所有 CommonEvent_\d{5}.json 文件
|
983
|
+
target_dir.glob('**/CommonEvent_[0-9][0-9][0-9][0-9][0-9].json').each do |file_path|
|
984
|
+
print "#{ESCAPE}#{BLUE_COLOR}Reading and Deserializing #{RESET_COLOR}#{file_path}...\r" if $global_options[:verbose]
|
985
|
+
object = Oj.load_file(file_path.to_s)
|
986
|
+
parent_dir = file_path.dirname
|
987
|
+
commonevents_hash[parent_dir] << object
|
988
|
+
commonevents_basenames_hash[parent_dir] << file_path.basename('.json').to_s
|
989
|
+
end
|
990
|
+
|
991
|
+
# 遍历每一个父目录的路径
|
992
|
+
commonevents_hash.each_key do |parent_dir|
|
993
|
+
commonevents = commonevents_hash[parent_dir]
|
994
|
+
commonevents_basenames = commonevents_basenames_hash[parent_dir]
|
995
|
+
|
996
|
+
case module_name
|
997
|
+
when :RPG
|
998
|
+
# 这里的类型检查要用紧凑模式,因为这是从 rvdata2 文件直接全部序列化后的 JSON 文件中读取的 object,其中可能存在 nil 元素
|
999
|
+
begin
|
1000
|
+
check_type(commonevents, 'CommonEvents', true, module_name)
|
1001
|
+
rescue RPGTypeError
|
1002
|
+
raise RPGJsonFileError.new(parent_dir.to_s), "Invalid RPG CommonEvents JSON file"
|
1003
|
+
end
|
1004
|
+
when :R3EXS
|
1005
|
+
# 这里的类型检查不能用紧凑模式,因为这是从 R3EXS 模块的类序列化后的 JSON 文件中读取的 object,程序设计中不应该存在 nil 元素
|
1006
|
+
begin
|
1007
|
+
check_type(commonevents, 'CommonEvents', false, module_name)
|
1008
|
+
rescue R3EXSTypeError
|
1009
|
+
raise R3EXSJsonFileError.new(parent_dir.to_s), "Invalid R3EXS CommonEvents JSON file"
|
1010
|
+
end
|
1011
|
+
else
|
1012
|
+
raise ModuleNameError.new(module_name), "Invalid module name: #{module_name}"
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
yield commonevents, commonevents_basenames, parent_dir.relative_path_from(target_dir)
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
# 读取 target_dir 下的所有 Ruby 源码文件,并调用 block
|
1020
|
+
#
|
1021
|
+
# @note 注意这里以二进制方式读取文件,因为 Prism 里面的节点的位置是相对二进制下的位置
|
1022
|
+
#
|
1023
|
+
# @param target_dir [Pathname] 目标目录
|
1024
|
+
#
|
1025
|
+
# @yieldparam scripts [Array<String>] 读取的 Ruby 源码文件数组
|
1026
|
+
# @yieldparam scripts_basenames [Array<String>] Ruby 源码文件名数组(不包含扩展名)
|
1027
|
+
# @yieldparam parent_relative_dir [Pathname] 文件所在目录的相对路径
|
1028
|
+
# @yieldreturn [void]
|
1029
|
+
#
|
1030
|
+
# @raise [JsonDirError] target_dir 不存在
|
1031
|
+
#
|
1032
|
+
# @return [void]
|
1033
|
+
def Utils.all_rb_files(target_dir)
|
1034
|
+
# 检查 target_dir 目录是否存在
|
1035
|
+
target_dir.exist? && target_dir.directory? or raise JsonDirError.new(target_dir.to_s), "JSON directory not found: #{target_dir}"
|
1036
|
+
|
1037
|
+
# 用两个个Hash来存储每一个父目录下的所有的 \d{3}.rb 文件的反序列化后的对象数组以及其文件名数组
|
1038
|
+
# Hash 的键是父目录的路径,值是一个数组,存储该目录下的所有 \d{3}.rb 文件的反序列化后的对象数组以及其文件名数组
|
1039
|
+
scripts_hash = Hash.new { |h, k| h[k] = [] }
|
1040
|
+
scripts_basenames_hash = Hash.new { |h, k| h[k] = [] }
|
1041
|
+
|
1042
|
+
# 递归获取 target_dir 下的所有 \d{5}.rb 文件
|
1043
|
+
target_dir.glob('**/[0-9][0-9][0-9].rb').each do |file_path|
|
1044
|
+
print "#{ESCAPE}#{BLUE_COLOR}Reading and Deserializing #{RESET_COLOR}#{file_path}...\r" if $global_options[:verbose]
|
1045
|
+
object = file_path.binread
|
1046
|
+
parent_dir = file_path.dirname
|
1047
|
+
scripts_hash[parent_dir] << object
|
1048
|
+
scripts_basenames_hash[parent_dir] << file_path.basename('.rb').to_s
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
# 遍历每一个父目录的路径
|
1052
|
+
scripts_hash.each_key do |parent_dir|
|
1053
|
+
scripts = scripts_hash[parent_dir]
|
1054
|
+
scripts_basenames = scripts_basenames_hash[parent_dir]
|
1055
|
+
yield scripts, scripts_basenames, parent_dir.relative_path_from(target_dir)
|
1056
|
+
end
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
# 将 object 序列化为 json 文件
|
1060
|
+
#
|
1061
|
+
# @param object [Object] 待序列化的对象
|
1062
|
+
# @param output_file [Pathname] 输出文件路径
|
1063
|
+
# @return [void]
|
1064
|
+
def Utils.object_json(object, output_file)
|
1065
|
+
output_file.dirname.mkpath unless output_file.dirname.exist?
|
1066
|
+
output_file.write(Oj.dump(object, indent: 2))
|
1067
|
+
end
|
1068
|
+
|
1069
|
+
# 将 object 序列化为 rvdata2 文件
|
1070
|
+
#
|
1071
|
+
# @param object [Object] 待序列化的对象
|
1072
|
+
# @param output_file [Pathname] 输出文件路径
|
1073
|
+
# @return [void]
|
1074
|
+
def Utils.object_rvdata2(object, output_file)
|
1075
|
+
output_file.dirname.mkpath unless output_file.dirname.exist?
|
1076
|
+
output_file.binwrite(Marshal.dump(object))
|
1077
|
+
end
|
1078
|
+
|
1079
|
+
end
|
1080
|
+
|
971
1081
|
end
|