aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Conor Allison <conoboy137@hotmail.co.uk>2024-03-03 12:59:46 +0100
committer Conor Allison <conoboy137@hotmail.co.uk>2024-03-03 12:59:46 +0100
commit8863865c8933c62a02384df6e17fb5a006fb606b (patch)
treedb2a6814a1fd107829c209bee8a714cfe62f2ed5
parentb29e3b4d5c18c26efe2d531ca4decc94d0810b61 (diff)
Individual techs are now populating
-rw-r--r--extension/src/openvic-extension/singletons/GameSingleton.cpp4
-rw-r--r--game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd56
2 files changed, 49 insertions, 11 deletions
diff --git a/extension/src/openvic-extension/singletons/GameSingleton.cpp b/extension/src/openvic-extension/singletons/GameSingleton.cpp
index 9bb2e51..88f2b5a 100644
--- a/extension/src/openvic-extension/singletons/GameSingleton.cpp
+++ b/extension/src/openvic-extension/singletons/GameSingleton.cpp
@@ -467,24 +467,24 @@ Dictionary GameSingleton::get_tech_areas() const{
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_identifier_key = "identifier";
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_identifier_key] = std_to_godot_string(std::string(fetched_technologies[i].get_identifier()));
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;
}
diff --git a/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd b/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
index 7c8dfef..b9d78f6 100644
--- a/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
+++ b/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
@@ -12,24 +12,22 @@ 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
+#populate godot dictionaries from the simulation backend
+var tech_folder_dict : Dictionary = GameSingleton.get_tech_folders()
+var tech_area_dict : Dictionary = GameSingleton.get_tech_areas()
+var tech_dict : Dictionary = GameSingleton.get_technologies()
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)
+
+
generate_interface()
- #in vic2, army tech is the initial window selected
- var selected_tech_window = folder_windows[0]
#setup the window since the gui file doesnt store positions, can probably be optimised
for folder_item in folder_windows:
country_technology.add_child(folder_item)
@@ -42,6 +40,9 @@ func _ready() -> void:
country_technology.add_child(research_item_row)
tech_windows.clear()
+ #in vic2, army tech is the initial window selected
+ populate_areas("army_tech")
+
var close_button : Button = get_button_from_nodepath(^"./country_technology/close_button")
if close_button:
@@ -69,7 +70,8 @@ func generate_interface():
#generate the initial UI elements
for i in 5:
var temp = folder_window.duplicate()
- temp.name = temp.name+str(i)
+ temp.name = tech_folder_dict[i].identifier
+ temp.get_child(2).text = tech_folder_dict[i].identifier
temp.position.x = 28+(194*i)
temp.position.y = 55
folder_windows.append(temp)
@@ -79,6 +81,42 @@ func generate_interface():
temp.position.x = 28+(194*i)
temp.position.y = 107
tech_groups.append(temp)
+
+func populate_areas(identifier):
+ var offset
+ match identifier:
+ "army_tech":
+ offset = 0
+ "navy_tech":
+ offset = 5
+ "commerce_tech":
+ offset = 10
+ "culture_tech":
+ offset = 15
+ "industry_tech":
+ offset = 20
+ for i in 5:
+ var node = get_node("/root/GameSession/Topbar/TechnologyMenu/country_technology/tech_group"+str(i))
+ node.get_child(0).text = tech_area_dict[offset+i].identifier
+ populate_techs(identifier)
+
+func populate_techs(identifier):
+ var offset
+ match identifier:
+ "army_tech":
+ offset = 0
+ "navy_tech":
+ offset = 30
+ "commerce_tech":
+ offset = 60
+ "culture_tech":
+ offset = 90
+ "industry_tech":
+ offset = 120
+ for x in 5:
+ for y in 6:
+ var node = get_node("/root/GameSession/Topbar/TechnologyMenu/country_technology/tech_window"+str(x)+"_"+str(y))
+ node.get_child(1).text = tech_dict[offset+x+y].identifier
func generate_tech_windows(x,y):
var matrix = []