diff --git a/src/enums/terrain.ts b/src/enums/terrain.ts deleted file mode 100644 index 6b02248..0000000 --- a/src/enums/terrain.ts +++ /dev/null @@ -1,16 +0,0 @@ -export enum Terrain { - Grass, - Sand, - Dirt, - Rock, - Martian, - Checkerboard, - GrassClumps, - Ice, - GridRed, - GridYellow, - GridBlue, - GridGreen, - SandDark, - SandLight -} diff --git a/src/utilities/colourdecider.ts b/src/utilities/colourdecider.ts index 5a1db18..4537ff4 100644 --- a/src/utilities/colourdecider.ts +++ b/src/utilities/colourdecider.ts @@ -84,11 +84,7 @@ export default class ColourDecider { } static getColourFromFootpath(element: FootpathElement): number { - if (element.surfaceObject !== null) { - return this.getColourFromFootpathType(element.surfaceObject); - } - - return 0; + return ColourUtilities.footpathToPalette(element.surfaceObject ?? element.object ?? 0); } static getColourFromSurface(element: SurfaceElement, options: Options): number { @@ -98,22 +94,4 @@ export default class ColourDecider { return options.showSurface ? ColourUtilities.surfaceToPalette(element.surfaceStyle) : ColourUtilities.colourToPalette(Colour.Black); } - - private static getColourFromFootpathType(object: number): number { - // We can't actually know what kind of footpath it is just - // based on the object number, since that number will - // change based on what objects are selected in the map. - - // However we should at least differentiate somehow, so - // let's pick some colors at random... - const colours: number[] = [ - ColourUtilities.colourToPalette(Colour.Grey), - ColourUtilities.colourToPalette(Colour.LightBrown), - ColourUtilities.colourToPalette(Colour.DarkBrown), - ColourUtilities.colourToPalette(Colour.SaturatedBrown), - ColourUtilities.colourToPalette(Colour.DarkOliveGreen) - ]; - - return colours[(object ?? 0) % colours.length]; - } } diff --git a/src/utilities/colourutilities.ts b/src/utilities/colourutilities.ts index 2422617..1109c73 100644 --- a/src/utilities/colourutilities.ts +++ b/src/utilities/colourutilities.ts @@ -1,29 +1,68 @@ import { Colour } from "../enums/colour"; -import { Terrain } from "../enums/terrain"; // See ImageImporter.h for colour indexes export default class ColourUtilities { static surfaceToPalette(surface: number): number { - switch (surface) { - case Terrain.Grass: return 72; - case Terrain.Sand: return 42; - case Terrain.Dirt: return 218; - case Terrain.Rock: return 13; - case Terrain.Martian: return 109; - case Terrain.Checkerboard: return 20; - case Terrain.GrassClumps: return 23; - case Terrain.Ice: return 139; - case Terrain.GridRed: return 173; - case Terrain.GridYellow: return 54; - case Terrain.GridBlue: return 157; // It's really purple - case Terrain.GridGreen: return 101; - case Terrain.SandDark: return 109; - case Terrain.SandLight: return 220; + const surfaceObject = objectManager.getObject("terrain_surface", surface); + switch (surfaceObject.identifier.split(".")[2]) { + case "grass": return 72; + case "grass_clumps": return 23; + case "dirt": return 218; + case "ice": return 139; + case "rock": return 13; + case "sand": return 44; + case "martian": return 109; + case "sand_brown": return 221; + case "sand_red": return 111; + + // rct1 + case "rust": return 220; + case "wood": return 47; + case "roof_grey": return 17; + case "roof_red": return 176; + + case "chequerboard": return 16; + case "grid_green": return 101; + case "grid_purple": return 157; + case "grid_red": return 173; + case "grid_yellow": return 54; + case "void": return 4; default: return 209; // undefined -> pink } } + static footpathToPalette(footpath: number): number { + const pathType = objectManager.getObject("footpath_surface", footpath); + switch (pathType.identifier.split(".")[2]) { + case "dirt": + return 216; + case "crazy_paving": + return 223; + case "ash": + return 10; + case "tarmac_red": + return 62; + case "tarmac_green": + return 75; + case "tarmac_brown": + return 34; + case "tarmac": + case "road": + return 15; + case "queue_yellow": + return 54; + case "queue_red": + return 173; + case "queue_green": + return 100; + case "queue_blue": + return 137; + default: + return 209; // undefined -> pink + } + } + static water(): number { return 237; }