Skip to content

Commit 8cec59e

Browse files
committed
add a little script to generate a JASC pal file from the loco palette
1 parent aa46d6f commit 8cec59e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

DataSanitiser/Program.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,33 @@
66
using OpenLoco.Dat.Objects;
77
using OpenLoco.Dat.Types;
88
using OpenLoco.Definitions.SourceData;
9+
using SixLabors.ImageSharp;
10+
using SixLabors.ImageSharp.PixelFormats;
911
using System.Text.Json;
1012
using System.Text.Json.Serialization;
1113

14+
// load 32bpp palette
15+
var paletteFile = "Q:\\Games\\Locomotion\\Palettes\\palette.png";
16+
var img = Image.Load<Rgba32>(paletteFile);
17+
var palStrings = new List<string>()
18+
{
19+
"JASC-PAL", // header
20+
"0100", // version
21+
"256", // colours in palette file
22+
};
23+
24+
for (var y = 0; y < img.Height; y++)
25+
{
26+
for (var x = 0; x < img.Width; x++)
27+
{
28+
var col = img[x, y];
29+
palStrings.Add($"{col.R} {col.G} {col.B}");
30+
}
31+
}
32+
File.WriteAllLines("Q:\\Games\\Locomotion\\Palettes\\jascpal.pal", palStrings);
33+
// spit out .pal file
34+
Environment.Exit(0);
35+
1236
var jsonOptions = new JsonSerializerOptions() { WriteIndented = true, Converters = { new JsonStringEnumConverter() }, };
1337
var objectMetadata = JsonSerializer.Deserialize<IEnumerable<ObjectMetadata>>(File.ReadAllText("Q:\\Games\\Locomotion\\Server\\Objects\\objectMetadata.json"), jsonOptions)
1438
.ToDictionary(x => (x.DatName, x.DatChecksum), x => x);

0 commit comments

Comments
 (0)