diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-07 18:18:43 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-07 18:19:42 +0100 |
commit | c83c8185aad63d8f36f3915814a320fd2da2ff7b (patch) | |
tree | fcb3052dc62f9cea60f436fae45b713a590ce531 | |
parent | 12fe161cd178b8336f0c8efada812d8297fc0468 (diff) |
a
-rw-r--r-- | serialize/wall-atlas.cpp | 22 | ||||
-rw-r--r-- | src/wall-atlas.hpp | 5 | ||||
-rw-r--r-- | test/json/wall-atlas-02_groups.json | 3 |
3 files changed, 16 insertions, 14 deletions
diff --git a/serialize/wall-atlas.cpp b/serialize/wall-atlas.cpp index 7f852e51..c0824a6a 100644 --- a/serialize/wall-atlas.cpp +++ b/serialize/wall-atlas.cpp @@ -53,8 +53,9 @@ Group read_group_metadata(const json& jgroup) val.from_rotation = (uint8_t)direction_index_from_name(std::string{ jgroup["from-rotation"s] }); if (jgroup.contains("mirrored"s)) val.mirrored = !!jgroup["mirrored"s]; - if (jgroup.contains("use-default-tint"s)) - val.use_default_tint = !!jgroup["use-default-tint"s]; + val._default_tint_specified = jgroup.contains("default-tint"s); + if (val._default_tint_specified) + val.default_tint = !!jgroup["default-tint"s]; fm_soft_assert(val.tint_mult >= Color4{0}); @@ -81,6 +82,12 @@ Direction read_direction_metadata(const json& jroot, Direction_ dir) return val; } +Info read_info_header(const json& jroot) +{ + Info val { std::string(jroot["name"s]), jroot["depth"] }; + return val; +} + void write_group_metadata(json& jgroup, const Group& val) { constexpr Group default_value; @@ -101,15 +108,8 @@ void write_group_metadata(json& jgroup, const Group& val) } if (val.mirrored != default_value.mirrored) jgroup["mirrored"s] = val.mirrored; - if (val.use_default_tint) - if (val.tint_mult != default_value.tint_mult || val.tint_add != default_value.tint_add) - jgroup["use-default-tint"s] = true; -} - -Info read_info_header(const json& jroot) -{ - Info val { std::string(jroot["name"s]), jroot["depth"] }; - return val; + if (val._default_tint_specified) + jgroup["default-tint"s] = val.default_tint; } } // namespace floormat::Wall::detail diff --git a/src/wall-atlas.hpp b/src/wall-atlas.hpp index 6a94b34f..9b41200e 100644 --- a/src/wall-atlas.hpp +++ b/src/wall-atlas.hpp @@ -24,8 +24,9 @@ struct Group Color4 tint_mult{1,1,1,1}; Color3 tint_add; uint8_t from_rotation = (uint8_t)-1; - bool mirrored : 1 = false, - use_default_tint : 1 = true; + bool mirrored : 1 = false, + default_tint : 1 = true, + _default_tint_specified : 1 = false; explicit operator bool() const noexcept { return !is_empty(); } bool is_empty() const noexcept { return count == 0; } diff --git a/test/json/wall-atlas-02_groups.json b/test/json/wall-atlas-02_groups.json index cf342eac..c8062b82 100644 --- a/test/json/wall-atlas-02_groups.json +++ b/test/json/wall-atlas-02_groups.json @@ -6,7 +6,8 @@ "w": { "wall": {}, "side": { - "pixel-size": "42 x 192" + "pixel-size": "42 x 192", + "default-tint": true } } } |