Skip to content

Commit e185d0c

Browse files
committed
rework imagetable view models for better mvvm style and fix group importing
1 parent 3db65d6 commit e185d0c

File tree

9 files changed

+266
-204
lines changed

9 files changed

+266
-204
lines changed

Dat/Types/G1Dat.cs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ public G1Dat(G1Header g1Header, List<GraphicsElement> graphicsElements)
2929
// 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
3030
Groups =
3131
[
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]),
32+
new ("terrain-masks", [.. graphicsElements[0..417], .. graphicsElements[3629..3896]]),
33+
new ("palettes", [.. graphicsElements[417..428], .. graphicsElements[2170..2305]]),
34+
new ("arrows", [.. graphicsElements[428..444], .. graphicsElements[449..457], .. graphicsElements[3492..3504]]),
35+
new ("unk", graphicsElements[444..449]),
36+
new ("supports", graphicsElements[457..1117]),
37+
new ("glyphs", graphicsElements[1117..2170]),
38+
new ("loading-bar", graphicsElements[2326..2335]),
39+
new ("interface", [.. graphicsElements[2335..2470], .. graphicsElements[3477..3479], .. graphicsElements[2305..2326], .. graphicsElements[3539..3547]]),
40+
new ("height-markers", graphicsElements[2470..3238]),
41+
new ("numerical-markers", graphicsElements[3238..3302]),
42+
new ("unk", graphicsElements[3302..3362]),
43+
new ("particles", graphicsElements[3362..3477]),
44+
new ("masks", [.. graphicsElements[3479..3492], graphicsElements[3504]]),
45+
new ("object-types", graphicsElements[3505..3539]),
46+
new ("title", graphicsElements[3547..3629]),
4747
]
4848
};
4949
}
@@ -53,21 +53,21 @@ public G1Dat(G1Header g1Header, List<GraphicsElement> graphicsElements)
5353
{
5454
Groups =
5555
[
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]),
56+
new ("terrain-masks", [.. graphicsElements[0..417], .. graphicsElements[3631..3898]]),
57+
new ("palettes", [.. graphicsElements[417..428], .. graphicsElements[2170..2305]]),
58+
new ("arrows", [.. graphicsElements[428..444], .. graphicsElements[449..457], .. graphicsElements[3492..3504]]),
59+
new ("unk", graphicsElements[444..449]),
60+
new ("supports", graphicsElements[457..1117]),
61+
new ("glyphs", [.. graphicsElements[1117..2170], .. graphicsElements[3898..4122]]),
62+
new ("loading-bar", graphicsElements[2326..2335]),
63+
new ("interface", [.. graphicsElements[2335..2470], .. graphicsElements[3477..3479], .. graphicsElements[2305..2326], .. graphicsElements[3539..3547]]),
64+
new ("height-markers", graphicsElements[2470..3238]),
65+
new ("numerical-markers", graphicsElements[3238..3302]),
66+
new ("unk", graphicsElements[3302..3362]),
67+
new ("particles", graphicsElements[3362..3477]),
68+
new ("masks", [.. graphicsElements[3479..3492], graphicsElements[3504]]),
69+
new ("object-types", graphicsElements[3505..3539]),
70+
new ("title", graphicsElements[3547..3631]),
7171
]
7272
};
7373
}

Definitions/ObjectModels/IImageTableNameProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Definitions.ObjectModels;
55

66
public interface IHasGraphicsElements
77
{
8-
List<GraphicsElement> GraphicsElements { get; set; } // todo: probably change to IEnumerable
8+
List<GraphicsElement> GraphicsElements { get; } // todo: probably change to IEnumerable
99
}
1010

1111
public interface IImageTableNameProvider

Definitions/ObjectModels/ImageTable.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Definitions.ObjectModels;
44

5+
public record ImageTableGroup(string Name, List<GraphicsElement> GraphicsElements);
6+
57
public class ImageTable : IHasGraphicsElements
68
{
79
public PaletteMap PaletteMap
@@ -28,16 +30,9 @@ public PaletteMap PaletteMap
2830

2931
// public/old interface
3032
public List<GraphicsElement> GraphicsElements
31-
{
32-
get => [.. Groups
33+
=> [.. Groups
3334
.SelectMany(x => x.GraphicsElements)
3435
.OrderBy(x => x.ImageTableIndex)];
35-
set
36-
{
37-
Groups.Clear();
38-
Groups.Add(("All", value));
39-
}
40-
}
4136

42-
public List<(string Name, List<GraphicsElement> GraphicsElements)> Groups { get; set; } = [];
37+
public List<ImageTableGroup> Groups { get; set; } = [];
4338
}

0 commit comments

Comments
 (0)