From fe4155580a3ed3e2f77df2076fbeac297494c651 Mon Sep 17 00:00:00 2001 From: jkpete <1031139173@qq.com> Date: Sat, 10 May 2025 17:29:09 +0800 Subject: [PATCH] fixed row data --- .../GodotUITemplete/EGodotTable.cs | 61 +++++++++++++++++-- .../GodotUITemplete/EGodotTableRowData.cs | 12 ++-- 2 files changed, 63 insertions(+), 10 deletions(-) diff --git a/addons/EGFramework/Module/GenerateTools/GodotUITemplete/EGodotTable.cs b/addons/EGFramework/Module/GenerateTools/GodotUITemplete/EGodotTable.cs index c994709..82851a9 100644 --- a/addons/EGFramework/Module/GenerateTools/GodotUITemplete/EGodotTable.cs +++ b/addons/EGFramework/Module/GenerateTools/GodotUITemplete/EGodotTable.cs @@ -1,17 +1,66 @@ +using System.Collections.Generic; using Godot; namespace EGFramework.UI{ public partial class EGodotTable : VBoxContainer,IEGFramework { - public override void _Ready() - { + 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 Dictionary TitleList { set; get; } = new Dictionary(); + private EGodotTablePageAdapter PageAdapter { set; get; } + private bool IsSearched { set; get; } + + /// + /// The max data count for one page. + /// + /// + [Export] + public int PageLimit { set; get; } = 10; + /// + /// Height mininum for RowDataContainer. + /// + /// + [Export] + public int MinHeight { set; get; } + + public void InitData(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(IEGSaveDataReadOnly saveData,string key)where T:new(){ - public override void _ExitTree() - { - } - + } + public class EGodotTablePageAdapter{ + public int DataLength { set; get; } + public int CurrentPage { set; get; } + public int MaxPage { set; get; } + public int PageLimit { set; get; } + + public EasyEvent OnLoad = new EasyEvent(); + + public EGodotTablePageAdapter(int dataLength,int pageLimit = 10){ + this.DataLength = dataLength; + this.PageLimit = pageLimit; + this.MaxPage = dataLength/PageLimit+1; + this.CurrentPage = 1; + } + + public void Reload(int dataLength,int pageLimit = 10){ + this.DataLength = dataLength; + this.PageLimit = pageLimit; + this.MaxPage = dataLength/PageLimit+1; + this.CurrentPage = 1; + OnLoad.Invoke(); + } } } \ No newline at end of file diff --git a/addons/EGFramework/Module/GenerateTools/GodotUITemplete/EGodotTableRowData.cs b/addons/EGFramework/Module/GenerateTools/GodotUITemplete/EGodotTableRowData.cs index 63ca1b6..dc9579a 100644 --- a/addons/EGFramework/Module/GenerateTools/GodotUITemplete/EGodotTableRowData.cs +++ b/addons/EGFramework/Module/GenerateTools/GodotUITemplete/EGodotTableRowData.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using Godot; namespace EGFramework.UI{ - public partial class EGodotTableRowData : VBoxContainer,IEGFramework + public partial class EGodotTableRowData : PanelContainer,IEGFramework { public Button ItemHover { get; set; } public ColorRect Line { get; set; } @@ -19,6 +19,12 @@ namespace EGFramework.UI{ public void InitRowData(Dictionary data){ this.Data = data; + BackGround = new ColorRect(); + BackGround.Name = "BackGround"; + BackGround.Color = new Color(0.5f,0.5f,1f); + BackGround.SizeFlagsHorizontal = SizeFlags.ExpandFill; + BackGround.SizeFlagsVertical = SizeFlags.ExpandFill; + this.AddChild(BackGround); List = new HBoxContainer(); List.Name = "TableRow_"+Resource.GenerateSceneUniqueId(); List.SizeFlagsHorizontal = Control.SizeFlags.ExpandFill; @@ -57,9 +63,7 @@ namespace EGFramework.UI{ OnDataEdit = e => { }; - } - public void RefreshRowData(){ - + this.AddThemeStyleboxOverride("panel",new StyleBoxEmpty()); } public void OnEdit(){