11using Definitions . ObjectModels ;
22using Definitions . ObjectModels . Types ;
33using System . ComponentModel ;
4+ using System . Diagnostics ;
45using System . Diagnostics . CodeAnalysis ;
56
67namespace Dat . Types ;
@@ -12,33 +13,67 @@ public class G1Dat
1213 public G1Header G1Header { get ; set ; }
1314 public ImageTable ImageTable { get ; set ; }
1415
16+ public const int SteamImageCount = 3896 ;
17+ public const int GoGImageCount = 4122 ;
18+
1519 public bool IsSteamG1
16- => ImageTable . GraphicsElements . Count == 3896 ;
20+ => ImageTable . GraphicsElements . Count == SteamImageCount ;
1721
1822 public G1Dat ( G1Header g1Header , List < GraphicsElement > graphicsElements )
1923 {
2024 G1Header = g1Header ;
21- ImageTable = new ImageTable
25+ if ( graphicsElements . Count == SteamImageCount )
26+ {
27+ ImageTable = new ImageTable
28+ {
29+ // Note: The grouping below is good but its for steam only, and because elements are out of order, saving is not possible unless each element stores its index
30+ Groups =
31+ [
32+ ( "terrain-masks" , [ .. graphicsElements [ 0 ..417 ] , .. graphicsElements [ 3629 ..3896 ] ] ) ,
33+ ( "palettes" , [ .. graphicsElements [ 417 ..428 ] , .. graphicsElements [ 2170 ..2305 ] ] ) ,
34+ ( "arrows" , [ .. graphicsElements [ 428 ..444 ] , .. graphicsElements [ 449 ..457 ] , .. graphicsElements [ 3492 ..3504 ] ] ) ,
35+ ( "unk" , graphicsElements [ 444 ..449 ] ) ,
36+ ( "supports" , graphicsElements [ 457 ..1117 ] ) ,
37+ ( "glyphs" , graphicsElements [ 1117 ..2170 ] ) ,
38+ ( "loading-bar" , graphicsElements [ 2326 ..2335 ] ) ,
39+ ( "interface" , [ .. graphicsElements [ 2335 ..2470 ] , .. graphicsElements [ 3477 ..3479 ] , .. graphicsElements [ 2305 ..2326 ] , .. graphicsElements [ 3539 ..3547 ] ] ) ,
40+ ( "height-markers" , graphicsElements [ 2470 ..3238 ] ) ,
41+ ( "numerical-markers" , graphicsElements [ 3238 ..3302 ] ) ,
42+ ( "unk" , graphicsElements [ 3302 ..3362 ] ) ,
43+ ( "particles" , graphicsElements [ 3362 ..3477 ] ) ,
44+ ( "masks" , [ .. graphicsElements [ 3479 ..3492 ] , graphicsElements [ 3504 ] ] ) ,
45+ ( "object-types" , graphicsElements [ 3505 ..3539 ] ) ,
46+ ( "title" , graphicsElements [ 3547 ..3629 ] ) ,
47+ ]
48+ } ;
49+ }
50+ else
2251 {
23- Groups =
24- [
25- ( "terrain-masks" , [ .. graphicsElements [ 0 ..417 ] , .. graphicsElements [ 3629 ..3896 ] ] ) ,
26- ( "palettes" , [ .. graphicsElements [ 417 ..428 ] , .. graphicsElements [ 2170 ..2304 ] ] ) ,
27- ( "arrows" , [ .. graphicsElements [ 428 ..444 ] , .. graphicsElements [ 449 ..457 ] , .. graphicsElements [ 3492 ..3504 ] ] ) ,
28- ( "unk" , graphicsElements [ 444 ..449 ] ) ,
29- ( "supports" , graphicsElements [ 457 ..1117 ] ) ,
30- ( "glyphs" , graphicsElements [ 1117 ..2169 ] ) ,
31- ( "loading-bar" , graphicsElements [ 2326 ..2335 ] ) ,
32- ( "interface" , [ .. graphicsElements [ 2335 ..2470 ] , .. graphicsElements [ 3477 ..3479 ] , .. graphicsElements [ 2305 ..2326 ] , .. graphicsElements [ 3539 ..3547 ] ] ) ,
33- ( "height-markers" , graphicsElements [ 2470 ..3238 ] ) ,
34- ( "numerical-markers" , graphicsElements [ 3238 ..3302 ] ) ,
35- ( "unk" , graphicsElements [ 3302 ..3362 ] ) ,
36- ( "particles" , graphicsElements [ 3362 ..3477 ] ) ,
37- ( "masks" , [ .. graphicsElements [ 3479 ..3492 ] , graphicsElements [ 3504 ] ] ) ,
38- ( "object-types" , graphicsElements [ 3505 ..3539 ] ) ,
39- ( "title" , graphicsElements [ 3547 ..3629 ] ) ,
40- ]
41- } ;
52+ ImageTable = new ImageTable ( )
53+ {
54+ Groups =
55+ [
56+ ( "terrain-masks" , [ .. graphicsElements [ 0 ..417 ] , .. graphicsElements [ 3631 ..3898 ] ] ) ,
57+ ( "palettes" , [ .. graphicsElements [ 417 ..428 ] , .. graphicsElements [ 2170 ..2305 ] ] ) ,
58+ ( "arrows" , [ .. graphicsElements [ 428 ..444 ] , .. graphicsElements [ 449 ..457 ] , .. graphicsElements [ 3492 ..3504 ] ] ) ,
59+ ( "unk" , graphicsElements [ 444 ..449 ] ) ,
60+ ( "supports" , graphicsElements [ 457 ..1117 ] ) ,
61+ ( "glyphs" , [ .. graphicsElements [ 1117 ..2170 ] , .. graphicsElements [ 3898 ..4122 ] ] ) ,
62+ ( "loading-bar" , graphicsElements [ 2326 ..2335 ] ) ,
63+ ( "interface" , [ .. graphicsElements [ 2335 ..2470 ] , .. graphicsElements [ 3477 ..3479 ] , .. graphicsElements [ 2305 ..2326 ] , .. graphicsElements [ 3539 ..3547 ] ] ) ,
64+ ( "height-markers" , graphicsElements [ 2470 ..3238 ] ) ,
65+ ( "numerical-markers" , graphicsElements [ 3238 ..3302 ] ) ,
66+ ( "unk" , graphicsElements [ 3302 ..3362 ] ) ,
67+ ( "particles" , graphicsElements [ 3362 ..3477 ] ) ,
68+ ( "masks" , [ .. graphicsElements [ 3479 ..3492 ] , graphicsElements [ 3504 ] ] ) ,
69+ ( "object-types" , graphicsElements [ 3505 ..3539 ] ) ,
70+ ( "title" , graphicsElements [ 3547 ..3631 ] ) ,
71+ ]
72+ } ;
73+ }
74+
75+ Debug . Assert ( G1Header . NumEntries == ImageTable . GraphicsElements . Count ) ;
76+ Debug . Assert ( ImageTable . GraphicsElements . Count == graphicsElements . Count ) ;
4277 }
4378
4479 public bool TryGetImageName ( int id , [ MaybeNullWhen ( false ) ] out string value )
0 commit comments