You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
568_Calc/Scripts/全局.gd

94 lines
2.1 KiB

11 months ago
extends Node
10 months ago
const CONFIG_PATH := "user://settings.cfg"
#var 应该使用字体 := false
11 months ago
func _ready():
10 months ago
#根据语言切换主题(读取设置并更改语言())
()
()
11 months ago
func (index):
if index == 0:
10 months ago
return ()
11 months ago
elif index == 1:
TranslationServer.set_locale("zh")
11 months ago
elif index == 2:
TranslationServer.set_locale("zht")
11 months ago
elif index == 3:
TranslationServer.set_locale("en")
11 months ago
elif index == 4:
TranslationServer.set_locale("jp")
elif index == 5:
11 months ago
TranslationServer.set_locale("es")
else:
push_error("切换语言时,选项“%d”不存在!" % index)
TranslationServer.set_locale("en")
return index
func (index):
10 months ago
var file := ConfigFile.new()
11 months ago
file.set_value("General", "Language", index)
10 months ago
var error := file.save(CONFIG_PATH)
11 months ago
if error != OK:
push_error("Failed to save config: %d" % error)
func (index):
10 months ago
return ((index))
11 months ago
10 months ago
func ():
var file := ConfigFile.new()
11 months ago
if FileAccess.file_exists(CONFIG_PATH):
10 months ago
var error := file.load(CONFIG_PATH)
11 months ago
if error == OK:
10 months ago
return file.get_value("General", "Language", 0)
11 months ago
else:
push_warning("Failed to load config: %d", error)
10 months ago
return ()
func ():
return (())
func ():
10 months ago
var locale := OS.get_locale()
if locale == "zh_CN":
10 months ago
(1)
elif locale == "zh_TW":
10 months ago
(2)
elif locale == "en":
10 months ago
(3)
elif locale == "jp":
10 months ago
(4)
elif locale == "es":
10 months ago
(5)
else:
10 months ago
(3)
return 0
func ():
10 months ago
return (0)
#func 根据语言切换主题(index):
#if index == 1 or index == 3 or index == 5:
#应该使用字体 = true
##propagate_call(“update”)
#else:
#应该使用字体 = false
func ():
10 months ago
var sys_name := OS.get_name()
if sys_name != "Android" and sys_name != "iOS" and sys_name != "Web":
get_viewport().size = Vector2(DisplayServer.screen_get_dpi() * 3.5, DisplayServer.screen_get_dpi() * 6.2)