diff --git a/scripts/Config.cs b/scripts/Config.cs
index 1943972..ffe96c9 100644
--- a/scripts/Config.cs
+++ b/scripts/Config.cs
@@ -216,6 +216,15 @@ public static class Config
///
public const string TimeInterval = "TimeInterval";
}
+
+ public class ZIndexManager
+ {
+ ///
+ /// Floating icon
+ /// 悬浮图标
+ ///
+ public const int FloatingIcon = 1;
+ }
///
/// Item data changes the event type
diff --git a/scripts/furniture/GuiFurniture.cs b/scripts/furniture/GuiFurniture.cs
index ebb5cc7..e8a585c 100644
--- a/scripts/furniture/GuiFurniture.cs
+++ b/scripts/furniture/GuiFurniture.cs
@@ -94,6 +94,7 @@ public partial class GuiFurniture : Furniture
public override void _PhysicsProcess(double delta)
{
+ base._PhysicsProcess(delta);
if (GameSceneDepend.Player == null || !_playerInRange || !_hasMouseOver)
{
return;
diff --git a/scripts/inventory/ItemSlotNode.cs b/scripts/inventory/ItemSlotNode.cs
index 48fa874..d9a58b8 100644
--- a/scripts/inventory/ItemSlotNode.cs
+++ b/scripts/inventory/ItemSlotNode.cs
@@ -49,6 +49,7 @@ public partial class ItemSlotNode : MarginContainer, IItemDisplay
textureRect.ExpandMode = _iconTextureRect.ExpandMode;
textureRect.Size = _iconTextureRect.Size;
textureRect.Texture = _iconTextureRect.Texture;
+ textureRect.ZIndex = Config.ZIndexManager.FloatingIcon;
SetDragPreview(textureRect);
return Variant.CreateFrom(this);
}
diff --git a/scripts/inventory/PlaceholderItem.cs b/scripts/inventory/PlaceholderItem.cs
index e7a7f1d..4ae581d 100644
--- a/scripts/inventory/PlaceholderItem.cs
+++ b/scripts/inventory/PlaceholderItem.cs
@@ -48,11 +48,9 @@ public class PlaceholderItem : IItem
public void Use(Node2D? owner, Vector2 targetGlobalPosition)
{
- throw new System.NotImplementedException();
}
public void OnThrow(Vector2 velocity)
{
- throw new System.NotImplementedException();
}
}
\ No newline at end of file
diff --git a/scripts/inventory/UniversalItemContainer.cs b/scripts/inventory/UniversalItemContainer.cs
index 97146f3..a4f7d2d 100644
--- a/scripts/inventory/UniversalItemContainer.cs
+++ b/scripts/inventory/UniversalItemContainer.cs
@@ -257,6 +257,10 @@ public class UniversalItemContainer(int totalCapacity) : IItemContainer
public bool ClearItem(int index)
{
+ if (!_itemDictionary.TryGetValue(index, out var item))
+ {
+ return false;
+ }
var result = _itemDictionary.Remove(index);
if (result)
{
@@ -268,6 +272,17 @@ public class UniversalItemContainer(int totalCapacity) : IItemContainer
OldItem = null,
Type = Config.ItemDataChangeEventType.Clear
});
+ if (SupportSelect && index == _selectIndex)
+ {
+ item.HideSelf();
+ SelectedItemChangeEvent?.Invoke(new SelectedItemChangeEvent()
+ {
+ NewIndex = index,
+ OldIndex = index,
+ NewItem = null,
+ OldItem = null
+ });
+ }
}
return result;
}
diff --git a/scripts/loader/uiLoader/SpellEditorUi.cs b/scripts/loader/uiLoader/SpellEditorUi.cs
index 027a6ec..1091b2d 100644
--- a/scripts/loader/uiLoader/SpellEditorUi.cs
+++ b/scripts/loader/uiLoader/SpellEditorUi.cs
@@ -21,11 +21,17 @@ public partial class SpellEditorUi : UiLoaderTemplate
private void OnItemDataChangeEvent(ItemDataChangeEvent itemDataChangeEvent)
{
- if (_itemSlot == null)
+ if (_itemSlot == null || _itemContainer == null)
{
return;
}
- _itemSlot.Update(itemDataChangeEvent.NewItem);
+ var item = itemDataChangeEvent.NewItem;
+ if (item == null)
+ {
+ item = _itemContainer.GetPlaceHolderItem(itemDataChangeEvent.NewIndex);
+ }
+ item.IsSelect = false;
+ _itemSlot.Update(item);
}
public override void _ExitTree()