update: 更新到godot4.4.1,并大量重构代码

This commit is contained in:
ZZY
2025-06-09 18:17:06 +08:00
parent b27abb55a2
commit 3fa39fc71e
39 changed files with 801 additions and 790 deletions

View File

@ -1,65 +1,59 @@
using Godot;
using System;
using System.IO;
public partial class Setting : Control
{
Global global;
public partial class Setting : Control {
private GlobalManager global = GlobalManager.Instance;
private IConfigManager config = GlobalManager.Instance.ConfigManager;
int font_size;
LineEdit fontOut;
private LineEdit fontOut = null!;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
global = GetNode<Global>("/root/Global");
public override void _Ready() {
fontOut = GetNode<LineEdit>("BoxContainer/MarginContainer5/HBoxContainer/FontSize");
font_size = (int)global.GlobalConfigDict["font_size"];
font_size = config.GetValue<int>("font_size");
GetNode<HSlider>("BoxContainer/MarginContainer6/FontSizeBar")
.Value = font_size;
fontOut.Text = font_size.ToString();
FillingData();
}
private void FillingData()
{
private void FillingData() {
GetNode<LineEdit>("BoxContainer/MarginContainer2/Server/LineEdit")
.Text = global.GlobalConfigDict["server_url"].ToString();
.Text = config.GetValue<string>("server_url");
GetNode<LineEdit>("BoxContainer/MarginContainer3/Name/LineEdit")
.Text = global.GlobalConfigDict["user_name"].ToString();
.Text = config.GetValue<string>("user_name");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
public override void _Process(double delta) {
}
private void OnBack() {
global.GotoScene("res://Main.tscn", null);
}
private void OnSave() {
global.SaveConfig();
// OS.Alert("Saved", "Setting");
}
void OnNameChanged(string Value)
{
global.GlobalConfigDict["user_name"] = Value;
// global.ConfigFlush();
}
void OnNameChanged(string Value) {
config.SetValue("user_name", Value);
// config.GetValue<>Flush();
}
private void OnServerUrlChanged(string Value)
{
global.GlobalConfigDict["server_url"] = Value;
// global.ConfigFlush();
}
private void OnServerUrlChanged(string Value) {
config.SetValue("server_url", Value);
// config.GetValue<>Flush();
}
private void OnFontSizeChanged(float Value)
{
private void OnFontSizeChanged(float Value) {
font_size = (int)Value;
global.GlobalConfigDict["font_size"] = font_size;
global.ConfigFlush();
config.SetValue("font_size", font_size);
global.GlobalThemeConfigFlush();
fontOut.Text = font_size.ToString();
}
}
private static void OnClearData() {
// ProjectSettings.GlobalizePath("user://");
@ -77,6 +71,11 @@ public partial class Setting : Control
}
}
private static void OnGetSettingsFile() {
string path = ProjectSettings.GlobalizePath(GlobalManager.ConfigPath);
OS.ShellOpen(Path.GetDirectoryName(path));
}
private static void OnGetCacheDir() {
OS.Alert(OS.GetCacheDir(), "Cache Dir");
}
@ -92,4 +91,7 @@ public partial class Setting : Control
private static void OnGetUserDataDir() {
OS.Alert(OS.GetUserDataDir(), "User Data Dir");
}
private static void ChangeLangZHCN(bool _) => TranslationServer.SetLocale("zh_CN");
private static void ChangeLangEN(bool _) => TranslationServer.SetLocale("en");
}