From 32dbfc1107b59085ba78929102f313b88c34a6a3 Mon Sep 17 00:00:00 2001 From: hop311 Date: Fri, 19 Jan 2024 13:02:05 +0000 Subject: Added overlay parchment map and refactored map shader --- extension/deps/openvic-simulation | 2 +- .../openvic-extension/singletons/GameSingleton.cpp | 22 ++++++++++++++++------ .../openvic-extension/singletons/GameSingleton.hpp | 7 ++++--- 3 files changed, 21 insertions(+), 10 deletions(-) (limited to 'extension') diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation index 2fcc7cc..93eaf0f 160000 --- a/extension/deps/openvic-simulation +++ b/extension/deps/openvic-simulation @@ -1 +1 @@ -Subproject commit 2fcc7ccd409701f6bad343e57afe74bd05246b68 +Subproject commit 93eaf0f4f2e812000316190c06e6614da2f841ee diff --git a/extension/src/openvic-extension/singletons/GameSingleton.cpp b/extension/src/openvic-extension/singletons/GameSingleton.cpp index 2730352..f9a6b9d 100644 --- a/extension/src/openvic-extension/singletons/GameSingleton.cpp +++ b/extension/src/openvic-extension/singletons/GameSingleton.cpp @@ -62,6 +62,7 @@ void GameSingleton::_bind_methods() { OV_BIND_METHOD(GameSingleton::get_mapmode_count); OV_BIND_METHOD(GameSingleton::get_mapmode_identifier); OV_BIND_METHOD(GameSingleton::set_mapmode, { "identifier" }); + OV_BIND_METHOD(GameSingleton::is_parchment_mapmode_allowed); OV_BIND_METHOD(GameSingleton::get_selected_province_index); OV_BIND_METHOD(GameSingleton::set_selected_province, { "index" }); @@ -286,7 +287,7 @@ float GameSingleton::get_map_aspect_ratio() const { return static_cast(get_map_width()) / static_cast(get_map_height()); } -Ref GameSingleton::get_terrain_texture() const { +Ref GameSingleton::get_terrain_texture() const { return terrain_texture; } @@ -309,11 +310,11 @@ Vector2i GameSingleton::get_province_shape_image_subdivisions() const { return image_subdivisions; } -Ref GameSingleton::get_province_shape_texture() const { +Ref GameSingleton::get_province_shape_texture() const { return province_shape_texture; } -Ref GameSingleton::get_province_colour_texture() const { +Ref GameSingleton::get_province_colour_texture() const { return province_colour_texture; } @@ -375,6 +376,15 @@ Error GameSingleton::set_mapmode(String const& identifier) { return _update_colour_image(); } +bool GameSingleton::is_parchment_mapmode_allowed() const { + // TODO - parchment bool per mapmode? + // TODO - move mapmode index to SIM/Map? + /* Disallows parchment mapmode for the cosmetic terrain mapmode */ + static constexpr std::string_view cosmetic_terrain_mapmode = "mapmode_terrain"; + Mapmode const* mapmode = game_manager.get_map().get_mapmode_by_index(mapmode_index); + return mapmode != nullptr && mapmode->get_identifier() != cosmetic_terrain_mapmode; +} + int32_t GameSingleton::get_selected_province_index() const { return game_manager.get_map().get_selected_province_index(); } @@ -555,10 +565,10 @@ Error GameSingleton::_load_terrain_variants() { TypedArray terrain_images; { - // TODO - load "map/terrain/water.dds" instead of using a solid colour (issue is that it's 512x512 - // while the texturesheet slices are 256x256, so they can't share a Texture2DArray) + /* This is a placeholder image so that we don't have to branch to avoid looking up terrain index 0 (water). + * It should never appear in game, and so is bright red to to make it obvious if it slips through. */ const Ref water_image = Utilities::make_solid_colour_image( - { 0.1f, 0.1f, 0.5f }, slice_size, slice_size, terrain_sheet->get_format() + { 1.0f, 0.0f, 0.0f }, slice_size, slice_size, terrain_sheet->get_format() ); ERR_FAIL_NULL_V_EDMSG(water_image, FAILED, "Failed to create water terrain image"); terrain_images.append(water_image); diff --git a/extension/src/openvic-extension/singletons/GameSingleton.hpp b/extension/src/openvic-extension/singletons/GameSingleton.hpp index 913bdd4..57a2014 100644 --- a/extension/src/openvic-extension/singletons/GameSingleton.hpp +++ b/extension/src/openvic-extension/singletons/GameSingleton.hpp @@ -73,7 +73,7 @@ namespace OpenVic { float get_map_aspect_ratio() const; /* The cosmetic terrain textures stored in a Texture2DArray. */ - godot::Ref get_terrain_texture() const; + godot::Ref get_terrain_texture() const; /* The flag image corresponding to the requested country / flag_type * combination, or nullptr if no such flag can be found. */ @@ -87,14 +87,15 @@ namespace OpenVic { /* The map, encoded in RGB8 with RG representing province index and B representing terrain texture. * To support a wider range of GPUs, the image is divided so that no piece has a dimension * greater than 16383 and the pieces are stored in a Texture2DArray. */ - godot::Ref get_province_shape_texture() const; + godot::Ref get_province_shape_texture() const; /* The base and stripe colours for each province. */ - godot::Ref get_province_colour_texture() const; + godot::Ref get_province_colour_texture() const; int32_t get_mapmode_count() const; godot::String get_mapmode_identifier(int32_t index) const; godot::Error set_mapmode(godot::String const& identifier); + bool is_parchment_mapmode_allowed() const; int32_t get_selected_province_index() const; void set_selected_province(int32_t index); -- cgit v1.2.3-56-ga3b1