summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-12-05 00:31:53 +0100
committerAki <please@ignore.pl>2022-12-05 00:31:53 +0100
commitc8e16e91ee8f7af4d1d6976d0aef5864f82c5277 (patch)
treee4923ed7363c005a68e24e47b0574bc8100b26a5
parent3f450f7bfe7f166c324e5eca207fb6b9bebb175c (diff)
downloadkurator-c8e16e91ee8f7af4d1d6976d0aef5864f82c5277.zip
kurator-c8e16e91ee8f7af4d1d6976d0aef5864f82c5277.tar.gz
kurator-c8e16e91ee8f7af4d1d6976d0aef5864f82c5277.tar.bz2
Extracted team colors into own file
-rw-r--r--kurator/CMakeLists.txt1
-rw-r--r--kurator/src/Battle.cpp3
-rw-r--r--kurator/src/colors.cpp28
-rw-r--r--kurator/src/colors.h13
4 files changed, 44 insertions, 1 deletions
diff --git a/kurator/CMakeLists.txt b/kurator/CMakeLists.txt
index 0dc7720..61b348c 100644
--- a/kurator/CMakeLists.txt
+++ b/kurator/CMakeLists.txt
@@ -2,6 +2,7 @@ project(kurator)
add_executable(
${PROJECT_NAME}
src/Battle.cpp
+ src/colors.cpp
src/main.cpp
src/Session.cpp
src/Skybox.cpp
diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp
index 3f7d39e..7bb4e7d 100644
--- a/kurator/src/Battle.cpp
+++ b/kurator/src/Battle.cpp
@@ -15,6 +15,7 @@
#include <kurator/sim/Point.h>
#include <kurator/universe/ShipType.h>
+#include "colors.h"
#include "components.h"
#include "Session.h"
#include "Title.h"
@@ -32,7 +33,7 @@ Battle::Battle(std::shared_ptr<Session> _session) :
auto& registry = battle->registry();
auto ships = registry.view<sim::Team, universe::ShipType>();
for (const auto& [entity, team, type] : ships.each())
- registry.emplace<Marker>(entity, 5.0, team.id ? GREEN : RED, type.name);
+ registry.emplace<Marker>(entity, 5.0, team_color(team.id), type.name);
}
diff --git a/kurator/src/colors.cpp b/kurator/src/colors.cpp
new file mode 100644
index 0000000..b3fc82a
--- /dev/null
+++ b/kurator/src/colors.cpp
@@ -0,0 +1,28 @@
+#include "colors.h"
+
+#include <raylib.h>
+
+
+namespace kurator
+{
+
+
+Color
+team_color(const int team)
+{
+ switch (team) {
+ case 0:
+ return GREEN;
+ case 1:
+ return RED;
+ case 2:
+ return YELLOW;
+ case 3:
+ return PURPLE;
+ default:
+ return GRAY;
+ }
+}
+
+
+} // namespace kurator
diff --git a/kurator/src/colors.h b/kurator/src/colors.h
new file mode 100644
index 0000000..d477791
--- /dev/null
+++ b/kurator/src/colors.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <raylib.h>
+
+
+namespace kurator
+{
+
+
+auto team_color(int team) -> Color;
+
+
+} // namespace kurator