File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 6
6
using OpenLoco . Dat . Objects ;
7
7
using OpenLoco . Dat . Types ;
8
8
using OpenLoco . Definitions . SourceData ;
9
+ using SixLabors . ImageSharp ;
10
+ using SixLabors . ImageSharp . PixelFormats ;
9
11
using System . Text . Json ;
10
12
using System . Text . Json . Serialization ;
11
13
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
+
12
36
var jsonOptions = new JsonSerializerOptions ( ) { WriteIndented = true , Converters = { new JsonStringEnumConverter ( ) } , } ;
13
37
var objectMetadata = JsonSerializer . Deserialize < IEnumerable < ObjectMetadata > > ( File . ReadAllText ( "Q:\\ Games\\ Locomotion\\ Server\\ Objects\\ objectMetadata.json" ) , jsonOptions )
14
38
. ToDictionary ( x => ( x . DatName , x . DatChecksum ) , x => x ) ;
You can’t perform that action at this time.
0 commit comments