diff options
Diffstat (limited to 'extension/src/GameSingleton.hpp')
-rw-r--r-- | extension/src/GameSingleton.hpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/extension/src/GameSingleton.hpp b/extension/src/GameSingleton.hpp index 99fe7bb..6bfb741 100644 --- a/extension/src/GameSingleton.hpp +++ b/extension/src/GameSingleton.hpp @@ -11,11 +11,16 @@ namespace OpenVic { const godot::Ref<godot::Image> image; public: + static constexpr size_t MAX_INDEX = 1 << (8 * sizeof(Map::terrain_t)); + TerrainVariant(std::string const& new_identfier, colour_t new_colour, - godot::Ref<godot::Image> const& new_image); + godot::Ref<godot::Image> const& new_image) + : HasIdentifier { new_identfier }, + HasColour { new_colour }, + image { new_image } {} TerrainVariant(TerrainVariant&&) = default; - godot::Ref<godot::Image> get_image() const; + godot::Ref<godot::Image> get_image() const { return image; } }; class GameSingleton : public godot::Object { GDCLASS(GameSingleton, godot::Object) @@ -36,16 +41,28 @@ namespace OpenVic { 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); - godot::Error _parse_terrain_entry(godot::String const& identifier, godot::Variant const& entry); + godot::Error _parse_terrain_entry(godot::String const& identifier, godot::Variant const& entry, godot::String const& terrain_texture_dir_path); godot::Error _parse_good_entry(godot::String const& identifier, godot::Variant const& entry); - 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_terrain_variant_file(godot::String const& file_path); - godot::Error load_map_images(godot::String const& province_image_path, godot::String const& terrain_image_path); - godot::Error load_goods(godot::String const& defines_path, godot::String const& icons_dir_path); + 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_terrain_variants(godot::String const& terrain_identifiers_path, godot::String const& terrain_texture_dir_path); + godot::Error _generate_terrain_texture_array(); + godot::Error _load_map_images(godot::String const& province_image_path, godot::String const& terrain_image_path, bool flip_vertical = false); + godot::Error _load_goods(godot::String const& defines_path, godot::String const& icons_dir_path); + + godot::Error _load_province_identifier_file_compatibility_mode(godot::String const& file_path); + godot::Error _load_terrain_variants_compatibility_mode(godot::String const& terrain_image_path, godot::String const& terrain_texturesheet_path); + + /* Hardcoded data for defining things for which parsing from files has + * not been implemented, currently mapmodes and building types. + */ + godot::Error _load_hardcoded_defines(); + /* Generate the province_colour_texture from the current mapmode. + */ + godot::Error _update_colour_image(); void _on_state_updated(); protected: @@ -61,6 +78,7 @@ namespace OpenVic { static godot::StringName const& get_water_province_file_key(); static godot::StringName const& get_region_file_key(); static godot::StringName const& get_terrain_variant_file_key(); + static godot::StringName const& get_terrain_texture_dir_key(); static godot::StringName const& get_province_image_file_key(); static godot::StringName const& get_terrain_image_file_key(); static godot::StringName const& get_goods_file_key(); @@ -71,6 +89,11 @@ namespace OpenVic { */ godot::Error load_defines(godot::Dictionary const& file_dict); + /* Load the game's defines in compatiblity mode from the filepath + * pointing to the defines folder. + */ + godot::Error load_defines_compatibility_mode(godot::String const& file_path); + /* Post-load/restart game setup - reset the game to post-load state * and (re)generate starting data, e.g. buildings. */ @@ -121,10 +144,6 @@ namespace OpenVic { */ godot::Ref<godot::Texture> get_province_colour_texture() const; - /* Generate the province_colour_texture from the current mapmode. - */ - 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); |