diff options
Diffstat (limited to 'game/src/LocaleButton.gd')
-rw-r--r-- | game/src/LocaleButton.gd | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/game/src/LocaleButton.gd b/game/src/LocaleButton.gd index eed815e..32807d0 100644 --- a/game/src/LocaleButton.gd +++ b/game/src/LocaleButton.gd @@ -4,8 +4,6 @@ var _locales_country_rename : Dictionary var _locales_list : Array[String] func _ready(): - print("Loading locale button") - _locales_country_rename = ProjectSettings.get_setting("internationalization/locale/country_short_name", {}) _locales_list = [TranslationServer.get_locale()] @@ -20,7 +18,18 @@ func _ready(): add_item("%s, %s" % [locale_first_part, locale_second_part]) + Events.Options.load_settings.connect(load_setting) + Events.Options.save_settings.connect(save_setting) + + +func load_setting(file : ConfigFile): + var locale_index := _locales_list.find(file.get_value("Localization", "Locale", "") as String) + if locale_index != -1: + selected = locale_index + +func save_setting(file : ConfigFile): + file.set_value("Localization", "Locale", _locales_list[selected]) func _on_item_selected(index): - print("Selected locale " + _locales_list[index]) TranslationServer.set_locale(_locales_list[index]) + Events.Options.save_settings_from_file.call_deferred() |