将 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)
|
||||
Reference in New Issue
Block a user