diff --git a/scripts/loader/uiLoader/PacksackUi.cs b/scripts/loader/uiLoader/PacksackUi.cs index fe3e140..c704a24 100644 --- a/scripts/loader/uiLoader/PacksackUi.cs +++ b/scripts/loader/uiLoader/PacksackUi.cs @@ -1,5 +1,4 @@ using ColdMint.scripts.inventory; -using ColdMint.scripts.utils; using Godot; namespace ColdMint.scripts.loader.uiLoader; @@ -22,6 +21,8 @@ public partial class PacksackUi : UiLoaderTemplate private Button? _exitButton; + private IItemContainerDisplay? _itemContainerDisplay; + /// /// title /// 标题 @@ -46,30 +47,10 @@ public partial class PacksackUi : UiLoaderTemplate set { _itemContainer = value; - PlaceItemSlot(value); + BindItemContainer(); } } - /// - /// Place item slots according to item information - /// 根据物品信息放置物品槽 - /// - /// - private void PlaceItemSlot(IItemContainer? itemContainer) - { - if (_hFlowContainer == null || itemContainer == null) - { - return; - } - - NodeUtils.DeleteAllChild(_hFlowContainer); - //todo:实现使用物品数据刷新物品槽的方法。 - // foreach (var item in itemContainer) - // { - // itemSlotNode.Reparent(_hFlowContainer); - // itemSlotNode.Show(); - // } - } /// /// SetTile @@ -91,14 +72,24 @@ public partial class PacksackUi : UiLoaderTemplate _packedScene = GD.Load("res://prefab/ui/ItemSlot.tscn"); } + private void BindItemContainer() + { + if (ItemContainer == null) + { + return; + } + _itemContainerDisplay?.BindItemContainer(ItemContainer); + } + public override void InitializeUi() { _hFlowContainer = GetNode("HFlowContainer"); _titleLabel = GetNode