aboutsummaryrefslogtreecommitdiff
path: root/extension/src/MapSingleton.hpp
diff options
context:
space:
mode:
author Gone2Daly <71726742+Gone2Daly@users.noreply.github.com>2023-04-07 18:10:49 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-04-14 17:22:22 +0200
commit7241811bd8c9493b7b6c6480e8d63a5fb7f38e4e (patch)
treeb5a33a733398b511eb0aa7781860c8accbadd2a0 /extension/src/MapSingleton.hpp
parentc0d76b78d3762e6eec3ed1c62618be84c5b7559b (diff)
Add minimap for terrain map
With accurate viewport shape display on minimap With Mapmode management With Region mapmode With Province mapmode With Index mapmode With Minimap single-click movement With Minimap drag-click movement
Diffstat (limited to 'extension/src/MapSingleton.hpp')
-rw-r--r--extension/src/MapSingleton.hpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/extension/src/MapSingleton.hpp b/extension/src/MapSingleton.hpp
index 71761cd..9205e92 100644
--- a/extension/src/MapSingleton.hpp
+++ b/extension/src/MapSingleton.hpp
@@ -1,19 +1,27 @@
#pragma once
+#include <functional>
+
#include <godot_cpp/classes/image.hpp>
+
#include "openvic2/Map.hpp"
namespace OpenVic2 {
class MapSingleton : public godot::Object {
+ using parse_json_entry_func_t = std::function<godot::Error (godot::String const&, godot::Variant const&)>;
GDCLASS(MapSingleton, godot::Object)
static MapSingleton* singleton;
- godot::Ref<godot::Image> province_shape_image, province_index_image, province_colour_image;
- int32_t width = 0, height = 0;
+ godot::Ref<godot::Image> province_index_image, province_colour_image;
Map map;
+ Mapmode::index_t mapmode_index = 0;
+ godot::Error parse_json_dictionary_file(godot::String const& file_description, godot::String const& file_path,
+ godot::String const& identifier_prefix, parse_json_entry_func_t parse_entry) const;
+ godot::Error _parse_province_identifier_entry(godot::String const& identifier, godot::Variant const& entry);
+ godot::Error _parse_region_entry(godot::String const& identifier, godot::Variant const& entry);
protected:
static void _bind_methods();
@@ -24,11 +32,21 @@ namespace OpenVic2 {
~MapSingleton();
godot::Error load_province_identifier_file(godot::String const& file_path);
+ godot::Error load_region_file(godot::String const& file_path);
godot::Error load_province_shape_file(godot::String const& file_path);
- godot::String get_province_identifier_from_pixel_coords(godot::Vector2i const& coords);
+
+ Province* get_province_from_uv_coords(godot::Vector2 const& coords);
+ Province const* get_province_from_uv_coords(godot::Vector2 const& coords) const;
+ int32_t get_province_index_from_uv_coords(godot::Vector2 const& coords) const;
+ godot::String get_province_identifier_from_uv_coords(godot::Vector2 const& coords) const;
int32_t get_width() const;
int32_t get_height() const;
godot::Ref<godot::Image> get_province_index_image() const;
godot::Ref<godot::Image> get_province_colour_image() const;
+
+ godot::Error update_colour_image();
+ int32_t get_mapmode_count() const;
+ godot::String get_mapmode_identifier(int32_t index) const;
+ godot::Error set_mapmode(godot::String const& identifier);
};
}