aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic2/Types.cpp
diff options
context:
space:
mode:
author ClarkeCode <clarke.john.robert@gmail.com>2023-04-28 23:34:45 +0200
committer ClarkeCode <clarke.john.robert@gmail.com>2023-04-28 23:34:45 +0200
commit1b35c3a4434873b98f8e3aa7770f0edd37ec053c (patch)
treed15169c42d04a09d6d1d74593fe21458cdb9f6df /extension/src/openvic2/Types.cpp
parent92d0f35b989b0164e2dd8c9a32213c6038e5d57f (diff)
Moved several type aliases to Types.hpp; Added HasColour class for items which need associated colours
Diffstat (limited to 'extension/src/openvic2/Types.cpp')
-rw-r--r--extension/src/openvic2/Types.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/extension/src/openvic2/Types.cpp b/extension/src/openvic2/Types.cpp
index 861ab50..42aa5a4 100644
--- a/extension/src/openvic2/Types.cpp
+++ b/extension/src/openvic2/Types.cpp
@@ -1,6 +1,9 @@
#include "openvic2/Types.hpp"
#include <cassert>
+#include <sstream>
+#include <iomanip>
+#include "Types.hpp"
using namespace OpenVic2;
@@ -11,3 +14,19 @@ HasIdentifier::HasIdentifier(std::string const& new_identifier) : identifier{ ne
std::string const& HasIdentifier::get_identifier() const {
return identifier;
}
+
+HasColour::HasColour(colour_t const new_colour) : colour(new_colour) {
+ assert(colour <= MAX_COLOUR && colour != NULL_COLOUR);
+}
+
+colour_t HasColour::get_colour() const { return colour; }
+
+std::string OpenVic2::HasColour::colour_to_hex_string(colour_t const colour) {
+ std::ostringstream stream;
+ stream << std::hex << std::setfill('0') << std::setw(6) << colour;
+ return stream.str();
+}
+
+std::string HasColour::colour_to_hex_string() const {
+ return colour_to_hex_string(colour);
+} \ No newline at end of file