将 DisplayItemInfoForm 更名为 ItemTooltipForm

This commit is contained in:
SepComet
2026-06-15 11:23:44 +08:00
parent bba17bbac2
commit 44498e5859
27 changed files with 108 additions and 110 deletions
@@ -57,7 +57,7 @@ namespace SepCore.Definition
/// <summary>
/// 物品信息展示页
/// </summary>
DisplayItemInfoForm = 205,
ItemTooltipForm = 205,
/// <summary>
/// 虚拟摇杆。
@@ -1,27 +0,0 @@
using GameFramework;
using GameFramework.Event;
namespace SepCore.Event
{
public class DisplayItemInfoLockEventArgs : GameEventArgs
{
public static readonly int EventId = typeof(DisplayItemInfoLockEventArgs).GetHashCode();
public override int Id => EventId;
public DisplayItemInfoLockEventArgs()
{
}
public static DisplayItemInfoLockEventArgs Create()
{
var args = ReferencePool.Acquire<DisplayItemInfoLockEventArgs>();
return args;
}
public override void Clear()
{
}
}
}
@@ -3,22 +3,22 @@ using GameFramework.Event;
namespace SepCore.Event
{
public class DisplayItemInfoHideEventArgs : GameEventArgs
public class ItemTooltipHideEventArgs : GameEventArgs
{
public static readonly int EventId = typeof(DisplayItemInfoHideEventArgs).GetHashCode();
public static readonly int EventId = typeof(ItemTooltipHideEventArgs).GetHashCode();
public override int Id => EventId;
public bool Force = false;
public DisplayItemInfoHideEventArgs()
public ItemTooltipHideEventArgs()
{
Force = false;
}
public static DisplayItemInfoHideEventArgs Create(bool force = false)
public static ItemTooltipHideEventArgs Create(bool force = false)
{
var args = ReferencePool.Acquire<DisplayItemInfoHideEventArgs>();
var args = ReferencePool.Acquire<ItemTooltipHideEventArgs>();
args.Force = force;
return args;
@@ -0,0 +1,27 @@
using GameFramework;
using GameFramework.Event;
namespace SepCore.Event
{
public class ItemTooltipLockEventArgs : GameEventArgs
{
public static readonly int EventId = typeof(ItemTooltipLockEventArgs).GetHashCode();
public override int Id => EventId;
public ItemTooltipLockEventArgs()
{
}
public static ItemTooltipLockEventArgs Create()
{
var args = ReferencePool.Acquire<ItemTooltipLockEventArgs>();
return args;
}
public override void Clear()
{
}
}
}
@@ -3,24 +3,24 @@ using GameFramework.Event;
namespace SepCore.Event
{
public class DisplayItemInfoRecycleEventArgs : GameEventArgs
public class ItemTooltipRecycleEventArgs : GameEventArgs
{
public static readonly int EventId = typeof(DisplayItemInfoRecycleEventArgs).GetHashCode();
public static readonly int EventId = typeof(ItemTooltipRecycleEventArgs).GetHashCode();
public override int Id => EventId;
public int Index;
public int Price;
public DisplayItemInfoRecycleEventArgs()
public ItemTooltipRecycleEventArgs()
{
Index = -1;
Price = 0;
}
public static DisplayItemInfoRecycleEventArgs Create(int index, int price)
public static ItemTooltipRecycleEventArgs Create(int index, int price)
{
var args = ReferencePool.Acquire<DisplayItemInfoRecycleEventArgs>();
var args = ReferencePool.Acquire<ItemTooltipRecycleEventArgs>();
args.Index = index;
args.Price = price;
@@ -4,9 +4,9 @@ using UnityEngine;
namespace SepCore.Event
{
public class DisplayItemShowEventArgs : GameEventArgs
public class ItemTooltipShowEventArgs : GameEventArgs
{
public static readonly int EventId = typeof(DisplayItemShowEventArgs).GetHashCode();
public static readonly int EventId = typeof(ItemTooltipShowEventArgs).GetHashCode();
public override int Id => EventId;
@@ -16,15 +16,15 @@ namespace SepCore.Event
public Vector3 TargetPos { get; private set; }
public DisplayItemShowEventArgs()
public ItemTooltipShowEventArgs()
{
Index = -1;
IsWeapon = false;
}
public static DisplayItemShowEventArgs Create(int index, bool isWeapon, Vector3 targetPos)
public static ItemTooltipShowEventArgs Create(int index, bool isWeapon, Vector3 targetPos)
{
var args = ReferencePool.Acquire<DisplayItemShowEventArgs>();
var args = ReferencePool.Acquire<ItemTooltipShowEventArgs>();
args.Index = index;
args.IsWeapon = isWeapon;
args.TargetPos = targetPos;
@@ -38,4 +38,4 @@ namespace SepCore.Event
TargetPos = Vector3.zero;
}
}
}
}
@@ -1,14 +1,10 @@
using System;
using System.Drawing;
using SepCore.CustomUtility;
using SepCore.Entity;
using SepCore.Entity.Weapon;
using SepCore.Definition;
using UnityEngine;
namespace SepCore.UI
{
public class DisplayItemInfoContext : UIContext
public class ItemTooltipContext : UIContext
{
public int Index;
public string IconAssetName;
@@ -20,7 +16,7 @@ namespace SepCore.UI
public Vector3 TargetPos;
public bool ShowRecycleButton;
public DisplayItemInfoContext()
public ItemTooltipContext()
{
Index = -1;
IconAssetName = string.Empty;
@@ -33,7 +29,7 @@ namespace SepCore.UI
ShowRecycleButton = false;
}
public DisplayItemInfoContext(DisplayItemInfoRawData rawData)
public ItemTooltipContext(ItemTooltipRawData rawData)
{
Index = rawData.Index;
ItemType = rawData.ItemType;
@@ -8,68 +8,68 @@ using UnityGameFramework.Runtime;
namespace SepCore.UI
{
public class DisplayItemInfoController : UIControllerBase<DisplayItemInfoContext, DisplayItemInfoForm>
public class ItemTooltipController : UIControllerBase<ItemTooltipContext, ItemTooltipForm>
{
protected override UIFormType UIFormType => UIFormType.DisplayItemInfoForm;
protected override UIFormType UIFormType => UIFormType.ItemTooltipForm;
private bool _locked = false;
private Action<int, int> _onRecycle;
protected override void SubscribeCustomEvents()
{
GameEntry.Event.Subscribe(DisplayItemInfoLockEventArgs.EventId, DisplayItemInfoLock);
GameEntry.Event.Subscribe(DisplayItemInfoHideEventArgs.EventId, DisplayItemInfoHide);
GameEntry.Event.Subscribe(DisplayItemInfoRecycleEventArgs.EventId, DisplayItemInfoRecycle);
GameEntry.Event.Subscribe(ItemTooltipLockEventArgs.EventId, ItemTooltipInfoLock);
GameEntry.Event.Subscribe(ItemTooltipHideEventArgs.EventId, ItemTooltipHide);
GameEntry.Event.Subscribe(ItemTooltipRecycleEventArgs.EventId, ItemTooltipRecycle);
}
protected override void UnsubscribeCustomEvents()
{
GameEntry.Event.Unsubscribe(DisplayItemInfoLockEventArgs.EventId, DisplayItemInfoLock);
GameEntry.Event.Unsubscribe(DisplayItemInfoHideEventArgs.EventId, DisplayItemInfoHide);
GameEntry.Event.Unsubscribe(DisplayItemInfoRecycleEventArgs.EventId, DisplayItemInfoRecycle);
GameEntry.Event.Unsubscribe(ItemTooltipLockEventArgs.EventId, ItemTooltipInfoLock);
GameEntry.Event.Unsubscribe(ItemTooltipHideEventArgs.EventId, ItemTooltipHide);
GameEntry.Event.Unsubscribe(ItemTooltipRecycleEventArgs.EventId, ItemTooltipRecycle);
}
protected override void RefreshUI(DisplayItemInfoForm form, DisplayItemInfoContext context)
protected override void RefreshUI(ItemTooltipForm form, ItemTooltipContext context)
{
form.RefreshUI(context).Forget();
}
protected override void CloseLoadedFormDirect(DisplayItemInfoForm form)
protected override void CloseLoadedFormDirect(ItemTooltipForm form)
{
GameEntry.UI.CloseUIForm(form);
}
private static DisplayItemInfoContext BuildContext(DisplayItemInfoRawData rawData)
private static ItemTooltipContext BuildContext(ItemTooltipRawData rawData)
{
if (rawData == null)
{
Log.Error("DisplayItemInfoFormController.BuildContext() rawData is null.");
Log.Error("ItemTooltipController.BuildContext() rawData is null.");
return null;
}
return new DisplayItemInfoContext(rawData);
return new ItemTooltipContext(rawData);
}
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
{
if (userData is not DisplayItemInfoRawData rawData)
if (userData is not ItemTooltipRawData rawData)
{
if (userData != null)
{
Log.Warning("DisplayItemInfoController.OpenUIAsync() userData type is invalid.");
Log.Warning("ItemTooltipController.OpenUIAsync() userData type is invalid.");
}
else
{
Log.Warning("DisplayItemInfoController.OpenUIAsync() rawData is required.");
Log.Warning("ItemTooltipController.OpenUIAsync() rawData is required.");
}
return;
}
DisplayItemInfoContext context = BuildContext(rawData);
ItemTooltipContext context = BuildContext(rawData);
if (context == null)
{
Log.Warning("DisplayItemInfoController.OpenUIAsync() rawData is invalid.");
Log.Warning("ItemTooltipController.OpenUIAsync() rawData is invalid.");
return;
}
@@ -88,15 +88,15 @@ namespace SepCore.UI
{
if (useCase != null)
{
Log.Warning("DisplayItemInfoController does not use a use case.");
Log.Warning("ItemTooltipController does not use a use case.");
}
}
private bool IsCurrentFormSender(object sender)
{
if (sender is DisplayItemInfoForm displayItemInfoForm)
if (sender is ItemTooltipForm ItemTooltipForm)
{
return displayItemInfoForm == Form;
return ItemTooltipForm == Form;
}
if (sender is Component component && Form != null)
@@ -109,9 +109,9 @@ namespace SepCore.UI
#region Event Handlers
private void DisplayItemInfoLock(object sender, GameEventArgs e)
private void ItemTooltipInfoLock(object sender, GameEventArgs e)
{
if (e is not DisplayItemInfoLockEventArgs)
if (e is not ItemTooltipLockEventArgs)
{
return;
}
@@ -119,21 +119,21 @@ namespace SepCore.UI
_locked = true;
}
private void DisplayItemInfoHide(object sender, GameEventArgs e)
private void ItemTooltipHide(object sender, GameEventArgs e)
{
if (e is not DisplayItemInfoHideEventArgs args)
if (e is not ItemTooltipHideEventArgs args)
{
return;
}
if (_locked && !args.Force) return;
GameEntry.UIRouter.CloseUIAsync(UIFormType.DisplayItemInfoForm).Forget();
GameEntry.UIRouter.CloseUIAsync(UIFormType.ItemTooltipForm).Forget();
}
private void DisplayItemInfoRecycle(object sender, GameEventArgs e)
private void ItemTooltipRecycle(object sender, GameEventArgs e)
{
if (e is not DisplayItemInfoRecycleEventArgs args)
if (e is not ItemTooltipRecycleEventArgs args)
{
return;
}
@@ -7,7 +7,7 @@ using UnityGameFramework.Runtime;
namespace SepCore.UI
{
public class DisplayItemInfoForm : UGuiForm
public class ItemTooltipForm : UGuiForm
{
[SerializeField] private RectTransform _content;
@@ -33,15 +33,15 @@ namespace SepCore.UI
[SerializeField] private float _screenEdgePadding = 0f;
private DisplayItemInfoContext _context;
private ItemTooltipContext _context;
private Vector3 _targetPos;
public async UniTaskVoid RefreshUI(DisplayItemInfoContext context)
public async UniTaskVoid RefreshUI(ItemTooltipContext context)
{
if (context == null)
{
Log.Warning("DisplayItemInfoForm context is invalid.");
Log.Warning("ItemTooltipForm context is invalid.");
return;
}
@@ -85,9 +85,9 @@ namespace SepCore.UI
{
base.OnOpen(userData);
if (!(userData is DisplayItemInfoContext context))
if (!(userData is ItemTooltipContext context))
{
Log.Error("DisplayItemInfoFormContext is invalid.");
Log.Error("ItemTooltipForm context is invalid.");
return;
}
@@ -192,12 +192,12 @@ namespace SepCore.UI
public void OnRecycleButtonClick()
{
if (_context == null) return;
GameEntry.Event.Fire(this, DisplayItemInfoRecycleEventArgs.Create(_context.Index, _context.Price));
GameEntry.Event.Fire(this, ItemTooltipRecycleEventArgs.Create(_context.Index, _context.Price));
}
public void OnCancelButtonClick()
{
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
GameEntry.Event.Fire(this, ItemTooltipHideEventArgs.Create(true));
}
private string BuildTypeText(ItemType type)
@@ -27,7 +27,7 @@ namespace SepCore.UI
GameEntry.Event.Subscribe(RefreshEventArgs.EventId, Refresh);
GameEntry.Event.Subscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
GameEntry.Event.Subscribe(ShopContinueEventArgs.EventId, ShopContinue);
GameEntry.Event.Subscribe(DisplayItemShowEventArgs.EventId, DisplayItemShow);
GameEntry.Event.Subscribe(ItemTooltipShowEventArgs.EventId, DisplayItemShow);
}
protected override void UnsubscribeCustomEvents()
@@ -35,7 +35,7 @@ namespace SepCore.UI
GameEntry.Event.Unsubscribe(RefreshEventArgs.EventId, Refresh);
GameEntry.Event.Unsubscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
GameEntry.Event.Unsubscribe(ShopContinueEventArgs.EventId, ShopContinue);
GameEntry.Event.Unsubscribe(DisplayItemShowEventArgs.EventId, DisplayItemShow);
GameEntry.Event.Unsubscribe(ItemTooltipShowEventArgs.EventId, DisplayItemShow);
}
#region BuildContext
@@ -205,7 +205,7 @@ namespace SepCore.UI
public override async UniTask CloseUIAsync(object userData = null, float timeout = 30f)
{
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
GameEntry.Event.Fire(this, ItemTooltipHideEventArgs.Create(true));
_rawData = null;
await base.CloseUIAsync(userData, timeout);
}
@@ -344,7 +344,7 @@ namespace SepCore.UI
return false;
}
private bool TryGetWeaponInfoRawData(int index, Vector3 targetPos, out DisplayItemInfoRawData rawData)
private bool TryGetWeaponInfoRawData(int index, Vector3 targetPos, out ItemTooltipRawData rawData)
{
rawData = null;
@@ -373,7 +373,7 @@ namespace SepCore.UI
return false;
}
rawData = new DisplayItemInfoRawData
rawData = new ItemTooltipRawData
{
TargetPos = targetPos,
Index = index,
@@ -386,7 +386,7 @@ namespace SepCore.UI
return true;
}
private bool TryGetPropInfoRawData(int index, Vector3 targetPos, out DisplayItemInfoRawData rawData)
private bool TryGetPropInfoRawData(int index, Vector3 targetPos, out ItemTooltipRawData rawData)
{
rawData = null;
@@ -409,7 +409,7 @@ namespace SepCore.UI
return false;
}
rawData = new DisplayItemInfoRawData
rawData = new ItemTooltipRawData
{
TargetPos = targetPos,
Index = index,
@@ -442,7 +442,7 @@ namespace SepCore.UI
}
Form?.RemoveWeaponDisplayItem(index);
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
GameEntry.Event.Fire(this, ItemTooltipHideEventArgs.Create(true));
}
#endregion
@@ -513,7 +513,7 @@ namespace SepCore.UI
private void DisplayItemShow(object sender, GameEventArgs e)
{
if (e is not DisplayItemShowEventArgs args)
if (e is not ItemTooltipShowEventArgs args)
{
return;
}
@@ -529,7 +529,7 @@ namespace SepCore.UI
return;
}
DisplayItemInfoRawData rawData;
ItemTooltipRawData rawData;
bool success = args.IsWeapon
? TryGetWeaponInfoRawData(args.Index, args.TargetPos, out rawData)
: TryGetPropInfoRawData(args.Index, args.TargetPos, out rawData);
@@ -539,7 +539,7 @@ namespace SepCore.UI
return;
}
GameEntry.UIRouter.OpenUIAsync(UIFormType.DisplayItemInfoForm, rawData).Forget();
GameEntry.UIRouter.OpenUIAsync(UIFormType.ItemTooltipForm, rawData).Forget();
}
#endregion
@@ -56,17 +56,17 @@ namespace SepCore.UI
rect.yMax,
0f)
);
GameEntry.Event.Fire(this, DisplayItemShowEventArgs.Create(_index, _context.IsWeapon, targetPos));
GameEntry.Event.Fire(this, ItemTooltipShowEventArgs.Create(_index, _context.IsWeapon, targetPos));
}
public void OnItemInfoLock()
{
GameEntry.Event.Fire(this, DisplayItemInfoLockEventArgs.Create());
GameEntry.Event.Fire(this, ItemTooltipLockEventArgs.Create());
}
public void OnItemInfoHide()
{
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create());
GameEntry.Event.Fire(this, ItemTooltipHideEventArgs.Create());
}
}
}
@@ -1,7 +1,6 @@
using System;
using SepCore.Definition;
using SepCore.Entity;
using SepCore.Entity.Weapon;
using UnityEngine;
namespace SepCore.UI
@@ -13,7 +12,7 @@ namespace SepCore.UI
Prop
}
public class DisplayItemInfoRawData
public class ItemTooltipRawData
{
public int Index;
public WeaponData WeaponData;