game-flow: allow string hex values

This commit is contained in:
Marcin Kurczewski 2025-04-12 15:16:28 +02:00
parent 1f6f85b0af
commit f980e4f22c
3 changed files with 20 additions and 5 deletions

View file

@ -196,7 +196,8 @@ remains distinct for each game.
</td>
<td>Float array</td>
<td>
Water color (R, G, B). 1.0 means pass-through, 0.0 means no value at all.
Water color (R, G, B) or `#RRGGBB`. 1.0 or `FF` means pass-through, 0.0
or `00` means completely black color.
See <a href="#water-color-table">this table</a> for reference values.</a>
</td>
</tr>
@ -338,9 +339,10 @@ remains distinct for each game.
<td>
<code>water_color</code>
</td>
<td>Float array or string</td>
<td>Float array or hex string</td>
<td>
Water color (R, G, B). 1.0 means pass-through, 0.0 means no value at all.
Water color (R, G, B) or `#RRGGBB`. 1.0 or `FF` means pass-through, 0.0
or `00` means completely black color.
See <a href="#water-color-table">this table</a> for reference values.</a>
</td>
</tr>

View file

@ -7,6 +7,7 @@
TombATI | 115 | 255 | 255 | ![#73FFFF](https://placehold.co/15x15/73FFFF/73FFFF.png) `#73FFFF`
PS1 | 77 | 255 | 255 | ![#4DFFFF](https://placehold.co/15x15/4DFFFF/4DFFFF.png) `#4DFFFF`
DOS | 153 | 179 | 255 | ![#99B3FF](https://placehold.co/15x15/99B3FF/99B3FF.png) `#99B3FF`
- added support for a hex water color notation (eg. `#80FFFF`) in the game flow file
- changed the `draw_distance_min` and `draw_distance_max` to `fog_start` and `fog_end`
- changed `Select Detail` dialog title to `Graphic Options`
- changed the number of static mesh slots from 50 to 256 (#2734)

View file

@ -11,6 +11,7 @@
#include "json.h"
#include "log.h"
#include "memory.h"
#include "strings.h"
#include <string.h>
@ -103,8 +104,9 @@ static void M_LoadCommonSettings(
}
{
JSON_ARRAY *const tmp_arr = JSON_ObjectGetArray(obj, "water_color");
if (tmp_arr != nullptr) {
JSON_VALUE *const tmp_value = JSON_ObjectGetValue(obj, "water_color");
if (tmp_value != nullptr && tmp_value->type == JSON_TYPE_ARRAY) {
const JSON_ARRAY *const tmp_arr = JSON_ValueAsArray(tmp_value);
const RGB_F color = {
JSON_ArrayGetDouble(tmp_arr, 0, JSON_INVALID_NUMBER),
JSON_ArrayGetDouble(tmp_arr, 1, JSON_INVALID_NUMBER),
@ -119,6 +121,16 @@ static void M_LoadCommonSettings(
color.b * 255.0f,
};
}
} else if (
tmp_value != nullptr && tmp_value->type == JSON_TYPE_STRING) {
const char *tmp_str =
JSON_ValueGetString(tmp_value, JSON_INVALID_STRING);
ASSERT(tmp_str != JSON_INVALID_STRING);
RGB_888 tmp_color;
if (String_ParseRGB888(tmp_str, &tmp_color)) {
settings->water_color.is_present = true;
settings->water_color.value = tmp_color;
}
}
}
}