Compare commits
85 Commits
98d5d0d6e3
...
f7476a9d99
136 changed files with 5945 additions and 1534 deletions
After Width: | Height: | Size: 3.6 KiB |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
[remap] |
||||
|
||||
importer="texture" |
||||
type="CompressedTexture2D" |
||||
uid="uid://cvw1gq522fjiw" |
||||
path="res://.godot/imported/EGFramework.png-34687d3295fa60912fa513ef2547d661.ctex" |
||||
metadata={ |
||||
"vram_texture": false |
||||
} |
||||
|
||||
[deps] |
||||
|
||||
source_file="res://EGFramework.png" |
||||
dest_files=["res://.godot/imported/EGFramework.png-34687d3295fa60912fa513ef2547d661.ctex"] |
||||
|
||||
[params] |
||||
|
||||
compress/mode=0 |
||||
compress/high_quality=false |
||||
compress/lossy_quality=0.7 |
||||
compress/hdr_compression=1 |
||||
compress/normal_map=0 |
||||
compress/channel_pack=0 |
||||
mipmaps/generate=false |
||||
mipmaps/limit=-1 |
||||
roughness/mode=0 |
||||
roughness/src_normal="" |
||||
process/fix_alpha_border=true |
||||
process/premult_alpha=false |
||||
process/normal_map_invert_y=false |
||||
process/hdr_as_srgb=false |
||||
process/hdr_clamp_exposure=false |
||||
process/size_limit=0 |
||||
detect_3d/compress_to=1 |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
[remap] |
||||
|
||||
importer="texture" |
||||
type="CompressedTexture2D" |
||||
uid="uid://bpmhdi6qsq8xk" |
||||
path.s3tc="res://.godot/imported/EGFramework.svg-659d185b06d3cb441710fca89d9b4015.s3tc.ctex" |
||||
path.etc2="res://.godot/imported/EGFramework.svg-659d185b06d3cb441710fca89d9b4015.etc2.ctex" |
||||
metadata={ |
||||
"imported_formats": ["s3tc_bptc", "etc2_astc"], |
||||
"vram_texture": true |
||||
} |
||||
|
||||
[deps] |
||||
|
||||
source_file="res://EGFramework.svg" |
||||
dest_files=["res://.godot/imported/EGFramework.svg-659d185b06d3cb441710fca89d9b4015.s3tc.ctex", "res://.godot/imported/EGFramework.svg-659d185b06d3cb441710fca89d9b4015.etc2.ctex"] |
||||
|
||||
[params] |
||||
|
||||
compress/mode=2 |
||||
compress/high_quality=false |
||||
compress/lossy_quality=0.7 |
||||
compress/hdr_compression=1 |
||||
compress/normal_map=0 |
||||
compress/channel_pack=0 |
||||
mipmaps/generate=true |
||||
mipmaps/limit=-1 |
||||
roughness/mode=0 |
||||
roughness/src_normal="" |
||||
process/fix_alpha_border=true |
||||
process/premult_alpha=false |
||||
process/normal_map_invert_y=false |
||||
process/hdr_as_srgb=false |
||||
process/hdr_clamp_exposure=false |
||||
process/size_limit=0 |
||||
detect_3d/compress_to=0 |
||||
svg/scale=1.0 |
||||
editor/scale_with_editor_scale=false |
||||
editor/convert_colors_with_editor_theme=false |
@ -0,0 +1,115 @@
@@ -0,0 +1,115 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://df4gmjq2o1ttn"] |
||||
|
||||
[ext_resource type="Script" path="res://Example/LocalMediaViewer/Script/ViewLocalVideoMediaViewer.cs" id="1_hfhp3"] |
||||
|
||||
[sub_resource type="VideoStreamTheora" id="VideoStreamTheora_6wg02"] |
||||
|
||||
[sub_resource type="ImageTexture" id="ImageTexture_2g46x"] |
||||
|
||||
[node name="LocalMediaViewer" 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_hfhp3") |
||||
|
||||
[node name="ViewVideo" type="VideoStreamPlayer" parent="."] |
||||
visible = false |
||||
layout_mode = 1 |
||||
anchors_preset = -1 |
||||
anchor_left = 0.2 |
||||
anchor_right = 1.0 |
||||
anchor_bottom = 0.8 |
||||
grow_horizontal = 2 |
||||
grow_vertical = 2 |
||||
stream = SubResource("VideoStreamTheora_6wg02") |
||||
expand = true |
||||
metadata/_edit_use_anchors_ = true |
||||
|
||||
[node name="ViewImage" type="TextureRect" parent="."] |
||||
layout_mode = 1 |
||||
anchors_preset = -1 |
||||
anchor_left = 0.2 |
||||
anchor_right = 1.0 |
||||
anchor_bottom = 0.8 |
||||
grow_horizontal = 2 |
||||
grow_vertical = 2 |
||||
texture = SubResource("ImageTexture_2g46x") |
||||
expand_mode = 1 |
||||
metadata/_edit_use_anchors_ = true |
||||
|
||||
[node name="Tab" type="TabContainer" parent="."] |
||||
layout_mode = 1 |
||||
anchors_preset = -1 |
||||
anchor_right = 0.2 |
||||
anchor_bottom = 0.8 |
||||
grow_horizontal = 2 |
||||
grow_vertical = 2 |
||||
current_tab = 0 |
||||
metadata/_edit_use_anchors_ = true |
||||
|
||||
[node name="Media" type="ScrollContainer" parent="Tab"] |
||||
layout_mode = 2 |
||||
metadata/_edit_use_anchors_ = true |
||||
metadata/_tab_index = 0 |
||||
|
||||
[node name="MediaList" type="VBoxContainer" parent="Tab/Media"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
|
||||
[node name="ControlList" type="HBoxContainer" parent="."] |
||||
layout_mode = 1 |
||||
anchors_preset = -1 |
||||
anchor_left = 0.2 |
||||
anchor_top = 0.8 |
||||
anchor_right = 1.0 |
||||
anchor_bottom = 1.0 |
||||
grow_horizontal = 2 |
||||
grow_vertical = 2 |
||||
metadata/_edit_use_anchors_ = true |
||||
|
||||
[node name="ImportList" type="HBoxContainer" parent="."] |
||||
layout_mode = 1 |
||||
anchors_preset = -1 |
||||
anchor_top = 0.8 |
||||
anchor_right = 0.2 |
||||
anchor_bottom = 1.0 |
||||
grow_horizontal = 2 |
||||
grow_vertical = 2 |
||||
metadata/_edit_use_anchors_ = true |
||||
|
||||
[node name="UploadImage" type="Button" parent="ImportList"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "导入图片" |
||||
|
||||
[node name="UploadVideo" type="Button" parent="ImportList"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "导入视频" |
||||
|
||||
[node name="ImportImage" type="FileDialog" parent="."] |
||||
title = "Open a File" |
||||
initial_position = 1 |
||||
size = Vector2i(960, 640) |
||||
ok_button_text = "Open" |
||||
file_mode = 0 |
||||
access = 2 |
||||
filters = PackedStringArray("*.png", "*.jpg") |
||||
|
||||
[node name="ImportVideo" type="FileDialog" parent="."] |
||||
auto_translate_mode = 1 |
||||
title = "Open a File" |
||||
initial_position = 1 |
||||
size = Vector2i(960, 640) |
||||
ok_button_text = "Open" |
||||
file_mode = 0 |
||||
access = 2 |
||||
filters = PackedStringArray("*.ogv") |
||||
|
||||
[connection signal="pressed" from="ImportList/UploadImage" to="." method="OpenImportImage"] |
||||
[connection signal="pressed" from="ImportList/UploadVideo" to="." method="OpenImportVideo"] |
||||
[connection signal="file_selected" from="ImportImage" to="." method="UploadImage"] |
||||
[connection signal="file_selected" from="ImportVideo" to="." method="UploadVideo"] |
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
using Godot; |
||||
using System; |
||||
using EGFramework; |
||||
using System.IO; |
||||
|
||||
public partial class ViewLocalVideoMediaViewer : Node,IEGFramework |
||||
{ |
||||
public EGLocalFileSave localFileSave { get; set; } |
||||
public VideoStreamPlayer ViewVideo { get; set; } |
||||
public TextureRect ViewImage { get; set; } |
||||
public VBoxContainer VideoList { get; set; } |
||||
public FileDialog ImportImage { get; set; } |
||||
public FileDialog ImportVideo { get; set; } |
||||
|
||||
// Called when the node enters the scene tree for the first time. |
||||
public override void _Ready() |
||||
{ |
||||
ViewVideo = this.GetNode<VideoStreamPlayer>("ViewVideo"); |
||||
ViewImage = this.GetNode<TextureRect>("ViewImage"); |
||||
VideoList = this.GetNode<VBoxContainer>("Tab/Media/MediaList"); |
||||
ImportImage = this.GetNode<FileDialog>("ImportImage"); |
||||
ImportVideo = this.GetNode<FileDialog>("ImportVideo"); |
||||
LoadFileSystem(); |
||||
} |
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame. |
||||
public override void _Process(double delta) |
||||
{ |
||||
|
||||
} |
||||
public void LoadFileSystem(){ |
||||
this.localFileSave = new EGLocalFileSave(); |
||||
localFileSave.RootPath = "SaveData"; |
||||
if(!localFileSave.IsRemoteDirectoryExist("Media")){ |
||||
localFileSave.MakeDirectory("Media"); |
||||
} |
||||
RefreshList(); |
||||
} |
||||
public void RefreshList(){ |
||||
string combinedPath = Path.Combine(localFileSave.RootPath, "Media"); |
||||
VideoList.ClearChildren(); |
||||
foreach (var file in localFileSave.ListRemoteFilePath("Media")){ |
||||
if(file.FileName.GetStrBehindSymbol('.')!="ogv" && file.FileName.GetStrBehindSymbol('.')!="jpg" && file.FileName.GetStrBehindSymbol('.')!="png"){ |
||||
continue; |
||||
} |
||||
Button button= new Button(); |
||||
button.Name = file.FileName; |
||||
button.Text = file.FileName; |
||||
string combinedFile = Path.Combine(combinedPath, button.Text); |
||||
button.Connect("pressed",Callable.From(()=>{ |
||||
if(button.Text.GetStrBehindSymbol('.')=="ogv"){ |
||||
PlayVideo(combinedFile); |
||||
} |
||||
if(button.Text.GetStrBehindSymbol('.')=="jpg" || button.Text.GetStrBehindSymbol('.')=="png"){ |
||||
PlayImage(combinedFile); |
||||
} |
||||
})); |
||||
VideoList.AddChild(button); |
||||
} |
||||
} |
||||
|
||||
public void PlayVideo(string videoName){ |
||||
ViewVideo.Visible = true; |
||||
ViewImage.Visible = false; |
||||
GD.Print("PlayVideo: " + videoName); |
||||
ViewVideo.Stream.File = videoName; |
||||
ViewVideo.Play(); |
||||
} |
||||
public void PlayImage(string imageName){ |
||||
ViewVideo.Visible = false; |
||||
ViewImage.Visible = true; |
||||
GD.Print("PlayImage: " + imageName); |
||||
Image image = Image.LoadFromFile(imageName); |
||||
ImageTexture texture = ImageTexture.CreateFromImage(image); |
||||
ViewImage.Texture = texture; |
||||
// ViewImage.Texture = imageName; |
||||
} |
||||
|
||||
public void OpenImportVideo(){ |
||||
ImportVideo.Popup(); |
||||
} |
||||
public void OpenImportImage(){ |
||||
ImportImage.Popup(); |
||||
} |
||||
public void UploadVideo(string localVideoPath){ |
||||
localFileSave.UploadFile(localVideoPath,"Media\\"+Path.GetFileName(localVideoPath)); |
||||
RefreshList(); |
||||
OS.Alert("Video Upload Success!","success"); |
||||
} |
||||
public void UploadImage(string localImagePath){ |
||||
localFileSave.UploadFile(localImagePath,"Media\\"+Path.GetFileName(localImagePath)); |
||||
RefreshList(); |
||||
OS.Alert("Image Upload Success!","success"); |
||||
} |
||||
} |
@ -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") |
Before Width: | Height: | Size: 4.1 MiB After Width: | Height: | Size: 4.1 MiB |
@ -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"] |
@ -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 |
@ -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"] |
@ -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 |
@ -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") |
@ -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,0 +1,229 @@
@@ -0,0 +1,229 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://byi2cseim0chx"] |
||||
|
||||
[ext_resource type="Script" path="res://Example/ProtocolHelper/Script/ViewProtocolHelper.cs" id="1_47a58"] |
||||
|
||||
[node name="ProtocolHelper" 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_47a58") |
||||
|
||||
[node name="DeviceMenu" type="VSplitContainer" parent="."] |
||||
layout_mode = 1 |
||||
anchors_preset = -1 |
||||
anchor_left = 0.01 |
||||
anchor_top = 0.01 |
||||
anchor_right = 0.19 |
||||
anchor_bottom = 0.99 |
||||
|
||||
[node name="DeviceScroll" type="ScrollContainer" parent="DeviceMenu"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
size_flags_stretch_ratio = 3.0 |
||||
|
||||
[node name="DeviceList" type="VBoxContainer" parent="DeviceMenu/DeviceScroll"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
|
||||
[node name="Device1" type="HSplitContainer" parent="DeviceMenu/DeviceScroll/DeviceList"] |
||||
layout_mode = 2 |
||||
|
||||
[node name="Button" type="Button" parent="DeviceMenu/DeviceScroll/DeviceList/Device1"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "Device1 |
||||
" |
||||
expand_icon = true |
||||
|
||||
[node name="CheckBox" type="CheckBox" parent="DeviceMenu/DeviceScroll/DeviceList/Device1"] |
||||
layout_mode = 2 |
||||
|
||||
[node name="DeviceFunctionList" type="VBoxContainer" parent="DeviceMenu"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
|
||||
[node name="Open" type="Button" parent="DeviceMenu/DeviceFunctionList"] |
||||
layout_mode = 2 |
||||
text = "启动设备" |
||||
|
||||
[node name="Close" type="Button" parent="DeviceMenu/DeviceFunctionList"] |
||||
layout_mode = 2 |
||||
text = "关闭设备" |
||||
|
||||
[node name="Add" type="Button" parent="DeviceMenu/DeviceFunctionList"] |
||||
layout_mode = 2 |
||||
text = "增加设备" |
||||
|
||||
[node name="Modify" type="Button" parent="DeviceMenu/DeviceFunctionList"] |
||||
layout_mode = 2 |
||||
text = "修改设备" |
||||
|
||||
[node name="Delete" type="Button" parent="DeviceMenu/DeviceFunctionList"] |
||||
layout_mode = 2 |
||||
text = "删除设备" |
||||
|
||||
[node name="ProtocolMenu" type="VSplitContainer" parent="."] |
||||
layout_mode = 1 |
||||
anchors_preset = -1 |
||||
anchor_left = 0.81 |
||||
anchor_top = 0.01 |
||||
anchor_right = 0.99 |
||||
anchor_bottom = 0.99 |
||||
grow_horizontal = 2 |
||||
grow_vertical = 2 |
||||
|
||||
[node name="ProtocolScroll" type="ScrollContainer" parent="ProtocolMenu"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
size_flags_stretch_ratio = 3.0 |
||||
|
||||
[node name="Protocol" type="VBoxContainer" parent="ProtocolMenu/ProtocolScroll"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
|
||||
[node name="ProtocolName" type="HSplitContainer" parent="ProtocolMenu/ProtocolScroll/Protocol"] |
||||
layout_mode = 2 |
||||
|
||||
[node name="Button" type="Button" parent="ProtocolMenu/ProtocolScroll/Protocol/ProtocolName"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "协议1" |
||||
|
||||
[node name="CheckBox" type="CheckBox" parent="ProtocolMenu/ProtocolScroll/Protocol/ProtocolName"] |
||||
layout_mode = 2 |
||||
|
||||
[node name="FunctionList" type="VBoxContainer" parent="ProtocolMenu"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
|
||||
[node name="Add" type="Button" parent="ProtocolMenu/FunctionList"] |
||||
layout_mode = 2 |
||||
text = "增加协议" |
||||
|
||||
[node name="Modify" type="Button" parent="ProtocolMenu/FunctionList"] |
||||
layout_mode = 2 |
||||
text = "修改协议" |
||||
|
||||
[node name="Delete" type="Button" parent="ProtocolMenu/FunctionList"] |
||||
layout_mode = 2 |
||||
text = "删除协议" |
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."] |
||||
layout_mode = 1 |
||||
anchors_preset = -1 |
||||
anchor_left = 0.2 |
||||
anchor_right = 0.8 |
||||
anchor_bottom = 1.0 |
||||
grow_horizontal = 2 |
||||
grow_vertical = 2 |
||||
|
||||
[node name="VSplitContainer" type="VSplitContainer" parent="PanelContainer"] |
||||
layout_mode = 2 |
||||
|
||||
[node name="Terminal" type="RichTextLabel" parent="PanelContainer/VSplitContainer"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
bbcode_enabled = true |
||||
text = "[color=gray]【13:45:55:105】【TCP】127.0.0.1@6000 has been connected[/color] |
||||
[color=green]【13:45:55:265】【TCP】127.0.0.1@6000:[/color]Request |
||||
[color=cyan]【13:45:55:358】【TCP】127.0.0.1@6000:[/color][color=yellow]Response[/color]" |
||||
|
||||
[node name="SettingGroup" type="VSplitContainer" parent="PanelContainer/VSplitContainer"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
|
||||
[node name="VSplitContainer" type="VSplitContainer" parent="PanelContainer/VSplitContainer/SettingGroup"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
|
||||
[node name="FunctionList2" type="HBoxContainer" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
|
||||
[node name="Button" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList2"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "报文筛选" |
||||
|
||||
[node name="Button2" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList2"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "报文分析" |
||||
|
||||
[node name="Button4" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList2"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "保存记录" |
||||
|
||||
[node name="Button3" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList2"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "清空记录" |
||||
|
||||
[node name="Button5" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList2"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "报文显示格式" |
||||
|
||||
[node name="Button6" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList2"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
|
||||
[node name="FunctionList1" type="HBoxContainer" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
|
||||
[node name="Button" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "连接设置" |
||||
|
||||
[node name="Button2" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "服务设置" |
||||
|
||||
[node name="Button3" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "发送设置" |
||||
|
||||
[node name="Button4" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "协议设置" |
||||
|
||||
[node name="Button5" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
|
||||
[node name="Button6" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
|
||||
[node name="SendArea" type="VSplitContainer" parent="PanelContainer/VSplitContainer/SettingGroup"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
size_flags_stretch_ratio = 2.0 |
||||
|
||||
[node name="SendEdit" type="TextEdit" parent="PanelContainer/VSplitContainer/SettingGroup/SendArea"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
size_flags_stretch_ratio = 2.0 |
||||
|
||||
[node name="SendButton" type="HBoxContainer" parent="PanelContainer/VSplitContainer/SettingGroup/SendArea"] |
||||
layout_mode = 2 |
||||
size_flags_vertical = 3 |
||||
|
||||
[node name="Send" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/SendArea/SendButton"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "发送" |
||||
|
||||
[node name="HexSend" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/SendArea/SendButton"] |
||||
layout_mode = 2 |
||||
size_flags_horizontal = 3 |
||||
text = "Hex发送" |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
namespace EGFramework.ProtocolHelper |
||||
{ |
||||
public struct DataDevice |
||||
{ |
||||
public string Sender { set; get; } |
||||
public ProtocolType ProtocolType { set; get; } |
||||
private bool IsConnected { set; get; } |
||||
} |
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
using Godot; |
||||
using System; |
||||
namespace EGFramework.ProtocolHelper |
||||
{ |
||||
public partial class ViewProtocolHelper : Node |
||||
{ |
||||
|
||||
public override void _Ready() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public override void _ExitTree() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public void RefreshConnectList() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public void RefreshProtocolList() |
||||
{ |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
using Godot; |
||||
using System; |
||||
|
||||
public partial class ViewProtocolHelperDeviceList : Node |
||||
{ |
||||
} |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
using Godot; |
||||
using System; |
||||
|
||||
public partial class ViewProtocolHelperProtocolList : Node |
||||
{ |
||||
} |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
using Godot; |
||||
using System; |
||||
|
||||
public partial class ViewProtocolHelperSendArea : Node |
||||
{ |
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
using EGFramework; |
||||
using Godot; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace EGFramework.ProtocolHelper |
||||
{ |
||||
public partial class ViewProtocolHelperTerminal : RichTextLabel |
||||
{ |
||||
public Dictionary<long, ResponseMsg> MessageMappings { set; get; } = new Dictionary<long, ResponseMsg>(); |
||||
public override void _Ready() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public void ClearArea() |
||||
{ |
||||
|
||||
} |
||||
public void RefreshProtocol() |
||||
{ |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bvnma1n064xbx"] |
||||
|
||||
[ext_resource type="Script" path="res://Example/SaveSystem/Script/ViewSaveSystem.cs" id="1_mtdgp"] |
||||
[ext_resource type="Texture2D" uid="uid://bpmhdi6qsq8xk" path="res://EGFramework.svg" id="2_qt8hb"] |
||||
|
||||
[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 |
||||
size_flags_horizontal = 3 |
||||
size_flags_vertical = 3 |
||||
script = ExtResource("1_mtdgp") |
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."] |
||||
visible = false |
||||
layout_mode = 0 |
||||
offset_right = 40.0 |
||||
offset_bottom = 40.0 |
||||
texture = ExtResource("2_qt8hb") |
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="."] |
||||
layout_mode = 1 |
||||
anchors_preset = -1 |
||||
anchor_right = 1.0 |
||||
anchor_bottom = 0.5 |
||||
grow_horizontal = 2 |
||||
grow_vertical = 2 |
@ -0,0 +1,129 @@
@@ -0,0 +1,129 @@
|
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Threading.Tasks; |
||||
using EGFramework.UI; |
||||
using Godot; |
||||
using LiteDB; |
||||
using Newtonsoft.Json; |
||||
using Renci.SshNet; |
||||
|
||||
namespace EGFramework.Examples.Test { |
||||
public partial class ViewSaveSystem : Node, IEGFramework |
||||
{ |
||||
public string[][] DataList { get; set; } |
||||
public string[][] DataList2 { get; set; } |
||||
Container container{ set; get; } |
||||
public override void _Ready() |
||||
{ |
||||
TestTree(); |
||||
} |
||||
|
||||
public override void _ExitTree() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public void TestJson() |
||||
{ |
||||
string json = @"{
|
||||
'CPU': 'Intel', |
||||
'PSU': '500W', |
||||
'Drives': [ |
||||
'DVD read/writer' |
||||
/*(broken)*/, |
||||
'500 gigabyte hard drive', |
||||
'200 gigabyte hard drive' |
||||
], |
||||
'My' : { |
||||
'AA':'BB', |
||||
'Date': new Date(123456789) |
||||
} |
||||
}";
|
||||
|
||||
JsonTextReader reader = new JsonTextReader(new StringReader(json)); |
||||
while (reader.Read()) |
||||
{ |
||||
if (reader.Value != null) |
||||
{ |
||||
GD.Print("Token: {"+reader.TokenType+"}, Value: {"+ reader.Value+"}"); |
||||
} |
||||
else |
||||
{ |
||||
GD.Print("Token: {"+ reader.TokenType+"}"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void TestTree() |
||||
{ |
||||
string json = @"{
|
||||
'CPU': 'Intel', |
||||
'PSU': '500W', |
||||
'My' : { |
||||
'AA':'BB', |
||||
'Date': 111 |
||||
} |
||||
}";
|
||||
container = this.GetNode<TabContainer>("TabContainer"); |
||||
EGodotTree eGodotTree = container.CreateNode<EGodotTree>("TestTree"); |
||||
eGodotTree.InitByJson(json); |
||||
} |
||||
|
||||
public void TestTable() |
||||
{ |
||||
container = this.GetNode<TabContainer>("TabContainer"); |
||||
List<DataStudent> dataStudents = new List<DataStudent>(); |
||||
for (int stu = 0; stu < 10; stu++) |
||||
{ |
||||
dataStudents.Add(new DataStudent("stu" + stu, 18)); |
||||
} |
||||
for (int stu = 0; stu < 11; stu++) |
||||
{ |
||||
dataStudents.Add(new DataStudent("A" + stu, 20 + stu)); |
||||
} |
||||
EGodotTable table = container.CreateNode<EGodotTable>("Default"); |
||||
table.InitData<DataStudent>(dataStudents); |
||||
|
||||
EGSqliteSave SqliteTest = this.EGSave().Load<EGSqliteSave>("SaveData/test.db"); |
||||
// IEnumerable<string> dataBaseKey = SqliteTest.GetKeys(); |
||||
// GD.Print(dataBaseKey); |
||||
// foreach (string data in dataBaseKey) |
||||
// { |
||||
// GD.Print(data); |
||||
// } |
||||
EGodotSaveTable PersonTable = container.CreateNode<EGodotSaveTable>("SQLite"); |
||||
PersonTable.InitSaveData<EGSqliteSave>(SqliteTest); |
||||
PersonTable.InitData<DataPerson>("person"); |
||||
|
||||
// EGodotTableRowData rowData = container.CreateNode<EGodotTableRowData>("RowData"); |
||||
// rowData.Init(new Dictionary<string, object>() { { "Name", "Tom" }, { "Age", 18 } }); |
||||
// EGodotRowData rowData2 = container.CreateNode<EGodotRowData>("RowData2"); |
||||
// rowData2.Init(new Dictionary<string, object>() { { "Name", "Z" }, { "Age", 1 } }); |
||||
// EGodotEditParam editParam = container.CreateNode<EGodotEditParam>("editParam"); |
||||
// editParam.Init(new KeyValuePair<string, object>("数量",1)); |
||||
} |
||||
|
||||
} |
||||
public struct DataStudent |
||||
{ |
||||
public string Name { get; set; } |
||||
public int Age; |
||||
public int ID; |
||||
public EGPathSelect Path { set; get; } |
||||
public DataStudent(string name, int age) |
||||
{ |
||||
Name = name; |
||||
Age = age; |
||||
ID = 0; |
||||
Path = new EGPathSelect(); |
||||
} |
||||
} |
||||
|
||||
public struct DataPerson{ |
||||
public string id { get; set; } |
||||
public string namee { set; get; } |
||||
public string workPlace { set; get; } |
||||
public string policeNum { set; get; } |
||||
} |
||||
} |
@ -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 |
@ -1,3 +0,0 @@
@@ -1,3 +0,0 @@
|
||||
[gd_resource type="Theme" format=3 uid="uid://cbf2s7b2p1p2j"] |
||||
|
||||
[resource] |
@ -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 |
@ -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; |
||||
} |
||||
|
||||
} |
@ -1,166 +0,0 @@
@@ -1,166 +0,0 @@
|
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Threading.Tasks; |
||||
using Godot; |
||||
using LiteDB; |
||||
|
||||
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); |
||||
//base._Ready(); |
||||
//TestCode(); |
||||
} |
||||
|
||||
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; |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -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 |
||||
} |
||||
} |
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
using System; |
||||
using System.Diagnostics; |
||||
namespace EGFramework{ |
||||
|
||||
public interface IPlatform{ |
||||
void Log(string message); |
||||
void Log(params object[] what); |
||||
} |
||||
public class EGPlatformGodot : IPlatform{ |
||||
public void Log(string message){ |
||||
Godot.GD.Print(message); |
||||
// Console.WriteLine(message); |
||||
} |
||||
public void Log(params object[] what){ |
||||
Godot.GD.Print(what); |
||||
// 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(); |
||||
public static void Print(string message){ |
||||
Platform.Log(message); |
||||
} |
||||
public static void Print(params object[] what){ |
||||
Platform.Log(what); |
||||
} |
||||
|
||||
} |
||||
|
||||
// public enum SupportPlatform{ |
||||
// Godot = 0x01, |
||||
// Unity = 0x02, |
||||
// WebApi = 0x03, |
||||
// WPF = 0x04, |
||||
// Form = 0x05, |
||||
// } |
||||
|
||||
} |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
The Dapper library and tools are licenced under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
The Dapper logo is copyright Marc Gravell 2021 onwards; it is fine to use the Dapper logo when referencing the Dapper library and utilities, but |
||||
the Dapper logo (including derivatives) must not be used in a way that misrepresents an external product or library as being affiliated or endorsed |
||||
with Dapper. For example, you must not use the Dapper logo as the package icon on your own external tool (even if it uses Dapper internally), |
||||
without written permission. If in doubt: ask. |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2015 Robin Rodricks and FluentFTP Contributors |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT) |
||||
|
||||
Copyright (c) 2014-2022 Mauricio David |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (c) 2018 Richard Schneider |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
GPL-2.0-only license licenseWITH license licenseUniversal-FOSS-exception-1.0 license |
||||
https://licenses.nuget.org/GPL-2.0-only |
||||
https://licenses.nuget.org/Universal-FOSS-exception-1.0 |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
The MIT License (MIT) |
||||
|
||||
Copyright (c) 2014 Stack Exchange |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
||||
|
||||
=============================================== |
||||
|
||||
Third Party Licenses: |
||||
|
||||
The Redis project (https://redis.io/) is independent of this client library, and |
||||
is licensed separately under the three clause BSD license. The full license |
||||
information can be viewed here: https://redis.io/topics/license |
||||
|
||||
This tool makes use of the "redis-doc" library from https://redis.io/documentation |
||||
in the intellisense comments, which is licensed under the |
||||
Creative Commons Attribution-ShareAlike 4.0 International license; full |
||||
details are available here: |
||||
https://github.com/antirez/redis-doc/blob/master/COPYRIGHT |
||||
|
||||
The development solution uses the Redis-64 package from nuget |
||||
(https://www.nuget.org/packages/Redis-64) by Microsoft Open Technologies, inc. |
||||
This is licensed under the BSD license; full details are available here: |
||||
https://github.com/MSOpenTech/redis/blob/2.6/license.txt |
||||
This tool is not used in the release binaries. |
||||
|
||||
The development solution uses the BookSleeve package from nuget |
||||
(https://code.google.com/p/booksleeve/) by Marc Gravell. This is licensed |
||||
under the Apache 2.0 license; full details are available here: |
||||
https://www.apache.org/licenses/LICENSE-2.0 |
||||
This tool is not used in the release binaries. |
@ -0,0 +1,224 @@
@@ -0,0 +1,224 @@
|
||||
# Protocol Tools 使用指南 |
||||
|
||||
> 本指南首次修订于:2025.6.13 |
||||
> |
||||
> 最后修改日期:2025.6.13 |
||||
|
||||
Protocol Tools允许您在任何通讯物理层发送信息、接受服务器返回的信息、过滤您的脏数据。 |
||||
|
||||
目前工具以发布+订阅的方式处理消息,后续会增加问答的方式处理消息。 |
||||
|
||||
本指南中,您将学到以下内容 |
||||
|
||||
- 如何在互联网&串口通讯&文件读写&进程吞吐中,发送您的请求,获取您的响应消息。 |
||||
- 如何自定义消息类,发送您的消息,处理远端响应的消息。 |
||||
- 自定义插拔式的开启或关闭消息处理功能。 |
||||
- Protocol Tools的消息解耦原理 |
||||
|
||||
--- |
||||
|
||||
# 目录 |
||||
|
||||
[TOC] |
||||
|
||||
|
||||
|
||||
--- |
||||
|
||||
# 发送请求部分 |
||||
|
||||
## 1. 定义您的请求 |
||||
|
||||
发送请求是通讯的第一步,如果您只需要连接到对应的服务器,接受对应的推送,而无需发送任何消息请移步至 [4. 定义您的响应](## 4. 定义您的响应) |
||||
|
||||
新建一个结构类`DataStudent` |
||||
|
||||
```csharp |
||||
public struct DataStudent{ |
||||
public string Name { get; set; } |
||||
public int Age; |
||||
public int ID; |
||||
public DataStudent(string name,int age){ |
||||
Name = name; |
||||
Age = age; |
||||
ID = 0; |
||||
} |
||||
} |
||||
``` |
||||
|
||||
实现`IRequest`接口 |
||||
|
||||
`IRequest`包含两种输出最终发送结果的方法,如果您需要发送字符类型的数据格式,请实现`ToProtocolData`这个方法,如果您需要发送Hex类型的数据格式,请实现`ToProcotolByteData`这个方法。 |
||||
|
||||
注意:切勿实现两个方法,实现两个方法会同时发送字符类型+Hex类型两种数据格式的拼接(字符在前,Hex在后,因为字符根据Encoding会转码成未知的Hex数据,不推荐这样做),请实现其中一个,另外一个使用 `return null` 来填补空缺 |
||||
|
||||
```csharp |
||||
public struct DataStudent :IRequest{ |
||||
public string Name { get; set; } |
||||
public int Age; |
||||
public int ID; |
||||
public DataStudent(string name,int age){ |
||||
Name = name; |
||||
Age = age; |
||||
ID = 0; |
||||
} |
||||
|
||||
public string ToProtocolData() |
||||
{ |
||||
return JsonConvert.SerializeObject(this); |
||||
} |
||||
|
||||
public byte[] ToProtocolByteData() |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
``` |
||||
|
||||
|
||||
|
||||
## 2. 发送您的请求 |
||||
|
||||
定义好您的请求后,在特定类的代码域里可以通过`this.EGSendMessage<T>(T t)`发送您的请求,该类需要实现`IEGFramework` |
||||
|
||||
该方法包含三个参数,实现`IRequest`的数据对象,发送对象(sender),以及协议类型。 |
||||
|
||||
发送对象一般为注册过的连接,包含IP地址以及端口等参数。 |
||||
|
||||
```csharp |
||||
public partial class ViewTestStudent : Node,IEGFramework |
||||
{ |
||||
public override void _Ready() |
||||
{ |
||||
this.EGSendMessage<DataStudent>(new DataStudent(), "127.0.0.1:6000", ProtocolType.TCPClient); |
||||
} |
||||
} |
||||
``` |
||||
|
||||
## 3. 设定您的发送间隔 |
||||
|
||||
您有没有发现,在您连续发送两条消息的时候,会产生一个0.1s左右的间隔,这个设计是为了防止连续多次发送消息的时候产生粘包现象,如果您需要立即发送,或者是延长这个间隔,可以通过以下方式设定发送间隔。 |
||||
|
||||
```csharp |
||||
// 两消息之间设定无间隔,立刻发送 |
||||
this.GetModule<EGMessage>().SetDelay(0); |
||||
// 两消息之间设定间隔1s后再发送 |
||||
this.GetModule<EGMessage>().SetDelay(1000); |
||||
``` |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--- |
||||
|
||||
# 处理响应部分 |
||||
|
||||
## 4. 定义您的响应 |
||||
|
||||
当连接到服务器时,如果您先发起请求,此时服务器会处理您的请求,有一段时间的空白期,或者该服务器是广播型服务器,即使不发送请求,也会推送数据给您。 |
||||
|
||||
新建一个结构类`DataStudent` |
||||
|
||||
```csharp |
||||
public struct DataStudent{ |
||||
public string Name { get; set; } |
||||
public int Age; |
||||
public int ID; |
||||
public DataStudent(string name,int age){ |
||||
Name = name; |
||||
Age = age; |
||||
ID = 0; |
||||
} |
||||
} |
||||
``` |
||||
|
||||
实现`IResponse`接口 |
||||
|
||||
`IResponse`包含两个输入数据的参数的方法用来过滤请求数据,建议您在这个方法内使用try catch 函数,以防止在程序处理异常时中断程序。如果您需要按照hex格式处理或者按照字符格式处理,请在这个函数里面写明对应的方法。 |
||||
|
||||
该实现方法会返回一个布尔值的变量,如果返回true,则认同这个消息为该类型的消息并对该条消息进行事件处理。如果返回false,则不认同,也不会对该条消息进行事件处理。 |
||||
|
||||
```csharp |
||||
public struct DataStudent :IResponse{ |
||||
public string Name { get; set; } |
||||
public int Age; |
||||
public int ID; |
||||
public DataStudent(string name,int age){ |
||||
Name = name; |
||||
Age = age; |
||||
ID = 0; |
||||
} |
||||
|
||||
public bool TrySetData(string protocolData, byte[] protocolBytes) |
||||
{ |
||||
try |
||||
{ |
||||
DataStudent input = JsonConvert.DeserializeObject<DataStudent>(protocolData); |
||||
if (this.Name == "") |
||||
{ |
||||
return false; |
||||
} |
||||
else |
||||
{ |
||||
this.Name = input.Name; |
||||
this.Age = input.Age; |
||||
this.ID = input.ID; |
||||
return true; |
||||
} |
||||
} |
||||
catch (System.Exception) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
``` |
||||
|
||||
## 5. 注册响应的处理事件 |
||||
|
||||
定义好您的响应后,您可以通过注册响应处理事件`this.EGRegisterMessageEvent<T>(Action<T> a)`实现收到该消息并处理。注册事件中有三个参数可以选择,分别是收到的消息本身的结构体&对象,发送对象(sender),以及协议类型。消息可以无关通讯协议的类型,做到任何连接推送的消息都能收到并按照注册的事件进行处理。 |
||||
|
||||
同时,注册事件结束后,必须手动开启消息处理`EGOnMessage`,如果有需要,也可以在处理完消息之后关闭消息处理。 |
||||
|
||||
```csharp |
||||
public partial class ViewSaveSystem : Node,IEGFramework |
||||
{ |
||||
public override void _Ready() |
||||
{ |
||||
this.EGRegisterMessageEvent<DataStudent>((data,sender,protocol) => |
||||
{ |
||||
GD.Print(data.Name); |
||||
// 关闭消息处理 |
||||
this.EGOffMessage<DataStudent>(); |
||||
}); |
||||
// 开启消息处理 |
||||
this.EGOnMessage<DataStudent>(); |
||||
} |
||||
} |
||||
``` |
||||
|
||||
## 6. 启用对应的协议工具 |
||||
|
||||
在场景中的Node下,注册改脚本并启用对应的协议工具,切记,所有通讯工具必须实现`IProtocolReceived`接口,大部分可用的通讯工具均以EG开头。 |
||||
|
||||
```csharp |
||||
public partial class ViewSaveSystem : Node,IEGFramework |
||||
{ |
||||
public override void _Ready() |
||||
{ |
||||
// 启用对应的协议工具,此处以TCP客户端为例,需要其它协议开启对应的工具即可 |
||||
this.EGEnabledProtocolTool<EGTCPClient>(); |
||||
// 处理消息部分 |
||||
this.EGRegisterMessageEvent<DataStudent>((data,sender,protocol) => |
||||
{ |
||||
GD.Print(data.Name); |
||||
// 关闭消息处理 |
||||
this.EGOffMessage<DataStudent>(); |
||||
}); |
||||
// 开启消息处理 |
||||
this.EGOnMessage<DataStudent>(); |
||||
} |
||||
} |
||||
``` |
||||
|
@ -0,0 +1,146 @@
@@ -0,0 +1,146 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
|
||||
namespace EGFramework |
||||
{ |
||||
public static class EGSqlExtension |
||||
{ |
||||
public static string ToCreateTableSQL(this PropertyInfo property) |
||||
{ |
||||
string sqlCommand; |
||||
if (property.Name == "ID" || property.Name == "id" || property.Name == "Id") |
||||
{ |
||||
return ""; |
||||
} |
||||
if (property.PropertyType == typeof(int) || property.PropertyType.IsEnum) |
||||
{ |
||||
sqlCommand = "`" + property.Name + "` INTEGER" + " NOT NULL,"; |
||||
} |
||||
else if (property.PropertyType == typeof(double) || property.PropertyType == typeof(float)) |
||||
{ |
||||
sqlCommand = "`" + property.Name + "` REAL" + " NOT NULL,"; |
||||
} |
||||
else if (property.PropertyType == typeof(bool)) |
||||
{ |
||||
sqlCommand = "`" + property.Name + "` REAL" + " NOT NULL,"; |
||||
} |
||||
else if (property.PropertyType == typeof(long)) |
||||
{ |
||||
sqlCommand = "`" + property.Name + "` BIGINT(20)" + " NOT NULL,"; |
||||
} |
||||
else if (property.PropertyType == typeof(string)) |
||||
{ |
||||
sqlCommand = "`" + property.Name + "` VARCHAR(255)" + " NOT NULL,"; |
||||
} |
||||
else |
||||
{ |
||||
sqlCommand = "`" + property.Name + "` VARCHAR(255)" + " NOT NULL,"; |
||||
} |
||||
return sqlCommand; |
||||
} |
||||
|
||||
public static string ToCreateTableSQL(this FieldInfo field) |
||||
{ |
||||
string sqlCommand; |
||||
if (field.Name == "ID" || field.Name == "id" || field.Name == "Id") |
||||
{ |
||||
return ""; |
||||
} |
||||
if (field.FieldType == typeof(int) || field.FieldType.IsEnum) |
||||
{ |
||||
sqlCommand = "`" + field.Name + "` INTEGER" + " NOT NULL,"; |
||||
} |
||||
else if (field.FieldType == typeof(double) || field.FieldType == typeof(float)) |
||||
{ |
||||
sqlCommand = "`" + field.Name + "` REAL" + " NOT NULL,"; |
||||
} |
||||
else if (field.FieldType == typeof(bool)) |
||||
{ |
||||
sqlCommand = "`" + field.Name + "` REAL" + " NOT NULL,"; |
||||
} |
||||
else if (field.FieldType == typeof(long)) |
||||
{ |
||||
sqlCommand = "`" + field.Name + "` BIGINT(20)" + " NOT NULL,"; |
||||
} |
||||
else if (field.FieldType == typeof(string)) |
||||
{ |
||||
sqlCommand = "`" + field.Name + "` VARCHAR(255)" + " NOT NULL,"; |
||||
} |
||||
else |
||||
{ |
||||
sqlCommand = "`" + field.Name + "` VARCHAR(255)" + " NOT NULL,"; |
||||
} |
||||
return sqlCommand; |
||||
} |
||||
|
||||
public static string ToCreateTableSQL(this KeyValuePair<string, Type> param) |
||||
{ |
||||
string sqlCommand; |
||||
if (param.Key == "ID" || param.Key == "id" || param.Key == "Id") |
||||
{ |
||||
return ""; |
||||
} |
||||
if (param.Value == typeof(int) || param.Value.IsEnum) |
||||
{ |
||||
sqlCommand = "`" + param.Key + "` INTEGER" + " NOT NULL,"; |
||||
} |
||||
else if (param.Value == typeof(double) || param.Value == typeof(float)) |
||||
{ |
||||
sqlCommand = "`" + param.Key + "` REAL" + " NOT NULL,"; |
||||
} |
||||
else if (param.Value == typeof(bool)) |
||||
{ |
||||
sqlCommand = "`" + param.Key + "` REAL" + " NOT NULL,"; |
||||
} |
||||
else if (param.Value == typeof(long)) |
||||
{ |
||||
sqlCommand = "`" + param.Key + "` BIGINT(20)" + " NOT NULL,"; |
||||
} |
||||
else if (param.Value == typeof(string)) |
||||
{ |
||||
sqlCommand = "`" + param.Key + "` VARCHAR(255)" + " NOT NULL,"; |
||||
} |
||||
else |
||||
{ |
||||
sqlCommand = "`" + param.Key + "` VARCHAR(255)" + " NOT NULL,"; |
||||
} |
||||
return sqlCommand; |
||||
} |
||||
|
||||
public static string ToCreateTableSQL(this Type type, string tableName) |
||||
{ |
||||
var properties = type.GetProperties(); |
||||
FieldInfo[] fields = type.GetFields(); |
||||
string keySet = ""; |
||||
foreach (PropertyInfo key in properties) |
||||
{ |
||||
keySet += key.ToCreateTableSQL(); |
||||
} |
||||
foreach (FieldInfo key in fields) |
||||
{ |
||||
keySet += key.ToCreateTableSQL(); |
||||
} |
||||
keySet = keySet.TrimEnd(','); |
||||
string createSql = @"CREATE TABLE " + tableName + " (" + |
||||
"`ID` INTEGER PRIMARY KEY AUTOINCREMENT, " + keySet |
||||
+ ");"; |
||||
return createSql; |
||||
} |
||||
|
||||
public static string ToCreateTableSQL(this Dictionary<string,Type> tableParam,string tableName) |
||||
{ |
||||
|
||||
string keySet = ""; |
||||
foreach(KeyValuePair<string,Type> key in tableParam){ |
||||
keySet += key.ToCreateTableSQL(); |
||||
} |
||||
keySet = keySet.TrimEnd(','); |
||||
string createSql = @"CREATE TABLE "+tableName+" ("+ |
||||
"`ID` INTEGER PRIMARY KEY AUTOINCREMENT, "+keySet |
||||
+");"; |
||||
return createSql; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
namespace EGFramework |
||||
{ |
||||
public class EGGenerate : EGModule |
||||
{ |
||||
public override void Init() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public T GenerateUI<T>(object data) where T : new() |
||||
{ |
||||
T ui = new T(); |
||||
return ui; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
namespace EGFramework |
||||
{ |
||||
public interface IGenerateToolsInterface |
||||
{ |
||||
public string GenerateCode<T>(); |
||||
} |
||||
public interface IGodotTable |
||||
{ |
||||
|
||||
} |
||||
public interface IGodotRowData |
||||
{ |
||||
|
||||
} |
||||
|
||||
public interface ITableData |
||||
{ |
||||
/// <summary> |
||||
/// Get the data of the table. |
||||
/// </summary> |
||||
/// <returns></returns> |
||||
string[][] GetTableData(); |
||||
/// <summary> |
||||
/// Get the header of the table. |
||||
/// </summary> |
||||
/// <returns></returns> |
||||
string[] GetTableHeader(); |
||||
} |
||||
|
||||
public interface ITableRowData |
||||
{ |
||||
string[] GetRowData(); |
||||
} |
||||
} |
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
namespace EGFramework.Code{ |
||||
public class EGSvgGenerator : IGenerateToolsInterface |
||||
{ |
||||
public string SvgHeader { get ; private set;} |
||||
public const string SvgFooter = "</svg>"; |
||||
|
||||
public int Width { get; set; } |
||||
public int Height { get; set; } |
||||
public EGSvgViewBox ViewBox { get; set; } |
||||
|
||||
public EGSvgGenerator(int width, int height, EGSvgViewBox viewBox) |
||||
{ |
||||
Width = width; |
||||
Height = height; |
||||
ViewBox = viewBox; |
||||
SvgHeader = $"<svg width=\"{width}\" height=\"{height}\" viewBox=\"{viewBox.X} {viewBox.Y} {viewBox.Width} {viewBox.Height}\" xmlns=\"http://www.w3.org/2000/svg\">"; |
||||
} |
||||
|
||||
public void DrawCircle(float x, float y, float radius, string color) |
||||
{ |
||||
// Implementation for drawing a circle in SVG format |
||||
string svgCircle = $"<circle cx=\"{x}\" cy=\"{y}\" r=\"{radius}\" fill=\"{color}\" />"; |
||||
} |
||||
public void DrawEllipse(float cx, float cy, float rx, float ry, string color) |
||||
{ |
||||
// Implementation for drawing an ellipse in SVG format |
||||
string svgEllipse = $"<ellipse cx=\"{cx}\" cy=\"{cy}\" rx=\"{rx}\" ry=\"{ry}\" fill=\"{color}\" />"; |
||||
} |
||||
public void DrawPolygon(float[] points, string color) |
||||
{ |
||||
// Implementation for drawing a polygon in SVG format |
||||
string svgPolygon = "<polygon points=\""; |
||||
for (int i = 0; i < points.Length; i += 2) |
||||
{ |
||||
svgPolygon += $"{points[i]},{points[i + 1]} "; |
||||
} |
||||
svgPolygon += $"\" fill=\"{color}\" />"; |
||||
} |
||||
public void DrawPolyline(float[] points, string color) |
||||
{ |
||||
// Implementation for drawing a polyline in SVG format |
||||
string svgPolyline = "<polyline points=\""; |
||||
for (int i = 0; i < points.Length; i += 2) |
||||
{ |
||||
svgPolyline += $"{points[i]},{points[i + 1]} "; |
||||
} |
||||
svgPolyline += $"\" stroke=\"{color}\" fill=\"none\" />"; |
||||
} |
||||
public void DrawPath(string d, string color) |
||||
{ |
||||
// Implementation for drawing a path in SVG format |
||||
string svgPath = $"<path d=\"{d}\" fill=\"{color}\" />"; |
||||
} |
||||
public void DrawRectangle(float x, float y, float width, float height, string color) |
||||
{ |
||||
// Implementation for drawing a rectangle in SVG format |
||||
string svgRectangle = $"<rect x=\"{x}\" y=\"{y}\" width=\"{width}\" height=\"{height}\" fill=\"{color}\" />"; |
||||
} |
||||
public void DrawLine(float x1, float y1, float x2, float y2, string color) |
||||
{ |
||||
// Implementation for drawing a line in SVG format |
||||
string svgLine = $"<line x1=\"{x1}\" y1=\"{y1}\" x2=\"{x2}\" y2=\"{y2}\" stroke=\"{color}\" />"; |
||||
} |
||||
public void DrawText(float x, float y, string text, string color) |
||||
{ |
||||
// Implementation for drawing text in SVG format |
||||
string svgText = $"<text x=\"{x}\" y=\"{y}\" fill=\"{color}\">{text}</text>"; |
||||
} |
||||
|
||||
|
||||
public string GenerateCode<T>() |
||||
{ |
||||
return typeof(T).Name; |
||||
} |
||||
} |
||||
public struct EGSvgViewBox { |
||||
public float X { get; set; } |
||||
public float Y { get; set; } |
||||
public float Width { get; set; } |
||||
public float Height { get; set; } |
||||
|
||||
public EGSvgViewBox(float x, float y, float width, float height) |
||||
{ |
||||
X = x; |
||||
Y = y; |
||||
Width = width; |
||||
Height = height; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
namespace EGFramework |
||||
{ |
||||
public static class EGSVG16PX |
||||
{ |
||||
public const string Circle = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"24\" cy=\"24\" r=\"20\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"3\"/></svg>"; |
||||
public const string Rect = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M39 6H9C7.34315 6 6 7.34315 6 9V39C6 40.6569 7.34315 42 9 42H39C40.6569 42 42 40.6569 42 39V9C42 7.34315 40.6569 6 39 6Z\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"3\"/></svg>"; |
||||
public const string Heart = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M15 8C8.92487 8 4 12.9249 4 19C4 30 17 40 24 42.3262C31 40 44 30 44 19C44 12.9249 39.0751 8 33 8C29.2797 8 25.9907 9.8469 24 12.6738C22.0093 9.8469 18.7203 8 15 8Z\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"miter\"/></svg>"; |
||||
public const string Star = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M23.9986 5L17.8856 17.4776L4 19.4911L14.0589 29.3251L11.6544 43L23.9986 36.4192L36.3454 43L33.9586 29.3251L44 19.4911L30.1913 17.4776L23.9986 5Z\" fill=\"none\" stroke=\"#ffffff\" stroke-width=\"3\" stroke-linejoin=\"miter\"/></svg>"; |
||||
|
||||
} |
||||
} |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
using System; |
||||
using Godot; |
||||
namespace EGFramework.UI |
||||
{ |
||||
public static class EGodotBasicDialogExtension |
||||
{ |
||||
public static void EGAlert(this Node self, string alertMsg, string title = "Alert") |
||||
{ |
||||
AcceptDialog acceptDialog = self.PopupNode<AcceptDialog>("AlertDialog"); |
||||
acceptDialog.Title = title; |
||||
acceptDialog.DialogText = alertMsg; |
||||
} |
||||
|
||||
public static void EGConfirm(this Node self, string alertMsg, Action<bool> callback, string title = "Confirm") |
||||
{ |
||||
EGodotConfirmationDialog confirmDialog = self.PopupNode<EGodotConfirmationDialog>("ConfirmDialog"); |
||||
confirmDialog.Title = title; |
||||
confirmDialog.DialogText = alertMsg; |
||||
confirmDialog.Init(callback); |
||||
} |
||||
|
||||
public static void EGFileOpen(this Node self, string filePath, Action<string> selectPath, string title = "Open a file") |
||||
{ |
||||
EGodotFileDialog fileDialog = self.PopupNode<EGodotFileDialog>("FileDialog"); |
||||
fileDialog.Title = title; |
||||
fileDialog.RootSubfolder = filePath; |
||||
fileDialog.InitFileSelect(selectPath); |
||||
} |
||||
|
||||
public static void EGFileSave(this Node self, string filePath, Action<string> selectPath, string title = "Save a file") |
||||
{ |
||||
EGodotFileDialog fileDialog = self.PopupNode<EGodotFileDialog>("FileDialog"); |
||||
fileDialog.Title = title; |
||||
fileDialog.CurrentFile = filePath; |
||||
fileDialog.InitSaveFileSelect(selectPath); |
||||
} |
||||
|
||||
public static void EGDocumentOpen(this Node self, string filePath, Action<string> selectPath, string title = "FileSelect") |
||||
{ |
||||
EGodotFileDialog fileDialog = self.PopupNode<EGodotFileDialog>("FileDialog"); |
||||
fileDialog.Title = title; |
||||
fileDialog.RootSubfolder = filePath; |
||||
fileDialog.InitDirSelect(selectPath); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
using System; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.UI { |
||||
public partial class EGodotConfirmationDialog : ConfirmationDialog, IEGFramework |
||||
{ |
||||
private EasyEventOnce<bool> OnConfirm { set; get; } = new EasyEventOnce<bool>(); |
||||
private bool IsInit { set; get; } = false; |
||||
public void Init(Action<bool> callback) |
||||
{ |
||||
OnConfirm.Register(callback); |
||||
if (!IsInit) |
||||
{ |
||||
this.Confirmed += () => OnConfirm.Invoke(true); |
||||
this.Canceled += () => OnConfirm.Invoke(false); |
||||
IsInit = true; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public partial class EGodotEditDialog : ConfirmationDialog, IEGFramework |
||||
{ |
||||
public VBoxContainer EditList { get; set; } |
||||
public List<HBoxContainer> EditListItem { get; set; } |
||||
public Label ErrorTips { get; set; } |
||||
|
||||
public EasyEvent<Dictionary<string, object>> OnEdit { set; get; } = new EasyEvent<Dictionary<string, object>>(); |
||||
private Dictionary<string, object> EditCache { set; get; } = new Dictionary<string, object>(); |
||||
private IUnRegister OnDataEdit { set; get; } |
||||
|
||||
public List<EGodotEditParam> ParamUIs { set; get; } = new List<EGodotEditParam>(); |
||||
private bool IsInit { set; get; } = false; |
||||
|
||||
const int DefaultWidth = 640; |
||||
const int DefaultHeight = 320; |
||||
|
||||
public void InitDialog(Dictionary<string, object> data, Action<Dictionary<string, object>> onDataEdit, string title = "Edit Data", int width = DefaultWidth, int height = DefaultHeight) |
||||
{ |
||||
if (!IsInit) |
||||
{ |
||||
EditList = new VBoxContainer(); |
||||
EditList.Name = "EditList"; |
||||
EditList.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; |
||||
this.AddChild(EditList); |
||||
this.Connect("confirmed", Callable.From(OnConfirm)); |
||||
this.Size = new Vector2I(width, height); |
||||
IsInit = true; |
||||
} |
||||
this.EditList.ClearChildren(); |
||||
ParamUIs.Clear(); |
||||
this.Title = title; |
||||
OnDataEdit = OnEdit.Register(onDataEdit); |
||||
this.ErrorTips = new Label(); |
||||
ErrorTips.Name = "ErrorTips"; |
||||
ErrorTips.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; |
||||
EditList.AddChild(ErrorTips); |
||||
ErrorTips.Visible = false; |
||||
foreach (KeyValuePair<string, object> param in data) |
||||
{ |
||||
EGodotEditParam paramUI = new EGodotEditParam(); |
||||
this.EditList.AddChild(paramUI); |
||||
paramUI.Init(param); |
||||
ParamUIs.Add(paramUI); |
||||
} |
||||
this.PopupCentered(); |
||||
} |
||||
|
||||
public void OnConfirm() |
||||
{ |
||||
EditCache.Clear(); |
||||
foreach (EGodotEditParam paramUI in ParamUIs) |
||||
{ |
||||
EditCache.Add(paramUI.GetKey(), paramUI.GetValue()); |
||||
} |
||||
try |
||||
{ |
||||
OnEdit.Invoke(EditCache); |
||||
OnDataEdit.UnRegister(); |
||||
this.Visible = false; |
||||
} |
||||
catch (NullReferenceException) |
||||
{ |
||||
this.OnErrorTips("某项数据不能为空!"); |
||||
} |
||||
catch (FormatException) |
||||
{ |
||||
this.OnErrorTips("某项数据格式不准确!"); |
||||
} |
||||
catch (Exception e) |
||||
{ |
||||
this.OnErrorTips(e.ToString()); |
||||
throw; |
||||
} |
||||
} |
||||
|
||||
public void OnErrorTips(string tips) |
||||
{ |
||||
ErrorTips.Visible = true; |
||||
ErrorTips.Text = tips; |
||||
} |
||||
|
||||
public void OnCancel() |
||||
{ |
||||
OnDataEdit.UnRegister(); |
||||
this.Visible = false; |
||||
} |
||||
} |
||||
public static class EGodotEditDialogExtension |
||||
{ |
||||
public static EGodotEditDialog EGEditDialog(this Node self, Dictionary<string, object> data, Action<Dictionary<string, object>> onDataEdit, string title = "Edit") |
||||
{ |
||||
EGodotEditDialog editDialog = self.PopupNode<EGodotEditDialog>("Edit"); |
||||
editDialog.InitDialog(data, onDataEdit, title); |
||||
// editDialog.PopupCentered(); |
||||
return editDialog; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
|
||||
using System; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public partial class EGodotFileDialog : FileDialog, IEGFramework |
||||
{ |
||||
private EasyEventOnce<string> OnFileSelect { set; get; } = new EasyEventOnce<string>(); |
||||
private EasyEventOnce<string> OnDirSelect { set; get; } = new EasyEventOnce<string>(); |
||||
private EasyEventOnce<string[]> OnFilesSelect { set; get; } = new EasyEventOnce<string[]>(); |
||||
|
||||
private bool IsInit { set; get; } = false; |
||||
public void Init() |
||||
{ |
||||
if (!IsInit) |
||||
{ |
||||
this.FileSelected += OnFileSelect.Invoke; |
||||
this.DirSelected += OnDirSelect.Invoke; |
||||
this.FilesSelected += OnFilesSelect.Invoke; |
||||
this.Size = new Vector2I(480, 320); |
||||
this.Access = AccessEnum.Filesystem; |
||||
IsInit = true; |
||||
} |
||||
} |
||||
public void InitFileSelect(Action<string> callback) |
||||
{ |
||||
OnFileSelect.Register(callback); |
||||
Init(); |
||||
this.FileMode = FileModeEnum.OpenFile; |
||||
} |
||||
|
||||
public void InitDirSelect(Action<string> callback) |
||||
{ |
||||
OnDirSelect.Register(callback); |
||||
this.FileMode = FileModeEnum.OpenDir; |
||||
Init(); |
||||
} |
||||
|
||||
public void InitFilesSelect(Action<string[]> callback) |
||||
{ |
||||
OnFilesSelect.Register(callback); |
||||
this.FileMode = FileModeEnum.OpenFiles; |
||||
Init(); |
||||
} |
||||
|
||||
public void InitAnySelect(Action<string> singleSelectCallback, Action<string[]> multiSelectCallback) |
||||
{ |
||||
OnFileSelect.Register(singleSelectCallback); |
||||
OnDirSelect.Register(singleSelectCallback); |
||||
OnFilesSelect.Register(multiSelectCallback); |
||||
this.FileMode = FileModeEnum.OpenAny; |
||||
Init(); |
||||
} |
||||
|
||||
public void InitSaveFileSelect(Action<string> callback) |
||||
{ |
||||
OnFileSelect.Register(callback); |
||||
this.FileMode = FileModeEnum.SaveFile; |
||||
Init(); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
using Godot; |
||||
using Mysqlx.Crud; |
||||
using static Godot.GD; |
||||
|
||||
namespace EGFramework{ |
||||
|
||||
public class EGSingletonNode : IEGFramework, IModule |
||||
{ |
||||
public IOCContainer NodeContainer = new IOCContainer(); |
||||
public Stack<Window> WindowCache = new Stack<Window>(); |
||||
public Window CurrentWindow { set; get; } |
||||
|
||||
private bool PopUpFlag { set; get; } |
||||
public void Init() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public void PopupNode(Window window) |
||||
{ |
||||
PopUpFlag = true; |
||||
if (CurrentWindow != null) |
||||
{ |
||||
this.CurrentWindow.Hide(); |
||||
CurrentWindow.VisibilityChanged -= OnPopUpUnitVisibleChanged; |
||||
WindowCache.Push(CurrentWindow); |
||||
} |
||||
|
||||
window.PopupCentered(); |
||||
this.CurrentWindow = window; |
||||
CurrentWindow.VisibilityChanged += OnPopUpUnitVisibleChanged; |
||||
PopUpFlag = false; |
||||
} |
||||
|
||||
public void OnPopUpUnitVisibleChanged() |
||||
{ |
||||
if (CurrentWindow != null && !CurrentWindow.Visible && !PopUpFlag) |
||||
{ |
||||
CurrentWindow.VisibilityChanged -= OnPopUpUnitVisibleChanged; |
||||
if (this.WindowCache.Count > 0) |
||||
{ |
||||
Window lastWindow = WindowCache.Pop(); |
||||
CurrentWindow = lastWindow; |
||||
Callable.From(() => CurrentWindow.PopupCentered()).CallDeferred(); |
||||
CurrentWindow.VisibilityChanged += OnPopUpUnitVisibleChanged; |
||||
} |
||||
else |
||||
{ |
||||
CurrentWindow = null; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public IArchitecture GetArchitecture() |
||||
{ |
||||
return EGArchitectureImplement.Interface; |
||||
} |
||||
|
||||
} |
||||
|
||||
public static class EGCanCreateNodeExtension |
||||
{ |
||||
public static TNode CreateNode<TNode>(this Node self) where TNode : Node, new() |
||||
{ |
||||
TNode nodeData = new TNode(); |
||||
nodeData.Name = typeof(TNode).Name; |
||||
self.AddChild(nodeData); |
||||
return nodeData; |
||||
} |
||||
|
||||
public static TNode CreateNode<TNode>(this Node self, string name) where TNode : Node, new() |
||||
{ |
||||
TNode nodeData = new TNode(); |
||||
nodeData.Name = name; |
||||
self.AddChild(nodeData); |
||||
return nodeData; |
||||
} |
||||
|
||||
public static TNode SingletoneNode<TNode>(this Node self, string name) where TNode : Node, new() |
||||
{ |
||||
TNode nodeData; |
||||
if (EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<TNode>() != null) |
||||
{ |
||||
nodeData = EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Get<TNode>(); |
||||
} |
||||
else |
||||
{ |
||||
nodeData = self.GetTree().Root.CreateNode<TNode>(); |
||||
EGArchitectureImplement.Interface.GetModule<EGSingletonNode>().NodeContainer.Register(nodeData); |
||||
} |
||||
nodeData.Name = name; |
||||
return nodeData; |
||||
} |
||||
|
||||
public static TWindowNode PopupNode<TWindowNode>(this Node self, string name) where TWindowNode : Window, new() |
||||
{ |
||||
TWindowNode nodeData; |
||||
EGSingletonNode singletonNode = EGArchitectureImplement.Interface.GetModule<EGSingletonNode>(); |
||||
if (singletonNode.NodeContainer.Get<TWindowNode>() != null) |
||||
{ |
||||
nodeData = singletonNode.NodeContainer.Get<TWindowNode>(); |
||||
} |
||||
else |
||||
{ |
||||
nodeData = self.GetTree().Root.CreateNode<TWindowNode>(); |
||||
singletonNode.NodeContainer.Register(nodeData); |
||||
} |
||||
singletonNode.PopupNode(nodeData); |
||||
nodeData.Name = name; |
||||
return nodeData; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public interface IEGodotData |
||||
{ |
||||
public void RefreshData(); |
||||
} |
||||
} |
@ -0,0 +1,197 @@
@@ -0,0 +1,197 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public partial class EGodotEditParam : EGodotParam, IEGFramework |
||||
{ |
||||
public LineEdit ParamEdit { get; set; } |
||||
public OptionButton ParamOption { get; set; } |
||||
public CheckButton ParamCheck { get; set; } |
||||
public List<CheckBox> ParamCheckList { get; set; } |
||||
public Label ParamReadOnly { get; set; } |
||||
public Label ParamPathSelect { get; set; } |
||||
public SpinBox ParamSpinBox { get; set; } |
||||
public HSlider ParamSlider { get; set; } |
||||
public Button ParamOperate { get; set; } |
||||
private Type ValueType { set; get; } |
||||
|
||||
public override void Init(KeyValuePair<string, object> editValue) |
||||
{ |
||||
base.Init(editValue); |
||||
if (editValue.Key == "id" || editValue.Key == "ID" || editValue.Key == "Id") |
||||
{ |
||||
this.ParamReadOnly = new Label(); |
||||
ParamReadOnly.Name = "ParamReadOnly"; |
||||
ParamReadOnly.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
ParamReadOnly.Text = editValue.Value.ToString(); |
||||
this.AddChild(ParamReadOnly); |
||||
return; |
||||
} |
||||
if (editValue.Value is string || editValue.Value is null) |
||||
{ |
||||
this.ParamEdit = new LineEdit(); |
||||
ParamEdit.Name = "ParamEdit"; |
||||
ParamEdit.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
ParamEdit.PlaceholderText = "Please input " + editValue.Key; |
||||
this.AddChild(ParamEdit); |
||||
ParamEdit.Text = (string)editValue.Value; |
||||
} |
||||
else if (editValue.Value is bool) |
||||
{ |
||||
this.ParamCheck = new CheckButton(); |
||||
ParamCheck.Name = "ParamCheck"; |
||||
ParamCheck.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
ParamCheck.Text = ""; |
||||
ParamCheck.ButtonPressed = (bool)editValue.Value; |
||||
this.AddChild(ParamCheck); |
||||
} |
||||
else if (editValue.Value is IEGReadOnlyString) |
||||
{ |
||||
this.ParamReadOnly = new Label(); |
||||
ParamReadOnly.Name = "ParamReadOnly"; |
||||
ParamReadOnly.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
ParamReadOnly.Text = ((IEGReadOnlyString)editValue.Value).GetString(); |
||||
this.AddChild(ParamReadOnly); |
||||
} |
||||
else if (editValue.Value is EGSelectParam) |
||||
{ |
||||
this.ParamOption = new OptionButton(); |
||||
ParamOption.Name = "ParamOption"; |
||||
ParamOption.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
this.AddChild(ParamOption); |
||||
foreach (KeyValuePair<int, string> selectOptions in ((EGSelectParam)editValue.Value).SelectList) |
||||
{ |
||||
this.ParamOption.AddItem(selectOptions.Value, selectOptions.Key); |
||||
} |
||||
this.ParamOption.Selected = this.ParamOption.GetItemIndex(((EGSelectParam)editValue.Value).SelectID); |
||||
} |
||||
else if (editValue.Value is int) |
||||
{ |
||||
this.ParamSpinBox = new SpinBox(); |
||||
ParamSpinBox.Name = "ParamSpinBox"; |
||||
ParamSpinBox.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
ParamSpinBox.MaxValue = int.MaxValue; |
||||
ParamSpinBox.MinValue = int.MinValue; |
||||
ParamSpinBox.Value = (int)editValue.Value; |
||||
this.AddChild(ParamSpinBox); |
||||
ValueType = typeof(int); |
||||
} |
||||
else if (editValue.Value is float) |
||||
{ |
||||
this.ParamSpinBox = new SpinBox(); |
||||
ParamSpinBox.Name = "ParamSpinBox"; |
||||
ParamSpinBox.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
ParamSpinBox.MaxValue = float.MaxValue; |
||||
ParamSpinBox.MinValue = float.MinValue; |
||||
ParamSpinBox.Value = (float)editValue.Value; |
||||
ParamSpinBox.Step = 0.01f; |
||||
this.AddChild(ParamSpinBox); |
||||
ValueType = typeof(float); |
||||
} |
||||
else if (editValue.Value is double) |
||||
{ |
||||
this.ParamSpinBox = new SpinBox(); |
||||
ParamSpinBox.Name = "ParamSpinBox"; |
||||
ParamSpinBox.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
ParamSpinBox.MaxValue = double.MaxValue; |
||||
ParamSpinBox.MinValue = double.MinValue; |
||||
ParamSpinBox.Value = (double)editValue.Value; |
||||
ParamSpinBox.Step = 0.0001f; |
||||
this.AddChild(ParamSpinBox); |
||||
ValueType = typeof(double); |
||||
} |
||||
else if (editValue.Value is EGRangeParam) |
||||
{ |
||||
this.ParamSlider = new HSlider(); |
||||
ParamSlider.Name = "ParamSlider"; |
||||
ParamSlider.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
EGRangeParam rangeParam = (EGRangeParam)editValue.Value; |
||||
ParamSlider.MinValue = rangeParam.Min; |
||||
ParamSlider.MaxValue = rangeParam.Max; |
||||
ParamSlider.Step = rangeParam.Step; |
||||
ParamSlider.Value = rangeParam.Value; |
||||
this.AddChild(ParamSlider); |
||||
} |
||||
else if (editValue.Value is EGPathSelect) |
||||
{ |
||||
EGPathSelect pathSelect = (EGPathSelect)editValue.Value; |
||||
this.ParamPathSelect = new Label(); |
||||
ParamPathSelect.Name = "ParamReadOnly"; |
||||
ParamPathSelect.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
ParamPathSelect.Text = pathSelect.Path; |
||||
this.AddChild(ParamPathSelect); |
||||
this.ParamOperate = new Button(); |
||||
ParamOperate.Name = "SelectBtn"; |
||||
ParamOperate.Text = "Select file"; |
||||
ParamOperate.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
ParamOperate.Pressed += () => |
||||
{ |
||||
this.EGFileOpen("res://", str => |
||||
{ |
||||
ParamPathSelect.Text = str; |
||||
}); |
||||
}; |
||||
// ParamOperate.Pressed += |
||||
this.AddChild(ParamOperate); |
||||
} |
||||
} |
||||
|
||||
public string GetKey() |
||||
{ |
||||
return ParamValue.Key; |
||||
} |
||||
|
||||
public object GetValue() |
||||
{ |
||||
if (ParamEdit != null) |
||||
{ |
||||
return ParamEdit.Text; |
||||
} |
||||
else if (ParamCheck != null) |
||||
{ |
||||
return ParamCheck.ButtonPressed; |
||||
} |
||||
else if (ParamOption != null) |
||||
{ |
||||
return ParamOption.Selected; |
||||
} |
||||
else if (ParamReadOnly != null) |
||||
{ |
||||
return ParamReadOnly.Text; |
||||
} |
||||
else if (ParamSpinBox != null) |
||||
{ |
||||
if (ValueType == typeof(int)) |
||||
{ |
||||
return (int)ParamSpinBox.Value; |
||||
} |
||||
else if (ValueType == typeof(float)) |
||||
{ |
||||
return (float)ParamSpinBox.Value; |
||||
} |
||||
return ParamSpinBox.Value; |
||||
} |
||||
else if (ParamSlider != null) |
||||
{ |
||||
return ParamSlider.Value; |
||||
} |
||||
else if (ParamPathSelect != null) |
||||
{ |
||||
return new EGPathSelect(){Path = ParamPathSelect.Text}; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public override KeyValuePair<string, object> GetData() |
||||
{ |
||||
return new KeyValuePair<string, object>(GetKey(), GetValue()); |
||||
} |
||||
|
||||
public override void RefreshData(KeyValuePair<string, object> data) |
||||
{ |
||||
//this param cannot be Refreshed,please remove and recreate a new EGodotEditParam. |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public partial class EGodotMenu : Control, IEGFramework |
||||
{ |
||||
public Dictionary<string, Control> PageContainer { set; get; } = new Dictionary<string, Control>(); |
||||
|
||||
public void RegisterPage<T>(string name,T page) where T : Control |
||||
{ |
||||
if (PageContainer.ContainsKey(name)) |
||||
{ |
||||
PageContainer[name] = page; |
||||
} |
||||
else |
||||
{ |
||||
PageContainer.Add(name,page); |
||||
} |
||||
} |
||||
|
||||
public void OpenPage<T>(string name,T page) where T : Control |
||||
{ |
||||
page.Visible = true; |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public interface IEGodotParam : IEGodotData |
||||
{ |
||||
public void Init(KeyValuePair<string, object> data); |
||||
public void RefreshData(KeyValuePair<string, object> data); |
||||
public KeyValuePair<string, object> GetData(); |
||||
} |
||||
public abstract partial class EGodotParam : BoxContainer, IEGFramework, IEGodotParam |
||||
{ |
||||
public Label ParamName { get; set; } |
||||
public KeyValuePair<string, object> ParamValue { get; set; } |
||||
|
||||
public virtual void Init(KeyValuePair<string, object> paramValue) |
||||
{ |
||||
ParamValue = paramValue; |
||||
this.ParamName = new Label(); |
||||
ParamName.Name = "ParamName"; |
||||
ParamName.Text = ParamValue.Key; |
||||
ParamName.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
this.AddChild(ParamName); |
||||
} |
||||
public void RefreshData() |
||||
{ |
||||
this.RefreshData(this.ParamValue); |
||||
} |
||||
public abstract KeyValuePair<string, object> GetData(); |
||||
|
||||
public abstract void RefreshData(KeyValuePair<string, object> data); |
||||
} |
||||
} |
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
using Godot; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
|
||||
public interface IEGodotRowData:IEGodotData |
||||
{ |
||||
public void Init(Dictionary<string, object> data); |
||||
public void RefreshData(Dictionary<string, object> data); |
||||
public Dictionary<string, object> GetData(); |
||||
} |
||||
public partial class EGodotRowData : PanelContainer, IEGFramework, IEGodotRowData |
||||
{ |
||||
|
||||
public Button ItemHover { get; set; } |
||||
public ColorRect Line { get; set; } |
||||
public ColorRect BackGround { get; set; } |
||||
public HBoxContainer List { get; set; } |
||||
|
||||
protected Dictionary<string, object> Data { get; set; } |
||||
protected bool IsInit { set; get; } = false; |
||||
|
||||
public Dictionary<string, object> GetData() |
||||
{ |
||||
return this.Data; |
||||
} |
||||
|
||||
|
||||
public virtual void Init(Dictionary<string, object> data) |
||||
{ |
||||
if (IsInit) |
||||
{ |
||||
this.Data = data; |
||||
this.RefreshData(data); |
||||
return; |
||||
} |
||||
this.Data = data; |
||||
BackGround = new ColorRect(); |
||||
BackGround.Name = "BackGround"; |
||||
BackGround.Color = new Color(0f, 0f, 0f, 0f); |
||||
BackGround.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
BackGround.SizeFlagsVertical = SizeFlags.ExpandFill; |
||||
this.AddChild(BackGround); |
||||
List = new HBoxContainer(); |
||||
List.Name = "TableRow_" + Resource.GenerateSceneUniqueId(); |
||||
List.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; |
||||
this.AddChild(List); |
||||
Line = new ColorRect(); |
||||
Line.Name = "Line"; |
||||
Line.Color = new Color(0f, 0f, 0f, 0f); |
||||
Line.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; |
||||
Line.SizeFlagsVertical = Control.SizeFlags.ShrinkEnd; |
||||
Line.CustomMinimumSize = new Vector2(0, 1); |
||||
this.AddChild(Line); |
||||
foreach (KeyValuePair<string, object> kv in data) |
||||
{ |
||||
this.List.AddChild(new Label() |
||||
{ |
||||
Name = kv.Key, |
||||
Text = kv.Value?.ToString(), |
||||
HorizontalAlignment = HorizontalAlignment.Center, |
||||
SizeFlagsHorizontal = Control.SizeFlags.ExpandFill |
||||
}); |
||||
} |
||||
this.AddThemeStyleboxOverride("panel", new StyleBoxEmpty()); |
||||
IsInit = true; |
||||
} |
||||
|
||||
public virtual void RefreshData(Dictionary<string, object> data) |
||||
{ |
||||
this.List.ClearChildren<Label>(); |
||||
foreach (KeyValuePair<string, object> kv in data) |
||||
{ |
||||
this.List.AddChild(new Label() |
||||
{ |
||||
Name = kv.Key, |
||||
Text = kv.Value.ToString(), |
||||
HorizontalAlignment = HorizontalAlignment.Center, |
||||
SizeFlagsHorizontal = Control.SizeFlags.ExpandFill |
||||
}); |
||||
} |
||||
} |
||||
|
||||
public void RefreshData() |
||||
{ |
||||
this.RefreshData(this.Data); |
||||
} |
||||
public void SetBackgroundColor(Color color) |
||||
{ |
||||
if (this.BackGround != null) |
||||
{ |
||||
this.BackGround.Color = color; |
||||
} |
||||
} |
||||
public void SetLineColor(Color color) |
||||
{ |
||||
if (this.Line != null) |
||||
{ |
||||
this.Line.Color = color; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,156 @@
@@ -0,0 +1,156 @@
|
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public partial class EGodotSaveTable : EGodotTable, IEGFramework |
||||
{ |
||||
public IEGSaveData SaveData { set; get; } |
||||
public Dictionary<string, string> TitleList { set; get; } = new Dictionary<string, string>(); |
||||
public string CurrentDataKey { set; get; } |
||||
|
||||
public EasyEvent QueryPage { set; get; } = new EasyEvent(); |
||||
|
||||
public EasyEvent SearchKey { set; get; } = new EasyEvent(); |
||||
|
||||
public void InitSaveData<TSaveData>(IEGSaveData eGSaveData) where TSaveData : IEGSaveData |
||||
{ |
||||
this.SaveData = eGSaveData; |
||||
|
||||
} |
||||
public void InitData<T>(string key) where T : new() |
||||
{ |
||||
int count = SaveData.GetDataCount(key); |
||||
if (PageAdapter == null) |
||||
{ |
||||
PageAdapter = new EGodotTablePageAdapter(count, PageLimit); |
||||
} |
||||
else |
||||
{ |
||||
PageAdapter.Reload(count, PageLimit); |
||||
} |
||||
this.Vertical = true; |
||||
CurrentDataKey = key; |
||||
EmptyData = typeof(T).EGenerateEmptyDictiontaryByType(); |
||||
QueryPage.Register(() => QueryPageData<T>()); |
||||
SearchKey.Register(() => SearchDataByKeyword<T>()); |
||||
TableName = typeof(T).Name; |
||||
TitleData = typeof(T).EGenerateDictiontaryByType(); |
||||
InitFunctionMenu(); |
||||
InitTitle(TitleData); |
||||
InitRowData(null); |
||||
InitPageMenu(); |
||||
} |
||||
|
||||
|
||||
public void QueryPageData<T>() where T : new() |
||||
{ |
||||
if (PageAdapter.CurrentPage <= 1) |
||||
{ |
||||
PageAdapter.CurrentPage = 1; |
||||
} |
||||
|
||||
TableData = SaveData.GetPage<T>(CurrentDataKey, PageAdapter.CurrentPage, PageAdapter.PageLimit).EGenerateDictionaryByGroup(); |
||||
} |
||||
|
||||
public void SearchDataByKeyword<T>() where T : new() |
||||
{ |
||||
string fieldName = FieldSelect.Text; |
||||
string keyWords = SearchEdit.Text; |
||||
TableData = SaveData.FindData<T>(CurrentDataKey, fieldName, keyWords).EGenerateDictionaryByGroup(); |
||||
} |
||||
|
||||
public override void OnAddData(Dictionary<string, object> data) |
||||
{ |
||||
// base.OnAddData(data); |
||||
SaveData.AddData(CurrentDataKey, data); |
||||
} |
||||
|
||||
public void ModifyData(Dictionary<string, object> eData) |
||||
{ |
||||
string primaryKey = ""; |
||||
if (eData.ContainsKey("ID")) primaryKey = "ID"; |
||||
if (eData.ContainsKey("id")) primaryKey = "id"; |
||||
if (eData.ContainsKey("Id")) primaryKey = "Id"; |
||||
if (primaryKey == "") |
||||
{ |
||||
this.EGAlert("Parmary key 'id' not defined!", "Error"); |
||||
return; |
||||
} |
||||
SaveData.UpdateData(CurrentDataKey, eData, eData[primaryKey]); |
||||
InitPageData(); |
||||
} |
||||
|
||||
|
||||
public override void InitPageData() |
||||
{ |
||||
RowDataContainer.ClearChildren(); |
||||
QueryPage.Invoke(); |
||||
int pointer = 0; |
||||
foreach (Dictionary<string, object> data in TableData) |
||||
{ |
||||
EGodotTableRowData rowData = RowDataContainer.CreateNode<EGodotTableRowData>("row" + pointer); |
||||
rowData.Init(data); |
||||
rowData.OnModify.Register(eData => |
||||
{ |
||||
this.EGEditDialog(eData, ModifyData, "Modify"); |
||||
}); |
||||
rowData.OnDelete.Register(() => |
||||
{ |
||||
string primaryKey = ""; |
||||
if (rowData.GetData().ContainsKey("ID")) primaryKey = "ID"; |
||||
if (rowData.GetData().ContainsKey("id")) primaryKey = "id"; |
||||
if (rowData.GetData().ContainsKey("Id")) primaryKey = "Id"; |
||||
if (primaryKey == "") |
||||
{ |
||||
this.EGAlert("Parmary key 'id' not defined!", "Error"); |
||||
return; |
||||
} |
||||
int remove_count = SaveData.RemoveData(CurrentDataKey, rowData.GetData()[primaryKey]); |
||||
PageAdapter.DataLength -= remove_count; |
||||
PageAdapter.Reload(PageAdapter.DataLength, PageLimit); |
||||
InitPageData(); |
||||
OnPageChanged.Invoke(); |
||||
}); |
||||
} |
||||
ResetSearch(); |
||||
//base.InitPageData(); |
||||
} |
||||
|
||||
public override void ExecuteSearch() |
||||
{ |
||||
RowDataContainer.ClearChildren(); |
||||
string fieldName = FieldSelect.Text; |
||||
string keyWords = SearchEdit.Text; |
||||
SearchKey.Invoke(); |
||||
int dataPointer = 0; |
||||
foreach (Dictionary<string, object> data in TableData) |
||||
{ |
||||
EGodotTableRowData rowData = RowDataContainer.CreateNode<EGodotTableRowData>("row" + dataPointer); |
||||
dataPointer++; |
||||
rowData.Init(data); |
||||
rowData.OnModify.Register(eData => |
||||
{ |
||||
this.EGEditDialog(eData, ModifyData, "Modify"); |
||||
}); |
||||
rowData.OnDelete.Register(() => |
||||
{ |
||||
string primaryKey = ""; |
||||
if (rowData.GetData().ContainsKey("ID")) primaryKey = "ID"; |
||||
if (rowData.GetData().ContainsKey("id")) primaryKey = "id"; |
||||
if (rowData.GetData().ContainsKey("Id")) primaryKey = "Id"; |
||||
if (primaryKey == "") |
||||
{ |
||||
this.EGAlert("Parmary key 'id' not defined!", "Error"); |
||||
return; |
||||
} |
||||
int remove_count = SaveData.RemoveData(CurrentDataKey, rowData.GetData()[primaryKey]); |
||||
PageAdapter.DataLength -= remove_count; |
||||
PageAdapter.Reload(PageAdapter.DataLength, PageLimit); |
||||
InitPageData(); |
||||
OnPageChanged.Invoke(); |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,457 @@
@@ -0,0 +1,457 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
using System.Security.Cryptography.X509Certificates; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public interface IEGodotTable |
||||
{ |
||||
|
||||
} |
||||
public partial class EGodotTable : BoxContainer, IEGFramework, IEGodotTable |
||||
{ |
||||
public BoxContainer FunctionContainer { set; get; } |
||||
public EGodotRowData Title { set; get; } |
||||
public BoxContainer RowDataContainer { set; get; } |
||||
public ScrollContainer RowDataScroll { set; get; } |
||||
public BoxContainer PageContainer { set; get; } |
||||
|
||||
public Color MainColor { set; get; } = new Color(); |
||||
public Color MinorColor { set; get; } = new Color(); |
||||
|
||||
protected EGodotTablePageAdapter PageAdapter { set; get; } |
||||
protected bool IsSearched { set; get; } |
||||
protected EasyEvent OnPageChanged { set; get; } = new EasyEvent(); |
||||
protected IUnRegister PageChangedRealease { set; get; } |
||||
|
||||
protected List<Dictionary<string, object>> TableData { set; get; } |
||||
protected Dictionary<string, object> EmptyData { set; get; } |
||||
protected Dictionary<string, object> TitleData { set; get; } = new Dictionary<string, object>(); |
||||
|
||||
protected EasyEvent<Dictionary<string, object>> AddData { set; get; } = new EasyEvent<Dictionary<string, object>>(); |
||||
|
||||
public Vector2 MinimumFunctionButtonSize = new Vector2(120,0); |
||||
|
||||
public string TableName { set; get; } = "-"; |
||||
|
||||
/// <summary> |
||||
/// The max data count for one page. |
||||
/// </summary> |
||||
/// <value></value> |
||||
[Export] |
||||
public int PageLimit { set; get; } = 10; |
||||
|
||||
public void InitData<T>(IEnumerable<T> tableData) where T : new() |
||||
{ |
||||
int count = tableData.Count(); |
||||
if (PageAdapter == null) |
||||
{ |
||||
PageAdapter = new EGodotTablePageAdapter(count, PageLimit); |
||||
} |
||||
else |
||||
{ |
||||
PageAdapter.Reload(count, PageLimit); |
||||
} |
||||
this.Vertical = true; |
||||
EmptyData = typeof(T).EGenerateEmptyDictiontaryByType(); |
||||
TitleData = typeof(T).EGenerateDictiontaryByType(); |
||||
TableName = typeof(T).Name; |
||||
InitFunctionMenu(); |
||||
InitTitle(TitleData); |
||||
InitRowData(tableData.EGenerateDictionaryByGroup()); |
||||
InitPageMenu(); |
||||
} |
||||
|
||||
public virtual void OnAddData(Dictionary<string, object> data) |
||||
{ |
||||
GD.Print("Add : " + data["Name"]); |
||||
string primaryKey = data.EGetDefaultPrimaryKey(); |
||||
if (primaryKey != "") |
||||
{ |
||||
data[primaryKey] = TableData.Count.ToString(); |
||||
} |
||||
TableData.Add(new Dictionary<string, object>(data)); |
||||
PageAdapter.DataLength++; |
||||
PageAdapter.Reload(PageAdapter.DataLength, PageLimit); |
||||
InitPageData(); |
||||
OnPageChanged.Invoke(); |
||||
} |
||||
|
||||
public virtual void OnOutputFile(string path) |
||||
{ |
||||
GD.Print("File has been Saved at " + path); |
||||
EGCsvSave eGCsvSave = new EGCsvSave(); |
||||
eGCsvSave.InitSave(path); |
||||
eGCsvSave.AddGroup("",TableData); |
||||
OS.ShellOpen(path); |
||||
} |
||||
|
||||
public virtual void OnInputFile(string path) |
||||
{ |
||||
|
||||
} |
||||
|
||||
protected OptionButton FieldSelect { set; get; } |
||||
protected LineEdit SearchEdit { set; get; } |
||||
public virtual void InitFunctionMenu() |
||||
{ |
||||
if (FunctionContainer == null) |
||||
{ |
||||
FunctionContainer = this.CreateNode<BoxContainer>("FunctionContainer"); |
||||
FunctionContainer.Vertical = false; |
||||
|
||||
Button add = FunctionContainer.CreateNode<Button>("add"); |
||||
add.Text = "Add"; |
||||
add.Connect("pressed", Callable.From(() => this.EGEditDialog(EmptyData, OnAddData, "Add"))); |
||||
add.FocusMode = FocusModeEnum.None; |
||||
add.CustomMinimumSize = MinimumFunctionButtonSize; |
||||
|
||||
Button refresh = FunctionContainer.CreateNode<Button>("refresh"); |
||||
refresh.Text = "Refresh"; |
||||
refresh.Connect("pressed", Callable.From(InitPageData)); |
||||
refresh.FocusMode = FocusModeEnum.None; |
||||
refresh.CustomMinimumSize = MinimumFunctionButtonSize; |
||||
|
||||
Button output = FunctionContainer.CreateNode<Button>("output"); |
||||
output.Text = "Output"; |
||||
output.Connect("pressed", Callable.From(() => this.EGFileSave(TableName + ".csv", OnOutputFile))); |
||||
output.FocusMode = FocusModeEnum.None; |
||||
output.CustomMinimumSize = MinimumFunctionButtonSize; |
||||
|
||||
Button input = FunctionContainer.CreateNode<Button>("input"); |
||||
input.Text = "Input"; |
||||
input.FocusMode = FocusModeEnum.None; |
||||
input.CustomMinimumSize = MinimumFunctionButtonSize; |
||||
|
||||
FieldSelect = FunctionContainer.CreateNode<OptionButton>("fieldSelect"); |
||||
FieldSelect.FocusMode = FocusModeEnum.None; |
||||
FieldSelect.SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkEnd; |
||||
FieldSelect.CustomMinimumSize = MinimumFunctionButtonSize; |
||||
foreach (string titleParam in TitleData.Keys) |
||||
{ |
||||
FieldSelect.AddItem(titleParam); |
||||
} |
||||
|
||||
|
||||
SearchEdit = FunctionContainer.CreateNode<LineEdit>("searchEdit"); |
||||
SearchEdit.PlaceholderText = "Please input search key"; |
||||
SearchEdit.SizeFlagsHorizontal = SizeFlags.ShrinkEnd; |
||||
SearchEdit.CustomMinimumSize = new Vector2(MinimumFunctionButtonSize.X * 2, MinimumFunctionButtonSize.Y); |
||||
|
||||
Button search = FunctionContainer.CreateNode<Button>("search"); |
||||
search.Text = "Search"; |
||||
search.FocusMode = FocusModeEnum.None; |
||||
search.SizeFlagsHorizontal = SizeFlags.ShrinkEnd; |
||||
search.CustomMinimumSize = MinimumFunctionButtonSize; |
||||
search.Connect("pressed", Callable.From(Search)); |
||||
|
||||
Button reset = FunctionContainer.CreateNode<Button>("reset"); |
||||
reset.Text = "Reset"; |
||||
reset.FocusMode = FocusModeEnum.None; |
||||
reset.SizeFlagsHorizontal = SizeFlags.ShrinkEnd; |
||||
reset.CustomMinimumSize = MinimumFunctionButtonSize; |
||||
reset.Connect("pressed", Callable.From(ResetSearch)); |
||||
} |
||||
} |
||||
|
||||
public virtual void InitTitle(Dictionary<string, object> titleData) |
||||
{ |
||||
if (Title == null) |
||||
{ |
||||
Title = this.CreateNode<EGodotRowData>("TitleContainer"); |
||||
titleData.Add("Operate", "Operate"); |
||||
Title.Init(titleData); |
||||
} |
||||
else |
||||
{ |
||||
Title.RefreshData(titleData); |
||||
} |
||||
} |
||||
|
||||
public void InitRowData(List<Dictionary<string, object>> rowDataList) |
||||
{ |
||||
RowDataScroll = this.CreateNode<ScrollContainer>("Scroll"); |
||||
RowDataScroll.SizeFlagsVertical = SizeFlags.ExpandFill; |
||||
|
||||
RowDataContainer = RowDataScroll.CreateNode<BoxContainer>("RowData"); |
||||
RowDataContainer.SizeFlagsHorizontal = SizeFlags.ExpandFill; |
||||
RowDataContainer.Vertical = true; |
||||
|
||||
this.TableData = rowDataList; |
||||
ToFirstPage(); |
||||
InitPageData(); |
||||
} |
||||
|
||||
public virtual void InitPageData() |
||||
{ |
||||
if (PageAdapter.CurrentPage <= 1) |
||||
{ |
||||
PageAdapter.CurrentPage = 1; |
||||
} |
||||
int dataPointer = (PageAdapter.CurrentPage - 1) * PageAdapter.PageLimit; |
||||
int dataEndPointer = dataPointer + PageAdapter.PageLimit; |
||||
if (dataEndPointer >= PageAdapter.DataLength) |
||||
{ |
||||
dataEndPointer = PageAdapter.DataLength; |
||||
} |
||||
RowDataContainer.ClearChildren(); |
||||
for (int dataId = dataPointer; dataId < dataEndPointer; dataId++) |
||||
{ |
||||
EGodotTableRowData rowData = RowDataContainer.CreateNode<EGodotTableRowData>("row" + dataPointer); |
||||
rowData.Init(TableData[dataId]); |
||||
rowData.OnModify.Register(data => |
||||
{ |
||||
this.EGEditDialog(data, rowData.OnDataEdit, "Modify"); |
||||
}); |
||||
rowData.OnDelete.Register(() => |
||||
{ |
||||
GD.Print("Delete : " + rowData.GetData()["Name"]); |
||||
this.TableData.Remove(rowData.GetData()); |
||||
PageAdapter.DataLength--; |
||||
PageAdapter.Reload(PageAdapter.DataLength, PageLimit); |
||||
InitPageData(); |
||||
OnPageChanged.Invoke(); |
||||
}); |
||||
} |
||||
ResetSearch(); |
||||
} |
||||
|
||||
public void InitPageMenu() |
||||
{ |
||||
if (PageContainer == null) |
||||
{ |
||||
PageContainer = this.CreateNode<BoxContainer>("PageContainer"); |
||||
PageContainer.Vertical = false; |
||||
PageContainer.Alignment = AlignmentMode.End; |
||||
|
||||
|
||||
Label labelCount = PageContainer.CreateNode<Label>("to"); |
||||
labelCount.Text = "Data count : " + PageAdapter.DataLength; |
||||
|
||||
Control empty1 = PageContainer.CreateNode<Control>("empty1"); |
||||
empty1.CustomMinimumSize = new Vector2(32, 0); |
||||
|
||||
Button firstPage = PageContainer.CreateNode<Button>("firstPage"); |
||||
firstPage.Text = "<<"; |
||||
firstPage.Connect("pressed", Callable.From(ToFirstPage)); |
||||
firstPage.FocusMode = FocusModeEnum.None; |
||||
|
||||
Button lastPage = PageContainer.CreateNode<Button>("lastPage"); |
||||
lastPage.Text = "<"; |
||||
lastPage.Connect("pressed", Callable.From(LastPage)); |
||||
lastPage.FocusMode = FocusModeEnum.None; |
||||
|
||||
Label currentPage = PageContainer.CreateNode<Label>("currenLabel"); |
||||
currentPage.Text = PageAdapter.CurrentPage.ToString(); |
||||
|
||||
|
||||
Button nextPage = PageContainer.CreateNode<Button>("next"); |
||||
nextPage.Text = ">"; |
||||
nextPage.Connect("pressed", Callable.From(NextPage)); |
||||
nextPage.FocusMode = FocusModeEnum.None; |
||||
|
||||
Button endPage = PageContainer.CreateNode<Button>("firstPage"); |
||||
endPage.Text = ">>"; |
||||
endPage.Connect("pressed", Callable.From(ToEndPage)); |
||||
endPage.FocusMode = FocusModeEnum.None; |
||||
|
||||
Control empty2 = PageContainer.CreateNode<Control>("empty2"); |
||||
empty2.CustomMinimumSize = new Vector2(32, 0); |
||||
|
||||
Label labelTo = PageContainer.CreateNode<Label>("to"); |
||||
labelTo.Text = "To"; |
||||
SpinBox inputPage = PageContainer.CreateNode<SpinBox>("pageEdit"); |
||||
inputPage.SetSize(new Vector2(120, 60)); |
||||
inputPage.MinValue = 1; |
||||
inputPage.MaxValue = PageAdapter.MaxPage; |
||||
inputPage.Alignment = HorizontalAlignment.Center; |
||||
inputPage.Connect("value_changed", Callable.From<int>(ToPage)); |
||||
|
||||
Label labelPage = PageContainer.CreateNode<Label>("page"); |
||||
labelPage.Text = "page"; |
||||
firstPage.Disabled = true; |
||||
lastPage.Disabled = true; |
||||
|
||||
PageChangedRealease = this.OnPageChanged.Register(() => |
||||
{ |
||||
labelCount.Text = "Data count : " + PageAdapter.DataLength + " Page : " + PageAdapter.CurrentPage; |
||||
currentPage.Text = PageAdapter.CurrentPage.ToString(); |
||||
if (PageAdapter.IsFirstPage()) |
||||
{ |
||||
firstPage.Disabled = true; |
||||
lastPage.Disabled = true; |
||||
} |
||||
else |
||||
{ |
||||
firstPage.Disabled = false; |
||||
lastPage.Disabled = false; |
||||
} |
||||
if (PageAdapter.IsLastPage()) |
||||
{ |
||||
endPage.Disabled = true; |
||||
nextPage.Disabled = true; |
||||
} |
||||
else |
||||
{ |
||||
endPage.Disabled = false; |
||||
nextPage.Disabled = false; |
||||
} |
||||
InitPageData(); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
public void ToFirstPage() |
||||
{ |
||||
this.PageAdapter.CurrentPage = 1; |
||||
OnPageChanged.Invoke(); |
||||
} |
||||
public void ToEndPage() |
||||
{ |
||||
this.PageAdapter.CurrentPage = this.PageAdapter.MaxPage; |
||||
OnPageChanged.Invoke(); |
||||
} |
||||
public void LastPage() |
||||
{ |
||||
if (this.PageAdapter.CurrentPage > 1) |
||||
{ |
||||
this.PageAdapter.CurrentPage--; |
||||
OnPageChanged.Invoke(); |
||||
} |
||||
} |
||||
public void NextPage() |
||||
{ |
||||
if (this.PageAdapter.CurrentPage < this.PageAdapter.MaxPage) |
||||
{ |
||||
this.PageAdapter.CurrentPage++; |
||||
OnPageChanged.Invoke(); |
||||
} |
||||
} |
||||
public void ToPage(int pageId) |
||||
{ |
||||
if (pageId >= 1 && pageId <= this.PageAdapter.MaxPage) |
||||
{ |
||||
this.PageAdapter.CurrentPage = pageId; |
||||
OnPageChanged.Invoke(); |
||||
} |
||||
} |
||||
|
||||
public void Search() |
||||
{ |
||||
if (SearchEdit.Text == "" && FieldSelect.Text == "") |
||||
{ |
||||
this.EGAlert("Please input key word in search edit and select a field.", "Message not enough!"); |
||||
} |
||||
else |
||||
{ |
||||
IsSearched = true; |
||||
PageContainer.Visible = false; |
||||
ExecuteSearch(); |
||||
} |
||||
} |
||||
|
||||
public void ResetSearch() |
||||
{ |
||||
if (IsSearched) |
||||
{ |
||||
IsSearched = false; |
||||
PageContainer.Visible = true; |
||||
InitPageData(); |
||||
} |
||||
} |
||||
|
||||
public virtual void ExecuteSearch() |
||||
{ |
||||
RowDataContainer.ClearChildren(); |
||||
string fieldName = FieldSelect.Text; |
||||
string keyWords = SearchEdit.Text; |
||||
List<Dictionary<string, object>> SearchData = TableData.ESearchByKeyword(fieldName, keyWords); |
||||
int dataPointer = 0; |
||||
foreach (Dictionary<string, object> searchrow in SearchData) |
||||
{ |
||||
EGodotTableRowData rowData = RowDataContainer.CreateNode<EGodotTableRowData>("row" + dataPointer); |
||||
dataPointer++; |
||||
rowData.Init(searchrow); |
||||
rowData.OnModify.Register(data => |
||||
{ |
||||
this.EGEditDialog(data, rowData.OnDataEdit, "Modify"); |
||||
}); |
||||
rowData.OnDelete.Register(() => |
||||
{ |
||||
GD.Print("Delete : " + rowData.GetData()["Name"]); |
||||
this.TableData.Remove(rowData.GetData()); |
||||
PageAdapter.DataLength--; |
||||
PageAdapter.Reload(PageAdapter.DataLength, PageLimit); |
||||
InitPageData(); |
||||
OnPageChanged.Invoke(); |
||||
}); |
||||
} |
||||
} |
||||
public override void _ExitTree() |
||||
{ |
||||
this.PageChangedRealease.UnRegister(); |
||||
base._ExitTree(); |
||||
} |
||||
} |
||||
|
||||
public static class EGGodotTableGenerator |
||||
{ |
||||
// public static EGodotTable CreateTable(this Node self, string[][] tableStr, string tableName = "Table") |
||||
// { |
||||
// VBoxContainer Table = new VBoxContainer(); |
||||
// Table.Name = tableName; |
||||
// int dataPointer = 0; |
||||
// foreach (string[] s in tableStr) |
||||
// { |
||||
// Table.CreateRowData(s, "tableRowData" + dataPointer); |
||||
// dataPointer++; |
||||
// } |
||||
// self.AddChild(Table); |
||||
// return Table; |
||||
// } |
||||
} |
||||
public class EGodotTablePageAdapter |
||||
{ |
||||
public int DataLength { set; get; } |
||||
public int CurrentPage { set; get; } |
||||
public int MaxPage { set; get; } |
||||
public int PageLimit { set; get; } |
||||
|
||||
public EasyEvent OnLoad = new EasyEvent(); |
||||
|
||||
public EGodotTablePageAdapter(int dataLength, int pageLimit = 10) |
||||
{ |
||||
this.DataLength = dataLength; |
||||
this.PageLimit = pageLimit; |
||||
this.MaxPage = dataLength / PageLimit + 1; |
||||
if (dataLength % pageLimit == 0) |
||||
{ |
||||
this.MaxPage -= 1; |
||||
} |
||||
this.CurrentPage = 1; |
||||
} |
||||
|
||||
public void Reload(int dataLength, int pageLimit = 10) |
||||
{ |
||||
this.DataLength = dataLength; |
||||
this.PageLimit = pageLimit; |
||||
this.MaxPage = dataLength / PageLimit + 1; |
||||
this.CurrentPage = 1; |
||||
OnLoad.Invoke(); |
||||
} |
||||
|
||||
public bool IsFirstPage() |
||||
{ |
||||
return this.CurrentPage == 1; |
||||
} |
||||
public bool IsLastPage() |
||||
{ |
||||
return this.CurrentPage == MaxPage; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,79 @@
@@ -0,0 +1,79 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using Godot; |
||||
using Tmds.Linux; |
||||
|
||||
namespace EGFramework.UI{ |
||||
public partial class EGodotTableRowData : EGodotRowData |
||||
{ |
||||
public Control Operate { get; set; } |
||||
public Button Modify { get; set; } |
||||
public Button Delete { get; set; } |
||||
|
||||
public EasyEvent<Dictionary<string, object>> OnModify { set; get; } = new EasyEvent<Dictionary<string, object>>(); |
||||
public EasyEvent OnDelete { set; get; } = new EasyEvent(); |
||||
|
||||
public override void Init(Dictionary<string, object> data) |
||||
{ |
||||
base.Init(data); |
||||
Operate = new HBoxContainer(); |
||||
Operate.Name = "Operate"; |
||||
Operate.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; |
||||
List.AddChild(Operate); |
||||
Modify = new Button(); |
||||
Modify.Name = "Modify"; |
||||
Modify.Text = "Modify"; |
||||
Modify.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; |
||||
Operate.AddChild(Modify); |
||||
Delete = new Button(); |
||||
Delete.Name = "Delete"; |
||||
Delete.Text = "Delete"; |
||||
Delete.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; |
||||
Operate.AddChild(Delete); |
||||
Modify.Connect("pressed", Callable.From(OnEdit)); |
||||
Delete.Connect("pressed", Callable.From(OnDeleteSelf)); |
||||
this.CustomMinimumSize = new Vector2(0, 32); |
||||
} |
||||
public void OnEdit() |
||||
{ |
||||
if (Data == null) |
||||
{ |
||||
return; |
||||
} |
||||
OnModify.Invoke(Data); |
||||
} |
||||
|
||||
public virtual void OnDataEdit(Dictionary<string, object> e) |
||||
{ |
||||
foreach (var pair in e) |
||||
{ |
||||
this.Data[pair.Key] = pair.Value; |
||||
} |
||||
// this.Data = e; |
||||
this.RefreshData(); |
||||
} |
||||
|
||||
public override void RefreshData(Dictionary<string, object> data) |
||||
{ |
||||
base.RefreshData(data); |
||||
Operate.ToEnd(); |
||||
} |
||||
public void OnDeleteSelf() |
||||
{ |
||||
this.EGConfirm("Delete this data? this operate cannot be canceled.", e => |
||||
{ |
||||
if (e) |
||||
{ |
||||
OnDelete.Invoke(); |
||||
} |
||||
}, "Delete"); |
||||
} |
||||
|
||||
public override void _ExitTree() |
||||
{ |
||||
Modify.Disconnect("pressed", Callable.From(OnEdit)); |
||||
Delete.Disconnect("pressed", Callable.From(OnDeleteSelf)); |
||||
base._ExitTree(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic; |
||||
using Godot; |
||||
|
||||
namespace EGFramework.UI |
||||
{ |
||||
public interface IEGodotTree |
||||
{ |
||||
void RenderTree(); |
||||
} |
||||
public partial class EGodotTree : Tree, IEGFramework, IEGodotTree |
||||
{ |
||||
public EGTree Tree { set; get; } |
||||
|
||||
public void Init(EGTree tree) |
||||
{ |
||||
this.Tree = tree; |
||||
RenderTree(); |
||||
} |
||||
|
||||
public void InitByJson(string json) |
||||
{ |
||||
EGTree eGTree = EGTreeFactory.CreateTreeByJson(json); |
||||
this.Tree = eGTree; |
||||
RenderTree(); |
||||
} |
||||
|
||||
public void RenderTree() |
||||
{ |
||||
this.HideRoot = true; |
||||
CreateTreeItem(Tree, this.GetRoot()); |
||||
} |
||||
|
||||
|
||||
public void CreateTreeItem(EGTree tree,TreeItem parent) |
||||
{ |
||||
TreeItem current = this.CreateItem(parent); |
||||
current.SetText(0,tree.Name); |
||||
current.SetTooltipText(0, tree.StrValue); |
||||
foreach (EGTree child in tree.GetChilds()) |
||||
{ |
||||
CreateTreeItem(child, current); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace EGFramework |
||||
{ |
||||
public struct EGSelectParam |
||||
{ |
||||
public int SelectID { set; get; } |
||||
|
||||
public Dictionary<int, string> SelectList { set; get; } |
||||
public EGSelectParam(int selectID, Dictionary<int, string> selectList) |
||||
{ |
||||
SelectID = selectID; |
||||
SelectList = selectList; |
||||
} |
||||
} |
||||
public struct EGRangeParam |
||||
{ |
||||
public double Min { set; get; } |
||||
public double Max { set; get; } |
||||
public double Step { set; get; } |
||||
public double Value { set; get; } |
||||
public EGRangeParam(double min, double max, double step, double value) |
||||
{ |
||||
Min = min; |
||||
Max = max; |
||||
Step = step; |
||||
Value = value; |
||||
} |
||||
} |
||||
|
||||
public struct EGPathSelect |
||||
{ |
||||
public string Path { set; get; } |
||||
public bool IsDir { set; get; } |
||||
public override string ToString() |
||||
{ |
||||
return Path; |
||||
} |
||||
} |
||||
|
||||
public interface IEGReadOnlyString |
||||
{ |
||||
public string GetString(); |
||||
} |
||||
public struct EGReadOnlyString : IEGReadOnlyString |
||||
{ |
||||
public string Value { get; private set; } |
||||
public EGReadOnlyString(string value) |
||||
{ |
||||
Value = value; |
||||
} |
||||
|
||||
public string GetString() |
||||
{ |
||||
return Value; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,127 @@
@@ -0,0 +1,127 @@
|
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using Newtonsoft.Json; |
||||
|
||||
namespace EGFramework |
||||
{ |
||||
public interface IEGTree |
||||
{ |
||||
public string Name { set; get; } |
||||
public IEGTree GetParent(); |
||||
public void SetParent(IEGTree tree); |
||||
public IEnumerable<IEGTree> GetChilds(); |
||||
public void AppendTree(IEGTree tree); |
||||
|
||||
} |
||||
|
||||
public class EGTree : IEGTree |
||||
{ |
||||
public string Name { set; get; } |
||||
|
||||
public string StrValue { set; get; } |
||||
public long IntegerValue { set; get; } |
||||
public byte[] ByteValue { set; get; } |
||||
public float FloatValue { set; get; } |
||||
public bool BoolValue { set; get; } |
||||
|
||||
public IEGTree Parent { set; get; } |
||||
public List<IEGTree> Childs { set; get; } = new List<IEGTree>(); |
||||
|
||||
public EGTree() |
||||
{ |
||||
} |
||||
|
||||
public EGTree(string name) |
||||
{ |
||||
this.Name = name; |
||||
} |
||||
|
||||
public void AppendTree(IEGTree tree) |
||||
{ |
||||
tree.SetParent(this); |
||||
Childs.Add(tree); |
||||
} |
||||
|
||||
public virtual IEnumerable<IEGTree> GetChilds() |
||||
{ |
||||
return Childs; |
||||
} |
||||
|
||||
public virtual IEGTree GetParent() |
||||
{ |
||||
return Parent; |
||||
} |
||||
|
||||
public void SetParent(IEGTree tree) |
||||
{ |
||||
this.Parent = tree; |
||||
} |
||||
} |
||||
|
||||
public static class EGTreeFactory |
||||
{ |
||||
public static EGTree CreateTreeByJson(string json) |
||||
{ |
||||
JsonTextReader reader = new JsonTextReader(new StringReader(json)); |
||||
Stack<IEGTree> TreeStack = new Stack<IEGTree>(); |
||||
EGTree resultTree = new EGTree(); |
||||
EGTree lastTree = null; |
||||
while (reader.Read()) |
||||
{ |
||||
if (reader.TokenType == JsonToken.StartObject) |
||||
{ |
||||
if (lastTree != null) |
||||
{ |
||||
TreeStack.Push(lastTree); |
||||
} |
||||
} |
||||
if (reader.TokenType == JsonToken.EndObject) |
||||
{ |
||||
if(TreeStack.Count>0) |
||||
TreeStack.Pop(); |
||||
} |
||||
|
||||
if (reader.TokenType == JsonToken.PropertyName) |
||||
{ |
||||
EGTree newTree = new EGTree(); |
||||
if (reader.Value != null) |
||||
{ |
||||
newTree.Name = reader.Value.ToString(); |
||||
} |
||||
if (TreeStack.Count > 0) |
||||
{ |
||||
TreeStack.Peek().AppendTree(newTree); |
||||
} |
||||
else |
||||
{ |
||||
resultTree.AppendTree(newTree); |
||||
} |
||||
lastTree = newTree; |
||||
} |
||||
|
||||
if (lastTree != null && reader.TokenType == JsonToken.Integer) |
||||
{ |
||||
lastTree.IntegerValue = (long)reader.Value; |
||||
} |
||||
if (lastTree != null && reader.TokenType == JsonToken.Boolean) |
||||
{ |
||||
lastTree.BoolValue = (bool)reader.Value; |
||||
} |
||||
if (lastTree != null && reader.TokenType == JsonToken.String) |
||||
{ |
||||
lastTree.StrValue = (string)reader.Value; |
||||
} |
||||
if (lastTree != null && reader.TokenType == JsonToken.Float) |
||||
{ |
||||
lastTree.FloatValue = (float)reader.Value; |
||||
} |
||||
if (lastTree!=null && reader.TokenType == JsonToken.Bytes) |
||||
{ |
||||
lastTree.ByteValue = (byte[])reader.Value; |
||||
} |
||||
} |
||||
return resultTree; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,127 @@
@@ -0,0 +1,127 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
|
||||
namespace EGFramework{ |
||||
public static class EGenerateVariant |
||||
{ |
||||
public static Dictionary<string, object> EGenerateDictiontaryByType(this Type self) |
||||
{ |
||||
PropertyInfo[] propertyNames = self.GetProperties(); |
||||
FieldInfo[] fieldNames = self.GetFields(); |
||||
Dictionary<string, object> result = new Dictionary<string, object>(); |
||||
foreach (PropertyInfo pName in propertyNames) |
||||
{ |
||||
result.Add(pName.Name, pName.Name); |
||||
} |
||||
foreach (FieldInfo fName in fieldNames) |
||||
{ |
||||
result.Add(fName.Name, fName.Name); |
||||
} |
||||
return result; |
||||
} |
||||
public static Dictionary<string, object> EGenerateEmptyDictiontaryByType(this Type self) |
||||
{ |
||||
PropertyInfo[] propertyNames = self.GetProperties(); |
||||
FieldInfo[] fieldNames = self.GetFields(); |
||||
Dictionary<string, object> result = new Dictionary<string, object>(); |
||||
foreach (PropertyInfo pName in propertyNames) |
||||
{ |
||||
result.Add(pName.Name, ""); |
||||
} |
||||
foreach (FieldInfo fName in fieldNames) |
||||
{ |
||||
result.Add(fName.Name, ""); |
||||
} |
||||
return result; |
||||
} |
||||
public static Dictionary<string, Type> EGenerateTypeDictiontaryByType(this Type self) |
||||
{ |
||||
PropertyInfo[] propertyNames = self.GetProperties(); |
||||
FieldInfo[] fieldNames = self.GetFields(); |
||||
Dictionary<string, Type> result = new Dictionary<string, Type>(); |
||||
foreach (PropertyInfo pName in propertyNames) |
||||
{ |
||||
result.Add(pName.Name, pName.PropertyType); |
||||
} |
||||
foreach (FieldInfo fName in fieldNames) |
||||
{ |
||||
result.Add(fName.Name, fName.FieldType); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public static Dictionary<string, object> EGenerateDictiontaryByObject<T>(this T self) |
||||
{ |
||||
PropertyInfo[] propertyNames = typeof(T).GetProperties(); |
||||
FieldInfo[] fieldNames = typeof(T).GetFields(); |
||||
// object[] s = propertyNames.Select(p => p.GetValue(self)).ToArray(); |
||||
// object[] a = fieldNames.Select(p => p.GetValue(self)).ToArray(); |
||||
Dictionary<string, object> result = new Dictionary<string, object>(); |
||||
foreach (PropertyInfo pName in propertyNames) |
||||
{ |
||||
object p = pName.GetValue(self); |
||||
result.Add(pName.Name, p); |
||||
} |
||||
foreach (FieldInfo fName in fieldNames) |
||||
{ |
||||
object p = fName.GetValue(self); |
||||
result.Add(fName.Name, p); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
public static List<Dictionary<string, object>> EGenerateDictionaryByGroup<T>(this IEnumerable<T> self) |
||||
{ |
||||
List<Dictionary<string, object>> result = new List<Dictionary<string, object>>(); |
||||
PropertyInfo[] propertyNames = typeof(T).GetProperties(); |
||||
FieldInfo[] fieldNames = typeof(T).GetFields(); |
||||
foreach (T member in self) |
||||
{ |
||||
Dictionary<string, object> mResult = new Dictionary<string, object>(); |
||||
foreach (PropertyInfo pName in propertyNames) |
||||
{ |
||||
object p = pName.GetValue(member); |
||||
mResult.Add(pName.Name, p); |
||||
} |
||||
foreach (FieldInfo fName in fieldNames) |
||||
{ |
||||
object p = fName.GetValue(member); |
||||
mResult.Add(fName.Name, p); |
||||
} |
||||
result.Add(mResult); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
//Default primary key is id,Id,ID. |
||||
public static string EGetDefaultPrimaryKey(this Dictionary<string, object> self) |
||||
{ |
||||
foreach (KeyValuePair<string, object> param in self) |
||||
{ |
||||
if (param.Key == "ID" || param.Key == "Id" || param.Key == "id") |
||||
{ |
||||
return param.Key; |
||||
} |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
public static List<Dictionary<string, object>> ESearchByKeyword(this List<Dictionary<string, object>> data, string fieldName, string keyWords) |
||||
{ |
||||
List<Dictionary<string, object>> result = new List<Dictionary<string, object>>(); |
||||
foreach (Dictionary<string, object> tablerow in data) |
||||
{ |
||||
if (tablerow.ContainsKey(fieldName)) |
||||
{ |
||||
if (tablerow[fieldName].ToString().Contains(keyWords)) |
||||
{ |
||||
result.Add(tablerow); |
||||
} |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
} |
||||
} |
@ -1,48 +0,0 @@
@@ -1,48 +0,0 @@
|
||||
using Godot; |
||||
using static Godot.GD; |
||||
|
||||
namespace EGFramework{ |
||||
|
||||
public class EGSingletonNode : IEGFramework, IModule |
||||
{ |
||||
public IOCContainer NodeContainer = new IOCContainer(); |
||||
public void Init() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public IArchitecture GetArchitecture() |
||||
{ |
||||
return EGArchitectureImplement.Interface; |
||||
} |
||||
|
||||
} |
||||
|
||||
public static class EGCanCreateNodeExtension |
||||
{ |
||||
public static TNode CreateNode<TNode>(this Node self) where TNode : Node,new(){ |
||||
TNode nodeData = new TNode(); |
||||
nodeData.Name = typeof(TNode).Name; |
||||
self.AddChild(nodeData); |
||||
return nodeData; |
||||
} |
||||
|
||||
public static TNode CreateNode<TNode>(this Node self,string name) where TNode : Node,new(){ |
||||
TNode nodeData = new TNode(); |
||||
nodeData.Name = name; |
||||
self.AddChild(nodeData); |
||||
return nodeData; |
||||
} |
||||
|
||||
public static TNode SingletonNode<TNode>(this Node self) where TNode : Node,new(){ |
||||
TNode nodeData = new TNode(); |
||||
nodeData.Name = typeof(TNode).Name; |
||||
self.AddChild(nodeData); |
||||
return nodeData; |
||||
} |
||||
|
||||
public static void Alert(this Node self,string alertMsg){ |
||||
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -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); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
using Godot; |
||||
|
||||
namespace EGFramework{ |
||||
/// <summary> |
||||
/// 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. |
||||
/// </summary> |
||||
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<EGProtocolScheduleGodot>().ProtocolSchedule; |
||||
} |
||||
public static void EGEnabledProtocolTools(this Node self){ |
||||
self.NodeModule<EGProtocolScheduleGodot>().ProtocolSchedule.EnabledAllTools(); |
||||
} |
||||
public static void EGEnabledProtocolTool<TProtocolReceived>(this Node self) where TProtocolReceived : class, IModule,IProtocolReceived,new(){ |
||||
self.NodeModule<EGProtocolScheduleGodot>().ProtocolSchedule.EnabledTool<TProtocolReceived>(); |
||||
} |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue