Compare commits

..

8 Commits

  1. 3
      Example/ProtocolHelper/Scene/ProtocolHelper.tscn
  2. 67
      Example/SaveSystem/Script/ViewSaveSystem.cs
  3. 9
      addons/EGFramework/Module/Extension/EGSqlExtension.cs
  4. 3
      addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs
  5. 123
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditList.cs
  6. 14
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs
  7. 2
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotSaveTable.cs
  8. 24
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTable.cs
  9. 2
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTableRowData.cs
  10. 41
      addons/EGFramework/Module/GenerateTools/Templete/Variant/EGTree.cs
  11. 28
      addons/EGFramework/Module/GenerateTools/Templete/Variant/EGVariantGenerator.cs
  12. 5
      addons/EGFramework/Module/SaveTools/Data/EGDapper.cs
  13. 5
      addons/EGFramework/Module/SaveTools/Data/EGSqliteSave.cs
  14. 24
      addons/EGFramework/Translate/EGFramework.csv
  15. 17
      addons/EGFramework/Translate/EGFramework.csv.import
  16. 4
      project.godot

3
Example/ProtocolHelper/Scene/ProtocolHelper.tscn

@ -171,6 +171,7 @@ text = "报文显示格式"
[node name="Button6" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList2"] [node name="Button6" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList2"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "虚拟设备"
[node name="FunctionList1" type="HBoxContainer" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer"] [node name="FunctionList1" type="HBoxContainer" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer"]
layout_mode = 2 layout_mode = 2
@ -199,10 +200,12 @@ text = "协议设置"
[node name="Button5" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"] [node name="Button5" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "校验设置"
[node name="Button6" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"] [node name="Button6" type="Button" parent="PanelContainer/VSplitContainer/SettingGroup/VSplitContainer/FunctionList1"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "数据解析设置"
[node name="SendArea" type="VSplitContainer" parent="PanelContainer/VSplitContainer/SettingGroup"] [node name="SendArea" type="VSplitContainer" parent="PanelContainer/VSplitContainer/SettingGroup"]
layout_mode = 2 layout_mode = 2

67
Example/SaveSystem/Script/ViewSaveSystem.cs

@ -8,19 +8,31 @@ using LiteDB;
using Newtonsoft.Json; using Newtonsoft.Json;
using Renci.SshNet; using Renci.SshNet;
namespace EGFramework.Examples.Test { namespace EGFramework.Examples.Test
{
public partial class ViewSaveSystem : Node, IEGFramework public partial class ViewSaveSystem : Node, IEGFramework
{ {
public string[][] DataList { get; set; } public string[][] DataList { get; set; }
public string[][] DataList2 { get; set; } public string[][] DataList2 { get; set; }
Container container{ set; get; } Container container { set; get; }
public override void _Ready() public override void _Ready()
{ {
// TestTree(); // TestTree();
// TranslationServer.SetLocale("jp");
// GD.Print(Tr("Data")+"+___+");
// TestTable(); // TestTable();
// TestJson(); // TestJson();
// this.CallDeferred("TestDialog");
// SchoolType school = SchoolType.London;
// school.EGenerateMappingByEnum();
// foreach (KeyValuePair<int, string> selectOptions in school.EGenerateMappingByEnum())
// {
// GD.Print(selectOptions.Key+"---"+selectOptions.Value);
// }
// TestDialog(); // TestDialog();
// TestMySQL(); // TestMySQL();
// EG.Print(OS.GetLocaleLanguage());
TestEdit();
} }
public override void _ExitTree() public override void _ExitTree()
@ -60,15 +72,28 @@ namespace EGFramework.Examples.Test {
public void TestDialog() public void TestDialog()
{ {
DataStudent dataStudent = new DataStudent(); DataStudent dataStudent = new DataStudent("ZG",10);
dataStudent.EGenerateDictiontaryByObject(); this.EGEditDialog(dataStudent.EGenerateDictiontaryByObject(), e =>
this.ExecuteAfterSecond(() => {
GD.Print("Name:" + e["Name"] + "Age:" + e["Age"]+"School:" + e["School"] + "Path:" + e["Path"]);
}, "Edit");
}
public void TestEdit()
{
DataStudent dataStudent = new DataStudent("ZG", 10);
container = this.GetNode<TabContainer>("TabContainer");
EGodotEditList editList = container.CreateNode<EGodotEditList>();
editList.InitList(dataStudent.EGenerateDictiontaryByObject(), e =>
{
GD.Print("Name:" + e["Name"] + "Age:" + e["Age"] + "School:" + e["School"] + "Path:" + e["Path"]);
}, "Edit");
DataStu dataStu = new DataStu("F", 1, "DE");
EGodotEditList editList2 = container.CreateNode<EGodotEditList>();
editList2.InitList(dataStu.EGenerateDictiontaryByObject(), e =>
{ {
this.EGEditDialog(new DataStudent().EGenerateDictiontaryByObject(), e => GD.Print("Name:" + e["Name"] + "Age:" + e["Age"] + "School:" + e["School"] + "Path:" + e["Path"]);
{ }, "Edit");
GD.Print("Name:" + e["Name"] + "Age:" + e["Age"]);
}, "Edit");
}, 0.2f);
} }
public void TestJson() public void TestJson()
@ -134,10 +159,10 @@ namespace EGFramework.Examples.Test {
EGodotTable table = container.CreateNode<EGodotTable>("Default"); EGodotTable table = container.CreateNode<EGodotTable>("Default");
table.InitData<DataStudent>(dataStudents); table.InitData<DataStudent>(dataStudents);
// EGSqliteSave SqliteTest = this.EGSave().Load<EGSqliteSave>("SaveData/test.db"); EGSqliteSave SqliteTest = this.EGSave().Load<EGSqliteSave>("SaveData/test.db");
// EGodotSaveTable PersonTable = container.CreateNode<EGodotSaveTable>("SQLite"); EGodotSaveTable PersonTable = container.CreateNode<EGodotSaveTable>("SQLite");
// PersonTable.InitSaveData<EGSqliteSave>(SqliteTest); PersonTable.InitSaveData<EGSqliteSave>(SqliteTest);
// PersonTable.InitData<DataPerson>("person"); PersonTable.InitData<DataPerson>("person");
} }
} }
@ -147,11 +172,13 @@ namespace EGFramework.Examples.Test {
public string Name { get; set; } public string Name { get; set; }
public int Age; public int Age;
public EGPathSelect Path { set; get; } public EGPathSelect Path { set; get; }
public SchoolType School { set; get; }
public DataStudent(string name, int age) public DataStudent(string name, int age)
{ {
Name = name; Name = name;
Age = age; Age = age;
ID = 0; ID = 0;
School = SchoolType.MIT;
Path = new EGPathSelect(); Path = new EGPathSelect();
} }
} }
@ -162,7 +189,7 @@ namespace EGFramework.Examples.Test {
public string Name { get; set; } public string Name { get; set; }
public int Age { set; get; } public int Age { set; get; }
public string Path { set; get; } public string Path { set; get; }
public DataStu(string name, int age,string path) public DataStu(string name, int age, string path)
{ {
Name = name; Name = name;
Age = age; Age = age;
@ -170,7 +197,7 @@ namespace EGFramework.Examples.Test {
Path = path; Path = path;
} }
} }
public struct DataPerson public struct DataPerson
{ {
public string id { get; set; } public string id { get; set; }
@ -178,4 +205,12 @@ namespace EGFramework.Examples.Test {
public string workPlace { set; get; } public string workPlace { set; get; }
public string policeNum { set; get; } public string policeNum { set; get; }
} }
public enum SchoolType
{
Tsinghua = 0,
MIT = 1,
London = 2,
Data = 3
}
} }

9
addons/EGFramework/Module/Extension/EGSqlExtension.cs

@ -107,8 +107,7 @@ namespace EGFramework
} }
return sqlCommand; return sqlCommand;
} }
public static string ToCreateTableSQL(this Type type, string tableName,string idType = "INTEGER PRIMARY KEY AUTO_INCREMENT")
public static string ToCreateTableSQL(this Type type, string tableName)
{ {
var properties = type.GetProperties(); var properties = type.GetProperties();
FieldInfo[] fields = type.GetFields(); FieldInfo[] fields = type.GetFields();
@ -123,12 +122,12 @@ namespace EGFramework
} }
keySet = keySet.TrimEnd(','); keySet = keySet.TrimEnd(',');
string createSql = @"CREATE TABLE " + tableName + " (" + string createSql = @"CREATE TABLE " + tableName + " (" +
"`ID` INTEGER PRIMARY KEY AUTO_INCREMENT, " + keySet "`ID` "+idType+", " + keySet
+ ");"; + ");";
return createSql; return createSql;
} }
public static string ToCreateTableSQL(this Dictionary<string,Type> tableParam,string tableName) public static string ToCreateTableSQL(this Dictionary<string,Type> tableParam,string tableName,string idType = "INTEGER PRIMARY KEY AUTO_INCREMENT")
{ {
string keySet = ""; string keySet = "";
@ -137,7 +136,7 @@ namespace EGFramework
} }
keySet = keySet.TrimEnd(','); keySet = keySet.TrimEnd(',');
string createSql = @"CREATE TABLE "+tableName+" ("+ string createSql = @"CREATE TABLE "+tableName+" ("+
"`ID` INTEGER PRIMARY KEY AUTOINCREMENT, "+keySet "`ID` "+idType+", "+keySet
+");"; +");";
return createSql; return createSql;
} }

3
addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using Godot; using Godot;
namespace EGFramework.UI namespace EGFramework.UI
{ {
@ -23,7 +24,7 @@ namespace EGFramework.UI
{ {
EGodotFileDialog fileDialog = self.PopupNode<EGodotFileDialog>("FileDialog"); EGodotFileDialog fileDialog = self.PopupNode<EGodotFileDialog>("FileDialog");
fileDialog.Title = title; fileDialog.Title = title;
fileDialog.RootSubfolder = filePath; fileDialog.RootSubfolder = Path.GetDirectoryName(filePath);
fileDialog.InitFileSelect(selectPath); fileDialog.InitFileSelect(selectPath);
} }

123
addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditList.cs

@ -0,0 +1,123 @@
using Godot;
using System;
using System.Collections.Generic;
namespace EGFramework.UI
{
public partial class EGodotEditList : VBoxContainer
{
public Label Title { set; get; }
public HBoxContainer OperateGroup { set; get; }
public VBoxContainer EditList { get; set; }
public Button ConfirmButton { set; get; }
public Button CancelButton { set; get; }
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 InitList(Dictionary<string, object> data, Action<Dictionary<string, object>> onDataEdit, string title = "Edit Data")
{
if (!IsInit)
{
Title = new Label();
Title.Name = "Title";
Title.HorizontalAlignment = HorizontalAlignment.Center;
this.AddChild(Title);
this.Name = "EditList";
this.ErrorTips = new Label();
ErrorTips.Name = "ErrorTips";
this.AddChild(ErrorTips);
ErrorTips.Visible = false;
EditList = new VBoxContainer();
EditList.Name = "EditContainer";
EditList.SizeFlagsVertical = Control.SizeFlags.ExpandFill;
this.AddChild(EditList);
this.OperateGroup = new HBoxContainer();
this.OperateGroup.Name = "OperateGroup";
this.AddChild(OperateGroup);
this.ConfirmButton = new Button();
this.ConfirmButton.Name = "ConfirmButton";
this.ConfirmButton.Text = "OK";
this.ConfirmButton.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill;
this.ConfirmButton.Connect("pressed", Callable.From(OnConfirm));
this.CancelButton = new Button();
this.CancelButton.Name = "CancelButton";
this.CancelButton.Text = "Cancel";
this.CancelButton.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill;
this.OperateGroup.AddChild(ConfirmButton);
this.OperateGroup.AddChild(CancelButton);
IsInit = true;
}
EditList.ClearChildren();
ParamUIs.Clear();
this.Title.Text = title;
OnDataEdit = OnEdit.Register(onDataEdit);
foreach (KeyValuePair<string, object> param in data)
{
EGodotEditParam paramUI = new EGodotEditParam();
EditList.AddChild(paramUI);
paramUI.Init(param);
ParamUIs.Add(paramUI);
}
}
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;
}
}
}

14
addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs

@ -67,6 +67,18 @@ namespace EGFramework.UI
} }
this.ParamOption.Selected = this.ParamOption.GetItemIndex(((EGSelectParam)editValue.Value).SelectID); this.ParamOption.Selected = this.ParamOption.GetItemIndex(((EGSelectParam)editValue.Value).SelectID);
} }
else if (editValue.Value is Enum)
{
this.ParamOption = new OptionButton();
ParamOption.Name = "ParamOption";
ParamOption.SizeFlagsHorizontal = SizeFlags.ExpandFill;
this.AddChild(ParamOption);
foreach (KeyValuePair<int, string> selectOptions in editValue.Value.GetType().EGenerateMappingByEnum())
{
this.ParamOption.AddItem(selectOptions.Value, selectOptions.Key);
}
this.ParamOption.Selected = this.ParamOption.GetItemIndex((int)editValue.Value);
}
else if (editValue.Value is int) else if (editValue.Value is int)
{ {
this.ParamSpinBox = new SpinBox(); this.ParamSpinBox = new SpinBox();
@ -128,7 +140,7 @@ namespace EGFramework.UI
ParamOperate.SizeFlagsHorizontal = SizeFlags.ExpandFill; ParamOperate.SizeFlagsHorizontal = SizeFlags.ExpandFill;
ParamOperate.Pressed += () => ParamOperate.Pressed += () =>
{ {
this.EGFileOpen("res://", str => this.EGFileOpen("", str =>
{ {
ParamPathSelect.Text = str; ParamPathSelect.Text = str;
}); });

2
addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotSaveTable.cs

@ -31,7 +31,7 @@ namespace EGFramework.UI
} }
this.Vertical = true; this.Vertical = true;
CurrentDataKey = key; CurrentDataKey = key;
EmptyData = typeof(T).EGenerateEmptyDictiontaryByType(); EmptyData = new T().EGenerateDictiontaryByObject();
QueryPage.Register(() => QueryPageData<T>()); QueryPage.Register(() => QueryPageData<T>());
SearchKey.Register(() => SearchDataByKeyword<T>()); SearchKey.Register(() => SearchDataByKeyword<T>());
TableName = typeof(T).Name; TableName = typeof(T).Name;

24
addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTable.cs

@ -33,7 +33,7 @@ namespace EGFramework.UI
protected EasyEvent<Dictionary<string, object>> AddData { set; get; } = new EasyEvent<Dictionary<string, object>>(); protected EasyEvent<Dictionary<string, object>> AddData { set; get; } = new EasyEvent<Dictionary<string, object>>();
public Vector2 MinimumFunctionButtonSize = new Vector2(120,0); public Vector2 MinimumFunctionButtonSize = new Vector2(60, 0);
public string TableName { set; get; } = "-"; public string TableName { set; get; } = "-";
@ -56,7 +56,7 @@ namespace EGFramework.UI
PageAdapter.Reload(count, PageLimit); PageAdapter.Reload(count, PageLimit);
} }
this.Vertical = true; this.Vertical = true;
EmptyData = typeof(T).EGenerateEmptyDictiontaryByType(); EmptyData = new T().EGenerateDictiontaryByObject();
TitleData = typeof(T).EGenerateDictiontaryByType(); TitleData = typeof(T).EGenerateDictiontaryByType();
TableName = typeof(T).Name; TableName = typeof(T).Name;
InitFunctionMenu(); InitFunctionMenu();
@ -85,10 +85,10 @@ namespace EGFramework.UI
GD.Print("File has been Saved at " + path); GD.Print("File has been Saved at " + path);
EGCsvSave eGCsvSave = new EGCsvSave(); EGCsvSave eGCsvSave = new EGCsvSave();
eGCsvSave.InitSave(path); eGCsvSave.InitSave(path);
eGCsvSave.AddGroup("",TableData); eGCsvSave.AddGroup("", TableData);
OS.ShellOpen(path); OS.ShellOpen(path);
} }
public virtual void OnInputFile(string path) public virtual void OnInputFile(string path)
{ {
@ -137,7 +137,7 @@ namespace EGFramework.UI
SearchEdit = FunctionContainer.CreateNode<LineEdit>("searchEdit"); SearchEdit = FunctionContainer.CreateNode<LineEdit>("searchEdit");
SearchEdit.PlaceholderText = "Please input search key"; SearchEdit.PlaceholderText = "PlaceholderSearch";
SearchEdit.SizeFlagsHorizontal = SizeFlags.ShrinkEnd; SearchEdit.SizeFlagsHorizontal = SizeFlags.ShrinkEnd;
SearchEdit.CustomMinimumSize = new Vector2(MinimumFunctionButtonSize.X * 2, MinimumFunctionButtonSize.Y); SearchEdit.CustomMinimumSize = new Vector2(MinimumFunctionButtonSize.X * 2, MinimumFunctionButtonSize.Y);
@ -218,7 +218,7 @@ namespace EGFramework.UI
} }
ResetSearch(); ResetSearch();
} }
public void InitPageMenu() public void InitPageMenu()
{ {
if (PageContainer == null) if (PageContainer == null)
@ -229,7 +229,7 @@ namespace EGFramework.UI
Label labelCount = PageContainer.CreateNode<Label>("to"); Label labelCount = PageContainer.CreateNode<Label>("to");
labelCount.Text = "Data count : " + PageAdapter.DataLength; labelCount.Text = Tr("Data") + " " + Tr("Count") +" : " + PageAdapter.DataLength + " "+Tr("Page")+" : " + PageAdapter.CurrentPage;
Control empty1 = PageContainer.CreateNode<Control>("empty1"); Control empty1 = PageContainer.CreateNode<Control>("empty1");
empty1.CustomMinimumSize = new Vector2(32, 0); empty1.CustomMinimumSize = new Vector2(32, 0);
@ -271,13 +271,13 @@ namespace EGFramework.UI
inputPage.Connect("value_changed", Callable.From<int>(ToPage)); inputPage.Connect("value_changed", Callable.From<int>(ToPage));
Label labelPage = PageContainer.CreateNode<Label>("page"); Label labelPage = PageContainer.CreateNode<Label>("page");
labelPage.Text = "page"; labelPage.Text = "Page";
firstPage.Disabled = true; firstPage.Disabled = true;
lastPage.Disabled = true; lastPage.Disabled = true;
PageChangedRealease = this.OnPageChanged.Register(() => PageChangedRealease = this.OnPageChanged.Register(() =>
{ {
labelCount.Text = "Data count : " + PageAdapter.DataLength + " Page : " + PageAdapter.CurrentPage; labelCount.Text = Tr("Data") + " " + Tr("Count") +" : " + PageAdapter.DataLength + " "+Tr("Page")+" : " + PageAdapter.CurrentPage;
currentPage.Text = PageAdapter.CurrentPage.ToString(); currentPage.Text = PageAdapter.CurrentPage.ToString();
if (PageAdapter.IsFirstPage()) if (PageAdapter.IsFirstPage())
{ {
@ -341,9 +341,9 @@ namespace EGFramework.UI
public void Search() public void Search()
{ {
if (SearchEdit.Text == "" && FieldSelect.Text == "") if (SearchEdit.Text == "" || FieldSelect.Text == "")
{ {
this.EGAlert("Please input key word in search edit and select a field.", "Message not enough!"); this.EGAlert("MissingMessage", "MessageNotEnough");
} }
else else
{ {
@ -453,5 +453,5 @@ namespace EGFramework.UI
} }
} }
} }

2
addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTableRowData.cs

@ -60,7 +60,7 @@ namespace EGFramework.UI{
} }
public void OnDeleteSelf() public void OnDeleteSelf()
{ {
this.EGConfirm("Delete this data? this operate cannot be canceled.", e => this.EGConfirm("DeleteConfirmation", e =>
{ {
if (e) if (e)
{ {

41
addons/EGFramework/Module/GenerateTools/Templete/Variant/EGTree.cs

@ -4,12 +4,13 @@ using Newtonsoft.Json;
namespace EGFramework namespace EGFramework
{ {
public interface IEGTree public interface IEGTree
{ {
public string Name { set; get; } public string Name { set; get; }
public IEGTree GetParent(); public IEGTree GetParent();
public void SetParent(IEGTree tree); public void SetParent(IEGTree tree);
public IEnumerable<IEGTree> GetChilds(); public IEnumerable<IEGTree> GetChilds();
public IEGTree GetChild(string key);
public void AppendTree(IEGTree tree); public void AppendTree(IEGTree tree);
} }
@ -25,7 +26,7 @@ namespace EGFramework
public bool BoolValue { set; get; } public bool BoolValue { set; get; }
public IEGTree Parent { set; get; } public IEGTree Parent { set; get; }
public List<IEGTree> Childs { set; get; } = new List<IEGTree>(); public Dictionary<string,IEGTree> Childs { set; get; } = new Dictionary<string,IEGTree>();
public EGTree() public EGTree()
{ {
@ -38,13 +39,31 @@ namespace EGFramework
public void AppendTree(IEGTree tree) public void AppendTree(IEGTree tree)
{ {
tree.SetParent(this); if (!Childs.ContainsKey(tree.Name))
Childs.Add(tree); {
tree.SetParent(this);
Childs.Add(tree.Name,tree);
}
}
public void AppendTree(string treeName)
{
if (!Childs.ContainsKey(treeName))
{
EGTree newTree = new EGTree(treeName);
newTree.SetParent(this);
Childs.Add(treeName, newTree);
}
}
public bool Contains(string name)
{
return Childs.ContainsKey(name);
} }
public virtual IEnumerable<IEGTree> GetChilds() public virtual IEnumerable<IEGTree> GetChilds()
{ {
return Childs; return Childs.Values;
} }
public virtual IEGTree GetParent() public virtual IEGTree GetParent()
@ -56,6 +75,18 @@ namespace EGFramework
{ {
this.Parent = tree; this.Parent = tree;
} }
public IEGTree GetChild(string key)
{
if (Childs.ContainsKey(key))
{
return Childs[key];
}
else
{
return null;
}
}
} }
public static class EGTreeFactory public static class EGTreeFactory

28
addons/EGFramework/Module/GenerateTools/Templete/Variant/EGVariantGenerator.cs

@ -21,21 +21,6 @@ namespace EGFramework{
} }
return result; 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) public static Dictionary<string, Type> EGenerateTypeDictiontaryByType(this Type self)
{ {
PropertyInfo[] propertyNames = self.GetProperties(); PropertyInfo[] propertyNames = self.GetProperties();
@ -123,5 +108,18 @@ namespace EGFramework{
} }
return result; return result;
} }
public static Dictionary<int, string> EGenerateMappingByEnum(this Type self)
{
Dictionary<int, string> result = new Dictionary<int, string>();
foreach (var value in Enum.GetValues(self))
{
if (!result.ContainsKey((int)value))
{
result.Add((int)value, value.ToString());
}
}
return result;
}
} }
} }

5
addons/EGFramework/Module/SaveTools/Data/EGDapper.cs

@ -11,6 +11,7 @@ namespace EGFramework
public abstract class EGDapper : IEGSave, IEGSaveData, IEGDataBase public abstract class EGDapper : IEGSave, IEGSaveData, IEGDataBase
{ {
public DbConnection Connection { get; set; } public DbConnection Connection { get; set; }
public string PrimaryType = "INTEGER PRIMARY KEY AUTO_INCREMENT";
public string ExceptionMsg; public string ExceptionMsg;
public abstract void InitSave(string conn); public abstract void InitSave(string conn);
@ -303,7 +304,7 @@ namespace EGFramework
EG.Print("Table " + dataKey + " has been created!"); EG.Print("Table " + dataKey + " has been created!");
return; return;
} }
string createSql = typeof(TData).ToCreateTableSQL(dataKey); string createSql = typeof(TData).ToCreateTableSQL(dataKey,PrimaryType);
int count = Connection.Execute(createSql); int count = Connection.Execute(createSql);
} }
@ -319,7 +320,7 @@ namespace EGFramework
{ {
tableType.Add(pair.Key, pair.Value.GetType()); tableType.Add(pair.Key, pair.Value.GetType());
} }
string createSql = tableType.ToCreateTableSQL(dataKey); string createSql = tableType.ToCreateTableSQL(dataKey,PrimaryType);
int count = Connection.Execute(createSql); int count = Connection.Execute(createSql);
} }

5
addons/EGFramework/Module/SaveTools/Data/EGSqliteSave.cs

@ -16,10 +16,7 @@ namespace EGFramework{
/// <param name="path">please add *.db suffix or your db file suffix</param> /// <param name="path">please add *.db suffix or your db file suffix</param>
public override void InitSave(string path) public override void InitSave(string path)
{ {
if (!File.Exists(path)) PrimaryType = "INTEGER PRIMARY KEY AUTOINCREMENT";
{
Directory.CreateDirectory(path);
}
InitDatabase(path); InitDatabase(path);
} }

24
addons/EGFramework/Translate/EGFramework.csv

@ -0,0 +1,24 @@
keys,en,zh,jp
Add,Add,添加,追加する
Refresh,Refresh,刷新,刷新
Output,Output,导出,エクスポート
Input,Input,导入,インポート
Search,Search,查找,検索する
PlaceholderSearch,Please input keyword,请输入关键词,キーワードを入力してください
MissingMessage,Please input key word in search edit and select a field,请在搜索编辑中输入关键字并选择一个字段,検索編集にキーワードを入力し、フィールドを選んでください
MessageNotEnough,Message not enough,消息不足,メッセージが足りません
Reset,Reset,重置,リセット
To,To,到,へ
Page,Page,页,ページ
Data,Data,数据,データ
Modify,Modify,更改,修正する
Delete,Delete,删除,削除する
Count,Count,数量,カウント
DeleteConfirmation,Delete this data? this operate cannot be canceled.,确认删除数据?此项操作不可被撤销。,このデータを削除しますか?この操作はキャンセルできません。
OK,OK,确认,はい
Cancel,Cancel,取消,キャンセル
ID,ID,ID,ID
Name,Name, 名称,ネーム
Age,Age, 年龄,エイジ
Path,Path, 路径,パス
Operate,Operate,操作,操作する
1 keys en zh jp
2 Add Add 添加 追加する
3 Refresh Refresh 刷新 刷新
4 Output Output 导出 エクスポート
5 Input Input 导入 インポート
6 Search Search 查找 検索する
7 PlaceholderSearch Please input keyword 请输入关键词 キーワードを入力してください
8 MissingMessage Please input key word in search edit and select a field 请在搜索编辑中输入关键字并选择一个字段 検索編集にキーワードを入力し、フィールドを選んでください
9 MessageNotEnough Message not enough 消息不足 メッセージが足りません
10 Reset Reset 重置 リセット
11 To To
12 Page Page ページ
13 Data Data 数据 データ
14 Modify Modify 更改 修正する
15 Delete Delete 删除 削除する
16 Count Count 数量 カウント
17 DeleteConfirmation Delete this data? this operate cannot be canceled. 确认删除数据?此项操作不可被撤销。 このデータを削除しますか?この操作はキャンセルできません。
18 OK OK 确认 はい
19 Cancel Cancel 取消 キャンセル
20 ID ID ID ID
21 Name Name 名称 ネーム
22 Age Age 年龄 エイジ
23 Path Path 路径 パス
24 Operate Operate 操作 操作する

17
addons/EGFramework/Translate/EGFramework.csv.import

@ -0,0 +1,17 @@
[remap]
importer="csv_translation"
type="Translation"
uid="uid://dkmbeivkbutkr"
[deps]
files=["res://addons/EGFramework/Translate/EGFramework.en.translation", "res://addons/EGFramework/Translate/EGFramework.zh.translation", "res://addons/EGFramework/Translate/EGFramework.jp.translation"]
source_file="res://addons/EGFramework/Translate/EGFramework.csv"
dest_files=["res://addons/EGFramework/Translate/EGFramework.en.translation", "res://addons/EGFramework/Translate/EGFramework.zh.translation", "res://addons/EGFramework/Translate/EGFramework.jp.translation"]
[params]
compress=true
delimiter=0

4
project.godot

@ -87,6 +87,10 @@ jump={
] ]
} }
[internationalization]
locale/translations=PackedStringArray("res://addons/EGFramework/Translate/EGFramework.en.translation", "res://addons/EGFramework/Translate/EGFramework.jp.translation", "res://addons/EGFramework/Translate/EGFramework.zh.translation")
[rendering] [rendering]
renderer/rendering_method="gl_compatibility" renderer/rendering_method="gl_compatibility"

Loading…
Cancel
Save