From 1b35c3a4434873b98f8e3aa7770f0edd37ec053c Mon Sep 17 00:00:00 2001 From: ClarkeCode Date: Fri, 28 Apr 2023 17:34:45 -0400 Subject: Moved several type aliases to Types.hpp; Added HasColour class for items which need associated colours --- extension/src/openvic2/Types.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'extension/src/openvic2/Types.cpp') 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 +#include +#include +#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 -- cgit v1.2.3-56-ga3b1