aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic2/Types.hpp
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.hpp
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.hpp')
-rw-r--r--extension/src/openvic2/Types.hpp29
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