2022-02-15 22:21:57 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
|
|
signal update_theme
|
|
|
|
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
$Window/VBoxContainer/Select.clear()
|
|
|
|
var id = 0
|
|
|
|
var selected = -1
|
|
|
|
var near_selected = -1
|
|
|
|
var current_locale = Themes.current_theme
|
|
|
|
var root_language = current_locale.split('_')[0]
|
|
|
|
for key in Themes.THEMES_CONTROL:
|
|
|
|
if key == current_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
|
|
|
|
$Window/VBoxContainer/Select.add_item( key, id )
|
|
|
|
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 = current_locale
|
|
|
|
$Window/VBoxContainer/Select.add_item( key, id)
|
|
|
|
selected = id
|
|
|
|
$Window/VBoxContainer/Select.select(selected)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_quit_pressed():
|
|
|
|
$Window.visible = false
|
|
|
|
|
|
|
|
|
2022-02-25 00:28:14 +00:00
|
|
|
func _on_select_item_selected(_index):
|
2022-02-15 22:21:57 +00:00
|
|
|
var pos = 0
|
|
|
|
for key in Themes.THEMES_CONTROL:
|
|
|
|
if pos == $Window/VBoxContainer/Select.get_selected():
|
|
|
|
Themes.current_theme = key
|
|
|
|
emit_signal( "update_theme" )
|
|
|
|
return
|
|
|
|
pos += 1
|