aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/GameSession
diff options
context:
space:
mode:
author BrickPi <ajmach6@gmail.com>2024-11-10 01:44:02 +0100
committer BrickPi <ajmach6@gmail.com>2024-11-10 01:44:02 +0100
commita0f4bc680956a56306981a7935579a06657aa68f (patch)
treedf5ebaf1cd3f73378a3017dc3220c963684e0225 /game/src/Game/GameSession
parent262173628c43c6dca3119fc91a45fc667bca8cb9 (diff)
load folders, areas, and techstopbar-tech
Diffstat (limited to 'game/src/Game/GameSession')
-rw-r--r--game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd93
1 files changed, 75 insertions, 18 deletions
diff --git a/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd b/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
index 8498621..ed570da 100644
--- a/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
+++ b/game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
@@ -5,6 +5,10 @@ var _active : bool = false
const _screen : NationManagement.Screen = NationManagement.Screen.TECHNOLOGY
var _tech_defines : Dictionary = MenuSingleton.get_technology_menu_defines()
+var _tech_folders : PackedStringArray
+var _tech_areas : Array
+var _technologies : Array
+var _folder_tech_counts : PackedInt32Array
var _tech_folder_buttons : Array
var _tech_folder_progressbars : Array
@@ -33,16 +37,18 @@ func _ready() -> void:
_current_research_cat_label = get_gui_label_from_nodepath(^"./country_technology/research_progress_category")
_current_research_progressbar = get_gui_progress_bar_from_nodepath(^"./country_technology/research_progress")
- var tech_folders : Array = _tech_defines.get("tech_folders")
- var tech_areas : Array = _tech_defines.get("tech_areas")
- for i in range(tech_folders.size()):
+ _tech_folders = _tech_defines.get("tech_folders")
+ _tech_areas = _tech_defines.get("tech_areas")
+ _technologies = _tech_defines.get("technologies")
+ _folder_tech_counts = _tech_defines.get("folder_tech_count")
+ for i in range(_tech_folders.size()):
add_gui_element("country_technology", "folder_window")
var folder_node = get_node(^"./folder_window")
var root_node = get_node(^"./country_technology")
folder_node.reparent(root_node)
- folder_node.name = tech_folders[i] + "_folder"
+ folder_node.name = _tech_folders[i] + "_folder"
var pos = GUINode.get_gui_position("country_technology", "folder_offset")
pos.x += folder_node.get_size().x * i
@@ -54,23 +60,23 @@ func _ready() -> void:
var title = GUINode.get_gui_label_from_node(folder_node.get_node(^"./folder_category"))
if title:
- title.set_text(tr(tech_folders[i]))
+ title.set_text(tr(_tech_folders[i]))
var button = GUINode.get_gui_icon_button_from_node(folder_node.get_node(^"./folder_button"))
var button_tooltip: String = tr("TECHNOLOGYVIEW_SHOW_FOLDER_TOOLTIP")
- var button_dict: Dictionary = { "FOLDER" : tech_folders[i] }
+ var button_dict: Dictionary = { "FOLDER" : _tech_folders[i] }
if button:
if i == 0:
button.set_icon_index(2)
- button.pressed.connect(
+ button.pressed.connect( # change selected technology area
func() -> void:
_tech_folder_buttons[_selected_folder].set_icon_index(1)
- for x in range(tech_areas[_selected_folder].size()):
- root_node.get_node("./" + tech_areas[_selected_folder][x]).visible = false
+ for x in range(_tech_areas[_selected_folder].size()):
+ root_node.get_node("./" + _tech_areas[_selected_folder][x]).visible = false
_selected_folder = i
button.set_icon_index(2)
- for x in range(tech_areas[_selected_folder].size()):
- root_node.get_node("./" + tech_areas[_selected_folder][x]).visible = true
+ for x in range(_tech_areas[_selected_folder].size()):
+ root_node.get_node("./" + _tech_areas[_selected_folder][x]).visible = true
)
button.set_tooltip_string_and_substitution_dict(button_tooltip, button_dict)
_tech_folder_buttons.push_back(button)
@@ -84,14 +90,15 @@ func _ready() -> void:
if discovered:
_tech_folder_number_discovered_labels.push_back(discovered)
- var folder_areas : Array = tech_areas[i]
+ # areas
+ var folder_areas : PackedStringArray = _tech_areas[i]
for area_index in range(folder_areas.size()):
add_gui_element("country_technology", "tech_group")
var area_node = get_node(^"./tech_group")
area_node.reparent(root_node)
- area_node.name = tech_areas[i][area_index]
+ area_node.name = folder_areas[area_index]
if i != 0:
area_node.set_visible(false)
@@ -101,7 +108,25 @@ func _ready() -> void:
var area_title = GUINode.get_gui_label_from_node(area_node.get_node(^"./group_name"))
if area_title:
- area_title.set_text(tr(tech_areas[i][area_index]))
+ area_title.set_text(tr(folder_areas[area_index]))
+
+ # technologies
+ var area_technologies : PackedStringArray = _technologies[i][area_index]
+ for tech_index in range(area_technologies.size()):
+ add_gui_element("country_technology", "tech_window")
+
+ var tech_node = get_node(^"./tech_window")
+
+ tech_node.reparent(area_node)
+ tech_node.name = area_technologies[tech_index]
+
+ pos = GUINode.get_gui_position("country_technology", "tech_offset")
+ pos.y += tech_node.get_size().y * tech_index
+ tech_node.set_position(pos)
+
+ var tech_name = GUINode.get_gui_label_from_node(tech_node.get_node(^"./tech_name"))
+ if tech_name:
+ tech_name.set_text(tr(area_technologies[tech_index]))
var close_button : GUIIconButton = get_gui_icon_button_from_nodepath(^"./country_technology/close_button")
if close_button:
@@ -126,9 +151,9 @@ func _update_info() -> void:
_tech_school.set_text(info.get("tech_school"))
if _tech_school_modifiers:
- var mod_values : Array = info.get("tech_school_mod_values")
- var mod_icons : Array = info.get("tech_school_mod_icons")
- var mod_tooltips : Array = info.get("tech_school_mod_tt")
+ var mod_values : PackedFloat32Array = info.get("tech_school_mod_values")
+ var mod_icons : PackedInt32Array = info.get("tech_school_mod_icons")
+ var mod_tooltips : PackedStringArray = info.get("tech_school_mod_tt")
var mod_count = mod_values.size()
_tech_school_modifiers.set_child_count(mod_count)
for i in range(mod_count):
@@ -141,12 +166,44 @@ func _update_info() -> void:
plusminus_icon.mouse_filter = Control.MOUSE_FILTER_PASS
plusminus_icon.set_tooltip_string(mod_tooltips[i])
+ var current_research : String = info.get("current_research_tech")
if _current_research_label:
- _current_research_label.set_text(info.get("current_research_tech"))
+ if current_research != "":
+ _current_research_label.set_text(tr(current_research))
+ else:
+ _current_research_label.set_text(tr("TECHNOLOGYVIEW_NO_RESEARCH"))
if _current_research_cat_label:
_current_research_cat_label.set_text(info.get("current_research_cat"))
+ if _current_research_progressbar:
+ if current_research != "":
+ _current_research_progressbar.set_tooltip_string_and_substitution_dict(tr("TECHNOLOGYVIEW_RESEARCH_TOOLTIP"), {"TECH": tr(current_research), "DATE": MenuSingleton.get_longform_date()})
+ else:
+ _current_research_progressbar.set_tooltip_string(tr("TECHNOLOGYVIEW_NO_RESEARCH_TOOLTIP"))
+
+ var researched_techs : PackedStringArray = info.get("researched_technologies")
+ for ix in range(_technologies.size()):
+ var folder_number_discovered = 0
+ for iy in range(_technologies[ix].size()):
+ for iz in range(_technologies[ix][iy].size()):
+ var tech_identifier = _technologies[ix][iy][iz]
+ var tech = get_gui_icon_button_from_nodepath("./country_technology/{y}/{z}/start_research".format({"y":_tech_areas[ix][iy], "z":tech_identifier}))
+ if tech:
+ if (researched_techs.has(tech_identifier)):
+ tech.set_icon_index(2)
+ folder_number_discovered += 1
+ elif current_research == tech_identifier:
+ tech.set_icon_index(1)
+ else:
+ tech.set_icon_index(4)
+ var label: GUILabel = _tech_folder_number_discovered_labels[ix]
+ if label:
+ label.set_text("{r}/{a}".format({"r":folder_number_discovered,"a":_folder_tech_counts[ix]}))
+ var progbar: GUIProgressBar = _tech_folder_progressbars[ix]
+ if progbar:
+ progbar.value = float(folder_number_discovered) / float(_folder_tech_counts[ix])
+
show()
else:
hide()