Browse Source

arrange the example

master
jkpete 3 months ago
parent
commit
3bd3eae1e7
  1. 6
      Example/OldTest/Action3D/MainGame.tscn
  2. 0
      Example/OldTest/Action3D/Script/ActionCamera.cs
  3. 0
      Example/OldTest/Action3D/Script/ActionPlayer.cs
  4. 0
      Example/OldTest/Action3D/SkyBox/lakeside.jpg
  5. 8
      Example/OldTest/Action3D/SkyBox/lakeside.jpg.import
  6. 8
      Example/OldTest/Gateway/Gateway.tscn
  7. 0
      Example/OldTest/Gateway/GatewayManual/BacnetGatewayManual_CN.md
  8. 2
      Example/OldTest/Gateway/ModbusGateway.tscn
  9. 0
      Example/OldTest/Gateway/Script/Data/DataBacNetGatewaySetting.cs
  10. 0
      Example/OldTest/Gateway/Script/Data/DataGatewayInfo.cs
  11. 0
      Example/OldTest/Gateway/Script/Data/DataModbusGatewaySettings.cs
  12. 0
      Example/OldTest/Gateway/Script/Data/DataTcpGatewaySetting.cs
  13. 0
      Example/OldTest/Gateway/Script/Interface/IGateway.cs
  14. 0
      Example/OldTest/Gateway/Script/OutData/ValueGenerator.cs
  15. 0
      Example/OldTest/Gateway/Script/View/ViewBacNetGateway.cs
  16. 0
      Example/OldTest/Gateway/Script/View/ViewBacnetHttpServer.cs
  17. 0
      Example/OldTest/Gateway/Script/View/ViewGateway.cs
  18. 0
      Example/OldTest/Gateway/Script/View/ViewModbusGateway.cs
  19. 0
      Example/OldTest/Gateway/Script/View/ViewTcpGateway.cs
  20. 2
      Example/OldTest/ModbusDebugTool/Component/modbus_item.tscn
  21. 0
      Example/OldTest/ModbusDebugTool/Script/DataModbusItem.cs
  22. 0
      Example/OldTest/ModbusDebugTool/Script/ViewEdit.cs
  23. 0
      Example/OldTest/ModbusDebugTool/Script/ViewMenu.cs
  24. 0
      Example/OldTest/ModbusDebugTool/Script/ViewMessage.cs
  25. 0
      Example/OldTest/ModbusDebugTool/Script/ViewModbusItem.cs
  26. 0
      Example/OldTest/ModbusDebugTool/Script/ViewSettings.cs
  27. 10
      Example/OldTest/ModbusDebugTool/TestModbus.tscn
  28. 2
      Example/OldTest/SystemExamples/ItemList/HPPotion.tres
  29. 0
      Example/OldTest/SystemExamples/ItemList/ItemList.CSV.import
  30. 0
      Example/OldTest/SystemExamples/ItemList/ItemList.json
  31. 0
      Example/OldTest/SystemExamples/ItemList/ItemList.txt
  32. 2
      Example/OldTest/SystemExamples/PlayerStorage/PlayerStorage.tscn
  33. 0
      Example/OldTest/SystemExamples/PlayerStorage/Script/DataStorageItem.cs
  34. 0
      Example/OldTest/SystemExamples/PlayerStorage/Script/InterfaceStorage.cs
  35. 0
      Example/OldTest/SystemExamples/PlayerStorage/Script/ViewStorage.cs
  36. 12
      Example/SaveSystem/Scene/SaveSystem.tscn
  37. 21
      Example/SaveSystem/Script/ViewSaveSystem.cs
  38. 14
      Example/Theme/StyleBox/CardFrame.tres
  39. 3
      Example/Theme/White/White.tres
  40. 4
      Example/Tween/EGTween.tscn
  41. 26
      Example/UsingTest/Scene/TestEGFramework.tscn
  42. 45
      Example/UsingTest/Script/EGMDnsTest.cs
  43. 249
      Example/UsingTest/Script/EGSaveTest.cs
  44. 315
      Example/UsingTest/Script/EGTest.cs
  45. 76
      ReadMe.md
  46. 16
      addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs

6
Example/Action3D/MainGame.tscn → Example/OldTest/Action3D/MainGame.tscn

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
[gd_scene load_steps=19 format=3 uid="uid://05atvgqt8tku"]
[ext_resource type="Texture2D" uid="uid://ss8dh8aaqc4w" path="res://Example/Action3D/SkyBox/lakeside.jpg" id="1_akq3m"]
[ext_resource type="Texture2D" uid="uid://ss8dh8aaqc4w" path="res://Example/OldTest/Action3D/SkyBox/lakeside.jpg" id="1_akq3m"]
[ext_resource type="Texture2D" uid="uid://31r216hix0wk" path="res://icon.svg" id="2_b66wh"]
[ext_resource type="Script" path="res://Example/Action3D/Script/ActionPlayer.cs" id="2_c0s4j"]
[ext_resource type="Script" path="res://Example/Action3D/Script/ActionCamera.cs" id="3_ue0e3"]
[ext_resource type="Script" path="res://Example/OldTest/Action3D/Script/ActionPlayer.cs" id="2_c0s4j"]
[ext_resource type="Script" path="res://Example/OldTest/Action3D/Script/ActionCamera.cs" id="3_ue0e3"]
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_hbme1"]
panorama = ExtResource("1_akq3m")

0
Example/Action3D/Script/ActionCamera.cs → Example/OldTest/Action3D/Script/ActionCamera.cs

0
Example/Action3D/Script/ActionPlayer.cs → Example/OldTest/Action3D/Script/ActionPlayer.cs

0
Example/Action3D/SkyBox/lakeside.jpg → Example/OldTest/Action3D/SkyBox/lakeside.jpg

Before

Width:  |  Height:  |  Size: 4.1 MiB

After

Width:  |  Height:  |  Size: 4.1 MiB

8
Example/Action3D/SkyBox/lakeside.jpg.import → Example/OldTest/Action3D/SkyBox/lakeside.jpg.import

@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://ss8dh8aaqc4w"
path.s3tc="res://.godot/imported/lakeside.jpg-33a4031d53286dbc1f7dd66477cda464.s3tc.ctex"
path.etc2="res://.godot/imported/lakeside.jpg-33a4031d53286dbc1f7dd66477cda464.etc2.ctex"
path.s3tc="res://.godot/imported/lakeside.jpg-73a51a0ded8953c63fe1a3672086bc03.s3tc.ctex"
path.etc2="res://.godot/imported/lakeside.jpg-73a51a0ded8953c63fe1a3672086bc03.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
@ -12,8 +12,8 @@ metadata={ @@ -12,8 +12,8 @@ metadata={
[deps]
source_file="res://Example/Action3D/SkyBox/lakeside.jpg"
dest_files=["res://.godot/imported/lakeside.jpg-33a4031d53286dbc1f7dd66477cda464.s3tc.ctex", "res://.godot/imported/lakeside.jpg-33a4031d53286dbc1f7dd66477cda464.etc2.ctex"]
source_file="res://Example/OldTest/Action3D/SkyBox/lakeside.jpg"
dest_files=["res://.godot/imported/lakeside.jpg-73a51a0ded8953c63fe1a3672086bc03.s3tc.ctex", "res://.godot/imported/lakeside.jpg-73a51a0ded8953c63fe1a3672086bc03.etc2.ctex"]
[params]

8
Example/Gateway/Gateway.tscn → Example/OldTest/Gateway/Gateway.tscn

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
[gd_scene load_steps=6 format=3 uid="uid://hp4ae14r3hpm"]
[ext_resource type="Script" path="res://Example/Gateway/Script/View/ViewGateway.cs" id="1_tas7d"]
[ext_resource type="Script" path="res://Example/Gateway/Script/View/ViewTcpGateway.cs" id="2_ct4oh"]
[ext_resource type="Script" path="res://Example/Gateway/Script/View/ViewBacNetGateway.cs" id="3_ip8nj"]
[ext_resource type="Script" path="res://Example/Gateway/Script/View/ViewBacnetHttpServer.cs" id="4_plubp"]
[ext_resource type="Script" path="res://Example/OldTest/Gateway/Script/View/ViewGateway.cs" id="1_tas7d"]
[ext_resource type="Script" path="res://Example/OldTest/Gateway/Script/View/ViewTcpGateway.cs" id="2_ct4oh"]
[ext_resource type="Script" path="res://Example/OldTest/Gateway/Script/View/ViewBacNetGateway.cs" id="3_ip8nj"]
[ext_resource type="Script" path="res://Example/OldTest/Gateway/Script/View/ViewBacnetHttpServer.cs" id="4_plubp"]
[ext_resource type="FontFile" uid="uid://b1atsgy4xkk7d" path="res://Font/SourceHanSansCN-Regular.otf" id="5_q4lsg"]
[node name="Gateway" type="Control"]

0
Example/Gateway/GatewayManual/BacnetGatewayManual_CN.md → Example/OldTest/Gateway/GatewayManual/BacnetGatewayManual_CN.md

2
Example/Gateway/ModbusGateway.tscn → Example/OldTest/Gateway/ModbusGateway.tscn

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://c8vhi8ojdtjnb"]
[ext_resource type="Script" path="res://Example/Gateway/Script/View/ViewModbusGateway.cs" id="1_34uaa"]
[ext_resource type="Script" path="res://Example/OldTest/Gateway/Script/View/ViewModbusGateway.cs" id="1_34uaa"]
[node name="ModbusGateway" type="Control"]
layout_mode = 3

0
Example/Gateway/Script/Data/DataBacNetGatewaySetting.cs → Example/OldTest/Gateway/Script/Data/DataBacNetGatewaySetting.cs

0
Example/Gateway/Script/Data/DataGatewayInfo.cs → Example/OldTest/Gateway/Script/Data/DataGatewayInfo.cs

0
Example/Gateway/Script/Data/DataModbusGatewaySettings.cs → Example/OldTest/Gateway/Script/Data/DataModbusGatewaySettings.cs

0
Example/Gateway/Script/Data/DataTcpGatewaySetting.cs → Example/OldTest/Gateway/Script/Data/DataTcpGatewaySetting.cs

0
Example/Gateway/Script/Interface/IGateway.cs → Example/OldTest/Gateway/Script/Interface/IGateway.cs

0
Example/Gateway/Script/OutData/ValueGenerator.cs → Example/OldTest/Gateway/Script/OutData/ValueGenerator.cs

0
Example/Gateway/Script/View/ViewBacNetGateway.cs → Example/OldTest/Gateway/Script/View/ViewBacNetGateway.cs

0
Example/Gateway/Script/View/ViewBacnetHttpServer.cs → Example/OldTest/Gateway/Script/View/ViewBacnetHttpServer.cs

0
Example/Gateway/Script/View/ViewGateway.cs → Example/OldTest/Gateway/Script/View/ViewGateway.cs

0
Example/Gateway/Script/View/ViewModbusGateway.cs → Example/OldTest/Gateway/Script/View/ViewModbusGateway.cs

0
Example/Gateway/Script/View/ViewTcpGateway.cs → Example/OldTest/Gateway/Script/View/ViewTcpGateway.cs

2
Example/ModbusDebugTool/Component/modbus_item.tscn → Example/OldTest/ModbusDebugTool/Component/modbus_item.tscn

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://c8kk7iegicmdr"]
[ext_resource type="Script" path="res://Example/ModbusDebugTool/Script/ViewModbusItem.cs" id="1_ih8g3"]
[ext_resource type="Script" path="res://Example/OldTest/ModbusDebugTool/Script/ViewModbusItem.cs" id="1_ih8g3"]
[ext_resource type="FontFile" uid="uid://b1atsgy4xkk7d" path="res://Font/SourceHanSansCN-Regular.otf" id="1_upshn"]
[node name="ModbusItem" type="Control"]

0
Example/ModbusDebugTool/Script/DataModbusItem.cs → Example/OldTest/ModbusDebugTool/Script/DataModbusItem.cs

0
Example/ModbusDebugTool/Script/ViewEdit.cs → Example/OldTest/ModbusDebugTool/Script/ViewEdit.cs

0
Example/ModbusDebugTool/Script/ViewMenu.cs → Example/OldTest/ModbusDebugTool/Script/ViewMenu.cs

0
Example/ModbusDebugTool/Script/ViewMessage.cs → Example/OldTest/ModbusDebugTool/Script/ViewMessage.cs

0
Example/ModbusDebugTool/Script/ViewModbusItem.cs → Example/OldTest/ModbusDebugTool/Script/ViewModbusItem.cs

0
Example/ModbusDebugTool/Script/ViewSettings.cs → Example/OldTest/ModbusDebugTool/Script/ViewSettings.cs

10
Example/ModbusDebugTool/TestModbus.tscn → Example/OldTest/ModbusDebugTool/TestModbus.tscn

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
[gd_scene load_steps=7 format=3 uid="uid://qo2w16ececmu"]
[ext_resource type="Script" path="res://Example/ModbusDebugTool/Script/ViewMenu.cs" id="1_7ubyu"]
[ext_resource type="Script" path="res://Example/OldTest/ModbusDebugTool/Script/ViewMenu.cs" id="1_7ubyu"]
[ext_resource type="FontFile" uid="uid://b1atsgy4xkk7d" path="res://Font/SourceHanSansCN-Regular.otf" id="1_tw1qu"]
[ext_resource type="PackedScene" uid="uid://c8kk7iegicmdr" path="res://Example/ModbusDebugTool/Component/modbus_item.tscn" id="3_c8jeq"]
[ext_resource type="Script" path="res://Example/ModbusDebugTool/Script/ViewEdit.cs" id="4_smsvf"]
[ext_resource type="Script" path="res://Example/ModbusDebugTool/Script/ViewMessage.cs" id="5_8s6lk"]
[ext_resource type="Script" path="res://Example/ModbusDebugTool/Script/ViewSettings.cs" id="6_38tri"]
[ext_resource type="PackedScene" uid="uid://c8kk7iegicmdr" path="res://Example/OldTest/ModbusDebugTool/Component/modbus_item.tscn" id="3_c8jeq"]
[ext_resource type="Script" path="res://Example/OldTest/ModbusDebugTool/Script/ViewEdit.cs" id="4_smsvf"]
[ext_resource type="Script" path="res://Example/OldTest/ModbusDebugTool/Script/ViewMessage.cs" id="5_8s6lk"]
[ext_resource type="Script" path="res://Example/OldTest/ModbusDebugTool/Script/ViewSettings.cs" id="6_38tri"]
[node name="Menu" type="Control"]
layout_mode = 3

2
Example/SystemExamples/ItemList/HPPotion.tres → Example/OldTest/SystemExamples/ItemList/HPPotion.tres

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://bhsavl0d80s6j"]
[ext_resource type="Script" path="res://Example/SystemExamples/PlayerStorage/Script/DataStorageItem.cs" id="1_j773b"]
[ext_resource type="Script" path="res://Example/OldTest/SystemExamples/PlayerStorage/Script/DataStorageItem.cs" id="1_j773b"]
[resource]
script = ExtResource("1_j773b")

0
Example/SystemExamples/ItemList/ItemList.CSV.import → Example/OldTest/SystemExamples/ItemList/ItemList.CSV.import

0
Example/SystemExamples/ItemList/ItemList.json → Example/OldTest/SystemExamples/ItemList/ItemList.json

0
Example/SystemExamples/ItemList/ItemList.txt → Example/OldTest/SystemExamples/ItemList/ItemList.txt

2
Example/SystemExamples/PlayerStorage/PlayerStorage.tscn → Example/OldTest/SystemExamples/PlayerStorage/PlayerStorage.tscn

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://tee7nc525si7"]
[ext_resource type="Script" path="res://Example/SystemExamples/PlayerStorage/Script/ViewStorage.cs" id="1_goow2"]
[ext_resource type="Script" path="res://Example/OldTest/SystemExamples/PlayerStorage/Script/ViewStorage.cs" id="1_goow2"]
[node name="PlayerStorage" type="Control"]
layout_mode = 3

0
Example/SystemExamples/PlayerStorage/Script/DataStorageItem.cs → Example/OldTest/SystemExamples/PlayerStorage/Script/DataStorageItem.cs

0
Example/SystemExamples/PlayerStorage/Script/InterfaceStorage.cs → Example/OldTest/SystemExamples/PlayerStorage/Script/InterfaceStorage.cs

0
Example/SystemExamples/PlayerStorage/Script/ViewStorage.cs → Example/OldTest/SystemExamples/PlayerStorage/Script/ViewStorage.cs

12
Example/SaveSystem/Scene/SaveSystem.tscn

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://bvnma1n064xbx"]
[ext_resource type="Script" path="res://Example/SaveSystem/Script/ViewSaveSystem.cs" id="1_mtdgp"]
[node name="SaveSystem" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_mtdgp")

21
Example/SaveSystem/Script/ViewSaveSystem.cs

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Godot;
using LiteDB;
using Renci.SshNet;
namespace EGFramework.Examples.Test{
public partial class ViewSaveSystem : Node,IEGFramework
{
public override void _Ready()
{
}
public override void _ExitTree()
{
}
}
}

14
Example/Theme/StyleBox/CardFrame.tres

@ -1,14 +0,0 @@ @@ -1,14 +0,0 @@
[gd_resource type="StyleBoxFlat" format=3 uid="uid://t4prctf3uxtb"]
[resource]
bg_color = Color(0.858824, 0.858824, 0.858824, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0, 0, 0, 1)
corner_radius_top_left = 16
corner_radius_top_right = 16
corner_radius_bottom_right = 16
corner_radius_bottom_left = 16
corner_detail = 1

3
Example/Theme/White/White.tres

@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
[gd_resource type="Theme" format=3 uid="uid://cbf2s7b2p1p2j"]
[resource]

4
Example/Tween/EGTween.tscn

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://1garq2laye1n"]
[gd_scene load_steps=2 format=3 uid="uid://1garq2laye1n"]
[ext_resource type="Script" path="res://Example/Tween/Script/TweenTest.cs" id="1_jpym0"]
[ext_resource type="StyleBox" uid="uid://t4prctf3uxtb" path="res://Example/Theme/StyleBox/CardFrame.tres" id="2_cbb73"]
[node name="EgTween" type="Control" node_paths=PackedStringArray("Target", "Target2D")]
layout_mode = 3
@ -20,7 +19,6 @@ Target2D = NodePath("Polygon2D") @@ -20,7 +19,6 @@ Target2D = NodePath("Polygon2D")
offset_right = 90.0
offset_bottom = 160.0
pivot_offset = Vector2(45, 80)
theme_override_styles/panel = ExtResource("2_cbb73")
[node name="Camera2D" type="Camera2D" parent="."]
position = Vector2(146, 80)

26
Example/UsingTest/Scene/TestEGFramework.tscn

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://dfa86yq8m28rk"]
[ext_resource type="Script" path="res://Example/UsingTest/Script/EGSaveTest.cs" id="1_eij2h"]
[node name="Test" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_eij2h")
[node name="Timer" type="Timer" parent="."]
autostart = true
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_right = 361.0
offset_bottom = 164.0
[node name="Button1" type="Button" parent="."]
visible = false
layout_mode = 0
offset_right = 50.0
offset_bottom = 50.0

45
Example/UsingTest/Script/EGMDnsTest.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
using Godot;
using System;
using EGFramework;
using WebDav;
using System.Threading.Tasks;
using System.Net;
public partial class EGMDnsTest : Node, IEGFramework
{
private string serverUrl = "http://192.168.1.170:5212/dav";
private string username = "ZK@zk.com";
private string password = "uQTl7lzLSMZQ1QBd7sZZMlG2Gya65XKM";
public override void _Ready()
{
//TestDav();
}
public async void TestDav(){
this.EGWebDav().InitClient(serverUrl,username,password);
await InitClient();
}
public async Task<bool> InitClient()
{
string result = EncodeCredentials(username,password);
GD.Print(result);
//ScanWebDavAndDownload();
//await this.EGWebDav().DownloadFile("/dav/Picture/风景1.jpg",ProjectSettings.GlobalizePath("user://"),"风景1.jpg");
//Print("download success!");
//await this.EGWebDav().UploadFile(ProjectSettings.GlobalizePath("user://4.mp4"),"/dav/Picture","4.mp4");
await this.EGWebDav().UploadFile(ProjectSettings.GlobalizePath("user://PPT_Test.jpg"),"/dav/Picture","PPT_Test.jpg");
GD.Print("upload success!");
//var result = await this.EGWebDav().GetList("/Video");
//Print(JsonConvert.SerializeObject(result));
return true;
}
public static string EncodeCredentials(string username, string password)
{
string credentials = $"{username}:{password}";
byte[] credentialsBytes = System.Text.Encoding.UTF8.GetBytes(credentials);
string encodedCredentials = Convert.ToBase64String(credentialsBytes);
return encodedCredentials;
}
}

249
Example/UsingTest/Script/EGSaveTest.cs

@ -1,249 +0,0 @@ @@ -1,249 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Godot;
using LiteDB;
using Renci.SshNet;
namespace EGFramework.Examples.Test{
public partial class EGSaveTest : Node,IEGFramework
{
public Label Label { set; get; }
public override void _Ready()
{
this.Label = this.GetNode<Label>("Label");
// this.EGEnabledThread();
// this.ExecuteAfterSecond(TestMainThreadFunc,2.0f);new PrivateKeyFile("../../../.ssh/id_ed25519")
//base._Ready();
//TestCode();
// this.EGEnabledProtocolTool<EGSsh>();
// this.EGEnabledProtocolTool<EGTCPClient>();
// this.EGEnabledProtocolTool<EGTCPServer>();
this.EGOnMessage<EasyMessage>();
this.EGRegisterMessageEvent<EasyMessage>((e,sender)=>{
});
TestProcess();
// //TestSsh();
// //TestTCPSend();
// TestTCPServer();
// TestFTP();
}
public override void _ExitTree()
{
this.EGProcess().CloseProcess("cmd.exe");
}
public void TestFTP(){
EGFtpSave ftp = new EGFtpSave();
ftp.InitSave("127.0.0.1");
IEnumerable<IEGFileMsg> msgs = ftp.ListRemoteFilePath("/App/");
foreach(IEGFileMsg msg in msgs){
GD.Print(msg.FileName+" | "+msg.IsCollection+" | "+msg.Size+"kb | "+msg.LastModify);
}
}
public void TestProcess(){
this.EGEnabledProtocolTool<EGProcess>();
this.EGProcess().InitProcess("cmd.exe");
// this.EGProcess().SendStringData("cmd.exe","SaveData\\ffmpeg.exe -version\n");
this.EGProcess().SendStringData("cmd.exe","ipconfig");
}
public async void TestSsh(){
await this.EGSsh().ConnectSsh("127.0.0.1","jkpete",new PrivateKeyFile("../../../.ssh/id_ed25519"));
this.EGSendMessage(new EasyMessage(){sendString = "ls -la"},"127.0.0.1",ProtocolType.SSHClient);
}
public async void TestTCPSend(){
await this.EGTCPClient().ConnectTCP("127.0.0.1",5555);
await this.EGTCPClient().ConnectTCP("127.0.0.1",6666);
this.EGSendMessage(new EasyMessage(){sendString = "ls -la"},"127.0.0.1:5555",ProtocolType.TCPClient);
this.EGSendMessage(new EasyMessage(){sendString = "ls -la"},"127.0.0.1:6666",ProtocolType.TCPClient);
this.EGSendMessage(new EasyMessage(){sendString = "ls -la"},"127.0.0.1:6666",ProtocolType.TCPClient);
this.EGSendMessage(new EasyMessage(){sendString = "ls -la"},"127.0.0.1:6666",ProtocolType.TCPClient);
this.EGSendMessage(new EasyMessage(){sendString = "ls -la"},"127.0.0.1:6666",ProtocolType.TCPClient);
this.EGSendMessage(new EasyMessage(){sendString = "ls -la"},"127.0.0.1:5555",ProtocolType.TCPClient);
}
public void TestTCPServer(){
this.EGTCPServer().StartServer(5555);
this.EGTCPServer().StartServer(6666);
}
public async void TestThread(){
await Task.Run(()=>{
//this.ExecuteInMainThread(TestMainThreadFunc);
this.ExecuteAfterSecond(TestMainThreadFunc,2.0f);
});
}
public void TestMainThreadFunc(){
this.Label.Text = "Thread Test";
GD.Print("Invoked!");
}
public void TestSqlite(){
// string result = this.EGSqlite().CreateTable<SqliteBackpackItem>();
this.EGSqlite().SaveData(new SqliteBackpackItem{
ItemID = 10,
ItemCount = 1,
BackpackID = 1,
});
GD.Print(this.EGSqlite().ExceptionMsg);
// var properties = typeof(SqliteBackpackItem).GetFields();
// Godot.GD.Print(properties.Count() + " Readed ");
}
public void TestCode(){
// this.EGSave().OpenUserPath();
// GD.Print(ProjectSettings.GlobalizePath("res://SaveData/Default.json"));
// GD.Print(ProjectSettings.GlobalizePath("user://SaveData/Default.json"));
// GD.Print(Path.GetDirectoryName(ProjectSettings.GlobalizePath("res://SaveData/Default.json")));
// string Path2 = "Data1.json".GetGodotResPath();
// this.EGSave().LoadObjectFile<EGJsonSave>(Path2);
// this.EGSave().SetObject(Path2,"Customer1",new Customer() { Name = "Andy" });
// this.EGSave().SetObject(Path2,"Customer3",new Customer() { Name = "Terry" });
// string CardPath1 = "Card1";
// FileAccess fileAccess = FileAccess.Open("res://SaveData/TestCsv.csv", FileAccess.ModeFlags.Read);
// GD.Print(fileAccess.GetAsText());
// FileAccess testJson = FileAccess.Open("res://TestJson.json", FileAccess.ModeFlags.Read);
// this.EGSave().ReadObject<EGJsonSave>("TestJson",testJson.GetAsText());
// Customer customer = this.EGSave().GetObject<Customer>("TestJson","Customer3");
// GD.Print("ReadName is "+customer.Name);
// FileAccess testCSV = FileAccess.Open("res://SaveData/TestCSV.json", FileAccess.ModeFlags.Read);
// EGCsvSave csvSave = new EGCsvSave();
// csvSave.InitSaveFile("SaveData/TestCsv.csv");
// Customer testData = csvSave.GetData<Customer>("",1);
// GD.Print("Name = "+testData.Name +" || ID = "+testData.Id);
// CustomerByte testData = new CustomerByte(){
// Id = 1008,
// Name = "AddDataDefault",
// IsActive = true
// };
// csvSave.SetData("",testData,2)
string Path1 = "SaveData/TestCsv.csv".GetGodotResPath();
this.EGSave().LoadDataFile<EGCsvSave>(Path1);
IEnumerable<Customer> allResult = this.EGSave().FindData<Customer>(Path1,"",cus=>cus.Id==0);
foreach(Customer customer in allResult){
GD.Print(customer.Id +"|" + customer.Name);
}
// this.EGSave().SetData(Path1,"Customer1",new Customer() { Name = "Andy" },9);
// IEnumerable<Customer> allResult = this.EGSave().GetAllData<Customer>(Path1,"");
// foreach(Customer customer in allResult){
// GD.Print(customer.Id +"|" + customer.Name);
// }
// Customer customer1 = this.EGSave().GetData<Customer>(Path1,"",0);
// GD.Print(customer1.Id +"|" + customer1.Name);
// FileAccess testCsv = FileAccess.Open("res://SaveData/TestCsv.csv", FileAccess.ModeFlags.Read);
// this.EGSave().ReadData<EGCsvSave>("TestCsv",testCsv.GetAsText());
// this.EGSave().LoadObjectFile<EGByteSave>("SaveData/testDat.dat");
// // this.EGSave().SetObject("SaveData/testDat.dat","",testData);
// CustomerByte testDat = this.EGSave().GetObject<CustomerByte>("SaveData/testDat.dat","");
// GD.Print(testDat.Id);
// System.Linq.Expressions.Expression<Func<Customer, bool>> expr = i => i.Name == "Creature";
// IEnumerable<Customer> linqResult = csvSave.FindData<Customer>("",expr);
// GD.Print("Find result " + linqResult.Count());
// foreach(Customer customer in linqResult){
// GD.Print(customer.Id);
// }
// GD.Print(typeof(Customer));
// Type type = typeof(Customer);
// foreach(PropertyInfo property in type.GetProperties()){
// GD.Print(property.Name);
// CsvParamAttribute csvParam = property.GetCustomAttribute<CsvParamAttribute>();
// if(csvParam != null){
// GD.Print("["+csvParam._name+"]");
// }
// }
// foreach(FieldInfo property in type.GetFields()){
// GD.Print(property.Name);
// }
}
}
public struct SqliteBackpackItem{
public int Id { get; set; }
public int ItemID { get; set; }
public int ItemCount { get; set; }
public int BackpackID { get; set; }
}
public class Customer
{
[CsvParam("ID")]
public int Id { get; set; }
[CsvParam("Name")]
public string Name { get; set; }
public string[] Phones { get; set; }
[CsvParam("是否启用")]
public bool IsActive { get; set; }
}
public class CustomerByte : Customer, IResponse, IRequest
{
public byte[] ToProtocolByteData()
{
byte[] data = new byte[0];
data = data.Concat(((uint)Id).ToBytesLittleEndian()).ToArray();
return data;
}
public string ToProtocolData()
{
return "";
}
public bool TrySetData(string protocolData, byte[] protocolBytes)
{
if(protocolBytes != null && protocolBytes.Length >= 4){
Id = (int)protocolBytes.ToUINTLittleEndian();
return true;
}else{
return false;
}
}
}
public class EasyMessage : IResponse, IRequest
{
public byte[] sendByte = null;
public string sendString = null;
public byte[] ToProtocolByteData()
{
return sendByte;
}
public string ToProtocolData()
{
return sendString;
}
public bool TrySetData(string protocolData, byte[] protocolBytes)
{
try
{
GD.Print("[String]"+protocolData);
// GD.Print("[Bytes]"+protocolBytes);
return true;
}
catch (System.Exception)
{
throw;
}
}
}
}

315
Example/UsingTest/Script/EGTest.cs

@ -1,315 +0,0 @@ @@ -1,315 +0,0 @@
using Godot;
using static Godot.GD;
using System.Collections.Generic;
using EGFramework;
using Newtonsoft.Json;
using System;
using System.Net;
namespace EGFramework.Examples{
public partial class EGTest : Node,IEGFramework
{
public Label label { set; get; }
public override void _Ready()
{
this.EGEnabledProtocolTools();
this.EGMqtt().ConnectMQTTServer("192.168.1.220");
//this.EGUDP().UDPDevices[5555].Connect(IPAddress.Parse("224.0.0.251"),5353);
//byte[] sendData = { 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x5F, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x07, 0x5F, 0x64, 0x6E, 0x73, 0x2D, 0x73, 0x64, 0x04, 0x5F, 0x75, 0x64, 0x70, 0x05, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x00, 0x00, 0x0C, 0x00, 0x01 };
//this.EGUDP().UDPDevices[5555].Send(sendData);
// this.EGRegisterMessageEvent<PrintResponse>((e,sender,protocol)=>{
// Print(sender);
// });
// this.EGOnMessage<PrintResponse>();
// this.EGReadFromFile("SaveData/MySeg2.seg2");
//TestTCPClient();
//TestSerialPort();
//TestTCPServer();
//this.EGUDP();
//this.EGUDPListen(11000);
//this.EGSendMessage(new MessageStruct(1,"xxx"),"192.168.1.192:9002",ProtocolType.UDP);
//this.EGHttpClient();
//this.EGHttpServer().Listen("http://+:6555/index/");
}
public override void _Process(double delta)
{
//Print(this.EGMqtt().MqttDevices["192.168.1.220"].IsConnected);
}
public override void _ExitTree()
{
}
public void OnButton1Click(){
this.EGMqtt().SubScribeTheme("192.168.1.220","test");
byte[] testData = {0x3A,0x55};
this.EGMqtt().PublishTheme("192.168.1.220","test",testData);
}
public void RefreshMsg(bool coil){
label.Text += coil+" ";
}
public void OnTimer(){
//this.EGSendMessage(new MessageStruct(1,"山东博裕1"),"COM4",ProtocolType.SerialPort);
//this.EGSendMessage(new MessageStruct(1,"山东博裕1"),"192.168.1.244:6060",ProtocolType.TCPClient);
//this.EGSendMessage(new ModbusTCP_WriteMultiCoil(1,0,sendData),"192.168.1.200:3000",ProtocolType.TCPClient);
//TestSingleCoil();
//TestMultiCoil();
//TestSingleHoldingRegister();
//TestMultiHoldingRegister();
}
public void TestModbus(){
label = this.GetNode<Label>("Label");
label.Text = "[Modbus]";
this.EGRegisterMessageEvent<MessageResponse>((e,sender,type)=>{
Print("[Got Response]"+"[sender = "+sender+"]"+"["+type+"]"+ e.MessageId+"||"+e.Author);
});
this.EGOnMessage<MessageResponse>();
this.EGRegisterMessageEvent<ModbusTCP_Response>((e,sender,type)=>{
if(type == ProtocolType.TCPClient && e.FunctionType == ModbusFunctionType.ReadCoil){
int registerId = 0;
foreach(bool coil in e.Coil){
Print(registerId + "Status:" + coil);
registerId++;
}
}
if(type == ProtocolType.TCPClient && e.FunctionType == ModbusFunctionType.ReadDiscreteInput){
int registerId = 0;
foreach(bool discreteInput in e.DiscreteInput){
Print(registerId + "Status:" + discreteInput);
registerId++;
}
}
if(type == ProtocolType.TCPClient && e.FunctionType == ModbusFunctionType.ReadHoldingRegisters){
int registerId = 0;
foreach(ushort holdingRegister in e.HoldingRegister){
Print(registerId + "Status:" + holdingRegister);
registerId++;
}
}
if(type == ProtocolType.TCPClient && e.FunctionType == ModbusFunctionType.ReadInputRegisters){
int registerId = 0;
foreach(ushort inputRegister in e.InputRegister){
Print(registerId + "Status:" + inputRegister);
label.Text+=registerId + "Status:" + inputRegister;
registerId++;
}
}
//this.EGOffMessage<ModbusTCP_Response>();
});
this.EGRegisterMessageEvent<ModbusRTU_Response>((e,sender,type)=>{
if(type == ProtocolType.SerialPort && e.FunctionType == ModbusFunctionType.ReadCoil){
int registerId = 0;
foreach(bool coil in e.Coil){
Print(registerId + "Status:" + coil);
registerId++;
}
}
if(type == ProtocolType.SerialPort && e.FunctionType == ModbusFunctionType.ReadDiscreteInput){
int registerId = 0;
foreach(bool discreteInput in e.DiscreteInput){
Print(registerId + "Status:" + discreteInput);
registerId++;
}
}
if(type == ProtocolType.SerialPort && e.FunctionType == ModbusFunctionType.ReadHoldingRegisters){
int registerId = 0;
foreach(ushort holdingRegister in e.HoldingRegister){
Print(registerId + "Status:" + holdingRegister);
registerId++;
}
}
if(type == ProtocolType.SerialPort && e.FunctionType == ModbusFunctionType.ReadInputRegisters){
int registerId = 0;
foreach(ushort inputRegister in e.InputRegister){
Print(registerId + "Status:" + inputRegister);
label.Text+=registerId + "Status:" + inputRegister;
registerId++;
}
}
//this.EGOffMessage<ModbusRTU_Response>();
});
}
public void TestTCPServer(){
this.EGTCPServer().OnClientConnect.Register(e=>{
Print(e +" is connected");
this.EGSendMessage(new MessageStruct(1,"Hello"),e,ProtocolType.TCPServer);
});
this.EGTCPServer().OnClientDisconnect.Register(e=>{
Print(e +" is disconnect");
});
this.EGTCPServerListen(9999);
}
public void TestSqlite(){
this.EGSqlite().SaveData(new TestBoxMessage());
List<TestBoxMessage> result = this.EGSqlite().GetDataSet<TestBoxMessage>();
if(result == null){
PrintErr(this.EGSqlite().ExceptionMsg);
}
Print("Result = " + result[0].TestDouble + result[0].TestFloat);
}
public void TestSerialPort(){
this.EGSerialPort().SetBaudRate(9600);
this.EGSendMessage(new ModbusRTU_ReadInputRegisters(1,0,2),"COM4",ProtocolType.SerialPort);
this.EGSendMessage(new ModbusRTU_ReadCoils(1,0,8),"COM4",ProtocolType.SerialPort);
this.EGOnMessage<ModbusRTU_Response>();
}
public void TestTCPClient(){
this.EGTCPClient();
this.EGSendMessage(new ModbusTCP_ReadDiscreteInput(1,0,8),"192.168.1.196:6000",ProtocolType.TCPClient);
this.EGSendMessage(new ModbusTCP_ReadInputRegisters(1,0,2),"192.168.1.196:6000",ProtocolType.TCPClient);
this.EGOnMessage<ModbusTCP_Response>();
}
private bool IsOpen = false;
public void TestSingleCoil(){
if(IsOpen){
//this.EGSendMessage(new ModbusRTU_WriteSingleCoil(1,0,false),"COM4",ProtocolType.SerialPort);
this.EGSendMessage(new ModbusTCP_WriteSingleCoil(1,0,false),"192.168.1.196:6000",ProtocolType.TCPClient);
IsOpen = false;
}else{
//this.EGSendMessage(new ModbusRTU_WriteSingleCoil(1,0,true),"COM4",ProtocolType.SerialPort);
this.EGSendMessage(new ModbusTCP_WriteSingleCoil(1,0,true),"192.168.1.196:6000",ProtocolType.TCPClient);
IsOpen = true;
}
}
public void TestMultiCoil(){
byte[] OpenCode = {0xFF};
byte[] CloseCode = {0x00};
if(IsOpen){
this.EGSendMessage(new ModbusRTU_WriteMultiCoil(1,0,CloseCode.ToBoolArray()),"COM4",ProtocolType.SerialPort);
IsOpen = false;
}else{
this.EGSendMessage(new ModbusRTU_WriteMultiCoil(1,0,OpenCode.ToBoolArray()),"COM4",ProtocolType.SerialPort);
IsOpen = true;
}
}
public void TestSingleHoldingRegister(){
if(IsOpen){
this.EGSendMessage(new ModbusRTU_WriteSingleHoldingRegister(1,0,0x00),"COM4",ProtocolType.SerialPort);
IsOpen = false;
}else{
this.EGSendMessage(new ModbusRTU_WriteSingleHoldingRegister(1,0,0x01),"COM4",ProtocolType.SerialPort);
IsOpen = true;
}
}
public void TestMultiHoldingRegister(){
ushort[] OpenCode = {1,1,1,1,1,1,1,1};
ushort[] CloseCode = {0,0,0,0,0,0,0,0};
if(IsOpen){
this.EGSendMessage(new ModbusRTU_WriteMultiHoldingRegister(1,0,CloseCode),"COM4",ProtocolType.SerialPort);
IsOpen = false;
}else{
this.EGSendMessage(new ModbusRTU_WriteMultiHoldingRegister(1,0,OpenCode),"COM4",ProtocolType.SerialPort);
IsOpen = true;
}
}
}
public class TestBoxMessage {
public int Code = 0;
public float TestFloat = 0.1f;
public double TestDouble;
public bool IsHaveMessage;
public string MessageInfo;
public MessageType MsgType;
public MessageStruct MsgStruct;
public MessagePair MsgPair;
public TestBoxMessage(){
this.Code = 1;
this.TestFloat = 1.2f;
this.TestDouble = 2.52;
this.IsHaveMessage = true;
this.MessageInfo = "DefaultInfo";
MsgType = MessageType.TypeInt;
MsgPair = new MessagePair();
MsgStruct = new MessageStruct(5,"Ad");
}
public string ToProtocolData()
{
return JsonConvert.SerializeObject(this);
}
}
public class MessagePair{
public int MessageId;
public string Author;
public string MessageInfo;
public int TimeStamp;
public MessagePair(){
this.MessageId = 10001;
this.Author = "Admin";
this.MessageInfo = "Hello every one!";
this.TimeStamp = 1690188342;
}
}
public struct MessageStruct : IRequest,IEGFramework{
public string FunctionCode;
public int MessageId;
public string Author;
public MessageStruct(int messageId,string author){
FunctionCode = "Message";
MessageId = messageId;
Author = author;
}
public byte[] ToProtocolByteData()
{
return JsonConvert.SerializeObject(this).ToBytesByEncoding("GBK");
}
public string ToProtocolData()
{
return "";
//return JsonConvert.SerializeObject(this);
}
}
public struct MessageResponse : IResponse
{
public string FunctionCode { set; get; }
public int MessageId;
public string Author;
public bool TrySetData(string protocolData, byte[] protocolBytes)
{
try
{
//GD.Print(protocolData);
MessageResponse res = JsonConvert.DeserializeObject<MessageResponse>(protocolData);
if(res.FunctionCode == "Message"){
this.FunctionCode = res.FunctionCode;
this.MessageId = res.MessageId;
this.Author = res.Author;
return true;
}
return false;
}
catch (Exception)
{
return false;
}
}
}
public struct PrintResponse : IResponse
{
public bool TrySetData(string protocolData, byte[] protocolBytes)
{
//Print("Received String is " + protocolData);
Print("Received bytes is " + protocolBytes.ToStringByHex());
return true;
}
}
public enum MessageType{
TypeString = 1,
TypeInt = 2,
TypeObject = 3,
TypeArray = 4
}
}

76
ReadMe.md

@ -18,6 +18,10 @@ @@ -18,6 +18,10 @@
>
> Godot 在 [宽松的 MIT 许可证](https://docs.godotengine.org/zh-cn/4.x/about/complying_with_licenses.html#doc-complying-with-licenses) 下完全自由且开源,没有附加条件、没有抽成、什么都没有。用户的游戏乃至引擎的每一行代码,都归用户自己所有。Godot 的开发完全独立且由社区驱动,允许用户为满足需求重塑引擎。它受到不以盈利为目标的 [Godot 基金会](https://godot.foundation/)支持。
---
# 一、准备工作
## 1.下载开发环境
@ -64,7 +68,44 @@ @@ -64,7 +68,44 @@
无需担心,除了部分Module存在相关依赖,大部分Module是支持直接删除的。
## 5.EGFramework构成一栏
---
# 二、框架简介
由于该框架使用了较多的Nuget包实现相关的功能,所以安装较为繁琐,同时因为用到较多的扩展方法,提示词可能比较冗余。您可以通过删除对应的Module来定制化自己的框架,也可以新增自己的Module来扩展自己的框架。
如果使用的Nuget包牵扯有侵犯您的许可,请联系作者Mail:1031139173@qq.com,作者尽可能第一时间删除对应的Module功能。
第三方许可文件均存放在目录addons\EGFramework\License_Third_Part下面
## 2.1 使用框架
添加using,并继承接口IEGFramework,即可使用该框架了。
```csharp
using Godot;
using static Godot.GD;
using System.Collections.Generic;
using EGFramework;
public partial class EGTest : Node,IEGFramework{
}
```
更多可参考Example。
## 2.2 发送与监听消息
## 2.3 使用本地存储
# 三、EGFramework-API
目前已有的EGFramework功能组件。标记是目前已编写完成,未标记是未编写完成或未测试。
@ -76,7 +117,7 @@ @@ -76,7 +117,7 @@
- [ ] GenerateTools
- [ ] UITools
### 5.1 消息篇(EGMessage-ProtocolTools)
### 3.1 消息篇(EGMessage-ProtocolTools)
---
@ -98,7 +139,7 @@ @@ -98,7 +139,7 @@
- [x] FileStream
- [x] Process
### 5.2 存储篇(EGMessage-ProtocolTools)
### 3.2 存储篇(EGMessage-ProtocolTools)
#### 键值对象存储支持
@ -120,32 +161,3 @@ @@ -120,32 +161,3 @@
- [x] LocalFile
- [ ] Sftp
- [ ] WebDav
# 二、框架简介
由于该框架使用了较多的Nuget包实现相关的功能,所以安装较为繁琐,同时因为用到较多的扩展方法,提示词可能比较冗余。您可以通过删除对应的Module来定制化自己的框架,也可以新增自己的Module来扩展自己的框架。
如果使用的Nuget包牵扯有侵犯您的许可,请联系作者Mail:1031139173@qq.com,作者尽可能第一时间删除对应的Module功能。
第三方许可文件均存放在目录addons\EGFramework\License_Third_Part下面
## 1.使用框架
添加using,并继承接口IEGFramework,即可使用该框架了。
```csharp
using Godot;
using static Godot.GD;
using System.Collections.Generic;
using EGFramework;
public partial class EGTest : Node,IEGFramework{
this.EGSave();
}
public class DataTest{
public string PlayerName;
public int Hp;
}
```

16
addons/EGFramework/Module/NodeExtension/EGTweenExtension.cs

@ -52,6 +52,22 @@ namespace EGFramework.EGTween{ @@ -52,6 +52,22 @@ namespace EGFramework.EGTween{
tween.TweenProperty(self,"rotation",angle*Mathf.Pi/180,delay);
return tween;
}
public static Tween TweenRotationByRad(this Node3D self,Vector3 rad,float delay){
Tween tween = self.CreateTween();
tween.TweenProperty(self,"rotation",rad,delay);
return tween;
}
public static Tween TweenRotationByAngle(this Node3D self,Vector3 eulerAngle,float delay){
Tween tween = self.CreateTween();
tween.TweenProperty(self,"rotation",eulerAngle*Mathf.Pi/180,delay);
return tween;
}
public static Vector3 EulerAngleToRad(this Vector3 eulerAngle){
return new Vector3(eulerAngle.X*Mathf.Pi/180,eulerAngle.Y*Mathf.Pi/180,eulerAngle.Z*Mathf.Pi/180);
}
public static Vector3 RadToEulerAngle(this Vector3 rad){
return new Vector3(rad.X/Mathf.Pi*180,rad.Y/Mathf.Pi*180,rad.Z/Mathf.Pi*180);
}
#endregion

Loading…
Cancel
Save