diff options
Diffstat (limited to 'extension/src/openvic2/Types.hpp')
-rw-r--r-- | extension/src/openvic2/Types.hpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/extension/src/openvic2/Types.hpp b/extension/src/openvic2/Types.hpp index 98e92ce..f1ba639 100644 --- a/extension/src/openvic2/Types.hpp +++ b/extension/src/openvic2/Types.hpp @@ -2,11 +2,22 @@ #include <string> #include <vector> +#include <cstdint> #include "openvic2/Logger.hpp" namespace OpenVic2 { + //Represents a 24-bit RGB integer + using colour_t = uint32_t; + using index_t = uint16_t; + + static constexpr colour_t NULL_COLOUR = 0, MAX_COLOUR = 0xFFFFFF; + static constexpr index_t NULL_INDEX = 0, MAX_INDEX = 0xFFFF; + + //TODO: price_t must be changed to a fixed-point numeric type before multiplayer + using price_t = double; using return_t = bool; + // This mirrors godot::Error, where `OK = 0` and `FAILED = 1`. static constexpr return_t SUCCESS = false, FAILURE = true; @@ -29,6 +40,24 @@ namespace OpenVic2 { }; /* + * Base class for objects with associated colour information + */ + class HasColour { + const colour_t colour; + protected: + HasColour(colour_t const new_colour); + public: + HasColour(HasColour const&) = delete; + HasColour(HasColour&&) = default; + HasColour& operator=(HasColour const&) = delete; + HasColour& operator=(HasColour&&) = delete; + + colour_t get_colour() const; + std::string colour_to_hex_string() const; + static std::string colour_to_hex_string(colour_t const colour); + }; + + /* * Template for a list of objects with unique string identifiers that can * be locked to prevent any further additions. The template argument T is * the type of object that the registry will store, and the second part ensures |