refactor(重构): 重构了事件驱动的代码体系,使用全新命名和版本,以及测试套件的初试
- 移除了.csproj文件 - 更新了.gitignore,添加了.editorconfig - 重构了IBoard和IPiece接口,引入了新的事件处理机制 - 优化了CCBoard、CCPiece等类的实现,使用新的事件驱动模型 - 删除了冗余代码,提高了代码的可读性和可维护性
This commit is contained in:
@ -1,15 +1,15 @@
|
||||
#nullable disable
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
using RPPackage;
|
||||
|
||||
public partial class Global : Node
|
||||
{
|
||||
public partial class Global : Node {
|
||||
public RPClientEDWS RPClient = new();
|
||||
public string sessionId;
|
||||
public Node CurrentScene { get; set; }
|
||||
public Theme GlobalTheme = null;
|
||||
|
||||
readonly GodotConfigManager GlobalConfig = new("user://config.cfg");
|
||||
readonly GodotConfigManager GlobalConfig = new("user://config.cfg");
|
||||
public Dictionary<string, Variant> GlobalConfigDict = new() {
|
||||
{"font_size", 20},
|
||||
{"server_url", "wss://game.zzyxyz.com/"},
|
||||
@ -21,8 +21,7 @@ public partial class Global : Node
|
||||
};
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
public override void _Ready() {
|
||||
if (OS.GetName() == "Android") {
|
||||
bool ret = OS.RequestPermissions();
|
||||
GD.Print($"RequestPermissions ret is {ret}");
|
||||
@ -37,41 +36,36 @@ public partial class Global : Node
|
||||
};
|
||||
|
||||
Viewport root = GetTree().Root;
|
||||
CurrentScene = root.GetChild(root.GetChildCount() - 1);
|
||||
CurrentScene = root.GetChild(root.GetChildCount() - 1);
|
||||
|
||||
GlobalConfig.LoadConfig("Global", GlobalConfigDict);
|
||||
SetProcess(false);
|
||||
}
|
||||
|
||||
public void ConfigFlush()
|
||||
{
|
||||
public void ConfigFlush() {
|
||||
int font_size = (int)GlobalConfigDict["font_size"];
|
||||
GlobalTheme.DefaultFontSize = font_size;
|
||||
// GlobalTheme?.SetFontSize("font_size", "Label", font_size);
|
||||
// GlobalTheme?.SetFontSize("font_size", "Button", font_size);
|
||||
// GlobalTheme?.SetFontSize("font_size", "TextEdit", font_size);
|
||||
// GlobalTheme?.SetFontSize("font_size", "LineEdit", font_size);
|
||||
// GlobalTheme?.SetFontSize("font_size", "Button", font_size);
|
||||
// GlobalTheme?.SetFontSize("font_size", "TextEdit", font_size);
|
||||
// GlobalTheme?.SetFontSize("font_size", "LineEdit", font_size);
|
||||
// CurrentScene.GetWindow().AddThemeFontSizeOverride("Control", (int)GlobalConfigDict["font_size"]);
|
||||
}
|
||||
|
||||
private void OnGotoScene()
|
||||
{
|
||||
private void OnGotoScene() {
|
||||
ConfigFlush();
|
||||
}
|
||||
|
||||
public void SaveConfig()
|
||||
{
|
||||
public void SaveConfig() {
|
||||
GlobalConfig.SaveConfig("Global", GlobalConfigDict);
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
public override void _Process(double delta) {
|
||||
RPClient.PollEx(delta);
|
||||
}
|
||||
|
||||
public override void _Notification(int what)
|
||||
{
|
||||
public override void _Notification(int what) {
|
||||
if (what == NotificationWMCloseRequest) {
|
||||
// SaveConfig();
|
||||
RPClient.Close();
|
||||
@ -81,8 +75,7 @@ public partial class Global : Node
|
||||
|
||||
public delegate void ChangeSceneCallback(Node newSence);
|
||||
private static ChangeSceneCallback changeSceneCallback = null;
|
||||
public void GotoScene(string path, ChangeSceneCallback callback = null)
|
||||
{
|
||||
public void GotoScene(string path, ChangeSceneCallback callback = null) {
|
||||
// This function will usually be called from a signal callback,
|
||||
// or some other function from the current scene.
|
||||
// Deleting the current scene at this point is
|
||||
@ -100,8 +93,7 @@ public partial class Global : Node
|
||||
changeSceneCallback = null;
|
||||
}
|
||||
|
||||
public void DeferredGotoScene(string path, Callable onLoaded)
|
||||
{
|
||||
public void DeferredGotoScene(string path, Callable onLoaded) {
|
||||
// It is now safe to remove the current scene.
|
||||
CurrentScene.Free();
|
||||
|
||||
|
Reference in New Issue
Block a user