From 124c6ce0baae4da64c94d102e337accc05df78a9 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Fri, 4 Oct 2024 16:13:34 +0800 Subject: [PATCH] =?UTF-8?q?The=20UI=20will=20be=20automatically=20closed?= =?UTF-8?q?=20when=20the=20player=20leaves=20the=20range=20of=20the=20furn?= =?UTF-8?q?iture.=20The=20spell=20editor=20is=20now=20able=20to=20load=20i?= =?UTF-8?q?nformation=20about=20items=20placed=20in=20it.=20=E7=8E=A9?= =?UTF-8?q?=E5=AE=B6=E7=A6=BB=E5=BC=80=E5=AE=B6=E5=85=B7=E7=9A=84=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E8=8C=83=E5=9B=B4=E6=97=B6=E4=BC=9A=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E9=97=ADUI=E4=BA=86=E3=80=82=E6=B3=95=E6=9C=AF?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E7=8E=B0=E5=9C=A8=E8=83=BD=E5=A4=9F?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=94=BE=E5=85=A5=E7=9A=84=E7=89=A9=E5=93=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prefab/ui/SpellEditorUI.tscn | 4 +-- scripts/furniture/GuiFurniture.cs | 13 ++++------ scripts/inventory/IItemContainerDisplay.cs | 2 +- .../inventory/ItemContainerDisplayTemplate.cs | 19 +++++++++++--- scripts/loader/uiLoader/SpellEditorUi.cs | 26 +++++++++++++------ 5 files changed, 41 insertions(+), 23 deletions(-) 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