diff options
Diffstat (limited to 'extension/src')
-rw-r--r-- | extension/src/openvic-extension/GameSingleton.cpp | 43 | ||||
-rw-r--r-- | extension/src/openvic-extension/GameSingleton.hpp | 2 | ||||
-rw-r--r-- | extension/src/openvic-extension/LoadGameOpenVic.cpp | 4 |
3 files changed, 21 insertions, 28 deletions
diff --git a/extension/src/openvic-extension/GameSingleton.cpp b/extension/src/openvic-extension/GameSingleton.cpp index a164b23..2d6f784 100644 --- a/extension/src/openvic-extension/GameSingleton.cpp +++ b/extension/src/openvic-extension/GameSingleton.cpp @@ -11,7 +11,7 @@ using namespace OpenVic; TerrainVariant::TerrainVariant(const std::string_view new_identfier, colour_t new_colour, Ref<Image> const& new_image) - : HasIdentifierAndColour { new_identfier, new_colour, true }, + : HasIdentifierAndColour { new_identfier, new_colour, true, false }, image { new_image } {} Ref<Image> TerrainVariant::get_image() const { @@ -43,7 +43,6 @@ void GameSingleton::_bind_methods() { ClassDB::bind_method(D_METHOD("set_selected_province", "index"), &GameSingleton::set_selected_province); ClassDB::bind_method(D_METHOD("expand_building", "province_index", "building_type_identifier"), &GameSingleton::expand_building); - ClassDB::bind_method(D_METHOD("get_good_icon_texture", "identifier"), &GameSingleton::get_good_icon_texture); ClassDB::bind_method(D_METHOD("set_paused", "paused"), &GameSingleton::set_paused); ClassDB::bind_method(D_METHOD("toggle_paused"), &GameSingleton::toggle_paused); @@ -133,7 +132,7 @@ Error GameSingleton::setup_game() { int32_t GameSingleton::get_province_index_from_uv_coords(Vector2 const& coords) const { const size_t x_mod_w = UtilityFunctions::fposmod(coords.x, 1.0f) * get_width(); const size_t y_mod_h = UtilityFunctions::fposmod(coords.y, 1.0f) * get_height(); - return game_manager.map.get_province_index_at(x_mod_w, y_mod_h); + return game_manager.get_map().get_province_index_at(x_mod_w, y_mod_h); } StringName const& GameSingleton::get_province_info_province_key() { @@ -219,7 +218,7 @@ Dictionary GameSingleton::_distribution_to_dictionary(distribution_t const& dist } Dictionary GameSingleton::get_province_info_from_index(int32_t index) const { - Province const* province = game_manager.map.get_province_by_index(index); + Province const* province = game_manager.get_map().get_province_by_index(index); if (province == nullptr) return {}; Dictionary ret; @@ -263,11 +262,11 @@ Dictionary GameSingleton::get_province_info_from_index(int32_t index) const { } int32_t GameSingleton::get_width() const { - return game_manager.map.get_width(); + return game_manager.get_map().get_width(); } int32_t GameSingleton::get_height() const { - return game_manager.map.get_height(); + return game_manager.get_map().get_height(); } float GameSingleton::get_aspect_ratio() const { @@ -296,7 +295,7 @@ Error GameSingleton::_update_colour_image() { colour_data_array.resize(colour_data_array_size); Error err = OK; - if (!game_manager.map.generate_mapmode_colours(mapmode_index, colour_data_array.ptrw())) + if (!game_manager.get_map().generate_mapmode_colours(mapmode_index, colour_data_array.ptrw())) err = FAILED; static constexpr int32_t PROVINCE_INDEX_SQRT = 1 << (sizeof(Province::index_t) * 4); @@ -316,17 +315,17 @@ Error GameSingleton::_update_colour_image() { } int32_t GameSingleton::get_mapmode_count() const { - return game_manager.map.get_mapmode_count(); + return game_manager.get_map().get_mapmode_count(); } String GameSingleton::get_mapmode_identifier(int32_t index) const { - Mapmode const* mapmode = game_manager.map.get_mapmode_by_index(index); + Mapmode const* mapmode = game_manager.get_map().get_mapmode_by_index(index); if (mapmode != nullptr) return std_to_godot_string(mapmode->get_identifier()); return String {}; } Error GameSingleton::set_mapmode(String const& identifier) { - Mapmode const* mapmode = game_manager.map.get_mapmode_by_identifier(godot_to_std_string(identifier)); + Mapmode const* mapmode = game_manager.get_map().get_mapmode_by_identifier(godot_to_std_string(identifier)); if (mapmode == nullptr) { UtilityFunctions::push_error("Failed to set mapmode to: ", identifier); return FAILED; @@ -337,11 +336,11 @@ Error GameSingleton::set_mapmode(String const& identifier) { } int32_t GameSingleton::get_selected_province_index() const { - return game_manager.map.get_selected_province_index(); + return game_manager.get_map().get_selected_province_index(); } void GameSingleton::set_selected_province(int32_t index) { - game_manager.map.set_selected_province(index); + game_manager.get_map().set_selected_province(index); _update_colour_image(); emit_signal("province_selected", index); } @@ -354,36 +353,32 @@ Error GameSingleton::expand_building(int32_t province_index, String const& build return OK; } -Ref<Texture> GameSingleton::get_good_icon_texture(String const& identifier) const { - return good_icons.get(identifier, {}); -} - void GameSingleton::set_paused(bool paused) { - game_manager.clock.isPaused = paused; + game_manager.get_clock().isPaused = paused; } void GameSingleton::toggle_paused() { - game_manager.clock.isPaused = !game_manager.clock.isPaused; + game_manager.get_clock().isPaused = !game_manager.get_clock().isPaused; } bool GameSingleton::is_paused() const { - return game_manager.clock.isPaused; + return game_manager.get_clock().isPaused; } void GameSingleton::increase_speed() { - game_manager.clock.increaseSimulationSpeed(); + game_manager.get_clock().increaseSimulationSpeed(); } void GameSingleton::decrease_speed() { - game_manager.clock.decreaseSimulationSpeed(); + game_manager.get_clock().decreaseSimulationSpeed(); } bool GameSingleton::can_increase_speed() const { - return game_manager.clock.canIncreaseSimulationSpeed(); + return game_manager.get_clock().canIncreaseSimulationSpeed(); } bool GameSingleton::can_decrease_speed() const { - return game_manager.clock.canDecreaseSimulationSpeed(); + return game_manager.get_clock().canDecreaseSimulationSpeed(); } String GameSingleton::get_longform_date() const { @@ -391,5 +386,5 @@ String GameSingleton::get_longform_date() const { } void GameSingleton::try_tick() { - game_manager.clock.conditionallyAdvanceGame(); + game_manager.get_clock().conditionallyAdvanceGame(); } diff --git a/extension/src/openvic-extension/GameSingleton.hpp b/extension/src/openvic-extension/GameSingleton.hpp index bd6b73c..4d9e912 100644 --- a/extension/src/openvic-extension/GameSingleton.hpp +++ b/extension/src/openvic-extension/GameSingleton.hpp @@ -41,7 +41,6 @@ namespace OpenVic { IdentifierRegistry<TerrainVariant> terrain_variants; Map::terrain_variant_map_t terrain_variant_map; godot::Ref<godot::Texture2DArray> terrain_texture; - godot::Dictionary good_icons; 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); @@ -143,7 +142,6 @@ namespace OpenVic { void set_selected_province(int32_t index); godot::Error expand_building(int32_t province_index, godot::String const& building_type_identifier); - godot::Ref<godot::Texture> get_good_icon_texture(godot::String const& identifier) const; void set_paused(bool paused); void toggle_paused(); diff --git a/extension/src/openvic-extension/LoadGameOpenVic.cpp b/extension/src/openvic-extension/LoadGameOpenVic.cpp index 87c66da..c34411c 100644 --- a/extension/src/openvic-extension/LoadGameOpenVic.cpp +++ b/extension/src/openvic-extension/LoadGameOpenVic.cpp @@ -86,7 +86,7 @@ Error GameSingleton::_load_map_images(String const& province_image_path, String if (err != OK) return err; // Generate interleaved province and terrain ID image - if (!game_manager.map.generate_province_shape_image(province_dims.x, province_dims.y, + if (!game_manager.get_map().generate_province_shape_image(province_dims.x, province_dims.y, province_image->get_data().ptr(), terrain_image->get_data().ptr(), terrain_variant_map, false /* <-- whether to print detailed map errors or not (specific missing/unrecognised colours) */ )) err = FAILED; @@ -97,7 +97,7 @@ Error GameSingleton::_load_map_images(String const& province_image_path, String for (image_subdivisions[i] = 1; province_dims[i] / image_subdivisions[i] > GPU_DIM_LIMIT || province_dims[i] % image_subdivisions[i] != 0; ++image_subdivisions[i]); - Map::shape_pixel_t const* province_shape_data = game_manager.map.get_province_shape_image().data(); + Map::shape_pixel_t const* province_shape_data = game_manager.get_map().get_province_shape_image().data(); const Vector2i divided_dims = province_dims / image_subdivisions; Array province_shape_images; province_shape_images.resize(image_subdivisions.x * image_subdivisions.y); |