aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic2/map/Map.hpp
diff options
context:
space:
mode:
author ClarkeCode <clarke.john.robert@gmail.com>2023-04-27 22:13:52 +0200
committer ClarkeCode <clarke.john.robert@gmail.com>2023-04-27 22:13:52 +0200
commit0b273743b480874281a8987c72b2f1b666bc289a (patch)
tree3f5d5a6316ac66407e61c8a56fe732cdf06209e5 /extension/src/openvic2/map/Map.hpp
parent98dd680a641a2cbe0f1f93202a5beffdfd35c9f7 (diff)
parent10053cf259c55ee45803268a844edf1011d8a16b (diff)
Merge branch 'main' of github.com:OpenVic2Project/OpenVic2 into goods
Diffstat (limited to 'extension/src/openvic2/map/Map.hpp')
-rw-r--r--extension/src/openvic2/map/Map.hpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/extension/src/openvic2/map/Map.hpp b/extension/src/openvic2/map/Map.hpp
new file mode 100644
index 0000000..ebc23be
--- /dev/null
+++ b/extension/src/openvic2/map/Map.hpp
@@ -0,0 +1,76 @@
+#pragma once
+
+#include <functional>
+
+#include "openvic2/map/Region.hpp"
+
+namespace OpenVic2 {
+
+ struct Mapmode : HasIdentifier {
+ friend struct Map;
+
+ using colour_func_t = std::function<Province::colour_t (Map const&, Province const&)>;
+ using index_t = size_t;
+ private:
+ const index_t index;
+ const colour_func_t colour_func;
+
+ Mapmode(index_t new_index, std::string const& new_identifier, colour_func_t new_colour_func);
+ public:
+ index_t get_index() const;
+ Province::colour_t get_colour(Map const& map, Province const& province) const;
+ };
+
+ /* REQUIREMENTS:
+ * MAP-4
+ */
+ struct Map {
+ private:
+ IdentifierRegistry<Province> provinces;
+ IdentifierRegistry<Region> regions;
+ IdentifierRegistry<Mapmode> mapmodes;
+ bool water_provinces_locked = false;
+ size_t water_province_count = 0;
+
+ size_t width = 0, height = 0;
+ std::vector<Province::index_t> province_index_image;
+ public:
+ Map();
+
+ return_t add_province(std::string const& identifier, Province::colour_t colour);
+ void lock_provinces();
+ return_t set_water_province(std::string const& identifier);
+ void lock_water_provinces();
+ return_t add_region(std::string const& identifier, std::vector<std::string> const& province_identifiers);
+ void lock_regions();
+
+ size_t get_province_count() const;
+ Province* get_province_by_index(Province::index_t index);
+ Province const* get_province_by_index(Province::index_t index) const;
+ Province* get_province_by_identifier(std::string const& identifier);
+ Province const* get_province_by_identifier(std::string const& identifier) const;
+ Province* get_province_by_colour(Province::colour_t colour);
+ Province const* get_province_by_colour(Province::colour_t colour) const;
+ Province::index_t get_province_index_at(size_t x, size_t y) const;
+
+ Region* get_region_by_identifier(std::string const& identifier);
+ Region const* get_region_by_identifier(std::string const& identifier) const;
+
+ return_t generate_province_index_image(size_t new_width, size_t new_height, uint8_t const* colour_data);
+ size_t get_width() const;
+ size_t get_height() const;
+ std::vector<Province::index_t> const& get_province_index_image() const;
+
+ return_t add_mapmode(std::string const& identifier, Mapmode::colour_func_t colour_func);
+ void lock_mapmodes();
+ size_t get_mapmode_count() const;
+ Mapmode const* get_mapmode_by_index(Mapmode::index_t index) const;
+ Mapmode const* get_mapmode_by_identifier(std::string const& identifier) const;
+ return_t generate_mapmode_colours(Mapmode::index_t index, uint8_t* target) const;
+
+ return_t generate_province_buildings(BuildingManager const& manager);
+
+ void update_state(Date const& today);
+ void tick(Date const& today);
+ };
+}