Browse Source

add Enum type to egeditParam Option button

master
jkpete 2 months ago
parent
commit
954ceefcaf
  1. 41
      Example/SaveSystem/Script/ViewSaveSystem.cs
  2. 3
      addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotBasicDialog.cs
  3. 14
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs
  4. 14
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTable.cs
  5. 13
      addons/EGFramework/Module/GenerateTools/Templete/Variant/EGVariantGenerator.cs
  6. 2
      addons/EGFramework/Translate/EGFramework.csv

41
Example/SaveSystem/Script/ViewSaveSystem.cs

@ -8,18 +8,27 @@ 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"); // TranslationServer.SetLocale("jp");
TestTable(); // GD.Print(Tr("Data")+"+___+");
// 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()); // EG.Print(OS.GetLocaleLanguage());
@ -62,15 +71,11 @@ 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(() =>
{ {
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()
@ -149,11 +154,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();
} }
} }
@ -164,7 +171,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;
@ -172,7 +179,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; }
@ -180,4 +187,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
}
} }

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);
} }

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;
}); });

14
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; } = "-";
@ -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
{ {
@ -454,12 +454,4 @@ namespace EGFramework.UI
} }
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class EGTitleAttribute : Attribute
{
public string _name { set; get; }
public EGTitleAttribute(string name){
this._name = name;
}
}
} }

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

@ -123,5 +123,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;
}
} }
} }

2
addons/EGFramework/Translate/EGFramework.csv

@ -5,6 +5,8 @@ Output,Output,导出,エクスポート
Input,Input,导入,インポート Input,Input,导入,インポート
Search,Search,查找,検索する Search,Search,查找,検索する
PlaceholderSearch,Please input keyword,请输入关键词,キーワードを入力してください PlaceholderSearch,Please input keyword,请输入关键词,キーワードを入力してください
MissingMessage,Please input key word in search edit and select a field,请在搜索编辑中输入关键字并选择一个字段,検索編集にキーワードを入力し、フィールドを選んでください
MessageNotEnough,Message not enough,消息不足,メッセージが足りません
Reset,Reset,重置,リセット Reset,Reset,重置,リセット
To,To,到,へ To,To,到,へ
Page,Page,页,ページ Page,Page,页,ページ

1 keys en zh jp
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 ページ
Loading…
Cancel
Save