aboutsummaryrefslogtreecommitdiff
path: root/game/src/LocaleButton.gd
diff options
context:
space:
mode:
author htmlJoel <ajmach6@gmail.com>2023-03-01 20:34:07 +0100
committer Joel Machens <ajmach6@gmail.com>2023-03-12 05:46:24 +0100
commit3573d59ef42c935dc27bb6a4ae9bb3c4ba041c08 (patch)
treefba91cccf66ddd07e518cb4fb9cb0ab89fed9fb4 /game/src/LocaleButton.gd
parentdfd6d33a9bd1fda56589efa66a9ca0f63f5e46f8 (diff)
Added General Tab
Fix OptionsMenu scaling Options UI extended Connected escape for back
Diffstat (limited to 'game/src/LocaleButton.gd')
-rw-r--r--game/src/LocaleButton.gd17
1 files changed, 14 insertions, 3 deletions
diff --git a/game/src/LocaleButton.gd b/game/src/LocaleButton.gd
index a8220de..c3c6925 100644
--- a/game/src/LocaleButton.gd
+++ b/game/src/LocaleButton.gd
@@ -23,6 +23,11 @@ func _ready():
Events.Options.load_settings.connect(load_setting)
Events.Options.save_settings.connect(save_setting)
+
+func _notification(what):
+ match what:
+ NOTIFICATION_TRANSLATION_CHANGED:
+ _select_locale_by_string(TranslationServer.get_locale())
func _valid_index(index : int) -> bool:
return 0 <= index and index < _locales_list.size()
@@ -32,12 +37,18 @@ func load_setting(file : ConfigFile) -> void:
var load_value = file.get_value(section_name, setting_name, TranslationServer.get_locale())
match typeof(load_value):
TYPE_STRING, TYPE_STRING_NAME:
- var locale_index := _locales_list.find(load_value as String)
- if locale_index != -1:
- selected = locale_index
+ if _select_locale_by_string(load_value as String):
+ item_selected.emit(selected)
return
push_error("Setting value '%s' invalid for setting [%s] %s" % [load_value, section_name, setting_name])
reset_setting()
+
+func _select_locale_by_string(locale : String) -> bool:
+ var locale_index := _locales_list.find(locale)
+ if locale_index != -1:
+ selected = locale_index
+ return true
+ return false
# REQUIREMENTS:
# * UIFUN-74