Skip to content

Commit

Permalink
New pop history loading + bookmark selection by index
Browse files Browse the repository at this point in the history
  • Loading branch information
Hop311 committed Dec 18, 2023
1 parent 0b3a162 commit fc79b86
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion extension/deps/openvic-simulation
Submodule openvic-simulation updated 37 files
+37 −0 src/openvic-simulation/GameManager.cpp
+89 −51 src/openvic-simulation/dataloader/Dataloader.cpp
+3 −6 src/openvic-simulation/dataloader/Dataloader.hpp
+15 −1 src/openvic-simulation/economy/BuildingType.cpp
+4 −1 src/openvic-simulation/economy/BuildingType.hpp
+16 −16 src/openvic-simulation/economy/Good.cpp
+1 −1 src/openvic-simulation/economy/Good.hpp
+10 −0 src/openvic-simulation/history/Bookmark.cpp
+2 −0 src/openvic-simulation/history/Bookmark.hpp
+65 −17 src/openvic-simulation/history/CountryHistory.cpp
+3 −3 src/openvic-simulation/history/CountryHistory.hpp
+2 −2 src/openvic-simulation/history/HistoryMap.cpp
+30 −18 src/openvic-simulation/history/HistoryMap.hpp
+61 −12 src/openvic-simulation/history/ProvinceHistory.cpp
+11 −0 src/openvic-simulation/history/ProvinceHistory.hpp
+1 −1 src/openvic-simulation/interface/UI.hpp
+130 −74 src/openvic-simulation/map/Map.cpp
+11 −14 src/openvic-simulation/map/Map.hpp
+239 −30 src/openvic-simulation/map/Province.cpp
+60 −14 src/openvic-simulation/map/Province.hpp
+39 −38 src/openvic-simulation/military/Unit.cpp
+1 −1 src/openvic-simulation/military/Unit.hpp
+2 −2 src/openvic-simulation/misc/Decision.cpp
+41 −0 src/openvic-simulation/misc/Event.cpp
+17 −0 src/openvic-simulation/misc/Event.hpp
+7 −17 src/openvic-simulation/misc/Modifier.cpp
+1 −1 src/openvic-simulation/misc/Modifier.hpp
+6 −0 src/openvic-simulation/politics/Government.cpp
+2 −0 src/openvic-simulation/politics/Government.hpp
+5 −4 src/openvic-simulation/politics/Rebel.cpp
+1 −1 src/openvic-simulation/politics/Rebel.hpp
+81 −24 src/openvic-simulation/pop/Pop.cpp
+36 −6 src/openvic-simulation/pop/Pop.hpp
+11 −8 src/openvic-simulation/research/Technology.cpp
+1 −1 src/openvic-simulation/research/Technology.hpp
+10 −0 src/openvic-simulation/types/Vector.hpp
+4 −0 src/openvic-simulation/types/fixed_point/FixedPoint.hpp
14 changes: 6 additions & 8 deletions extension/src/openvic-extension/singletons/GameSingleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void GameSingleton::_bind_methods() {
OV_BIND_METHOD(GameSingleton::load_defines_compatibility_mode, { "file_paths" });
OV_BIND_SMETHOD(search_for_game_path, { "hint_path" }, DEFVAL(String {}));

OV_BIND_METHOD(GameSingleton::setup_game);
OV_BIND_METHOD(GameSingleton::setup_game, { "bookmark_index" });

OV_BIND_METHOD(GameSingleton::get_province_index_from_uv_coords, { "coords" });
OV_BIND_METHOD(GameSingleton::get_province_info_from_index, { "index" });
Expand Down Expand Up @@ -112,15 +112,13 @@ Dataloader const& GameSingleton::get_dataloader() const {
return dataloader;
}

Error GameSingleton::setup_game() {
BookmarkManager const& bookmark_manager = game_manager.get_history_manager().get_bookmark_manager();
if (bookmark_manager.bookmarks_empty()) {
UtilityFunctions::push_error("No bookmark to load!");
Error GameSingleton::setup_game(int32_t bookmark_index) {
Bookmark const* bookmark = game_manager.get_history_manager().get_bookmark_manager().get_bookmark_by_index(bookmark_index);
if (bookmark == nullptr) {
UtilityFunctions::push_error("Failed to get bookmark with index: ", bookmark_index);
return FAILED;
}
bool ret = game_manager.load_bookmark(&bookmark_manager.get_bookmarks().front());
// TODO - load pop history with the new history system
ret &= dataloader.load_pop_history(game_manager, "history/pops/" + game_manager.get_today().to_string());
bool ret = game_manager.load_bookmark(bookmark);
for (Province& province : game_manager.get_map().get_provinces()) {
province.set_crime(
game_manager.get_crime_manager().get_crime_modifier_by_index(
Expand Down
5 changes: 2 additions & 3 deletions extension/src/openvic-extension/singletons/GameSingleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ namespace OpenVic {

static godot::String search_for_game_path(godot::String hint_path = {});

/* Post-load/restart game setup - reset the game to post-load state
* and (re)generate starting data, e.g. buildings. */
godot::Error setup_game();
/* Post-load/restart game setup - reset the game to post-load state and load the specified bookmark. */
godot::Error setup_game(int32_t bookmark_index);

int32_t get_province_index_from_uv_coords(godot::Vector2 const& coords) const;

Expand Down
2 changes: 2 additions & 0 deletions game/localisation/en_GB/mapmodes.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ mapmode_infrastructure;Infrastructure
mapmode_population;Population Density
mapmode_culture;Nationality
mapmode_religion;Religion
mapmode_adjacencies;Adjacencies
mapmode_port;Ports
2 changes: 1 addition & 1 deletion game/src/Game/GameSession/GameSession.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ extends Control

func _ready():
Events.Options.load_settings_from_file()
if GameSingleton.setup_game() != OK:
if GameSingleton.setup_game(0) != OK:
push_error("Failed to setup game")

func _process(_delta : float):
Expand Down
1 change: 1 addition & 0 deletions game/src/Game/GameSession/MapView.gd
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func zoom_out() -> void:

func _on_province_selected(index : int) -> void:
_map_shader_material.set_shader_parameter(GameLoader.ShaderManager.param_selected_index, index)
print("Province selected with index: ", index)

# REQUIREMENTS
# * SS-31
Expand Down

0 comments on commit fc79b86

Please sign in to comment.