diff options
author | Conor Allison <conoboy137@hotmail.co.uk> | 2024-03-03 12:08:00 +0100 |
---|---|---|
committer | Conor Allison <conoboy137@hotmail.co.uk> | 2024-03-03 12:08:00 +0100 |
commit | b29e3b4d5c18c26efe2d531ca4decc94d0810b61 (patch) | |
tree | 39a7297aae3cbd85a1107236025b999a6e6d63fb | |
parent | 92a43a51c898e42e7290c1e2421f57d9b9500a16 (diff) |
Tech loading from sim
Wrote C++ functions to get tech data loading from the sim to godot
-rw-r--r-- | .clang-format | 88 | ||||
-rw-r--r-- | clang-format.sh | 13 | ||||
m--------- | extension/deps/openvic-simulation | 0 | ||||
-rw-r--r-- | extension/src/openvic-extension/singletons/GameSingleton.cpp | 60 | ||||
-rw-r--r-- | extension/src/openvic-extension/singletons/GameSingleton.hpp | 4 | ||||
-rw-r--r-- | game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd | 9 |
6 files changed, 73 insertions, 101 deletions
diff --git a/.clang-format b/.clang-format deleted file mode 100644 index dea31ab..0000000 --- a/.clang-format +++ /dev/null @@ -1,88 +0,0 @@ ---- -Language: Cpp -UseCRLF: false -Standard: c++20 -UseTab: Always -TabWidth: 4 -IndentWidth: 4 -ColumnLimit: 128 -PointerAlignment: Left -DerivePointerAlignment: false -SpacesInSquareBrackets: false -SpacesInParentheses: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: false -SpacesInConditionalStatement: false -SpacesInAngles: false -SpaceInEmptyParentheses: false -SpaceInEmptyBlock: false -SpacesInParens: Never -SpaceBeforeSquareBrackets: false -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeInheritanceColon: true -SpaceBeforeCtorInitializerColon: true -SpaceBeforeCpp11BracedList: true -SpaceBeforeAssignmentOperators: true -SpaceAfterTemplateKeyword: false -SpaceAfterLogicalNot: false -PackConstructorInitializers: BinPack -NamespaceIndentation: All -#LambdaBodyIndentation: Signature -IndentExternBlock: Indent -IndentCaseBlocks: false -IndentCaseLabels: false -IndentAccessModifiers: false -IndentRequiresClause: false -IncludeBlocks: Regroup -FixNamespaceComments: false -EmptyLineBeforeAccessModifier: LogicalBlock -Cpp11BracedListStyle: false -CompactNamespaces: false -BreakConstructorInitializers: BeforeColon -BreakBeforeBraces: Attach -AlwaysBreakTemplateDeclarations: Yes -AlwaysBreakAfterReturnType: None -PenaltyReturnTypeOnItsOwnLine: 10 -BreakBeforeConceptDeclarations: Always -AllowShortLambdasOnASingleLine: Empty -AllowShortIfStatementsOnASingleLine: Never -AllowShortEnumsOnASingleLine: true -AllowShortCaseLabelsOnASingleLine: true -AllowShortBlocksOnASingleLine: Empty -AllowShortCompoundRequirementOnASingleLine: true -AllowShortFunctionsOnASingleLine: Empty -AllowShortLoopsOnASingleLine: false -AlignTrailingComments: - Kind: Never - OverEmptyLines: 0 -AlignEscapedNewlines: DontAlign -AlignAfterOpenBracket: BlockIndent -AlignOperands: DontAlign -AlignConsecutiveShortCaseStatements: - Enabled: true - AcrossEmptyLines: true - AcrossComments: true - AlignCaseColons: false -BinPackArguments: true -BinPackParameters: true -AccessModifierOffset: -4 -InsertNewlineAtEOF: true -InsertBraces: true -MaxEmptyLinesToKeep: 2 -RequiresClausePosition: OwnLine -IncludeCategories: - - Regex: <[[:alnum:]_]+> - Priority: 1 - - Regex: <[[:alnum:]_]+[.]h> - Priority: 2 - - Regex: ^<godot_cpp/ - Priority: 3 - - Regex: ^<openvic-dataloader/ - Priority: 4 - - Regex: ^<openvic-simulation/ - Priority: 5 - - Regex: ^"openvic-extension/ - Priority: 6 - - Regex: .* - Priority: 7 diff --git a/clang-format.sh b/clang-format.sh deleted file mode 100644 index 3b45543..0000000 --- a/clang-format.sh +++ /dev/null @@ -1,13 +0,0 @@ -#/usr/bin/env bash - -echo "\n\nFormatting openvic-extension with clang-format:\n" -find ./extension/src/ -iname *.hpp -o -iname *.cpp | xargs clang-format --verbose -i - -if [ -d ./extension/deps/openvic-simulation ]; then - cd ./extension/deps/openvic-simulation - if [ -f ./clang-format.sh ]; then - ./clang-format.sh - fi -fi - -exit 0 diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation -Subproject 164e76e367ff7dc5914f0d7105b5914fd3fba90 +Subproject 2c892c99a6647be15ef23cabf6cc40f08769283 diff --git a/extension/src/openvic-extension/singletons/GameSingleton.cpp b/extension/src/openvic-extension/singletons/GameSingleton.cpp index 9b8abce..9bb2e51 100644 --- a/extension/src/openvic-extension/singletons/GameSingleton.cpp +++ b/extension/src/openvic-extension/singletons/GameSingleton.cpp @@ -8,11 +8,13 @@ #include <openvic-simulation/utility/Logger.hpp> +#include "godot_cpp/variant/dictionary.hpp" #include "openvic-extension/classes/GFXPieChartTexture.hpp" #include "openvic-extension/singletons/AssetManager.hpp" #include "openvic-extension/singletons/LoadLocalisation.hpp" #include "openvic-extension/utility/ClassBindings.hpp" #include "openvic-extension/utility/Utilities.hpp" +#include "openvic-simulation/research/Technology.hpp" using namespace godot; using namespace OpenVic; @@ -72,6 +74,9 @@ void GameSingleton::_bind_methods() { OV_BIND_METHOD(GameSingleton::get_slave_pop_icon_index); OV_BIND_METHOD(GameSingleton::get_administrative_pop_icon_index); OV_BIND_METHOD(GameSingleton::get_rgo_owner_pop_icon_index); + OV_BIND_METHOD(GameSingleton::get_tech_folders); + OV_BIND_METHOD(GameSingleton::get_tech_areas); + OV_BIND_METHOD(GameSingleton::get_technologies); OV_BIND_METHOD(GameSingleton::set_paused, { "paused" }); OV_BIND_METHOD(GameSingleton::toggle_paused); @@ -432,6 +437,61 @@ int32_t GameSingleton::get_rgo_owner_pop_icon_index() const { return sprite; } +Dictionary GameSingleton::get_tech_folders() const{ + std::vector<TechnologyFolder> const& fetched_folders = game_manager.get_research_manager().get_technology_manager().get_technology_folders(); + static const StringName technology_folder_identifier_key = "identifier"; + + Dictionary folders; + for (size_t i = 0; i < fetched_folders.size(); i++) { + Dictionary folder; + folder[technology_folder_identifier_key] = std_to_godot_string(std::string(fetched_folders[i].get_identifier())); + folders[i] = folder; + } + return folders; +} + +Dictionary GameSingleton::get_tech_areas() const{ + std::vector<TechnologyArea> const& fetched_areas = game_manager.get_research_manager().get_technology_manager().get_technology_areas(); + static const StringName technology_area_identifier_key = "identifier"; + static const StringName technology_area_folder_key = "folder"; + + Dictionary areas; + for (size_t i = 0; i < fetched_areas.size(); i++) { + Dictionary area; + area[technology_area_identifier_key] = std_to_godot_string(std::string(fetched_areas[i].get_identifier())); + area[technology_area_folder_key] = std_to_godot_string(std::string(fetched_areas[i].get_folder().get_identifier())); + areas[i] = area; + } + return areas; +} + +Dictionary GameSingleton::get_technologies() const{ + std::vector<Technology> const& fetched_technologies = game_manager.get_research_manager().get_technology_manager().get_technologies(); + static const StringName technology_info_area_key = "area"; + static const StringName technology_info_year_key = "year"; + static const StringName technology_info_cost_key = "cost"; + static const StringName technology_info_unit_key = "unit"; + static const StringName technology_info_activated_unit_key = "activated_units"; + static const StringName technology_info_activated_buildings_key = "activated_buildings"; + static const StringName technology_info_values_key = "values"; + static const StringName technology_info_ai_chance_key = "ai_chance"; + Dictionary techs; + for (size_t i = 0; i < fetched_technologies.size(); i++) { + Dictionary tech; + tech[technology_info_area_key] = std_to_godot_string(std::string(fetched_technologies[i].get_area().get_identifier())); + tech[technology_info_year_key] = static_cast<int32_t>(fetched_technologies[i].get_year()); + tech[technology_info_cost_key] = static_cast<int32_t>(fetched_technologies[i].get_cost()); + tech[technology_info_unit_key] = std_to_godot_string("WIP"); + tech[technology_info_activated_unit_key] = std_to_godot_string("WIP"); + tech[technology_info_activated_buildings_key] = std_to_godot_string("WIP"); + tech[technology_info_values_key] = std_to_godot_string("WIP"); + tech[technology_info_ai_chance_key] = std_to_godot_string("WIP"); + techs[i] = tech; + } + return techs; +} + + void GameSingleton::set_paused(bool paused) { game_manager.get_simulation_clock().set_paused(paused); } diff --git a/extension/src/openvic-extension/singletons/GameSingleton.hpp b/extension/src/openvic-extension/singletons/GameSingleton.hpp index 35f7437..b65ade1 100644 --- a/extension/src/openvic-extension/singletons/GameSingleton.hpp +++ b/extension/src/openvic-extension/singletons/GameSingleton.hpp @@ -1,5 +1,6 @@ #pragma once +#include "godot_cpp/variant/dictionary.hpp" #include <godot_cpp/classes/control.hpp> #include <godot_cpp/classes/image_texture.hpp> #include <godot_cpp/classes/texture2d_array.hpp> @@ -105,6 +106,9 @@ namespace OpenVic { int32_t get_slave_pop_icon_index() const; int32_t get_administrative_pop_icon_index() const; int32_t get_rgo_owner_pop_icon_index() const; + godot::Dictionary get_tech_folders() const; + godot::Dictionary get_tech_areas() const; + godot::Dictionary get_technologies() const; void set_paused(bool paused); void toggle_paused(); diff --git a/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd b/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd index 41dc2c8..7c8dfef 100644 --- a/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd +++ b/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd @@ -12,9 +12,18 @@ var tech_groups = [] var tech_window : Control = generate_gui_element("country_technology", "tech_window") var tech_windows = generate_tech_windows(5,6) +var tech_folder_dict : Dictionary +var tech_area_dict : Dictionary +var tech_dict : Dictionary + + + func _ready() -> void: + tech_folder_dict = GameSingleton.get_tech_folders() + tech_area_dict = GameSingleton.get_tech_areas() + tech_dict = GameSingleton.get_technologies() GameSingleton.gamestate_updated.connect(_update_info) add_child(country_technology) Events.NationManagementScreens.update_active_nation_management_screen.connect(_on_update_active_nation_management_screen) |