Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SIM submodule #217

Merged
merged 3 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extension/deps/openvic-simulation
Submodule openvic-simulation updated 39 files
+13 −1 src/openvic-simulation/GameManager.cpp
+4 −1 src/openvic-simulation/GameManager.hpp
+12 −10 src/openvic-simulation/country/Country.cpp
+5 −5 src/openvic-simulation/country/Country.hpp
+81 −23 src/openvic-simulation/country/CountryInstance.cpp
+20 −1 src/openvic-simulation/country/CountryInstance.hpp
+3 −7 src/openvic-simulation/dataloader/Dataloader.cpp
+29 −2 src/openvic-simulation/dataloader/NodeTools.hpp
+65 −65 src/openvic-simulation/economy/BuildingType.cpp
+22 −12 src/openvic-simulation/economy/BuildingType.hpp
+7 −7 src/openvic-simulation/history/CountryHistory.cpp
+4 −4 src/openvic-simulation/history/ProvinceHistory.cpp
+192 −0 src/openvic-simulation/interface/GFXObject.cpp
+77 −0 src/openvic-simulation/interface/GFXObject.hpp
+1 −1 src/openvic-simulation/interface/GFXSprite.cpp
+0 −0 src/openvic-simulation/interface/GFXSprite.hpp
+1 −1 src/openvic-simulation/interface/GUI.hpp
+19 −1 src/openvic-simulation/interface/UI.cpp
+6 −1 src/openvic-simulation/interface/UI.hpp
+35 −29 src/openvic-simulation/map/Map.cpp
+11 −3 src/openvic-simulation/map/Map.hpp
+113 −17 src/openvic-simulation/map/Province.cpp
+24 −14 src/openvic-simulation/map/Province.hpp
+11 −5 src/openvic-simulation/map/Region.cpp
+2 −3 src/openvic-simulation/map/Region.hpp
+49 −14 src/openvic-simulation/military/Deployment.cpp
+29 −11 src/openvic-simulation/military/Deployment.hpp
+2 −0 src/openvic-simulation/military/Leader.hpp
+4 −0 src/openvic-simulation/military/MilitaryManager.hpp
+164 −6 src/openvic-simulation/military/UnitInstance.cpp
+102 −14 src/openvic-simulation/military/UnitInstance.hpp
+2 −2 src/openvic-simulation/politics/Government.cpp
+1 −1 src/openvic-simulation/politics/Government.hpp
+16 −14 src/openvic-simulation/pop/Culture.cpp
+5 −2 src/openvic-simulation/pop/Culture.hpp
+46 −11 src/openvic-simulation/types/IdentifierRegistry.hpp
+9 −0 src/openvic-simulation/types/Vector.hpp
+15 −1 src/openvic-simulation/types/fixed_point/FixedPoint.hpp
+13 −0 src/openvic-simulation/types/fixed_point/FixedPointMap.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <openvic-simulation/country/Country.hpp>
#include <openvic-simulation/interface/GFX.hpp>
#include <openvic-simulation/interface/GFXSprite.hpp>

#include "openvic-extension/classes/GFXButtonStateTexture.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <godot_cpp/classes/image_texture.hpp>

#include <openvic-simulation/interface/GFX.hpp>
#include <openvic-simulation/interface/GFXSprite.hpp>

#include "openvic-extension/utility/Utilities.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <godot_cpp/classes/atlas_texture.hpp>

#include <openvic-simulation/interface/GFX.hpp>
#include <openvic-simulation/interface/GFXSprite.hpp>

#include "openvic-extension/classes/GFXButtonStateTexture.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <godot_cpp/classes/image_texture.hpp>
#include <godot_cpp/core/class_db.hpp>

#include <openvic-simulation/interface/GFX.hpp>
#include <openvic-simulation/interface/GFXSprite.hpp>

namespace OpenVic {
class AssetManager : public godot::Object {
Expand Down
10 changes: 7 additions & 3 deletions extension/src/openvic-extension/singletons/GameSingleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void GameSingleton::_bind_methods() {

OV_BIND_METHOD(GameSingleton::get_map_width);
OV_BIND_METHOD(GameSingleton::get_map_height);
OV_BIND_METHOD(GameSingleton::get_map_dims);
OV_BIND_METHOD(GameSingleton::get_map_aspect_ratio);
OV_BIND_METHOD(GameSingleton::get_terrain_texture);
OV_BIND_METHOD(GameSingleton::get_province_shape_image_subdivisions);
Expand Down Expand Up @@ -133,9 +134,8 @@ Error GameSingleton::setup_game(int32_t bookmark_index) {
}

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_map_width();
const size_t y_mod_h = UtilityFunctions::fposmod(coords.y, 1.0f) * get_map_height();
return game_manager.get_map().get_province_index_at(x_mod_w, y_mod_h);
const Vector2 pos = coords.posmod(1.0f) * get_map_dims();
return game_manager.get_map().get_province_index_at(Utilities::from_godot_ivec2(pos));
}

int32_t GameSingleton::get_map_width() const {
Expand All @@ -146,6 +146,10 @@ int32_t GameSingleton::get_map_height() const {
return game_manager.get_map().get_height();
}

Vector2i GameSingleton::get_map_dims() const {
return Utilities::to_godot_ivec2(game_manager.get_map().get_dims());
}

float GameSingleton::get_map_aspect_ratio() const {
return static_cast<float>(get_map_width()) / static_cast<float>(get_map_height());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ namespace OpenVic {

int32_t get_map_width() const;
int32_t get_map_height() const;
godot::Vector2i get_map_dims() const;
float get_map_aspect_ratio() const;

/* The cosmetic terrain textures stored in a Texture2DArray. */
Expand Down
12 changes: 9 additions & 3 deletions extension/src/openvic-extension/singletons/PopulationMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ int32_t MenuSingleton::get_population_menu_province_list_row_count() const {
}

TypedArray<Dictionary> MenuSingleton::get_population_menu_province_list_rows(int32_t start, int32_t count) const {
// TODO - remove when country population is used instead of total map population
ERR_FAIL_NULL_V(game_manager, {});

if (population_menu.province_list_entries.empty()) {
return {};
}
Expand All @@ -81,6 +84,9 @@ TypedArray<Dictionary> MenuSingleton::get_population_menu_province_list_rows(int
int32_t& start_counter;
int32_t& count_counter;

// TODO - remove when country population is used instead of total map population
const Pop::pop_size_t total_map_population;

/* This is the index among all entries, not just visible ones unlike start and count. */
int32_t index = 0;

Expand All @@ -98,7 +104,7 @@ TypedArray<Dictionary> MenuSingleton::get_population_menu_province_list_rows(int
country_dict[type_key] = population_menu_t::LIST_ENTRY_COUNTRY;
country_dict[index_key] = index;
country_dict[name_key] = std_view_to_godot_string(country_entry.country.get_identifier());
country_dict[size_key] = 0;
country_dict[size_key] = total_map_population;
country_dict[change_key] = 0;
country_dict[selected_key] = country_entry.selected;

Expand All @@ -119,7 +125,7 @@ TypedArray<Dictionary> MenuSingleton::get_population_menu_province_list_rows(int
state_dict[type_key] = population_menu_t::LIST_ENTRY_STATE;
state_dict[index_key] = index;
state_dict[name_key] = std_view_to_godot_string(state_entry.state.get_identifier());
state_dict[size_key] = 0;
state_dict[size_key] = state_entry.state.calculate_total_population();
state_dict[change_key] = 0;
state_dict[selected_key] = state_entry.selected;
state_dict[expanded_key] = state_entry.expanded;
Expand Down Expand Up @@ -151,7 +157,7 @@ TypedArray<Dictionary> MenuSingleton::get_population_menu_province_list_rows(int

return true;
}
} entry_visitor { start, count };
} entry_visitor { start, count, game_manager->get_map().get_total_map_population() };

while (entry_visitor.index < population_menu.province_list_entries.size()
&& std::visit(entry_visitor, population_menu.province_list_entries[entry_visitor.index])) {
Expand Down
2 changes: 1 addition & 1 deletion extension/src/openvic-extension/utility/UITools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <godot_cpp/classes/control.hpp>

#include <openvic-simulation/interface/GFX.hpp>
#include <openvic-simulation/interface/GFXSprite.hpp>
#include <openvic-simulation/interface/GUI.hpp>

namespace OpenVic::UITools {
Expand Down
8 changes: 6 additions & 2 deletions extension/src/openvic-extension/utility/Utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ namespace OpenVic::Utilities {
return { colour.redf(), colour.greenf(), colour.bluef(), colour.alphaf() };
}

_FORCE_INLINE_ godot::Vector2i to_godot_ivec2(ivec2_t vec) {
_FORCE_INLINE_ godot::Vector2i to_godot_ivec2(ivec2_t const& vec) {
return { vec.x, vec.y };
}

_FORCE_INLINE_ godot::Vector2 to_godot_fvec2(fvec2_t vec) {
_FORCE_INLINE_ godot::Vector2 to_godot_fvec2(fvec2_t const& vec) {
return { vec.x, vec.y };
}

_FORCE_INLINE_ ivec2_t from_godot_ivec2(godot::Vector2i const& vec) {
return { vec.x, vec.y };
}

Expand Down