Browse Source

add basic interface type row data ,and param

master
jkpete 2 months ago
parent
commit
5b626cd141
  1. 4
      Example/SaveSystem/Script/ViewSaveSystem.cs
  2. 6
      addons/EGFramework/Module/GenerateTools/Templete/Godot/EGodotTableRowData.cs
  3. 7
      addons/EGFramework/Module/GenerateTools/Templete/Godot/Interface/EGGodotData.cs
  4. 60
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotEditParam.cs
  5. 36
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotRowData.cs

4
Example/SaveSystem/Script/ViewSaveSystem.cs

@ -40,7 +40,9 @@ namespace EGFramework.Examples.Test{ @@ -40,7 +40,9 @@ namespace EGFramework.Examples.Test{
// });
EGodotTableRowData rowData = table.CreateNode<EGodotTableRowData>("RowData");
rowData.InitRowData(new Dictionary<string, object>() { { "Name", "Tom" }, { "Age", 18 } });
rowData.Init(new Dictionary<string, object>() { { "Name", "Tom" }, { "Age", 18 } });
EGodotRowData rowData2 = table.CreateNode<EGodotRowData>("RowData2");
rowData2.Init(new Dictionary<string, object>() { { "Name", "Z" }, { "Age", 1 } });
}
public override void _ExitTree()

6
addons/EGFramework/Module/GenerateTools/Templete/Godot/EGodotTableRowData.cs

@ -3,7 +3,7 @@ using System.Collections.Generic; @@ -3,7 +3,7 @@ using System.Collections.Generic;
using Godot;
namespace EGFramework.UI{
public partial class EGodotTableRowData : EGRowData
public partial class EGodotTableRowData : EGodotRowData
{
public Control Operate { get; set; }
public Button Modify { get; set; }
@ -11,9 +11,9 @@ namespace EGFramework.UI{ @@ -11,9 +11,9 @@ namespace EGFramework.UI{
private Action<Dictionary<string,object>> OnDataEdit;
public override void InitRowData(Dictionary<string, object> data)
public override void Init(Dictionary<string, object> data)
{
base.InitRowData(data);
base.Init(data);
Operate = new HBoxContainer();
Operate.Name = "Operate";

7
addons/EGFramework/Module/GenerateTools/Templete/Godot/Interface/EGGodotData.cs

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
namespace EGFramework.UI
{
public interface IEGodotData
{
public void RefreshData();
}
}

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

@ -3,6 +3,12 @@ using Godot; @@ -3,6 +3,12 @@ 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 partial class EGodotEditParam : HBoxContainer, IEGFramework
{
public Label ParamName { get; set; }
@ -16,7 +22,8 @@ namespace EGFramework.UI @@ -16,7 +22,8 @@ namespace EGFramework.UI
public KeyValuePair<string, object> EditValue { get; set; }
public void Init(KeyValuePair<string,object> editValue){
public void Init(KeyValuePair<string, object> editValue)
{
EditValue = editValue;
this.ParamName = new Label();
ParamName.Name = "ParamName";
@ -24,7 +31,8 @@ namespace EGFramework.UI @@ -24,7 +31,8 @@ namespace EGFramework.UI
ParamName.SizeFlagsHorizontal = SizeFlags.ExpandFill;
this.AddChild(ParamName);
ParamName.Text = editValue.Key;
if(editValue.Value is string){
if (editValue.Value is string)
{
this.ParamEdit = new LineEdit();
ParamEdit.Name = "ParamEdit";
ParamEdit.SizeFlagsHorizontal = SizeFlags.ExpandFill;
@ -32,7 +40,8 @@ namespace EGFramework.UI @@ -32,7 +40,8 @@ namespace EGFramework.UI
this.AddChild(ParamEdit);
ParamEdit.Text = (string)editValue.Value;
}
else if(editValue.Value is bool){
else if (editValue.Value is bool)
{
this.ParamCheck = new CheckButton();
ParamCheck.Name = "ParamCheck";
ParamCheck.SizeFlagsHorizontal = SizeFlags.ExpandFill;
@ -40,24 +49,28 @@ namespace EGFramework.UI @@ -40,24 +49,28 @@ namespace EGFramework.UI
ParamCheck.ButtonPressed = (bool)editValue.Value;
this.AddChild(ParamCheck);
}
else if(editValue.Value is IEGReadOnlyString){
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){
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){
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){
else if (editValue.Value is int)
{
this.ParamSpinBox = new SpinBox();
ParamSpinBox.Name = "ParamSpinBox";
ParamSpinBox.SizeFlagsHorizontal = SizeFlags.ExpandFill;
@ -66,7 +79,8 @@ namespace EGFramework.UI @@ -66,7 +79,8 @@ namespace EGFramework.UI
ParamSpinBox.MinValue = int.MinValue;
this.AddChild(ParamSpinBox);
}
else if(editValue.Value is float){
else if (editValue.Value is float)
{
this.ParamSpinBox = new SpinBox();
ParamSpinBox.Name = "ParamSpinBox";
ParamSpinBox.SizeFlagsHorizontal = SizeFlags.ExpandFill;
@ -76,7 +90,8 @@ namespace EGFramework.UI @@ -76,7 +90,8 @@ namespace EGFramework.UI
ParamSpinBox.Step = 0.01f;
this.AddChild(ParamSpinBox);
}
else if(editValue.Value is double){
else if (editValue.Value is double)
{
this.ParamSpinBox = new SpinBox();
ParamSpinBox.Name = "ParamSpinBox";
ParamSpinBox.SizeFlagsHorizontal = SizeFlags.ExpandFill;
@ -86,7 +101,8 @@ namespace EGFramework.UI @@ -86,7 +101,8 @@ namespace EGFramework.UI
ParamSpinBox.Step = 0.0001f;
this.AddChild(ParamSpinBox);
}
else if(editValue.Value is EGRangeParam){
else if (editValue.Value is EGRangeParam)
{
this.ParamSlider = new HSlider();
ParamSlider.Name = "ParamSlider";
ParamSlider.SizeFlagsHorizontal = SizeFlags.ExpandFill;
@ -99,27 +115,35 @@ namespace EGFramework.UI @@ -99,27 +115,35 @@ namespace EGFramework.UI
}
}
public string GetKey(){
public string GetKey()
{
return EditValue.Key;
}
public object GetValue(){
if(ParamEdit != null){
public object GetValue()
{
if (ParamEdit != null)
{
return ParamEdit.Text;
}
else if(ParamCheck != null){
else if (ParamCheck != null)
{
return ParamCheck.ButtonPressed;
}
else if(ParamOption != null){
else if (ParamOption != null)
{
return ParamOption.Selected;
}
else if(ParamReadOnly != null){
else if (ParamReadOnly != null)
{
return ParamReadOnly.Text;
}
else if(ParamSpinBox != null){
else if (ParamSpinBox != null)
{
return ParamSpinBox.Value;
}
else if(ParamSlider != null){
else if (ParamSlider != null)
{
return ParamSlider.Value;
}
return null;

36
addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGRowData.cs → addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotRowData.cs

@ -4,12 +4,14 @@ using System.Collections.Generic; @@ -4,12 +4,14 @@ using System.Collections.Generic;
namespace EGFramework.UI
{
public interface IEGRowData
public interface IEGodotRowData:IEGodotData
{
public void InitRowData(Dictionary<string, object> data);
public void Init(Dictionary<string, object> data);
public void RefreshData(Dictionary<string, object> data);
public Dictionary<string, object> GetData();
}
public partial class EGRowData : PanelContainer, IEGFramework,IEGRowData
public partial class EGodotRowData : PanelContainer, IEGFramework, IEGodotRowData
{
public Button ItemHover { get; set; }
@ -20,7 +22,13 @@ namespace EGFramework.UI @@ -20,7 +22,13 @@ namespace EGFramework.UI
protected Dictionary<string, object> Data { get; set; }
protected bool IsInit { set; get; } = false;
public virtual void InitRowData(Dictionary<string, object> data)
public Dictionary<string, object> GetData()
{
return this.Data;
}
public virtual void Init(Dictionary<string, object> data)
{
if (IsInit)
{
@ -57,6 +65,7 @@ namespace EGFramework.UI @@ -57,6 +65,7 @@ namespace EGFramework.UI
});
}
this.AddThemeStyleboxOverride("panel", new StyleBoxEmpty());
IsInit = true;
}
public virtual void RefreshData(Dictionary<string, object> data)
@ -73,5 +82,24 @@ namespace EGFramework.UI @@ -73,5 +82,24 @@ namespace EGFramework.UI
});
}
}
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;
}
}
}
}
Loading…
Cancel
Save