2022-02-12 19:45:44 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2022-06-26 13:20:42 +00:00
|
|
|
$Window/NinePatchRect/V/H2/VBoxContainer/Select.clear()
|
2022-02-12 19:45:44 +00:00
|
|
|
var id = 0
|
|
|
|
var selected = -1
|
|
|
|
var near_selected = -1
|
|
|
|
var current_locale = TranslationServer.get_locale()
|
|
|
|
var root_language = current_locale.split('_')[0]
|
|
|
|
for key in TranslationServer.get_loaded_locales():
|
|
|
|
if key == TranslationServer.get_locale():
|
|
|
|
selected = id
|
|
|
|
else:
|
|
|
|
var tmp = key.split("_")
|
|
|
|
# print("tmp:" + tmp[0])
|
|
|
|
if tmp[0] == root_language:
|
|
|
|
if tmp.size() == 1:
|
|
|
|
near_selected = id
|
|
|
|
elif near_selected == -1:
|
|
|
|
near_selected = id
|
2022-06-26 13:20:42 +00:00
|
|
|
$Window/NinePatchRect/V/H2/VBoxContainer/Select.add_item(TranslationServer.get_locale_name(key) + " [" + key + "]", id)
|
2022-02-12 19:45:44 +00:00
|
|
|
id += 1
|
|
|
|
if selected == -1 and near_selected != -1:
|
|
|
|
selected = near_selected
|
|
|
|
if selected == -1:
|
|
|
|
# Your language not exist, create it just for the form
|
|
|
|
var key = TranslationServer.get_locale()
|
2022-06-26 13:20:42 +00:00
|
|
|
$Window/NinePatchRect/V/H2/VBoxContainer/Select.add_item(TranslationServer.get_locale_name(key) + " (" + key + " !)", id)
|
2022-02-12 19:45:44 +00:00
|
|
|
selected = id
|
2022-06-26 13:20:42 +00:00
|
|
|
$Window/NinePatchRect/V/H2/VBoxContainer/Select.select(selected)
|
2022-02-12 19:45:44 +00:00
|
|
|
|
|
|
|
|
2022-02-12 22:15:01 +00:00
|
|
|
func _on_select_item_selected(_index):
|
2022-02-12 19:45:44 +00:00
|
|
|
var pos = 0
|
|
|
|
for key in TranslationServer.get_loaded_locales():
|
2022-06-26 13:20:42 +00:00
|
|
|
if pos == $Window/NinePatchRect/V/H2/VBoxContainer/Select.get_selected():
|
2022-02-12 19:45:44 +00:00
|
|
|
TranslationServer.set_locale(key)
|
|
|
|
return
|
|
|
|
pos += 1
|
|
|
|
|
|
|
|
|
|
|
|
func _on_quit_pressed():
|
2022-06-15 20:53:34 +00:00
|
|
|
$Window.set_visible(false)
|
2022-06-26 13:20:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
func show_window():
|
|
|
|
Common.msg_debug("+ Open windows languages")
|
|
|
|
$Window.show_window()
|
|
|
|
#.visible = true
|
|
|
|
|