Browse Source

fixed data

master
jkpete 2 months ago
parent
commit
e3494c99cf
  1. 2
      addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotEditDialog.cs
  2. 41
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotSaveTable.cs
  3. 17
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTable.cs
  4. 6
      addons/EGFramework/Module/GenerateTools/Templete/Godot/UI/EGodotTableRowData.cs

2
addons/EGFramework/Module/GenerateTools/Templete/Godot/Dialog/EGodotEditDialog.cs

@ -57,8 +57,6 @@ namespace EGFramework.UI
foreach (EGodotEditParam paramUI in ParamUIs) foreach (EGodotEditParam paramUI in ParamUIs)
{ {
EditCache.Add(paramUI.GetKey(), paramUI.GetValue()); EditCache.Add(paramUI.GetKey(), paramUI.GetValue());
GD.Print(paramUI.GetValue());
} }
try try
{ {

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

@ -3,48 +3,9 @@ using Godot;
namespace EGFramework.UI namespace EGFramework.UI
{ {
public partial class EGodotSaveTable : VBoxContainer, IEGFramework public partial class EGodotSaveTable : EGodotTable, IEGFramework
{ {
public HBoxContainer FunctionContainer { set; get; }
public HBoxContainer TitleContainer { set; get; }
public VBoxContainer RowDataContainer { set; get; }
public HBoxContainer PageContainer { set; get; }
public IEGSaveData SaveData { set; get; } public IEGSaveData SaveData { set; get; }
public Dictionary<string, string> TitleList { set; get; } = new Dictionary<string, string>(); public Dictionary<string, string> TitleList { set; get; } = new Dictionary<string, string>();
private EGodotTablePageAdapter PageAdapter { set; get; }
private bool IsSearched { set; get; }
/// <summary>
/// The max data count for one page.
/// </summary>
/// <value></value>
[Export]
public int PageLimit { set; get; } = 10;
/// <summary>
/// Height mininum for RowDataContainer.
/// </summary>
/// <value></value>
[Export]
public int MinHeight { set; get; }
public void InitData<T>(IEGSaveData saveData, string key) where T : new()
{
int count = saveData.GetDataCount(key);
if (PageAdapter == null)
{
PageAdapter = new EGodotTablePageAdapter(count, PageLimit);
}
else
{
PageAdapter.Reload(count, PageLimit);
}
}
public void InitReadOnlyData<T>(IEGSaveDataReadOnly saveData, string key) where T : new()
{
}
} }
} }

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

@ -18,18 +18,15 @@ namespace EGFramework.UI
public ScrollContainer RowDataScroll { set; get; } public ScrollContainer RowDataScroll { set; get; }
public BoxContainer PageContainer { set; get; } public BoxContainer PageContainer { set; get; }
public IEGSaveData SaveData { set; get; }
public Dictionary<string, string> TitleList { set; get; } = new Dictionary<string, string>();
public Color MainColor { set; get; } = new Color(); public Color MainColor { set; get; } = new Color();
public Color MinorColor { set; get; } = new Color(); public Color MinorColor { set; get; } = new Color();
private EGodotTablePageAdapter PageAdapter { set; get; } protected EGodotTablePageAdapter PageAdapter { set; get; }
private bool IsSearched { set; get; } protected bool IsSearched { set; get; }
private EasyEvent OnPageChanged { set; get; } = new EasyEvent(); protected EasyEvent OnPageChanged { set; get; } = new EasyEvent();
private IUnRegister PageChangedRealease { set; get; } protected IUnRegister PageChangedRealease { set; get; }
private List<Dictionary<string, object>> TableData { set; get; } protected List<Dictionary<string, object>> TableData { set; get; }
/// <summary> /// <summary>
/// The max data count for one page. /// The max data count for one page.
@ -172,6 +169,8 @@ namespace EGFramework.UI
inputPage.MinValue = 1; inputPage.MinValue = 1;
inputPage.MaxValue = PageAdapter.MaxPage; inputPage.MaxValue = PageAdapter.MaxPage;
inputPage.Alignment = HorizontalAlignment.Center; inputPage.Alignment = HorizontalAlignment.Center;
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";
@ -232,7 +231,7 @@ namespace EGFramework.UI
} }
public void ToPage(int pageId) public void ToPage(int pageId)
{ {
if (pageId > 1 && this.PageAdapter.CurrentPage < pageId) if (pageId >= 1 && pageId <= this.PageAdapter.MaxPage)
{ {
this.PageAdapter.CurrentPage = pageId; this.PageAdapter.CurrentPage = pageId;
OnPageChanged.Invoke(); OnPageChanged.Invoke();

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

@ -43,7 +43,11 @@ namespace EGFramework.UI{
public virtual void OnDataEdit(Dictionary<string, object> e) public virtual void OnDataEdit(Dictionary<string, object> e)
{ {
this.Data = e; foreach (var pair in e)
{
this.Data[pair.Key] = pair.Value;
}
// this.Data = e;
this.RefreshData(); this.RefreshData();
} }

Loading…
Cancel
Save