From c8e16e91ee8f7af4d1d6976d0aef5864f82c5277 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 5 Dec 2022 00:31:53 +0100 Subject: Extracted team colors into own file --- kurator/CMakeLists.txt | 1 + kurator/src/Battle.cpp | 3 ++- kurator/src/colors.cpp | 28 ++++++++++++++++++++++++++++ kurator/src/colors.h | 13 +++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 kurator/src/colors.cpp create mode 100644 kurator/src/colors.h 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 #include +#include "colors.h" #include "components.h" #include "Session.h" #include "Title.h" @@ -32,7 +33,7 @@ Battle::Battle(std::shared_ptr _session) : auto& registry = battle->registry(); auto ships = registry.view(); for (const auto& [entity, team, type] : ships.each()) - registry.emplace(entity, 5.0, team.id ? GREEN : RED, type.name); + registry.emplace(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 + + +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 + + +namespace kurator +{ + + +auto team_color(int team) -> Color; + + +} // namespace kurator -- cgit v1.1