将 DisplayItemInfoForm 更名为 ItemTooltipForm
This commit is contained in:
+3
-7
@@ -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;
|
||||
+28
-28
@@ -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;
|
||||
}
|
||||
+8
-8
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user