-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathucdextractor.pas
More file actions
1125 lines (1066 loc) · 76.4 KB
/
ucdextractor.pas
File metadata and controls
1125 lines (1066 loc) · 76.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(******************************************************************************)
(* *)
(* Author : Uwe Schächterle (Corpsman) *)
(* *)
(* This file is part of FPC_Atomic *)
(* *)
(* See the file license.md, located under: *)
(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *)
(* for details about the license. *)
(* *)
(* It is not allowed to change or remove this text from any *)
(* source file of the project. *)
(* *)
(******************************************************************************)
Unit ucdextractor;
{$MODE ObjFPC}{$H+}
Interface
Uses
Classes, SysUtils, Graphics;
(*
* History: 0.01 = Initial version
* 0.02 = Switch to relative paths
* Add Addon Pack warning
* 0.03 = Add Hohle and Jump animation
* FIX crash, when creating a new job
* 0.04 = Remove Relative Path Handling
*)
Const
DefCaption = 'FPC Atomic data extractor ver. 0.04';
Type
TTransparentMode = (
tmBlack, // Replace clBlack by clFuchsia
tmFirstPixel, // Replace the color of pixel[0,0] by clFuchsia
tmFirstPixelPerFrame // Replace the color of pixel[0,0] by clFuchsia (on each subimage)
);
TAniJob = Record
SourceAni: String; // Source File from Atomic Bomberman CD
Width, Height: integer; // Width and Height of each Subimage
FramesPerRow: integer; // Number of Subimages Per Row
Alignment: TAlignment; // Alignment of Subimages in width (only relevant if subimage width <> width)
Layout: ttextlayout; // Layout of Subimages in height (only relevant if subimage height <> height)
ImageSequence: String; // The sequence of subimages taken from .Ani and packet into the resulting image
DestPng: String; // Filename to store the result to
TransparentMode: TTransparentMode; // Transparent color creation mode
End;
(*
* Callback for user informations
*)
TLogCallback = Procedure(Logtext: String) Of Object;
(*
* Partly separated to be able to use it in the ani job creator ;)
*)
Function DoAniJob(CDFolder: String; Job: TAniJob): TBitmap;
Procedure SetLogCallback(LogCallBack: TLogCallback);
(*
* Helper Routines, use on own will.
*)
Function CheckCDRootFolder(aFolder: String): boolean; // True, if aFolder seems to be a correct Atomic Bomberman CD Root folder
Function CheckFPCAtomicFolder(aFolder: String): boolean; // True, if fpc_atomic binary is part of
(*
* This is the routine that does all the work, it handles everyting what needs to be done
*)
Procedure DoExtraction(CDFolder, AtomicFolder: String; LogCallBack: TLogCallback);
Function ConcatRelativePath(Const BaseName: String; Const RelativeName: String): String;
Implementation
Uses
FileUtil, math
, upcx
, uwave
, uanifile
, ugraphics
, uopengl_animation
;
Type
(*
* Multiple TAniJobs thats result will be merged into one resulting image
*)
TCascadeJob = Array Of TAniJob;
(*
* Container to hold the detailed Sprite informations during Sprite creation
*)
TSpriteData = Record
FrameOffset: Integer;
FrameCount: integer;
End;
(*
* Converts a Atomic Bomberman .ani into a FPC_Atomic .ani file
*)
TAniToAniJob = Record
AniJob: TAniJob; // Atomic Bomberman .ani -> Bitmap
(*
* Additional Settings for FPC_Atomic .ani
*)
AngleOffset: Single; // Angle offset for Rendering
FramesPerRow: integer; // Redundant to AniJob.FramesPerRow
FramesPerCol: integer; // Number of Rows in the Bitmap from AniJob
TimePerFrame: integer; // Time in ms to show a single frame
SpriteData: Array Of TSpriteData; // Per Range informations
End;
TPCXJob = Record
Sourcefile: String; // Filename on Atomic Disc
Destname: String; // Filename in FPC_Atomic
End;
TSoundJob = Record
Sourcefile: String; // Filename on Atomic Disc
Destname: String; // Filename in FPC_Atomic
End;
Const
(*
* All Jobs that need to be done to convert Atomic Bomberman .pcx files into FPC_Atomic .png files
*)
PCXJobs: Array[0..43] Of TPCXJob =
(
// data/maps/Field** [11]
(Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD0.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field00' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD1.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field01' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD2.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field02' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD3.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field03' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD4.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field04' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD5.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field05' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD6.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field06' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD7.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field07' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD8.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field08' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD9.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field09' + PathDelim + 'field.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'FIELD10.PCX'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field10' + PathDelim + 'field.png')
// data/res [33]
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'DRAW.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'draw.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'GLUE1.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'fieldsetup.png') // -- This is the special case (handled hardcoded in the "ExtractAtomicPCXs" routine)
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'GLUE5.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'join.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'WINZ.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'loaddialog.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'MAINMENU.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'mainmenu.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'GLUE2.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'options.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWBOMB.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powbomb.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWDISEA.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powdisea.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWEBOLA.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powebola.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWFLAME.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powflame.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWGOLD.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powgold.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWGRAB.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powgrab.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWJELLY.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powjelly.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWKICK.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powkick.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWPUNCH.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powpunch.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWRAND.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powrand.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWSKATE.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powskate.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWSLOW.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powslow.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWSPOOG.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powspoog.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'POWTRIG.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'powtrig.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'RESULTS.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'results.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'TEAM0.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'team0.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'TEAM1.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'team1.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY0.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory0.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY1.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory1.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY2.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory2.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY3.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory3.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY4.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory4.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY5.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory5.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY6.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory6.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY7.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory7.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY8.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory8.png')
, (Sourcefile: 'data' + PathDelim + 'res' + PathDelim + 'VICTORY9.PCX'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'victory9.png')
);
(*
* All Jobs that need to be done to convert Atomic Bomberman .rss files into FPC_Atomic .wav files
*)
SoundJobs: Array[0..101] Of TSoundJob =
(
// data/maps/Field** [11]
(Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'GRNACRES.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field00' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'GENERIC.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field01' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'HOCKEY.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field02' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'PYRAMID.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field03' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'MINESHFT.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field04' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'BATTLE.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field05' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'GIEGER.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field06' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'HAUNTED.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field07' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'OCEAN.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field08' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'SWAMP.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field09' + PathDelim + 'sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'SEWER.RSS'; Destname: 'data' + PathDelim + 'maps' + PathDelim + 'Field10' + PathDelim + 'sound.wav') // Fertig, getestet
// data/res [6]
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'DRAW.RSS'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'draw.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'NETWORK.RSS'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'join_sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'MENU.RSS'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'mainmenu_sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'MENUEXIT.RSS'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'menuexit.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'WIN.RSS'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'player_setup_sound.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'QUITGAME.RSS'; Destname: 'data' + PathDelim + 'res' + PathDelim + 'quitgame.wav') // Fertig, getestet
// data/sounds [85]
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + '1000.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + '1000.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + '1017.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + '1017.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + '1036.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + '1036.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + '1045.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + '1045.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'allrite.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'allrite.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bmbstop1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bmbstop1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bmbstop2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bmbstop2.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bmbthrw1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bmbthrw1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bmbthrw3.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bmbthrw3.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bmbthrw4.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bmbthrw4.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bmbthrw5.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bmbthrw5.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bmdrop1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bmdrop1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bmdrop2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bmdrop2.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bmdrop3.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bmdrop3.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_01.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_01.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_02.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_02.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_04.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_04.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_04b.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_04b.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_05.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_05.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_06.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_06.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_07.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_07.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_07b.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_07b.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_09.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_09.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_11.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_11.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_12.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_12.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_12b.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_12b.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_17.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_17.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_19.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_19.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bomb_24.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bomb_24.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bombboun.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bombboun.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'bombstop.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'bombstop.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'clikplat.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'clikplat.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'coolpop.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'coolpop.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'cribrown.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'cribrown.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'cul8r.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'cul8r.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'die1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'die1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'disease1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'disease1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'disease2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'disease2.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'disease3.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'disease3.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'eatdust.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'eatdust.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'expl6.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'expl6.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'explo1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'explo1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'explode2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'explode2.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'explode3.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'explode3.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'explode4.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'explode4.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'get1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'get1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'get2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'get2.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'gotahurt.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'gotahurt.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'gotcha.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'gotcha.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'grab1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'grab1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'grab2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'grab2.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'hurry.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'hurry.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'hurytuf.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'hurytuf.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'kbomb1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'kbomb1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'kbomb2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'kbomb2.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'kicker3.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'kicker3.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'kicker10.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'kicker10.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'later.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'later.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'ohno1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'ohno1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'proud.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'proud.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'roasted.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'roasted.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'schwing.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'schwing.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'scream1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'scream1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'smelsmok.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'smelsmok.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'sqrdrop2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'sqrdrop2.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'sqrdrop4.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'sqrdrop4.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'sqrdrop5.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'sqrdrop5.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'sqrdrop6.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'sqrdrop6.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'sqrdrop7.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'sqrdrop7.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'sqrdrop8.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'sqrdrop8.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'stupidio.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'stupidio.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'suckitdn.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'suckitdn.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'tastpai2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'tastpai2.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'tastpain.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'tastpain.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'theman.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'theman.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'trampo.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'trampo.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'transin.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'transin.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'transout.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'transout.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'toeasy.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'toeasy.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'warp1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'warp1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'woohoo1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'woohoo1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'youblow.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'youblow.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'youwin1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'youwin1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'zen1.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'zen1.wav') // Fertig, getestet
, (Sourcefile: 'data' + PathDelim + 'sound' + PathDelim + 'zen2.RSS'; Destname: 'data' + PathDelim + 'sounds' + PathDelim + 'zen2.wav') // Fertig, getestet
);
Var
AniJobs: Array Of TAniJob; // All the .ani jobs will be set in the initialization part of the unit.
CascadeJobs: Array Of TCascadeJob; // All jobs that where merged into one image.
AniToAniJobs: Array Of TAniToAniJob; // All the jobs where a Atomic Bomberman Ani directly is converted into a FPC_Atomic.ani file
AddLog: TLogCallback = Nil; // unit global callback for logging ;)
{$IFDEF Linux}
(*
* Searches Recursive trough folder and corrects all Subfolder directories according to der caseing
*)
Function FindCaseInsensitiveFolder(Folder: String): String;
Var
sl: TStringList;
i: Integer;
subfolder: String;
Begin
If Folder = '' Then Begin
result := '';
End
Else Begin
If DirectoryExists(Folder) Then Begin
result := Folder;
End
Else Begin
subfolder := ExtractFileName(ExcludeTrailingPathDelimiter(Folder));
Folder := FindCaseInsensitiveFolder(ExtractFilePath(ExcludeTrailingPathDelimiter(Folder)));
If Folder <> '' Then Begin
sl := FindAllDirectories(Folder, false);
For i := 0 To sl.Count - 1 Do Begin
If lowercase(sl[i]) = lowercase(folder + subfolder) Then Begin
result := sl[i] + PathDelim;
sl.free;
exit;
End;
End;
sl.free;
result := '';
End;
End;
End;
End;
{$ENDIF}
(*
Example:
var
rootf, df, relf: String;
Begin
relf := ExtractRelativePath(rootf, df);
assert(ConcatRelativePath(rootf, relf) = df, 'Error, invert did not match);
end;
*)
Function ConcatRelativePath(Const BaseName: String; Const RelativeName: String
): String;
Var
pre, suf: String;
i: integer;
Begin
(*
* BaseName = d:\asdasd\asdas\
* RelativeName = ..\..\temp
* Erg: d:\Temp
*)
result := IncludeTrailingPathDelimiter(BaseName) + RelativeName;
i := pos('..', result);
(*
* Die Idee wir suchen immer nach "..\" blöcken und ersetzen diese Inplace
* Dies ermöglicht verschieden "Krüppelige" Verzeichnisse Korrekt auf zu lösen
*)
While i <> 0 Do Begin
Pre := copy(result, 1, i - 1); // d:\asdasd\asdas\
Suf := copy(result, i + 2, length(result)); //\..\temp
If (Length(suf) = 0) Or (length(pre) = 0) Then exit; // Irgendwas ist hier Falsch !
If (Not (pre[length(pre)] In AllowDirectorySeparators)) Then exit; // Irgendwas ist hier Falsch !
If (Not (Suf[1] In AllowDirectorySeparators)) Then exit; // Irgendwas ist hier Falsch !
Pre := ExcludeTrailingPathDelimiter(pre);
pre := ExtractFilePath(pre);
result := pre + copy(suf, 2, length(suf));
i := pos('..', result);
End;
End;
Function CheckCDRootFolder(aFolder: String): boolean;
Var
sl: TStringList;
checks: Array[0..3] Of Boolean;
i: integer;
Begin
result := true;
sl := FindAllDirectories(aFolder, True);
For i := 0 To high(checks) Do Begin
checks[i] := false;
End;
For i := 0 To sl.Count - 1 Do Begin
If pos('data' + PathDelim + 'ani', lowercase(sl[i])) <> 0 Then checks[0] := true;
If pos('data' + PathDelim + 'res', lowercase(sl[i])) <> 0 Then checks[1] := true;
If pos('data' + PathDelim + 'schemes', lowercase(sl[i])) <> 0 Then checks[2] := true;
If pos('data' + PathDelim + 'sound', lowercase(sl[i])) <> 0 Then checks[3] := true;
End;
For i := 0 To high(checks) Do Begin
result := result And checks[i];
End;
sl.free;
End;
Function CheckFPCAtomicFolder(aFolder: String): boolean;
Var
s: String;
Begin
s := 'fpc_atomic';
{$IFDEF Windows}
s := s + '.exe';
{$ENDIF}
result := FileExists(IncludeTrailingPathDelimiter(aFolder) + s);
End;
(*
* Searches all folders and subfolders of RootFolder for "Match" String and returns
* this one (This is more or less only needed on Linux (Case sensitive) systems.
*)
Function GetFolderByMatch(RootFolder, Match: String): String;
Var
sl: TStringList;
i: Integer;
Begin
result := '';
sl := FindAllDirectories(RootFolder, True);
For i := 0 To sl.Count - 1 Do Begin
If pos(lowercase(match), lowercase(sl[i])) <> 0 Then Begin
result := sl[i];
break;
End;
End;
sl.free;
End;
(*
* Converts the "Match" Filename into a correct (Case sensitive) filename
* this is more or less only needed on Linux (Case sensitive) systems.
* if match is not found result will be ''
*)
Function GetFileByMatch(Folder, Match: String): String;
Var
sl: TStringList;
i: Integer;
{$IFDEF Linux}
NewFolder: String;
{$ENDIF}
Begin
result := '';
{$IFDEF Linux}
(*
* Linux is case sensitive, if the folder "Casing" does not match
* -> fix that!
*)
If Not DirectoryExists(Folder) Then Begin
NewFolder := FindCaseInsensitiveFolder(Folder);
If lowercase(folder) <> lowercase(NewFolder) Then Begin
result := '';
exit;
End
Else Begin
Folder := newFolder;
End;
End;
{$ENDIF}
sl := FindAllFiles(Folder, '*', false);
For i := 0 To sl.Count - 1 Do Begin
If pos(lowercase(match), lowercase(sl[i])) <> 0 Then Begin
result := sl[i];
break;
End;
End;
sl.free;
End;
(*
* Does one TAniJob, returns the resulting image if succeed, otherwise NIL
*)
Function DoAniJob(CDFolder: String; Job: TAniJob): TBitmap;
Var
ani: TAniFile;
AniFilename: String;
cnt, w, h, fpr, i, x, y: integer;
elements: TStringArray;
s: String;
index: LongInt;
SubImage: TBitmap;
Begin
result := Nil;
w := Job.Width;
h := Job.Height;
fpr := Job.FramesPerRow;
If fpr = 0 Then Begin
exit;
End;
AniFilename := GetFileByMatch(ExtractFilePath(CDFolder + Job.SourceAni), Job.SourceAni);
If AniFilename = '' Then Begin
AddLog(' Error: could not find: ' + Job.SourceAni);
exit;
End;
ani := TAniFile.Create();
If Not ani.LoadFromFile(AniFilename) Then Begin
ani.free;
exit;
End;
s := Job.ImageSequence;
elements := s.Split(',');
cnt := Length(elements);
Result := TBitmap.Create;
Result.Transparent := false;
Result.Width := w * fpr;
Result.Height := h * ceil(cnt / fpr);
Result.Canvas.Brush.Color := clFuchsia;
Result.Canvas.Brush.Style := bsSolid;
Result.Canvas.Rectangle(-1, -1, Result.Width + 1, Result.Height + 1);
For i := 0 To high(elements) Do Begin
index := strtointdef(elements[i], -1);
If (index >= ani.ImageCount) Or (index < 0) Then Begin
ani.free;
result.free;
result := Nil;
exit;
End;
SubImage := TBitmap.Create;
SubImage.Transparent := false;
Subimage.Width := w;
SubImage.Height := h;
SubImage.Canvas.Brush.Color := clFuchsia;
SubImage.Canvas.Brush.Style := bsSolid;
SubImage.Canvas.Rectangle(-1, -1, SubImage.Width + 1, SubImage.Height + 1);
Case Job.Alignment Of
taLeftJustify: x := 0;
taCenter: x := (w - Ani.Image[index].Bitmap.Width) Div 2;
taRightJustify: x := (w - Ani.Image[index].Bitmap.Width);
End;
Case Job.Layout Of
tlTop: y := 0;
tlCenter: y := (h - Ani.Image[index].Bitmap.Height) Div 2;
tlBottom: y := (h - Ani.Image[index].Bitmap.Height);
End;
If job.TransparentMode = tmFirstPixelPerFrame Then Begin
SwapColor(Ani.Image[index].Bitmap, Ani.Image[index].Bitmap.Canvas.Pixels[0, 0], clFuchsia);
End;
SubImage.Canvas.Draw(x, y, Ani.Image[index].Bitmap);
Result.Canvas.Draw(w * (i Mod fpr), h * (i Div fpr), SubImage);
subimage.free;
End;
ani.free;
Case job.TransparentMode Of
tmFirstPixel: SwapColor(result, result.Canvas.Pixels[0, 0], clFuchsia);
tmBlack: SwapColor(result, clblack, clFuchsia);
End;
End;
Procedure SetLogCallback(LogCallBack: TLogCallback);
Begin
AddLog := LogCallBack;
End;
(*
* Runs all jobs who's source is a Atomic Bomberman .ani file and the result is a single .png image
* -> TAniJob
* -> TCascadeJob
*)
Procedure ExtractAtomicAnis(CDFolder, AtomicFolder: String);
Function StoreBmp(b: TBitmap; Filename: String): Boolean;
Var
p: TPortableNetworkGraphic;
Begin
result := false;
p := TPortableNetworkGraphic.Create;
p.assign(b);
If Not ForceDirectories(ExtractFilePath(Filename)) Then Begin
AddLog(' Error: could not create folder: ' + ExtractFilePath(Filename));
End
Else Begin
Try
p.SaveToFile(Filename);
result := true;
Except
AddLog(' Error: could not save: ' + Filename);
End;
End;
p.free;
End;
Var
i: Integer;
b: TBitmap;
cnt, j, k: integer;
bmps: Array Of TBitmap;
AniWarning: Boolean;
Begin
CDFolder := IncludeTrailingPathDelimiter(CDFolder);
AtomicFolder := IncludeTrailingPathDelimiter(AtomicFolder);
cnt := 0;
AniWarning := false;
// The Normal Jobs
For i := 0 To high(AniJobs) Do Begin
b := DoAniJob(CDFolder, AniJobs[i]);
If Not assigned(b) Then Begin
AniWarning := true;
Continue;
End;
(*
* Unfortunatunelly this special texture needs a little "Fix", which is here
* hardcoded ;)
*)
If pos('flame.png', lowercase(AniJobs[i].DestPng)) <> 0 Then Begin
SwapColor(b, $00F800F8, clFuchsia);
End;
If assigned(b) Then Begin
If StoreBmp(b, AtomicFolder + AniJobs[i].DestPng) Then inc(cnt);
b.free;
End
Else Begin
AddLog(format(' Error: %s could not be done.', [AniJobs[i].SourceAni]));
End;
End;
// The Cascade Jobs
bmps := Nil;
For i := 0 To high(CascadeJobs) Do Begin
setlength(bmps, length(CascadeJobs[i]));
For j := 0 To high(CascadeJobs[i]) Do Begin
bmps[j] := DoAniJob(CDFolder, CascadeJobs[i, j]);
If Not assigned(bmps[j]) Then Begin
For k := 0 To j - 1 Do Begin
bmps[k].free;
End;
setlength(bmps, 0);
AddLog(format(' Error: %s could not be done.', [CascadeJobs[i, j].SourceAni]));
break;
End;
End;
If Not Assigned(bmps) Then Continue;
b := TBitmap.Create;
b.Width := bmps[0].Width;
b.Height := bmps[0].Height * length(bmps);
b.Transparent := false;
For j := high(bmps) Downto 0 Do Begin // as we free the bmp in the same loop and always refer to image 0, the loop needs to run inverted !
bmps[j].Transparent := false;
b.canvas.Draw(0, j * bmps[0].Height, bmps[j]);
bmps[j].free;
End;
setlength(bmps, 0);
If StoreBmp(b, AtomicFolder + CascadeJobs[i, high(CascadeJobs[i])].DestPng) Then inc(cnt);
b.free;
End;
If AniWarning Then Begin
AddLog(' Did you merge the Atomic Bomberman expansion pack from:');
AddLog(' https://www.oocities.org/timessquare/tower/4056/ani.html ?');
End;
AddLog(format(' %d files created', [cnt]));
End;
(*
* Runs all jobs who's source is a Atomic Bomberman .ani file and the result is a FPC_Atomic .ani file
* -> TAniToAniJob
*)
Procedure ExtractAtomicAniToAnis(CDFolder, AtomicFolder: String);
Var
cnt, i, j: integer;
b: TBitmap;
ani: TOpenGL_Animation;
s: TAniSprite;
targetAniFile: String;
Begin
cnt := 0;
CDFolder := IncludeTrailingPathDelimiter(CDFolder);
AtomicFolder := IncludeTrailingPathDelimiter(AtomicFolder);
For i := 0 To high(AniToAniJobs) Do Begin
b := DoAniJob(CDFolder, AniToAniJobs[i].AniJob);
If Not assigned(b) Then Begin
Continue;
End;
ani := TOpenGL_Animation.Create;
ani.AngleOffset := AniToAniJobs[i].AngleOffset;
For j := 0 To high(AniToAniJobs[i].SpriteData) Do Begin
If j <> 0 Then ani.AddRange(true); // the first range already exists -> create one less ;)
s := ani.Sprite[j];
If j = 0 Then Begin // The first sprite gets the Image, all others derive from it.
s.Bitmap := b;
s.Derived := false;
End
Else Begin
s.Bitmap := Nil;
s.Derived := true;
End;
s.AlphaImage := true;
s.AlphaMask := Nil;
s.TimePerFrame := AniToAniJobs[i].TimePerFrame;
s.rect := rect(0, 0, b.Width, b.Height);
// s.Name := targetAniFile; -- Wird automatisch gesetzt
s.Width := b.Width Div AniToAniJobs[i].FramesPerRow;
s.Height := b.height Div AniToAniJobs[i].FramesPerCol;
s.FramesPerRow := AniToAniJobs[i].FramesPerRow;
s.FramesPerCol := AniToAniJobs[i].FramesPerCol;
s.FrameOffset := AniToAniJobs[i].SpriteData[j].FrameOffset;
s.FrameCount := AniToAniJobs[i].SpriteData[j].FrameCount;
ani.Sprite[j] := s;
End;
targetAniFile := AtomicFolder + AniToAniJobs[i].AniJob.DestPng;
If Not ForceDirectories(ExtractFilePath(targetAniFile)) Then Begin
addlog(' Error unable to create dir: ' + ExtractFilePath(targetAniFile));
ani.free;
Continue;
End;
Try
ani.SaveToFile(targetAniFile);
inc(cnt);
Except
addlog(' Error unable to save: ' + targetAniFile);
End;
// b.free; -- the sprite handles the Bitmap now !
ani.free;
End;
AddLog(format(' %d files created', [cnt]));
End;
(*
* Runs all jobs who's source is a Atomic Bomberman .pcx file and the result is a FPC_Atomic .png file
* -> TPCXJob
*)
Procedure ExtractAtomicPCXs(CDFolder, AtomicFolder: String);
Var
cnt, i: integer;
pcx: TPCX;
sPCXFile, tPCXFile: String;
b: TBitmap;
p: TPortableNetworkGraphic;
Begin
cnt := 0;
CDFolder := IncludeTrailingPathDelimiter(CDFolder);
AtomicFolder := IncludeTrailingPathDelimiter(AtomicFolder);
For i := 0 To high(PCXJobs) Do Begin
sPCXFile := GetFileByMatch(ExtractFilePath(CDFolder + PCXJobs[i].Sourcefile), PCXJobs[i].Sourcefile);
If sPCXFile = '' Then Begin
AddLog(' Error could not locate: ' + PCXJobs[i].Sourcefile);
Continue;
End;
pcx := TPCX.Create();
pcx.LoadFromFile(sPCXFile);
b := pcx.AsTBitmap();
pcx.free;
p := TPortableNetworkGraphic.Create;
(*
* This Image has to be "hacked" a window in, which is not part of the "orig" files
*)
If pos('fieldsetup.png', PCXJobs[i].Destname) <> 0 Then Begin
b.Canvas.Pen.Color := clwhite;
b.Canvas.Pen.Width := 2;
b.Canvas.Brush.Color := clFuchsia;
b.Canvas.Rectangle(379, 81, 601, 282);
b.Canvas.Pixels[378, 80] := clWhite;
b.Canvas.Pixels[600, 80] := clWhite;
End;
p.assign(b);
b.free;
// Store the thing ;)
tPCXFile := AtomicFolder + PCXJobs[i].Destname;
If Not ForceDirectories(ExtractFilePath(tPCXFile)) Then Begin
addlog(' Error unable to create dir: ' + ExtractFilePath(tPCXFile));
p.free;
Continue;
End;
Try
p.SaveToFile(tPCXFile);
inc(cnt);
Except
addlog(' Error unable to save: ' + tPCXFile);
End;
p.free;
End;
AddLog(format(' %d files created', [cnt]));
End;
(*
* Runs all jobs who's source is a Atomic Bomberman .rss file and the result is a FPC_Atomic .wav file
* -> TSoundJob
*)
Procedure ExtractAtomicSounds(CDFolder, AtomicFolder: String);
Var
samplecnt, cnt, i, j: integer;
sSoundFile, tSoundFile: String;
SoundWarning: Boolean;
wav: TWave;
sFile: TFileStream;
sint: int32;
Begin
SoundWarning := false;
cnt := 0;
CDFolder := IncludeTrailingPathDelimiter(CDFolder);
AtomicFolder := IncludeTrailingPathDelimiter(AtomicFolder);
(*
* normally you would see here a for i := 0 to high(SoundJobs) do begin
*
* but during development i did not want to do all jobs again and again and again
* so i switchted to a repeat and therefor was able to init i with higher values
* and skip the already tested ones.
*)
i := 0;
Repeat
// Find the source file
sSoundFile := GetFileByMatch(ExtractFilePath(CDFolder + SoundJobs[i].Sourcefile), SoundJobs[i].Sourcefile);
If sSoundFile = '' Then Begin
AddLog(' Error could not locate: ' + SoundJobs[i].Sourcefile);
SoundWarning := true;
inc(i);
Continue;
End;
// Load the source file stream and convert into a .wav file
wav := TWave.Create;
sFile := TFileStream.Create(sSoundFile, fmOpenRead);
samplecnt := sFile.Size Div sizeof(sint);
wav.InitNewBuffer(1, 22050, 16, samplecnt);
Sint := 0;
For j := 0 To samplecnt - 1 Do Begin
sfile.read(Sint, sizeof(sint));
wav.Sample[0, j] := sint / 2147483647; // Convert into [-1 .. 1]
End;
sFile.Free;
// Store the thing ;)
tSoundFile := AtomicFolder + SoundJobs[i].Destname;
If Not ForceDirectories(ExtractFilePath(tSoundFile)) Then Begin
addlog(' Error unable to create dir: ' + ExtractFilePath(tSoundFile));
wav.free;
Continue;
End;
If wav.SaveToFile(tSoundFile) Then Begin
inc(cnt);
End
Else Begin
addlog(' Error unable to save: ' + tSoundFile);
End;
wav.free;
inc(i);
Until i > high(SoundJobs);
AddLog(format(' %d files created', [cnt]));
If SoundWarning Then Begin
Addlog(' with missing sounds the game is still playable, but with less fun.');
End;
End;
(*
* Copy's all .sch files from the Atomic Bomberman CD into the corresponding scheme folder of FPC_Atomic, no conversion needed.
*)
Procedure ExtractAtomicShemes(CDFolder, AtomicFolder: String);
Var
sSchemeFolder, tSchemeFolder: String;
sl: TStringList;
cnt, i: Integer;
Begin
sSchemeFolder := GetFolderByMatch(CDFolder, 'data' + PathDelim + 'schemes');
If sSchemeFolder = '' Then Begin
addlog(' Error, unable to find schemes folder.');
exit;
End;
tSchemeFolder := IncludeTrailingPathDelimiter(AtomicFolder) + 'data' + PathDelim + 'schemes';
If Not ForceDirectories(tSchemeFolder) Then Begin
addlog(' Error, could not create: ' + tSchemeFolder);
exit;
End;
tSchemeFolder := IncludeTrailingPathDelimiter(tSchemeFolder);
sl := FindAllFiles(sSchemeFolder, '*', false);
cnt := 0;
For i := 0 To sl.Count - 1 Do Begin
If lowercase(ExtractFileExt(sl[i])) = '.sch' Then Begin
If CopyFile(sl[i], tSchemeFolder + uppercase(ExtractFileName(sl[i]))) Then inc(cnt);
End;
End;
AddLog(format(' %d files copied', [cnt]));
sl.free;
End;
(*
* This is the routine that does all the work, it handles everyting what needs to be done
*)
Procedure DoExtraction(CDFolder, AtomicFolder: String; LogCallBack: TLogCallback);
Var
n: QWord;
Begin
If Not assigned(LogCallBack) Then Begin
Raise Exception.Create('Error, missing LogCallback!');
End;
SetLogCallback(LogCallBack);
n := GetTickCount64();
// Start Extraction
AddLog('Start');
Addlog(' be aware the process will take some time (approx. 60s), ...');
// Start extraction
If Not CheckCDRootFolder(CDFolder) Then Begin
AddLog('Error: invalid atomic bomberman CD-Image folder');
exit;
End;
If Not CheckFPCAtomicFolder(AtomicFolder) Then Begin
AddLog('Error: invalid fpc-atomic folder');
exit;
End;
If Not ForceDirectories(IncludeTrailingPathDelimiter(AtomicFolder) + 'data') Then Begin
addlog('Error, could not create data folder.');
exit;
End;
AddLog('PCXs');
ExtractAtomicPCXs(CDFolder, AtomicFolder);
AddLog('ANIs');
ExtractAtomicAnis(CDFolder, AtomicFolder);
ExtractAtomicAniToAnis(CDFolder, AtomicFolder);
AddLog('Sounds');
ExtractAtomicSounds(CDFolder, AtomicFolder);
AddLog('Shemes');
ExtractAtomicShemes(CDFolder, AtomicFolder);
n := GetTickCount64() - n;
Addlog('Extraction took: ' + inttostr(n Div 1000) + 's');
AddLog('Done, please check results.');
End;
(*
* Helper during initialization section
*)
Procedure AddAniJob(SourceAni: String; Width, Height, FPR: integer; Alignment: TAlignment; Layout: ttextlayout; ImageSequence, DestPng: String; TransparentMode: TTransparentMode);
Begin
setlength(AniJobs, high(AniJobs) + 2);
AniJobs[high(AniJobs)].SourceAni := SourceAni;
AniJobs[high(AniJobs)].Width := Width;
AniJobs[high(AniJobs)].Height := Height;
AniJobs[high(AniJobs)].FramesPerRow := FPR;
AniJobs[high(AniJobs)].Alignment := Alignment;
AniJobs[high(AniJobs)].Layout := Layout;
AniJobs[high(AniJobs)].ImageSequence := ImageSequence;
AniJobs[high(AniJobs)].DestPng := DestPng;
AniJobs[high(AniJobs)].TransparentMode := TransparentMode;
End;
(*
* Helper during initialization section
*
* JobCount = number of Jobs to be merged into one Cascade Job
*)
Procedure PopCascade(JobCount: Integer);
Var
cj: TCascadeJob;
i: Integer;
Begin
cj := Nil;
setlength(cj, JobCount);
For i := 0 To JobCount - 1 Do Begin
cj[high(cj) - i] := AniJobs[high(AniJobs) - i];
End;
setlength(AniJobs, Length(AniJobs) - JobCount);
setlength(CascadeJobs, high(CascadeJobs) + 2);
CascadeJobs[High(CascadeJobs)] := cj;
End;
(*
* Helper during initialization section
*
* 2 Datapoints give 1 Dataset
* \- first = FrameOffset
* \- second = FrameCount
*)
Procedure PopAniJob(FramesPerRow, FramesPerCol, TimePerFrame: integer; AngleOffset: Single; DataPoints: Array Of Integer);
Var
i: Integer;
Begin
If length(DataPoints) Mod 2 <> 0 Then Begin
Raise exception.create('Error, invalid settings.');
End;
setlength(AniToAniJobs, high(AniToAniJobs) + 2);
AniToAniJobs[high(AniToAniJobs)].AniJob := AniJobs[high(AniJobs)];
setlength(AniJobs, high(AniJobs));
AniToAniJobs[high(AniToAniJobs)].FramesPerRow := FramesPerRow;
AniToAniJobs[high(AniToAniJobs)].FramesPerCol := FramesPerCol;
AniToAniJobs[high(AniToAniJobs)].TimePerFrame := TimePerFrame;
AniToAniJobs[high(AniToAniJobs)].AngleOffset := AngleOffset;
setlength(AniToAniJobs[high(AniToAniJobs)].SpriteData, length(DataPoints) Div 2);
For i := 0 To high(AniToAniJobs[high(AniToAniJobs)].SpriteData) Do Begin
AniToAniJobs[high(AniToAniJobs)].SpriteData[i].FrameOffset := DataPoints[i * 2];
AniToAniJobs[high(AniToAniJobs)].SpriteData[i].FrameCount := DataPoints[i * 2 + 1];
End;
End;
Initialization
AniJobs := Nil;
CascadeJobs := Nil;
AniToAniJobs := Nil;
(*
* Paste here the content from "Copy job to clipboard" button (from unit2.pos [enable button6, see TForm1.FormCreate])
*
* AddAniJob: extracts frames from a .ani file into one output image