diff options
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.cpp | 10 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/NodeTools.hpp | 19 |
2 files changed, 22 insertions, 7 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp index d01f6ff..f99417f 100644 --- a/src/openvic-simulation/dataloader/Dataloader.cpp +++ b/src/openvic-simulation/dataloader/Dataloader.cpp @@ -280,8 +280,7 @@ bool Dataloader::_load_interface_files(UIManager& ui_manager) const { return ui_manager.load_gfx_file(parse_defines(file).get_file_node()); } ); - ui_manager.lock_sprites(); - ui_manager.lock_fonts(); + ui_manager.lock_gfx_registries(); /* Hard-coded GUI file names, might be replaced with a dynamic system but everything should still be loaded on startup. */ static const std::vector<std::string_view> gui_files { @@ -513,12 +512,14 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi { /* Country History */ CountryHistoryManager& country_history_manager = game_manager.get_history_manager().get_country_manager(); + DeploymentManager& deployment_manager = game_manager.get_military_manager().get_deployment_manager(); static constexpr std::string_view country_history_directory = "history/countries"; const path_vector_t country_history_files = lookup_basic_indentifier_prefixed_files_in_dir(country_history_directory, ".txt"); country_history_manager.reserve_more_country_histories(country_history_files.size()); + deployment_manager.reserve_more_deployments(country_history_files.size()); ret &= apply_to_files( country_history_files, @@ -541,11 +542,6 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi ); country_history_manager.lock_country_histories(); - } - - { - DeploymentManager& deployment_manager = game_manager.get_military_manager().get_deployment_manager(); - deployment_manager.lock_deployments(); if (deployment_manager.get_missing_oob_file_count() > 0) { diff --git a/src/openvic-simulation/dataloader/NodeTools.hpp b/src/openvic-simulation/dataloader/NodeTools.hpp index b99fc48..0bb4d5b 100644 --- a/src/openvic-simulation/dataloader/NodeTools.hpp +++ b/src/openvic-simulation/dataloader/NodeTools.hpp @@ -514,5 +514,24 @@ namespace OpenVic { return warn; }; } + + /* Often used for rotations which must be negated due to OpenVic's coordinate system being orientated + * oppositely to Vic2's. */ + template<typename T = fixed_point_t> + constexpr Callback<T> auto negate_callback(Callback<T> auto callback) { + return [callback](T val) -> bool { + return callback(-val); + }; + } + + /* Often used for map-space coordinates which must have their y-coordinate flipped due to OpenVic using the + * top-left of the map as the origin as opposed Vic2 using the bottom-left. */ + template<typename T> + constexpr Callback<vec2_t<T>> auto flip_y_callback(Callback<vec2_t<T>> auto callback, T height) { + return [callback, height](vec2_t<T> val) -> bool { + val.y = height - val.y; + return callback(val); + }; + } } } |