diff --git a/addons/EGFramework/EGPlatform.cs b/addons/EGFramework/EGPlatform.cs index 571cb7c..a8d8cbf 100644 --- a/addons/EGFramework/EGPlatform.cs +++ b/addons/EGFramework/EGPlatform.cs @@ -16,6 +16,15 @@ namespace EGFramework{ // Console.WriteLine(what); } } + // if not use please explain this + public class EGPlatformDotnet : IPlatform{ + public void Log(string message){ + Console.WriteLine(message); + } + public void Log(params object[] what){ + Console.WriteLine(what); + } + } public static class EG { public static EGPlatformGodot Platform = new EGPlatformGodot(); diff --git a/addons/EGFramework/Module/EGMessage.cs b/addons/EGFramework/Module/EGMessage.cs index 531717c..7a08f76 100644 --- a/addons/EGFramework/Module/EGMessage.cs +++ b/addons/EGFramework/Module/EGMessage.cs @@ -15,7 +15,7 @@ namespace EGFramework public EasyEvent OnRequest { set; get; } = new EasyEvent(); /// - /// Send delay in millisecond,if you don't need a Timer to delay send message,you can set it to 0. + /// Send delay in millisecond,if you don't need a Timer to delay send message,you can set it to 0. ( this delay options is prevent for sticky package ) /// /// public int SendDelay { set; get; } = 100; diff --git a/addons/EGFramework/Module/NodeExtension/EGGodotPath.cs b/addons/EGFramework/Module/NodeExtension/EGGodotPath.cs new file mode 100644 index 0000000..158d9d3 --- /dev/null +++ b/addons/EGFramework/Module/NodeExtension/EGGodotPath.cs @@ -0,0 +1,38 @@ +using Godot; + +namespace EGFramework{ + + public partial class EGGodotPath : IModule, IEGFramework + { + public void Init() + { + + } + + public void OpenResPath(){ + OS.ShellOpen("".GetGodotResPath()); + } + + public void OpenUserPath(){ + OS.ShellOpen("".GetGodotUserPath()); + } + public IArchitecture GetArchitecture() + { + throw new System.NotImplementedException(); + } + + + } + + public static class GodotPathExtension{ + + public static string GetGodotResPath(this string path){ + return ProjectSettings.GlobalizePath("res://"+path); + } + + public static string GetGodotUserPath(this string path){ + return ProjectSettings.GlobalizePath("user://"+path); + } + + } +} \ No newline at end of file diff --git a/addons/EGFramework/Module/NodeExtension/EGProtocolScheduleGodot.cs b/addons/EGFramework/Module/NodeExtension/EGProtocolScheduleGodot.cs new file mode 100644 index 0000000..bdee3e9 --- /dev/null +++ b/addons/EGFramework/Module/NodeExtension/EGProtocolScheduleGodot.cs @@ -0,0 +1,37 @@ +using Godot; + +namespace EGFramework{ + /// + /// In Godot engine, the async method return cannot operate the godot main thread such as Screen Trees Node. + /// The protocol schedule provide a main thread to check the message in protocol tools 's response message. + /// If you have more idea ,please issue to me, thanks. + /// + public partial class EGProtocolScheduleGodot : Node, IModule, IEGFramework + { + public EGProtocolSchedule ProtocolSchedule { set; get; } = new EGProtocolSchedule(); + public override void _Process(double delta) + { + ProtocolSchedule.CheckedProcess(); + } + public void Init() + { + + } + public IArchitecture GetArchitecture() + { + return EGArchitectureImplement.Interface; + } + } + + public static class CanGetEGProtocolInGodotExtension{ + public static EGProtocolSchedule EGProtocolSchedule(this Node self){ + return self.NodeModule().ProtocolSchedule; + } + public static void EGEnabledProtocolTools(this Node self){ + self.NodeModule().ProtocolSchedule.EnabledAllTools(); + } + public static void EGEnabledProtocolTool(this Node self) where TProtocolReceived : class, IModule,IProtocolReceived,new(){ + self.NodeModule().ProtocolSchedule.EnabledTool(); + } + } +} \ No newline at end of file diff --git a/addons/EGFramework/Module/ProtocolTools/EGProtocolSchedule.cs b/addons/EGFramework/Module/ProtocolTools/EGProtocolSchedule.cs index 3a9e2b8..76b3e0b 100644 --- a/addons/EGFramework/Module/ProtocolTools/EGProtocolSchedule.cs +++ b/addons/EGFramework/Module/ProtocolTools/EGProtocolSchedule.cs @@ -3,21 +3,11 @@ using System; using System.Collections.Generic; namespace EGFramework{ - /// - /// In Godot engine, the async method return cannot operate the godot main thread such as Screen Trees Node. - /// The protocol schedule provide a main thread to check the message in protocol tools 's response message. - /// If you have more idea ,please issue to me, thanks. - /// - public partial class EGProtocolSchedule : Node, IModule,IEGFramework + public class EGProtocolSchedule : IEGFramework { public Dictionary ProtocolTools = new Dictionary(); - public void Init() - { - - } - public override void _Process(double delta) - { + public void CheckedProcess(){ foreach(IProtocolReceived tool in ProtocolTools.Values){ if(tool.GetReceivedMsg().Count>0){ this.GetModule().OnDataReceived.Invoke(tool.GetReceivedMsg().Dequeue()); @@ -55,17 +45,5 @@ namespace EGFramework{ } } - public static class CanGetEGProtocolExtension{ - public static EGProtocolSchedule EGProtocolSchedule(this Node self){ - return self.NodeModule(); - } - public static void EGEnabledProtocolTools(this Node self){ - self.NodeModule().EnabledAllTools(); - } - public static void EGEnabledProtocolTool(this Node self) where TProtocolReceived : class, IModule,IProtocolReceived,new(){ - self.NodeModule().EnabledTool(); - } - - } } diff --git a/addons/EGFramework/Module/ProtocolTools/EGSsh.cs b/addons/EGFramework/Module/ProtocolTools/EGSsh.cs index 62ce79c..04aa99d 100644 --- a/addons/EGFramework/Module/ProtocolTools/EGSsh.cs +++ b/addons/EGFramework/Module/ProtocolTools/EGSsh.cs @@ -83,7 +83,7 @@ namespace EGFramework{ }else{ CancellationTokenSource sourceReconnect = new CancellationTokenSource(); CancellationToken tokenReconnect = sourceReconnect.Token; - tokenReconnect.Register(() => Godot.GD.Print("Ssh connect timeout!")); + tokenReconnect.Register(() => EG.Print("Ssh connect timeout!")); await SshClientDevices[host].ConnectAsync(tokenReconnect); if(!SshClientDevices[host].IsConnected){ return false; @@ -96,7 +96,7 @@ namespace EGFramework{ SshClient client = new SshClient(host, username, keyFile); CancellationTokenSource source = new CancellationTokenSource(); CancellationToken token = source.Token; - token.Register(() => Godot.GD.Print("Ssh connect timeout!")); + token.Register(() => EG.Print("Ssh connect timeout!")); source.CancelAfter(TimeOutDelay); await client.ConnectAsync(token); if(!client.IsConnected){ diff --git a/addons/EGFramework/Module/ProtocolTools/EGUDP.cs b/addons/EGFramework/Module/ProtocolTools/EGUDP.cs index c898a91..8ff4cea 100644 --- a/addons/EGFramework/Module/ProtocolTools/EGUDP.cs +++ b/addons/EGFramework/Module/ProtocolTools/EGUDP.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Net.Sockets; using System.Text; -using Godot; + namespace EGFramework{ public class EGUDP : IEGFramework, IModule, IProtocolSend, IProtocolReceived { diff --git a/addons/EGFramework/Module/SaveTools/EGSave.cs b/addons/EGFramework/Module/SaveTools/EGSave.cs index c6a0b9e..28f1502 100644 --- a/addons/EGFramework/Module/SaveTools/EGSave.cs +++ b/addons/EGFramework/Module/SaveTools/EGSave.cs @@ -1,7 +1,6 @@ using System; using System.IO; using System.Collections.Generic; -using Godot; namespace EGFramework { @@ -33,7 +32,7 @@ namespace EGFramework public EGSave() {} public override void Init() { - LoadObjectFile("SaveData/DefaultJsonSave.json".GetGodotResPath()); + LoadObjectFile("SaveData/DefaultJsonSave.json"); } public void LoadDataFile(string path) where TSaveData:IEGSaveData,IEGSave,new(){ @@ -196,32 +195,12 @@ namespace EGFramework } #endregion - //------------------------------------------------------------------------------// - - - public void OpenResPath(){ - OS.ShellOpen("".GetGodotResPath()); - } - - public void OpenUserPath(){ - OS.ShellOpen("".GetGodotUserPath()); - } - - } public static class CanGetEGSaveExtension{ public static EGSave EGSave(this IEGFramework self){ return self.GetModule(); } - - public static string GetGodotResPath(this string path){ - return ProjectSettings.GlobalizePath("res://"+path); - } - - public static string GetGodotUserPath(this string path){ - return ProjectSettings.GlobalizePath("user://"+path); - } public static string GetDirectoryName(this string path){ return Path.GetDirectoryName(path);