Browse Source

add Enum type to egeditParam Option button

master
jkpete 2 months ago
parent
commit
954ceefcaf
  1. 33
      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

33
Example/SaveSystem/Script/ViewSaveSystem.cs

@ -8,7 +8,8 @@ using LiteDB; @@ -8,7 +8,8 @@ using LiteDB;
using Newtonsoft.Json;
using Renci.SshNet;
namespace EGFramework.Examples.Test {
namespace EGFramework.Examples.Test
{
public partial class ViewSaveSystem : Node, IEGFramework
{
public string[][] DataList { get; set; }
@ -18,8 +19,16 @@ namespace EGFramework.Examples.Test { @@ -18,8 +19,16 @@ namespace EGFramework.Examples.Test {
{
// TestTree();
// TranslationServer.SetLocale("jp");
TestTable();
// GD.Print(Tr("Data")+"+___+");
// TestTable();
// 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();
// TestMySQL();
// EG.Print(OS.GetLocaleLanguage());
@ -62,15 +71,11 @@ namespace EGFramework.Examples.Test { @@ -62,15 +71,11 @@ namespace EGFramework.Examples.Test {
public void TestDialog()
{
DataStudent dataStudent = new DataStudent();
dataStudent.EGenerateDictiontaryByObject();
this.ExecuteAfterSecond(() =>
{
this.EGEditDialog(new DataStudent().EGenerateDictiontaryByObject(), e =>
DataStudent dataStudent = new DataStudent("ZG",10);
this.EGEditDialog(dataStudent.EGenerateDictiontaryByObject(), e =>
{
GD.Print("Name:" + e["Name"] + "Age:" + e["Age"]);
GD.Print("Name:" + e["Name"] + "Age:" + e["Age"]+"School:" + e["School"] + "Path:" + e["Path"]);
}, "Edit");
}, 0.2f);
}
public void TestJson()
@ -149,11 +154,13 @@ namespace EGFramework.Examples.Test { @@ -149,11 +154,13 @@ namespace EGFramework.Examples.Test {
public string Name { get; set; }
public int Age;
public EGPathSelect Path { set; get; }
public SchoolType School { set; get; }
public DataStudent(string name, int age)
{
Name = name;
Age = age;
ID = 0;
School = SchoolType.MIT;
Path = new EGPathSelect();
}
}
@ -180,4 +187,12 @@ namespace EGFramework.Examples.Test { @@ -180,4 +187,12 @@ namespace EGFramework.Examples.Test {
public string workPlace { 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 @@ @@ -1,4 +1,5 @@
using System;
using System.IO;
using Godot;
namespace EGFramework.UI
{
@ -23,7 +24,7 @@ namespace EGFramework.UI @@ -23,7 +24,7 @@ namespace EGFramework.UI
{
EGodotFileDialog fileDialog = self.PopupNode<EGodotFileDialog>("FileDialog");
fileDialog.Title = title;
fileDialog.RootSubfolder = filePath;
fileDialog.RootSubfolder = Path.GetDirectoryName(filePath);
fileDialog.InitFileSelect(selectPath);
}

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

@ -67,6 +67,18 @@ namespace EGFramework.UI @@ -67,6 +67,18 @@ namespace EGFramework.UI
}
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)
{
this.ParamSpinBox = new SpinBox();
@ -128,7 +140,7 @@ namespace EGFramework.UI @@ -128,7 +140,7 @@ namespace EGFramework.UI
ParamOperate.SizeFlagsHorizontal = SizeFlags.ExpandFill;
ParamOperate.Pressed += () =>
{
this.EGFileOpen("res://", str =>
this.EGFileOpen("", str =>
{
ParamPathSelect.Text = str;
});

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

@ -33,7 +33,7 @@ namespace EGFramework.UI @@ -33,7 +33,7 @@ namespace EGFramework.UI
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; } = "-";
@ -341,9 +341,9 @@ namespace EGFramework.UI @@ -341,9 +341,9 @@ namespace EGFramework.UI
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
{
@ -454,12 +454,4 @@ namespace EGFramework.UI @@ -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{ @@ -123,5 +123,18 @@ namespace EGFramework{
}
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,导出,エクスポート @@ -5,6 +5,8 @@ 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,页,ページ

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