aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-10 13:03:47 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-10 13:03:47 +0200
commit3ed5fcd2d4d29c531f4641a8794878328410ffde (patch)
treef5068d2e69cbad8002d20f48dc0b170aa69e89c9
parent112d1a25506dee481b7ab4a95b8146d40eef1e1a (diff)
fix color loading
-rw-r--r--CMakeLists.txt11
-rw-r--r--TileAppearance.cpp10
-rw-r--r--TileAppearance.h6
-rw-r--r--input/test.xml8
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 @@
<?xml version="1.0" ?>
<canvas rows="3" cols="3">
<nodeTypes>
- <nodeType tag="Y"/>
- <nodeType tag="B"/>
- <nodeType tag="R"/>
- <nodeType tag="G"/>
+ <nodeType tag="Y" red="255" green="255" blue="0"/>
+ <nodeType tag="B" red="0" green="0" blue="255"/>
+ <nodeType tag="R" red="255" green="0" blue="0"/>
+ <nodeType tag="G" red="0" green="255" blue="0"/>
</nodeTypes>
<nodes>
<Y x="0" y="0"/>