diff --git a/prefab/ui/SpellEditorUI.tscn b/prefab/ui/SpellEditorUI.tscn index 39b44fc..e4171e8 100644 --- a/prefab/ui/SpellEditorUI.tscn +++ b/prefab/ui/SpellEditorUI.tscn @@ -38,10 +38,10 @@ text = "ui_close" layout_mode = 1 anchors_preset = 10 anchor_right = 1.0 -offset_left = 35.0 +offset_left = 32.0 offset_top = 127.0 offset_right = -20.0 -offset_bottom = 446.0 +offset_bottom = 629.0 grow_horizontal = 2 mouse_filter = 2 diff --git a/scripts/furniture/GuiFurniture.cs b/scripts/furniture/GuiFurniture.cs index e8a585c..2d50717 100644 --- a/scripts/furniture/GuiFurniture.cs +++ b/scripts/furniture/GuiFurniture.cs @@ -64,14 +64,7 @@ public partial class GuiFurniture : Furniture { return; } - GameSceneDepend.DynamicUiGroup?.ShowControl(Path, control => - { - if (control is SpellEditorUi spellEditorUi) - { - // spellEditorUi.Title = Name; - // spellEditorUi.ItemContainer = SelfItemContainer; - } - }); + GameSceneDepend.DynamicUiGroup?.ShowControl(Path); } public override void _MouseEnter() @@ -110,6 +103,10 @@ public partial class GuiFurniture : Furniture if (node2D is Player) { _playerInRange = false; + if (Path != null) + { + GameSceneDepend.DynamicUiGroup?.HideControl(Path); + } } } diff --git a/scripts/inventory/IItemContainerDisplay.cs b/scripts/inventory/IItemContainerDisplay.cs index 73508b6..ea5fffd 100644 --- a/scripts/inventory/IItemContainerDisplay.cs +++ b/scripts/inventory/IItemContainerDisplay.cs @@ -9,5 +9,5 @@ public interface IItemContainerDisplay : IEnumerable /// 为物品容器显示器绑定物品容器 /// /// - void BindItemContainer(IItemContainer itemContainer); + void BindItemContainer(IItemContainer? itemContainer); } \ No newline at end of file diff --git a/scripts/inventory/ItemContainerDisplayTemplate.cs b/scripts/inventory/ItemContainerDisplayTemplate.cs index 93a4050..57ffec5 100644 --- a/scripts/inventory/ItemContainerDisplayTemplate.cs +++ b/scripts/inventory/ItemContainerDisplayTemplate.cs @@ -10,7 +10,7 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay protected readonly List ItemDisplayList = []; private IItemContainer? _itemContainer; - public async void BindItemContainer(IItemContainer itemContainer) + public async void BindItemContainer(IItemContainer? itemContainer) { if (_itemContainer == itemContainer) { @@ -24,8 +24,19 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay } _itemContainer = itemContainer; - _itemContainer.SelectedItemChangeEvent += OnSelectedItemChangeEvent; - _itemContainer.ItemDataChangeEvent += OnItemDataChangeEvent; + if (itemContainer == null) + { + //Set empty items container to hide all ui. + //设置空物品容器,隐藏全部ui。 + foreach (var itemDisplay in ItemDisplayList) + { + itemDisplay.Update(null); + itemDisplay.HideSelf(); + } + return; + } + itemContainer.SelectedItemChangeEvent += OnSelectedItemChangeEvent; + itemContainer.ItemDataChangeEvent += OnItemDataChangeEvent; var totalCapacity = itemContainer.GetTotalCapacity(); var currentCapacity = ItemDisplayList.Count; var capacityDifference = totalCapacity - currentCapacity; @@ -102,7 +113,7 @@ public abstract class ItemContainerDisplayTemplate : IItemContainerDisplay { for (var i = startIndex; i < endIndex; i++) { - UpdateDataForSingleLocation(itemContainer,i); + UpdateDataForSingleLocation(itemContainer, i); } } diff --git a/scripts/loader/uiLoader/SpellEditorUi.cs b/scripts/loader/uiLoader/SpellEditorUi.cs index 1091b2d..59dcaf7 100644 --- a/scripts/loader/uiLoader/SpellEditorUi.cs +++ b/scripts/loader/uiLoader/SpellEditorUi.cs @@ -4,42 +4,52 @@ using Godot; namespace ColdMint.scripts.loader.uiLoader; +/// +/// SpellEditorUi +/// 法术编辑器UI +/// public partial class SpellEditorUi : UiLoaderTemplate { private Button? _exitButton; - private IItemContainer? _itemContainer; + private IItemContainer? _projectileWeaponContainer; private ItemSlotNode? _itemSlot; + private HFlowContainer? _flowContainer; + private IItemContainerDisplay? _itemContainerDisplay; public override void InitializeUi() { _exitButton = GetNode