aboutsummaryrefslogtreecommitdiff
path: root/extension/src/GameSingleton.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/GameSingleton.hpp
parent98dd680a641a2cbe0f1f93202a5beffdfd35c9f7 (diff)
parent10053cf259c55ee45803268a844edf1011d8a16b (diff)
Merge branch 'main' of github.com:OpenVic2Project/OpenVic2 into goods
Diffstat (limited to 'extension/src/GameSingleton.hpp')
-rw-r--r--extension/src/GameSingleton.hpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/extension/src/GameSingleton.hpp b/extension/src/GameSingleton.hpp
new file mode 100644
index 0000000..d9879ef
--- /dev/null
+++ b/extension/src/GameSingleton.hpp
@@ -0,0 +1,63 @@
+#pragma once
+
+#include <functional>
+
+#include <godot_cpp/classes/image.hpp>
+
+#include "openvic2/GameManager.hpp"
+
+namespace OpenVic2 {
+ class GameSingleton : public godot::Object {
+ GDCLASS(GameSingleton, godot::Object)
+
+ static GameSingleton* singleton;
+
+ GameManager game_manager;
+
+ static constexpr int image_width_divide = 2;
+ godot::Ref<godot::Image> province_index_image[image_width_divide], province_colour_image;
+ Mapmode::index_t mapmode_index = 0;
+
+ 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);
+ void _tick();
+ protected:
+ static void _bind_methods();
+
+ public:
+ static GameSingleton* get_singleton();
+
+ GameSingleton();
+ ~GameSingleton();
+
+ godot::Error load_province_identifier_file(godot::String const& file_path);
+ godot::Error load_water_province_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::Error setup();
+
+ int32_t get_province_index_from_uv_coords(godot::Vector2 const& coords) const;
+ godot::Dictionary get_province_info_from_index(int32_t index) const;
+ int32_t get_width() const;
+ int32_t get_height() const;
+ godot::Array get_province_index_images() 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);
+
+ godot::Error expand_building(int32_t province_index, godot::String const& building_type_identifier);
+
+ void set_paused(bool paused);
+ void toggle_paused();
+ bool is_paused() const;
+ void increase_speed();
+ void decrease_speed();
+ bool can_increase_speed() const;
+ bool can_decrease_speed() const;
+ godot::String get_longform_date() const;
+ void try_tick();
+ };
+}