Tooltip - events
This commit is contained in:
parent
48832ab428
commit
815c5de830
@ -33,6 +33,8 @@ public abstract class DraggablePanelController : PanelController<IndexValuePair<
|
|||||||
slot.OnDragEvent += Drag;
|
slot.OnDragEvent += Drag;
|
||||||
slot.OnDropEvent += Drop;
|
slot.OnDropEvent += Drop;
|
||||||
slot.OnPointerClickEvent += MouseClick;
|
slot.OnPointerClickEvent += MouseClick;
|
||||||
|
slot.OnPointerEnterEvent += MouseEnter;
|
||||||
|
slot.OnPointerExitEvent += MouseExit;
|
||||||
|
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
@ -143,6 +145,15 @@ public abstract class DraggablePanelController : PanelController<IndexValuePair<
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region toolpit
|
||||||
|
public virtual void MouseEnter(ItemSlot itemSlot, PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (itemSlot.Item == null)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void MouseExit(ItemSlot itemSlot, PointerEventData eventData) { }
|
||||||
|
#endregion
|
||||||
|
|
||||||
public ISlot GetDraggedSlot()
|
public ISlot GetDraggedSlot()
|
||||||
{
|
{
|
||||||
|
@ -94,10 +94,29 @@ public class InventoryPanelController : WarehousePanelController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region mouse actions
|
||||||
public override void SingleLeftMouseClick(ItemSlot itemSlot)
|
public override void SingleLeftMouseClick(ItemSlot itemSlot)
|
||||||
{
|
{
|
||||||
// mark item as selected in shop panel
|
// mark item as selected in shop panel
|
||||||
if (ShopContentUIManager.Instance.DynamicPanel)
|
if (ShopContentUIManager.Instance.DynamicPanel)
|
||||||
ShopContentUIManager.Instance.DynamicPanel.transform.Find("ItemDetails").GetComponent<ShopItemCardKeeper>().ShowItemDetails(itemSlot, ShopItemCardMode.Sell);
|
ShopContentUIManager.Instance.DynamicPanel.transform.Find("ItemDetails").GetComponent<ShopItemCardKeeper>().ShowItemDetails(itemSlot, ShopItemCardMode.Sell);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region tooltip
|
||||||
|
public override void MouseEnter(ItemSlot itemSlot, PointerEventData eventData)
|
||||||
|
{
|
||||||
|
// check if there is item on slot else retrun null breaking function
|
||||||
|
base.MouseEnter(itemSlot, eventData);
|
||||||
|
|
||||||
|
// todo open tooltip panel with item data
|
||||||
|
// Tooltip.OpenPanel(itemSlot. Item); - instantiate tooltip panel object
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void MouseExit(ItemSlot itemSlot, PointerEventData eventData)
|
||||||
|
{
|
||||||
|
// Tooltip.CloePanel(); - destroy gameobject if panel is opened
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ public interface ISlot
|
|||||||
event Action<ItemSlot> OnDragEvent;
|
event Action<ItemSlot> OnDragEvent;
|
||||||
event Action<ItemSlot> OnDropEvent;
|
event Action<ItemSlot> OnDropEvent;
|
||||||
event Action<ItemSlot, PointerEventData> OnPointerClickEvent;
|
event Action<ItemSlot, PointerEventData> OnPointerClickEvent;
|
||||||
|
event Action<ItemSlot, PointerEventData> OnPointerEnterEvent;
|
||||||
|
event Action<ItemSlot, PointerEventData> OnPointerExitEvent;
|
||||||
//(B)Islot // as B
|
//(B)Islot // as B
|
||||||
|
|
||||||
public void SetupSlot(int _number, EquippableItem _item, WarehousePanelController _PanelController);
|
public void SetupSlot(int _number, EquippableItem _item, WarehousePanelController _PanelController);
|
||||||
|
@ -6,7 +6,15 @@ using UnityEngine.UI;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using System; // for Action type
|
using System; // for Action type
|
||||||
|
|
||||||
public class ItemSlot : MonoBehaviour, ISlot, IBeginDragHandler, IEndDragHandler, IDragHandler, IDropHandler, IPointerClickHandler
|
public class ItemSlot : MonoBehaviour,
|
||||||
|
ISlot,
|
||||||
|
IBeginDragHandler,
|
||||||
|
IEndDragHandler,
|
||||||
|
IDragHandler,
|
||||||
|
IDropHandler,
|
||||||
|
IPointerClickHandler,
|
||||||
|
IPointerEnterHandler,
|
||||||
|
IPointerExitHandler
|
||||||
{
|
{
|
||||||
[Header("UI Stuff to change")]
|
[Header("UI Stuff to change")]
|
||||||
[SerializeField] private TextMeshProUGUI slotItemNumberText;
|
[SerializeField] private TextMeshProUGUI slotItemNumberText;
|
||||||
@ -48,6 +56,8 @@ public class ItemSlot : MonoBehaviour, ISlot, IBeginDragHandler, IEndDragHandler
|
|||||||
public event Action<ItemSlot> OnDragEvent;
|
public event Action<ItemSlot> OnDragEvent;
|
||||||
public event Action<ItemSlot> OnDropEvent;
|
public event Action<ItemSlot> OnDropEvent;
|
||||||
public event Action<ItemSlot, PointerEventData> OnPointerClickEvent;
|
public event Action<ItemSlot, PointerEventData> OnPointerClickEvent;
|
||||||
|
public event Action<ItemSlot, PointerEventData> OnPointerEnterEvent;
|
||||||
|
public event Action<ItemSlot, PointerEventData> OnPointerExitEvent;
|
||||||
|
|
||||||
/* public ItemSlot() { }
|
/* public ItemSlot() { }
|
||||||
public ItemSlot(int number, EquippableItem item = null)
|
public ItemSlot(int number, EquippableItem item = null)
|
||||||
@ -161,5 +171,17 @@ public class ItemSlot : MonoBehaviour, ISlot, IBeginDragHandler, IEndDragHandler
|
|||||||
if (OnPointerClickEvent != null)
|
if (OnPointerClickEvent != null)
|
||||||
OnPointerClickEvent(this, eventData);
|
OnPointerClickEvent(this, eventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnPointerEnter(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (OnPointerEnterEvent != null)
|
||||||
|
OnPointerEnterEvent(this, eventData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPointerExit(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (OnPointerExitEvent != null)
|
||||||
|
OnPointerExitEvent(this, eventData);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user