1 /*****************************************************************************
2  * Copyright (c) 2014-2020 OpenRCT2 developers
3  *
4  * For a complete list of all authors, please refer to contributors.md
5  * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
6  *
7  * OpenRCT2 is licensed under the GNU General Public License version 3.
8  *****************************************************************************/
9 
10 #pragma once
11 
12 #include "../common.h"
13 
14 #include <string_view>
15 
16 /**
17  * Colour IDs as used by the colour dropdown, NOT palette indices.
18  */
19 enum : colour_t
20 {
21     COLOUR_BLACK,
22     COLOUR_GREY,
23     COLOUR_WHITE,
24     COLOUR_DARK_PURPLE,
25     COLOUR_LIGHT_PURPLE,
26     COLOUR_BRIGHT_PURPLE,
27     COLOUR_DARK_BLUE,
28     COLOUR_LIGHT_BLUE,
29     COLOUR_ICY_BLUE,
30     COLOUR_TEAL,
31     COLOUR_AQUAMARINE,
32     COLOUR_SATURATED_GREEN,
33     COLOUR_DARK_GREEN,
34     COLOUR_MOSS_GREEN,
35     COLOUR_BRIGHT_GREEN,
36     COLOUR_OLIVE_GREEN,
37     COLOUR_DARK_OLIVE_GREEN,
38     COLOUR_BRIGHT_YELLOW,
39     COLOUR_YELLOW,
40     COLOUR_DARK_YELLOW,
41     COLOUR_LIGHT_ORANGE,
42     COLOUR_DARK_ORANGE,
43     COLOUR_LIGHT_BROWN,
44     COLOUR_SATURATED_BROWN,
45     COLOUR_DARK_BROWN,
46     COLOUR_SALMON_PINK,
47     COLOUR_BORDEAUX_RED,
48     COLOUR_SATURATED_RED,
49     COLOUR_BRIGHT_RED,
50     COLOUR_DARK_PINK,
51     COLOUR_BRIGHT_PINK,
52     COLOUR_LIGHT_PINK,
53 
54     COLOUR_COUNT,
55 
56     COLOUR_NULL = 255,
57 };
58 
59 /**
60  * These colours change depending on the current water colours.
61  */
62 enum
63 {
64     COLOUR_DARK_WATER = 9,
65     COLOUR_LIGHT_WATER = 10
66 };
67 
68 enum : uint8_t
69 {
70     PALETTE_INDEX_0 = 0,     // Transparent
71     PALETTE_INDEX_10 = 10,   // Black (0-dark), Dark grey (0)
72     PALETTE_INDEX_11 = 11,   // Black (middark)
73     PALETTE_INDEX_12 = 12,   // Black (midlight), Dark grey (1-darkest)
74     PALETTE_INDEX_14 = 14,   // Black (lighter), Dark grey (dark)
75     PALETTE_INDEX_13 = 13,   //
76     PALETTE_INDEX_16 = 16,   //
77     PALETTE_INDEX_17 = 17,   // Black (11), Dark grey (light), White (dark)
78     PALETTE_INDEX_20 = 20,   // Dark grey (10), White (light)
79     PALETTE_INDEX_21 = 21,   // Dark grey (11), White (lighter-11)
80     PALETTE_INDEX_40 = 40,   //
81     PALETTE_INDEX_42 = 42,   // Light Brown (lighter), Saturated brown (11)
82     PALETTE_INDEX_46 = 46,   // Tertiary remap 0  / Yellow (darkest)
83     PALETTE_INDEX_47 = 47,   // Tertiary remap 1  / Yellow
84     PALETTE_INDEX_48 = 48,   // Tertiary remap 2  / Yellow
85     PALETTE_INDEX_49 = 49,   // Tertiary remap 3  / Yellow
86     PALETTE_INDEX_50 = 50,   // Tertiary remap 4  / Yellow
87     PALETTE_INDEX_51 = 51,   // Tertiary remap 5  / Yellow
88     PALETTE_INDEX_52 = 52,   // Tertiary remap 6  / Yellow
89     PALETTE_INDEX_53 = 53,   // Tertiary remap 7  / Yellow
90     PALETTE_INDEX_54 = 54,   // Tertiary remap 8  / Yellow
91     PALETTE_INDEX_55 = 55,   // Tertiary remap 9  / Yellow
92     PALETTE_INDEX_56 = 56,   // Tertiary remap 10 / Yellow
93     PALETTE_INDEX_57 = 57,   // Tertiary remap 11 / Yellow (lightest)
94     PALETTE_INDEX_61 = 61,   // Bordeaux Red (darker)
95     PALETTE_INDEX_62 = 62,   //
96     PALETTE_INDEX_68 = 68,   //
97     PALETTE_INDEX_73 = 73,   //
98     PALETTE_INDEX_99 = 99,   //
99     PALETTE_INDEX_102 = 102, // Bright green (lighter)
100     PALETTE_INDEX_108 = 108, //
101     PALETTE_INDEX_111 = 111, //
102     PALETTE_INDEX_129 = 129, // Light Purple (11)
103     PALETTE_INDEX_135 = 135, //
104     PALETTE_INDEX_136 = 136, // Dark Blue (10-11), Light Blue (midlight), Icy Blue (darker)
105     PALETTE_INDEX_138 = 138, // Light Blue (lighter), Icy Blue (middark)
106     PALETTE_INDEX_141 = 141, //
107     PALETTE_INDEX_144 = 144, // Dark Green (1-darkest,
108     PALETTE_INDEX_161 = 161, // Bright Purple (light)
109     PALETTE_INDEX_162 = 162, //
110     PALETTE_INDEX_171 = 171, // Saturated Red (lightest) Bright Red (middark)
111     PALETTE_INDEX_172 = 172, // Saturated Red (10-11), Bright Red (midlight)
112     PALETTE_INDEX_173 = 173, // Used to draw intense lines in the Ride Graphs window
113     PALETTE_INDEX_183 = 183, // Used to draw rides in the Map window
114     PALETTE_INDEX_186 = 186, //
115     PALETTE_INDEX_194 = 194, //
116     PALETTE_INDEX_195 = 195, //
117     PALETTE_INDEX_202 = 202, // Secondary remap 0  / Pink (darkest)
118     PALETTE_INDEX_203 = 203, // Secondary remap 1  / Pink
119     PALETTE_INDEX_204 = 204, // Secondary remap 2  / Pink
120     PALETTE_INDEX_205 = 205, // Secondary remap 3  / Pink
121     PALETTE_INDEX_206 = 206, // Secondary remap 4  / Pink
122     PALETTE_INDEX_207 = 207, // Secondary remap 5  / Pink
123     PALETTE_INDEX_208 = 208, // Secondary remap 6  / Pink
124     PALETTE_INDEX_209 = 209, // Secondary remap 7  / Pink
125     PALETTE_INDEX_210 = 210, // Secondary remap 8  / Pink
126     PALETTE_INDEX_211 = 211, // Secondary remap 9  / Pink
127     PALETTE_INDEX_212 = 212, // Secondary remap 10 / Pink
128     PALETTE_INDEX_213 = 213, // Secondary remap 11 / Pink (lightest)
129     PALETTE_INDEX_222 = 222, //
130     PALETTE_INDEX_230 = 230, // Water (waves)
131     PALETTE_INDEX_231 = 231, // Water (waves)
132     PALETTE_INDEX_232 = 232, // Water (waves)
133     PALETTE_INDEX_233 = 233, // Water (waves)
134     PALETTE_INDEX_234 = 234, // Water (waves)
135     PALETTE_INDEX_235 = 235, // Water (sparkles)
136     PALETTE_INDEX_236 = 236, // Water (sparkles)
137     PALETTE_INDEX_237 = 237, // Water (sparkles)
138     PALETTE_INDEX_238 = 238, // Water (sparkles)
139     PALETTE_INDEX_239 = 239, // Water (sparkles)
140     PALETTE_INDEX_240 = 240, // Track rails
141     PALETTE_INDEX_241 = 241, // Track rails
142     PALETTE_INDEX_242 = 242, // Track rails
143     PALETTE_INDEX_243 = 243, // Primary remap 0
144     PALETTE_INDEX_244 = 244, // Primary remap 1
145     PALETTE_INDEX_245 = 245, // Primary remap 2
146     PALETTE_INDEX_246 = 246, // Primary remap 3
147     PALETTE_INDEX_247 = 247, // Primary remap 4
148     PALETTE_INDEX_248 = 248, // Primary remap 5
149     PALETTE_INDEX_249 = 249, // Primary remap 6
150     PALETTE_INDEX_250 = 250, // Primary remap 7
151     PALETTE_INDEX_251 = 251, // Primary remap 8
152     PALETTE_INDEX_252 = 252, // Primary remap 9
153     PALETTE_INDEX_253 = 253, // Primary remap 10
154     PALETTE_INDEX_254 = 254, // Primary remap 11
155 };
156 
157 constexpr size_t PALETTE_COUNT = 256;
158 
159 constexpr uint8_t PALETTE_OFFSET_DYNAMIC = PALETTE_INDEX_10;
160 constexpr uint8_t PALETTE_LENGTH_DYNAMIC = 236;
161 
162 constexpr uint8_t PALETTE_OFFSET_WATER_WAVES = PALETTE_INDEX_230;
163 constexpr uint8_t PALETTE_OFFSET_WATER_SPARKLES = PALETTE_INDEX_235;
164 constexpr uint8_t PALETTE_LENGTH_WATER_WAVES = 5;
165 constexpr uint8_t PALETTE_LENGTH_WATER_SPARKLES = 5;
166 
167 constexpr uint8_t PALETTE_OFFSET_TRACK_RAILS = PALETTE_INDEX_240;
168 constexpr uint8_t PALETTE_LENGTH_TRACK_RAILS = 3;
169 
170 constexpr uint8_t PALETTE_OFFSET_REMAP_PRIMARY = PALETTE_INDEX_243;
171 constexpr uint8_t PALETTE_OFFSET_REMAP_SECONDARY = PALETTE_INDEX_202;
172 constexpr uint8_t PALETTE_OFFSET_REMAP_TERTIARY = PALETTE_INDEX_46;
173 constexpr uint8_t PALETTE_LENGTH_REMAP = 12;
174 
175 constexpr uint8_t PALETTE_OFFSET_ANIMATED = PALETTE_INDEX_230;
176 constexpr uint8_t PALETTE_LENGTH_ANIMATED = 16;
177 
178 #define TEXT_COLOUR_254 (254)
179 #define TEXT_COLOUR_255 (255)
180 
181 enum
182 {
183     COLOUR_FLAG_OUTLINE = (1 << 5),
184     COLOUR_FLAG_INSET = (1 << 6), // 64, 0x40
185     COLOUR_FLAG_TRANSLUCENT = (1 << 7),
186     COLOUR_FLAG_8 = (1 << 8)
187 };
188 
189 #define TRANSLUCENT(x) ((x) | COLOUR_FLAG_TRANSLUCENT)
190 #define NOT_TRANSLUCENT(x) ((x) & ~COLOUR_FLAG_TRANSLUCENT)
191 #define BASE_COLOUR(x) ((x)&0x1F)
192 
193 struct rct_colour_map
194 {
195     uint8_t colour_0;
196     uint8_t colour_1;
197     uint8_t darkest;
198     uint8_t darker;
199     uint8_t dark;
200     uint8_t mid_dark;
201     uint8_t mid_light;
202     uint8_t light;
203     uint8_t lighter;
204     uint8_t lightest;
205     uint8_t colour_10;
206     uint8_t colour_11;
207 };
208 
209 extern rct_colour_map ColourMapA[COLOUR_COUNT];
210 
211 void colours_init_maps();
212 
213 namespace Colour
214 {
215     colour_t FromString(std::string_view s, colour_t defaultValue = COLOUR_BLACK);
216 }
217 
218 #ifndef NO_TTF
219 uint8_t blendColours(const uint8_t paletteIndex1, const uint8_t paletteIndex2);
220 #endif
221