Skip to content

Commit 2e5c6d0

Browse files
committed
use the zoomoffset and flags read from the json file...
1 parent c08ae61 commit 2e5c6d0

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

Dat/Types/G1Element32.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public record G1Element32(
2929
) : ILocoStruct
3030
{
3131
public static int StructLength => 0x10;
32+
33+
[Browsable(false)]
3234
public byte[] ImageData { get; set; } = [];
3335

3436
public ReadOnlySpan<byte> Write()

Gui/ViewModels/SubObjectTypes/ImageTableViewModel.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,7 @@ public async Task ImportImages()
283283
var offsetPath = offsetList[i].Path;
284284
var validPath = string.IsNullOrEmpty(offsetPath) ? $"{i}.png" : offsetPath;
285285
var filename = Path.Combine(dirPath, validPath);
286-
287-
if (i < G1Provider.G1Elements.Count)
288-
{
289-
var g1 = G1Provider.G1Elements[i];
290-
LoadSprite(filename, 0, offsetList[i].XOffset, offsetList[i].YOffset, g1.Flags, g1.ZoomOffset);
291-
}
292-
else
293-
{
294-
LoadSprite(filename, 0, offsetList[i].XOffset, offsetList[i].YOffset, G1ElementFlags.None, 0);
295-
}
286+
LoadSprite(filename, offsetList[i]);
296287
}
297288

298289
Logger.Debug($"Imported {G1Provider.G1Elements.Count} images successfully");
@@ -306,7 +297,7 @@ public async Task ImportImages()
306297

307298
animationTimer.Start();
308299

309-
void LoadSprite(string filename, uint imageOffset, short xOffset, short yOffset, G1ElementFlags flags, short zoomOffset)
300+
void LoadSprite(string filename, G1Element32Json ele)
310301
{
311302
if (!File.Exists(filename))
312303
{
@@ -316,7 +307,8 @@ void LoadSprite(string filename, uint imageOffset, short xOffset, short yOffset,
316307

317308
var img = Image.Load<Rgba32>(filename);
318309

319-
var newElement = new G1Element32(imageOffset, (int16_t)img.Width, (int16_t)img.Height, xOffset, yOffset, flags, zoomOffset)
310+
var flags = ele.Flags ?? G1ElementFlags.None;
311+
var newElement = new G1Element32(0, (int16_t)img.Width, (int16_t)img.Height, ele.XOffset, ele.YOffset, flags, ele.ZoomOffset ?? 0)
320312
{
321313
ImageData = PaletteMap.ConvertRgba32ImageToG1Data(img, flags, SelectedPrimarySwatch, SelectedSecondarySwatch)
322314
};

0 commit comments

Comments
 (0)