新增保存设置

pull/1/head
PJ568 11 months ago
parent 75d2fbc868
commit 47b5588323

@ -0,0 +1,60 @@
extends Node
const CONFIG_PATH = "user://settings.cfg"
func _ready():
()
func (index):
if index == 0:
TranslationServer.set_locale("zh")
elif index == 1:
TranslationServer.set_locale("zht")
elif index == 2:
TranslationServer.set_locale("en")
elif index == 3:
TranslationServer.set_locale("jp")
elif index == 4:
TranslationServer.set_locale("es")
else:
push_error("切换语言时,选项“%d”不存在!" % index)
TranslationServer.set_locale("en")
return index
func (index):
var file = ConfigFile.new()
file.set_value("General", "Language", index)
var error = file.save(CONFIG_PATH)
if error != OK:
push_error("Failed to save config: %d" % error)
func (index):
((index))
func ():
var file = ConfigFile.new()
if FileAccess.file_exists(CONFIG_PATH):
var error = file.load(CONFIG_PATH)
if error == OK:
return (file.get_value("General", "Language", 0))
else:
push_warning("Failed to load config: %d", error)
return (0)
else:
var locale = OS.get_locale()
if locale == "zh_CN":
return (0)
elif locale == "zh_TW":
return (1)
elif locale == "en":
return (2)
elif locale == "jp":
return (3)
elif locale == "es":
return (4)

@ -4,38 +4,19 @@ extends Control
@onready var = $"面板/背景色/MarginContainer/色/内容按钮分隔/正文和标题分隔2/语言"
func _ready():
var locale = OS.get_locale()
if locale == "zh_CN":
_on__item_selected(0)
elif locale == "zh_TW":
_on__item_selected(1)
elif locale == "en":
_on__item_selected(2)
elif locale == "jp":
_on__item_selected(3)
elif locale == "es":
_on__item_selected(4)
@warning_ignore("unused_parameter")
func _unhandled_input(event) -> void:
if Input.is_action_pressed("归零") or Input.is_action_pressed("ui_menu") or Input.is_action_pressed("ui_home") or Input.is_action_pressed("ui_text_backspace") or Input.is_action_pressed("关于") or Input.is_action_pressed("ui_cancel"):
_on__pressed()
func _ready():
.selected = Global.()
func _on__pressed():
get_tree ().change_scene_to_file("res://主界面.tscn")
func _on__item_selected(index):
if index == 0:
TranslationServer.set_locale("zh")
elif index == 1:
TranslationServer.set_locale("zht")
elif index == 2:
TranslationServer.set_locale("en")
elif index == 3:
TranslationServer.set_locale("jp")
elif index == 4:
TranslationServer.set_locale("es")
Global.(index)

@ -19,6 +19,10 @@ boot_splash/image="res://Assets/568_Calc.png"
boot_splash/fullsize=false
config/icon="res://Assets/icon.svg"
[autoload]
Global="*res://Scripts/全局.gd"
[display]
window/size/viewport_width=720

@ -75,7 +75,6 @@ text_overrun_behavior = 2
[node name="语言" type="OptionButton" parent="面板/背景色/MarginContainer/色/内容按钮分隔/正文和标题分隔2"]
layout_mode = 2
theme_override_fonts/font = ExtResource("2_fcls7")
theme_override_font_sizes/font_size = 48
item_count = 5
popup/item_0/text = "简体中文"

Loading…
Cancel
Save