Skip to content

Commit

Permalink
Merge pull request #292 from OpenVicProject/add/dev-console
Browse files Browse the repository at this point in the history
Add simulation dev console
  • Loading branch information
Spartan322 authored Feb 4, 2025
2 parents 5aba049 + bd16dd9 commit 6b921dc
Show file tree
Hide file tree
Showing 5 changed files with 542 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/openvic-simulation/InstanceManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "InstanceManager.hpp"

#include "openvic-simulation/DefinitionManager.hpp"
#include "openvic-simulation/console/ConsoleInstance.hpp"
#include "openvic-simulation/utility/Logger.hpp"

using namespace OpenVic;
Expand All @@ -27,6 +28,7 @@ InstanceManager::InstanceManager(
std::bind(&InstanceManager::tick, this), std::bind(&InstanceManager::update_gamestate, this),
clock_state_changed_callback ? std::move(clock_state_changed_callback) : []() {}
},
console_instance { *this },
gamestate_updated { gamestate_updated_callback ? std::move(gamestate_updated_callback) : []() {} } {}

void InstanceManager::set_gamestate_needs_update() {
Expand Down Expand Up @@ -203,6 +205,18 @@ bool InstanceManager::update_clock() {
return true;
}

bool InstanceManager::set_today_and_update(Date new_today) {
if (!is_game_session_started()) {
Logger::error("Cannot update clock - game session not started!");
return false;
}

today = new_today;
gamestate_needs_update = true;
update_gamestate();
return true;
}

bool InstanceManager::expand_selected_province_building(size_t building_index) {
set_gamestate_needs_update();
ProvinceInstance* province = map_instance.get_selected_province();
Expand Down
4 changes: 4 additions & 0 deletions src/openvic-simulation/InstanceManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <functional>

#include "openvic-simulation/console/ConsoleInstance.hpp"
#include "openvic-simulation/country/CountryInstance.hpp"
#include "openvic-simulation/diplomacy/CountryRelation.hpp"
#include "openvic-simulation/economy/GoodInstance.hpp"
Expand Down Expand Up @@ -39,6 +40,7 @@ namespace OpenVic {
* e.g. if we want to remove military units from the province they're in when they're destructed. */
MapInstance PROPERTY_REF(map_instance);
SimulationClock PROPERTY_REF(simulation_clock);
ConsoleInstance PROPERTY_REF(console_instance);

bool PROPERTY_CUSTOM_PREFIX(game_instance_setup, is, false);
bool PROPERTY_CUSTOM_PREFIX(game_session_started, is, false);
Expand Down Expand Up @@ -71,6 +73,8 @@ namespace OpenVic {
bool start_game_session();
bool update_clock();

bool set_today_and_update(Date new_today);

bool expand_selected_province_building(size_t building_index);
};
}
Loading

0 comments on commit 6b921dc

Please sign in to comment.