-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Technology Menu #334
base: master
Are you sure you want to change the base?
Conversation
891c6c1
to
0f67b06
Compare
game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
Outdated
Show resolved
Hide resolved
cae21ea
to
6b9a012
Compare
game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
Outdated
Show resolved
Hide resolved
game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
Outdated
Show resolved
Hide resolved
game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
Outdated
Show resolved
Hide resolved
game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
Outdated
Show resolved
Hide resolved
game/src/Game/GameSession/NationManagementScreen/TechnologyMenu.gd
Outdated
Show resolved
Hide resolved
|
||
PackedStringArray tech_folder_identifiers {}; | ||
TypedArray<PackedStringArray> tech_area_identifiers {}; | ||
Array tech_identifiers {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array tech_identifiers {}; | |
TypedArray<PackedStringArray> tech_identifiers {}; |
This can be a typed array
return ret; | ||
} | ||
|
||
TechnologySchool const* tech_school = country->get_tech_school(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TechnologySchool const* tech_school = country->get_tech_school(); | |
TechnologySchool const* tech_school = country->get_tech_school(); |
Extra tab
_current_research_progressbar = get_gui_progress_bar_from_nodepath(^"./country_technology/research_progress") | ||
|
||
# FOLDERS, AREAS, TECHNOLOGIES | ||
_tech_folders = _tech_defines.get("tech_folders", [] as PackedStringArray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_tech_folders = _tech_defines.get("tech_folders", [] as PackedStringArray) | |
_tech_folders = _tech_defines.get(&"tech_folders", [] as PackedStringArray) |
All these get
calls should be using StringName
s rather than String
s (GDScript: "string literal"
vs &"string name literal"
)
pos.x += folder_node.get_size().x * i | ||
folder_node.set_position(pos) | ||
|
||
var icon : GUIIcon = GUINode.get_gui_icon_from_node(folder_node.get_node(^"./folder_icon")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var icon : GUIIcon = GUINode.get_gui_icon_from_node(folder_node.get_node(^"./folder_icon")) | |
var icon : GUIIcon = GUINode.get_gui_icon_from_node_and_path(folder_node, ^"./folder_icon") |
I've recently added another kind of helper function which does the get_node
lookup for you, useful in similar cases throughout this file
if _technologies.size() > 0 and _technologies[0].size() > 0 and _technologies[0][0].size() > 0 and _technologies[0][0][0]: | ||
_selected_technology = _technologies[0][0][0] | ||
_selected_technology_info = MenuSingleton.get_specific_technology_info(_selected_technology) | ||
_folder_tech_counts = _tech_defines.get("folder_tech_count", 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_folder_tech_counts = _tech_defines.get("folder_tech_count", 0) | |
_folder_tech_counts = _tech_defines.get("folder_tech_count", [] as PackedInt32Array) |
Fallback types need to match the variable type otherwise they'll cause a crash when they're fallen back to. Could you check that there aren't any other mismatches in this file?
add_gui_element("country_technology", "tech_group") | ||
|
||
var area_node : Node = get_node(^"./tech_group") | ||
|
||
area_node.reparent(root_node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than generating at the top level and reparenting, you can use GUINode.generate_gui_element
, store the result in a variable, and then add_child
it to the desired parent if it's not null (applies to similar cases throughout this file)
if i != 0: | ||
area_node.set_visible(false) | ||
|
||
pos = GUINode.get_gui_position("country_technology", "tech_group_offset") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be gotten once at the beginning of the _ready
function and re-used without multiple lookups
main_icon.mouse_filter = Control.MOUSE_FILTER_PASS | ||
main_icon.set_tooltip_string(mod_tooltips[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_tooltip_string
automatically changes mouse filter to PASS if it's currently IGNORE, so the change above isn't necessary unless you're changing it from something other than IGNORE
_current_research_progressbar.set_tooltip_string_and_substitution_dict( | ||
tr("TECHNOLOGYVIEW_RESEARCH_TOOLTIP") + "\n" + | ||
tr("TECHNOLOGYVIEW_RESEARCH_INVESTED_TOOLTIP") + | ||
MenuSingleton.get_tooltip_separator() + | ||
info.get("current_research_effect_tt", ""), | ||
{ | ||
"TECH": tr(current_research), | ||
"DATE": info.get("current_research_finish_date", "1836.1.1"), | ||
"INVESTED": info.get("current_research_invested", 0), | ||
"COST": info.get("current_research_cost", 0) | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already generate the top half of this tooltip here, so you could separate out that code into a helper function under MenuSingleton
then store its result in the info
dictionary rather than passing up all the constituent parts
if _start_research_button: | ||
if current_research == _selected_technology: | ||
_start_research_button.disabled = true | ||
_start_research_button.set_tooltip_string_and_substitution_dict(tr("TECHNOLOGYVIEW_UNDER_RESEARCH_TOOLTIP"), { "TECH": tr(_selected_technology) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In cases like this you don't have to manually translate the tooltip string, it'll get auto translated by the tooltip node. The only common reason for manually translating is when you need to modify the result somehow, e.g. combine multiple seaprate localised keys together or manually substitute something inside it, but when you're using the substitution dict functionality that's all taken care of by the tooltip node.
Also you'll probably have to rebase onto master to account for the submodule already being updated |
_make_modifier_effect_tooltip
for single modifiers