From f881d43c3b9a006f40deff7ae600f66eb9012b92 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Thu, 26 Sep 2024 22:43:10 +0800 Subject: [PATCH] =?UTF-8?q?Bind=20the=20backpack=20to=20the=20ui.=20?= =?UTF-8?q?=E4=BD=BF=E8=83=8C=E5=8C=85=E5=92=8Cui=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/loader/uiLoader/PacksackUi.cs | 37 ++++++++++----------------- 1 file changed, 14 insertions(+), 23 deletions(-) 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