From cbfbc584fae1525a79c5179c3ed8517e79501fe1 Mon Sep 17 00:00:00 2001
From: jkpete <1031139173@qq.com>
Date: Thu, 9 Jan 2025 16:43:45 +0800
Subject: [PATCH] add thread and dapper
---
EGFramework.csproj | 2 +
Example/UsingTest/Script/EGSaveTest.cs | 10 ++---
.../Module/Extension/EGDateTimeExtension.cs | 21 +++++++---
.../Module/NodeExtension/EGNode.cs | 20 ++++++++++
.../Module/NodeExtension/EGThread.cs | 26 +++++++++++++
.../Module/NodeExtension/EGTweenExtension.cs | 8 ++--
.../EGFramework/Module/SaveTools/EGDapper.cs | 39 +++++++++++++++++++
.../EGFramework/Module/SaveTools/EGSqlite.cs | 5 ---
8 files changed, 112 insertions(+), 19 deletions(-)
create mode 100644 addons/EGFramework/Module/NodeExtension/EGThread.cs
create mode 100644 addons/EGFramework/Module/SaveTools/EGDapper.cs
diff --git a/EGFramework.csproj b/EGFramework.csproj
index f518583..07afd46 100644
--- a/EGFramework.csproj
+++ b/EGFramework.csproj
@@ -16,5 +16,7 @@
+
+
\ No newline at end of file
diff --git a/Example/UsingTest/Script/EGSaveTest.cs b/Example/UsingTest/Script/EGSaveTest.cs
index 6dab551..78d0a7e 100644
--- a/Example/UsingTest/Script/EGSaveTest.cs
+++ b/Example/UsingTest/Script/EGSaveTest.cs
@@ -6,11 +6,11 @@ using LiteDB;
namespace EGFramework.Examples.Test{
public partial class EGSaveTest : Node,IEGFramework
{
- public override void _Ready()
- {
- base._Ready();
- TestCode();
- }
+ public override void _Ready()
+ {
+ base._Ready();
+ TestCode();
+ }
public void TestSqlite(){
// string result = this.EGSqlite().CreateTable();
diff --git a/addons/EGFramework/Module/Extension/EGDateTimeExtension.cs b/addons/EGFramework/Module/Extension/EGDateTimeExtension.cs
index 61d58d6..8fc3f00 100644
--- a/addons/EGFramework/Module/Extension/EGDateTimeExtension.cs
+++ b/addons/EGFramework/Module/Extension/EGDateTimeExtension.cs
@@ -10,11 +10,22 @@ namespace EGFramework{
{
return DateTime.Now.ToString("HH:mm:ss");
}
- public static long GetTimeStamp(this IEGFramework self)
+ public static long GetDateTime(this object self)
{
- TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0, 0);
- return System.Convert.ToInt64(ts.TotalSeconds);
+ DateTime dt = DateTime.Now;
+ return dt.Ticks;
+ }
+ public static string GetFullDateMsg(this long ticks){
+ DateTime dateTime = new DateTime(ticks);
+ return dateTime.ToString("yyyy-MM-dd") + " " + dateTime.ToString("HH:mm:ss");
+ }
+ public static string GetDayDateMsg(this long ticks){
+ DateTime dateTime = new DateTime(ticks);
+ return dateTime.ToString("HH:mm:ss");
+ }
+ public static string GetDateMsg(this long ticks){
+ DateTime dateTime = new DateTime(ticks);
+ return dateTime.ToString("yyyy-MM-dd");
}
}
-}
-
+}
\ No newline at end of file
diff --git a/addons/EGFramework/Module/NodeExtension/EGNode.cs b/addons/EGFramework/Module/NodeExtension/EGNode.cs
index af55e86..37d373c 100644
--- a/addons/EGFramework/Module/NodeExtension/EGNode.cs
+++ b/addons/EGFramework/Module/NodeExtension/EGNode.cs
@@ -25,5 +25,25 @@ namespace EGFramework{
}
}
+ public static void ClearChildren(this Node itemContainer) where T : Node
+ {
+ foreach (Node child in itemContainer.GetChildren())
+ {
+ if(child.GetType()==typeof(T)){
+ child.QueueFree();
+ }
+ }
+ }
+
+ public static void ClearChildrenLabel(this Node itemContainer)
+ {
+ foreach (Node child in itemContainer.GetChildren())
+ {
+ if(child.GetType()==typeof(Label)){
+ child.QueueFree();
+ }
+ }
+ }
+
}
}
\ No newline at end of file
diff --git a/addons/EGFramework/Module/NodeExtension/EGThread.cs b/addons/EGFramework/Module/NodeExtension/EGThread.cs
new file mode 100644
index 0000000..1de26ec
--- /dev/null
+++ b/addons/EGFramework/Module/NodeExtension/EGThread.cs
@@ -0,0 +1,26 @@
+using Godot;
+using static Godot.GD;
+using System;
+namespace EGFramework{
+ public partial class EGThread : Node{
+ public override void _Ready()
+ {
+ base._Ready();
+ }
+
+ public override void _Process(double delta)
+ {
+ base._Process(delta);
+ }
+ }
+ public static class EGThreadExtension
+ {
+ public static void ExecuteInMainThread(this Node self, Action action){
+ //action.Invoke();
+ }
+
+ public static void ExecuteAfterSecond(this Node self, Action action,float delay){
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs b/addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs
index 183f0c9..84d3c71 100644
--- a/addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs
+++ b/addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs
@@ -5,10 +5,10 @@ namespace EGFramework.EGTween{
public static class EGTweenExtension
{
#region Function
- public static Tween KillOnEnd(this Tween self){
- self.TweenCallback(Callable.From(self.Kill));
- return self;
- }
+ public static Tween KillOnEnd(this Tween self){
+ self.TweenCallback(Callable.From(self.Kill));
+ return self;
+ }
#endregion
#region Position
public static Tween TweenPosition(this Control self,Vector2 position,float delay){
diff --git a/addons/EGFramework/Module/SaveTools/EGDapper.cs b/addons/EGFramework/Module/SaveTools/EGDapper.cs
new file mode 100644
index 0000000..91ef747
--- /dev/null
+++ b/addons/EGFramework/Module/SaveTools/EGDapper.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Common;
+using System.Linq.Expressions;
+
+//ORM Save tools. First support SQLite and MySQL,In future we will support other Database who implement DBConnection.
+namespace EGFramework{
+ public class EGDapper : IEGSave, IEGSaveData
+ {
+ ///
+ ///
+ ///
+ /// files conn Str or address ip port,username and passwd
+ public void InitSaveFile(string conn)
+ {
+ throw new System.NotImplementedException();
+ }
+
+ public IEnumerable FindData(string dataKey, Expression> expression) where TData : new()
+ {
+ throw new NotImplementedException();
+ }
+
+ public IEnumerable GetAll(string dataKey) where TData : new()
+ {
+ throw new NotImplementedException();
+ }
+
+ public TData GetData(string dataKey, object id) where TData : new()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SetData(string dataKey, TData data, object id)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/addons/EGFramework/Module/SaveTools/EGSqlite.cs b/addons/EGFramework/Module/SaveTools/EGSqlite.cs
index 747f47b..d9f37c5 100644
--- a/addons/EGFramework/Module/SaveTools/EGSqlite.cs
+++ b/addons/EGFramework/Module/SaveTools/EGSqlite.cs
@@ -6,11 +6,6 @@ using Microsoft.Data.Sqlite;
using Newtonsoft.Json;
namespace EGFramework{
- public interface IEGSqlite{
- void SaveData(TData data) where TData : new();
- List GetDataSet() where TData : new();
- void InitDatabase(string dataBaseName);
- }
public class EGSqlite : EGModule
{
public string DBName = "Default";