对 DisplayItemInfoForm 按 5 层 UI 规范做结构整理

- 删除无用的 DisplayItemInfoUseCase,转为轻量 UI(Controller + Context + View)
- RawData 类型安全:object Data 拆分为 WeaponData + PropItem
- View 事件规范:回收按钮改用 UI 专用事件,由 Controller 通过回调转发
- 简化 _locked 状态管理,统一在 CloseUIAsync 中清理
This commit is contained in:
SepComet
2026-06-15 11:03:31 +08:00
parent 9dd4f57e6a
commit bba17bbac2
11 changed files with 107 additions and 173 deletions
@@ -26,7 +26,6 @@ namespace SepCore.UI
{
GameEntry.Event.Subscribe(RefreshEventArgs.EventId, Refresh);
GameEntry.Event.Subscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
GameEntry.Event.Subscribe(ShopWeaponRecycleEventArgs.EventId, WeaponRecycle);
GameEntry.Event.Subscribe(ShopContinueEventArgs.EventId, ShopContinue);
GameEntry.Event.Subscribe(DisplayItemShowEventArgs.EventId, DisplayItemShow);
}
@@ -35,7 +34,6 @@ namespace SepCore.UI
{
GameEntry.Event.Unsubscribe(RefreshEventArgs.EventId, Refresh);
GameEntry.Event.Unsubscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
GameEntry.Event.Unsubscribe(ShopWeaponRecycleEventArgs.EventId, WeaponRecycle);
GameEntry.Event.Unsubscribe(ShopContinueEventArgs.EventId, ShopContinue);
GameEntry.Event.Unsubscribe(DisplayItemShowEventArgs.EventId, DisplayItemShow);
}
@@ -379,10 +377,11 @@ namespace SepCore.UI
{
TargetPos = targetPos,
Index = index,
Data = weapon.WeaponData,
WeaponData = weapon.WeaponData,
Rarity = weapon.WeaponData.Rarity,
ItemType = ItemType.Weapon,
Price = Mathf.FloorToInt(weapon.WeaponData.Price * Context.WeaponRecycleRate),
OnRecycle = (recycleIndex, recyclePrice) => RecycleWeapon(recycleIndex, recyclePrice),
};
return true;
}
@@ -414,7 +413,7 @@ namespace SepCore.UI
{
TargetPos = targetPos,
Index = index,
Data = propItem,
PropData = propItem,
Rarity = propItem.Rarity,
ItemType = ItemType.Prop,
Price = 0
@@ -422,6 +421,30 @@ namespace SepCore.UI
return true;
}
private void RecycleWeapon(int index, int price)
{
if (_useCase == null || Context == null)
{
Log.Error("ShopFormController.RecycleWeapon() controller state is invalid.");
return;
}
bool success = _useCase.TryRecycleWeapon(index, price);
if (!success)
{
return;
}
if (Context.WeaponListContext != null)
{
int currentCount = Mathf.Max(0, Context.WeaponListContext.CurrentCount - 1);
Context.WeaponListContext.CurrentCount = currentCount;
}
Form?.RemoveWeaponDisplayItem(index);
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
}
#endregion
#region Event Handlers
@@ -519,40 +542,6 @@ namespace SepCore.UI
GameEntry.UIRouter.OpenUIAsync(UIFormType.DisplayItemInfoForm, rawData).Forget();
}
private void WeaponRecycle(object sender, GameEventArgs e)
{
if (e is not ShopWeaponRecycleEventArgs args)
{
return;
}
if (sender is not DisplayItemInfoForm)
{
return;
}
if (_useCase == null || Context == null)
{
Log.Error("ShopFormController.WeaponRecycle() controller state is invalid.");
return;
}
bool success = _useCase.TryRecycleWeapon(args.Index, args.Price);
if (!success)
{
return;
}
if (Context.WeaponListContext != null)
{
int currentCount = Mathf.Max(0, Context.WeaponListContext.CurrentCount - 1);
Context.WeaponListContext.CurrentCount = currentCount;
}
Form?.RemoveWeaponDisplayItem(args.Index);
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
}
#endregion
}
}