aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-06-24 00:55:45 +0200
committer GitHub <noreply@github.com>2023-06-24 00:55:45 +0200
commit432000a3ab73980fc6421b3587de4b97af30d3ad (patch)
tree4b80d98261252f25011e34b22a8d49767525559f /game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
parent40cf0fa95e325f3bf875e42c11254da23192f506 (diff)
parent206cafc8bba310e4d4f35f4898ef3ac289abe81a (diff)
Merge pull request #131 from OpenVicProject/ui-cleanup
Localisation and UI focus cleanup
Diffstat (limited to 'game/src/Game/Menu/OptionMenu/ResolutionSelector.gd')
-rw-r--r--game/src/Game/Menu/OptionMenu/ResolutionSelector.gd47
1 files changed, 29 insertions, 18 deletions
diff --git a/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
index ebdf718..2791ecb 100644
--- a/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
+++ b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd
@@ -14,31 +14,20 @@ func _find_resolution_index_by_value(value : Vector2i) -> int:
return item_index
return -1
-func _sync_resolutions(
- value : Vector2i = Resolution.error_resolution,
- _resolution_name = null,
- _resolution_display_name = null
-) -> void:
+func _sync_resolutions(value : Vector2i = Resolution.error_resolution) -> void:
clear()
default_selected = -1
selected = -1
- var resolution_list := Resolution.get_resolution_value_list()
- if value != Resolution.error_resolution:
- resolution_list.append(value)
- for resolution_value in resolution_list:
- var display_name := "%sx%s" % [resolution_value.x, resolution_value.y]
- var resolution_name := Resolution.get_resolution_name(resolution_value)
- if resolution_name == &"Default":
- display_name = "Default (%s)" % resolution_name
- if not resolution_name.is_empty():
- display_name = "%s (%s)" % [display_name, resolution_name + (", Default" if resolution_value == default_value else "")]
- add_item(display_name)
+ var current_resolution := Resolution.get_current_resolution()
+ for resolution_value in Resolution.get_resolution_value_list():
+ # Placeholder option text awaiting _update_resolution_options_text()
+ add_item(str(resolution_value))
set_item_metadata(item_count - 1, resolution_value)
if resolution_value == default_value:
default_selected = item_count - 1
- if resolution_value == Resolution.get_current_resolution():
+ if resolution_value == current_resolution:
selected = item_count - 1
if default_selected == -1:
@@ -46,6 +35,28 @@ func _sync_resolutions(
if selected == -1:
selected = default_selected
+ _update_resolution_options_text()
+
+func _notification(what : int):
+ match what:
+ NOTIFICATION_TRANSLATION_CHANGED:
+ _update_resolution_options_text()
+
+func _update_resolution_options_text() -> void:
+ for index in get_item_count():
+ var resolution_value : Vector2i = get_item_metadata(index)
+ var format_dict := { "width": resolution_value.x, "height": resolution_value.y }
+ format_dict["name"] = tr("OPTIONS_VIDEO_RESOLUTION_{width}x{height}".format(format_dict))
+ if format_dict["name"].begins_with("OPTIONS"): format_dict["name"] = ""
+ var display_name := "OPTIONS_VIDEO_RESOLUTION_DIMS"
+ if format_dict["name"]:
+ display_name += "_NAMED"
+ if resolution_value == default_value:
+ display_name += "_DEFAULT"
+ format_dict["width"] = Events.Localisation.tr_number(resolution_value.x)
+ format_dict["height"] = Events.Localisation.tr_number(resolution_value.y)
+ display_name = tr(display_name).format(format_dict)
+ set_item_text(index, display_name)
func _setup_button() -> void:
Resolution.resolution_added.connect(_sync_resolutions)
@@ -54,7 +65,7 @@ func _setup_button() -> void:
if default_value.y <= 0:
default_value.y = ProjectSettings.get_setting("display/window/size/viewport_height")
if not Resolution.has_resolution(default_value):
- Resolution.add_resolution(default_value, &"Default")
+ Resolution.add_resolution(default_value)
else:
_sync_resolutions()