diff --git a/source/code/themes.cpp b/source/code/themes.cpp index e0fed8c..bb0b016 100644 --- a/source/code/themes.cpp +++ b/source/code/themes.cpp @@ -25,7 +25,7 @@ https://www.blockattack.net #include "themes.hpp" #include "sago/SagoMisc.hpp" #include -#include +#include #include "nlohmann/json.hpp" using json = nlohmann::json; @@ -39,15 +39,20 @@ void to_json(json& j, const Theme& p) { j = json{ {"theme_name", p.theme_name}, {"back_board", p.back_board}, {"background_name", p.background.name}, {"decoration_name", p.decoration.name} }; } +void to_json(json& j, const DecorationData& p) { + j = json{ {"name", p.name}, {"decoration_sprites", p.decoration_sprites} }; +} + void to_json(json& j, const ThemeFileData& p) { - j = json{ {"background_data", p.background_data}, {"themes", p.themes} }; + j = json{ {"background_data", p.background_data}, {"decoration_data", p.decoration_data}, {"themes", p.themes} }; } static std::vector themes(1); -static std::unordered_map background_data; +static std::map background_data; +static std::map decoration_data; static bool initialized = false; static size_t current_theme = 0; @@ -58,7 +63,7 @@ static void InitBackGroundData() { standard.background_sprite = "background"; standard.background_sprite_16x9 = "background_sixteen_nine"; standard.background_scale = ImgScale::Stretch; - background_data["standard"] = standard; + background_data[standard.name] = standard; BackGroundData alt_background; alt_background.name = "alt_background"; alt_background.background_sprite = "background_sample"; @@ -66,7 +71,9 @@ static void InitBackGroundData() { alt_background.background_scale = ImgScale::Tile; alt_background.tileMoveSpeedX = 50; alt_background.tileMoveSpeedY = 100; - background_data["alt_background"] = alt_background; + background_data[alt_background.name] = alt_background; + DecorationData smileys; + decoration_data[smileys.name] = smileys; } static void FillMissingFields(Theme& theme) { @@ -84,6 +91,9 @@ void DumpThemeData() { for (auto& pair : background_data) { tfd.background_data.push_back(pair.second); } + for (auto& pair : decoration_data) { + tfd.decoration_data.push_back(pair.second); + } json j = tfd; std::string s = j.dump(4); sago::WriteFileContent("themes_dump.json", s); diff --git a/source/code/themes.hpp b/source/code/themes.hpp index d71da27..5f0977b 100644 --- a/source/code/themes.hpp +++ b/source/code/themes.hpp @@ -55,6 +55,7 @@ struct Theme { struct ThemeFileData { std::vector background_data; + std::vector decoration_data; std::vector themes; };