diff --git a/scenes/mainMenu.tscn b/scenes/mainMenu.tscn
index 55186b5..3fdf717 100644
--- a/scenes/mainMenu.tscn
+++ b/scenes/mainMenu.tscn
@@ -35,6 +35,7 @@ offset_top = 215.0
offset_right = 50.5
offset_bottom = 248.0
grow_horizontal = 2
+disabled = true
text = "ui_settings"
[node name="levelGraphEditorButton" type="Button" parent="."]
diff --git a/scripts/inventory/IItemContainer.cs b/scripts/inventory/IItemContainer.cs
index 732294a..9e2f55c 100644
--- a/scripts/inventory/IItemContainer.cs
+++ b/scripts/inventory/IItemContainer.cs
@@ -120,8 +120,11 @@ public interface IItemContainer
/// 清理物品
///
///
- ///
- bool ClearItem(int index);
+ ///
+ ///Returns the item to be cleaned, or null if the item to be cleaned cannot be found
+ ///返回要清理的物品,如果找不到要清理的物品则返回null
+ ///
+ IItem? ClearItem(int index);
///
/// ClearAllItems
diff --git a/scripts/inventory/UniversalItemContainer.cs b/scripts/inventory/UniversalItemContainer.cs
index 7f0f49a..019928b 100644
--- a/scripts/inventory/UniversalItemContainer.cs
+++ b/scripts/inventory/UniversalItemContainer.cs
@@ -304,43 +304,49 @@ public class UniversalItemContainer(int totalCapacity) : IItemContainer
}
- public bool ClearItem(int index)
+ public IItem? ClearItem(int index)
{
if (!_itemDictionary.TryGetValue(index, out var item))
{
- return false;
+ return null;
}
- var result = _itemDictionary.Remove(index);
- if (result)
+ if (!_itemDictionary.Remove(index))
{
- ItemDataChangeEvent?.Invoke(new ItemDataChangeEvent
+ return null;
+ }
+ ItemDataChangeEvent?.Invoke(new ItemDataChangeEvent
+ {
+ NewItem = null,
+ NewIndex = index,
+ OldIndex = index,
+ OldItem = null,
+ Type = Config.ItemDataChangeEventType.Clear
+ });
+ if (SupportSelect && index == _selectIndex)
+ {
+ item.HideSelf();
+ SelectedItemChangeEvent?.Invoke(new SelectedItemChangeEvent
{
- NewItem = null,
NewIndex = index,
OldIndex = index,
- OldItem = null,
- Type = Config.ItemDataChangeEventType.Clear
+ NewItem = null,
+ OldItem = null
});
- if (SupportSelect && index == _selectIndex)
- {
- item.HideSelf();
- SelectedItemChangeEvent?.Invoke(new SelectedItemChangeEvent
- {
- NewIndex = index,
- OldIndex = index,
- NewItem = null,
- OldItem = null
- });
- }
}
- return result;
+ return item;
}
public void ClearAllItems()
{
foreach (var itemDictionaryKey in _itemDictionary.Keys)
{
- ClearItem(itemDictionaryKey);
+ var item = ClearItem(itemDictionaryKey);
+ if (item == null)
+ {
+ continue;
+ }
+ item.SelfItemContainer?.ClearAllItems();
+ item.QueueFreeSelf();
}
}