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 12, 2023
1 parent 0b3a162 commit 7f2c0c2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
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: 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

0 comments on commit 7f2c0c2

Please sign in to comment.