From 3ed5fcd2d4d29c531f4641a8794878328410ffde Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 10 Oct 2024 13:03:47 +0200 Subject: fix color loading --- CMakeLists.txt | 11 ++++++----- TileAppearance.cpp | 10 +++------- TileAppearance.h | 6 ++++++ input/test.xml | 8 ++++---- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 921b6d9..ed1ad24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,11 +5,12 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_EXPORT_COMPILE_COMMANDS 1) set(CMAKE_BUILD_TYPE Debug) -# find_package(SDL2 REQUIRED) -# find_package(cpr REQUIRED) -add_subdirectory(lib/SDL) -add_subdirectory(lib/cpr) -add_subdirectory(lib/pugixml) +find_package(SDL2 REQUIRED) +find_package(cpr REQUIRED) +find_package(pugixml REQUIRED) +# add_subdirectory(lib/SDL) +# add_subdirectory(lib/cpr) +# add_subdirectory(lib/pugixml) project(main C CXX) diff --git a/TileAppearance.cpp b/TileAppearance.cpp index 988b02f..b91301f 100644 --- a/TileAppearance.cpp +++ b/TileAppearance.cpp @@ -3,20 +3,16 @@ using namespace std; Color TileAppearance::get_color(string type) { - auto type_map = TileAppearance::get_collection(); + auto & type_map = TileAppearance::get_collection(); if (type_map.contains(type)) return type_map.at(type); - return { - .red = 0xff, - .green = 0xff, - .blue = 0xff, - }; + return TileAppearance::default_color; } void TileAppearance::register_color(string type, Color color) { - auto type_map = TileAppearance::get_collection(); + auto & type_map = TileAppearance::get_collection(); type_map[type] = color; } diff --git a/TileAppearance.h b/TileAppearance.h index 8a7a0f7..2c89f48 100644 --- a/TileAppearance.h +++ b/TileAppearance.h @@ -17,5 +17,11 @@ private: static TileAppearanceCollection c = {}; return c; } + + static constexpr Color default_color = { + .red = 0xff, + .green = 0xff, + .blue = 0xff, + }; }; diff --git a/input/test.xml b/input/test.xml index 42ed1d2..8258501 100644 --- a/input/test.xml +++ b/input/test.xml @@ -1,10 +1,10 @@ - - - - + + + + -- cgit v1.2.3