Fixed an issue where the spell Editor could not remove items placed in the second time.
修复法术编辑器二次放入物品无法取出的问题。
This commit is contained in:
parent
81344faa3e
commit
bb0f582fed
|
@ -216,6 +216,15 @@ public static class Config
|
|||
/// </summary>
|
||||
public const string TimeInterval = "TimeInterval";
|
||||
}
|
||||
|
||||
public class ZIndexManager
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>Floating icon</para>
|
||||
/// <para>悬浮图标</para>
|
||||
/// </summary>
|
||||
public const int FloatingIcon = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>Item data changes the event type</para>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user