继续重构调整(UI)
- 引入 UniTask 和异步版本的 UIModule - 调整 Runtime/UIBase 和 Presentation 下的脚本命名空间到 SepCore.UI - 将原来的 5 层 UI 迁移到异步实现 - 规范各层的 UI 脚本命名
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DisplayItemContext : UIContext
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DisplayListAreaContext : UIContext
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class GoodsItemContext : UIContext
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class LevelUpRewardItemContext : UIContext
|
||||
{
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DisplayItemInfoFormContext : UIContext
|
||||
public class DisplayItemInfoContext : UIContext
|
||||
{
|
||||
public int Index;
|
||||
public string IconAssetName;
|
||||
@@ -15,4 +15,4 @@ namespace UI
|
||||
public bool IsWeapon;
|
||||
public Vector3 TargetPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
-47
@@ -1,15 +1,15 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Event;
|
||||
using SepCore.Definition;
|
||||
using GameFramework.Event;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DisplayItemInfoFormController : UIFormControllerCommonBase<
|
||||
DisplayItemInfoFormContext, DisplayItemInfoForm>
|
||||
public class DisplayItemInfoController : UIControllerBase<DisplayItemInfoContext, DisplayItemInfoForm>
|
||||
{
|
||||
protected override UIFormType UIFormTypeId => UIFormType.DisplayItemInfoForm;
|
||||
protected override UIFormType UIFormType => UIFormType.DisplayItemInfoForm;
|
||||
|
||||
private bool _locked = false;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace UI
|
||||
GameEntry.Event.Unsubscribe(DisplayItemInfoHideEventArgs.EventId, DisplayItemInfoHide);
|
||||
}
|
||||
|
||||
protected override void RefreshUI(DisplayItemInfoForm form, DisplayItemInfoFormContext context)
|
||||
protected override void RefreshUI(DisplayItemInfoForm form, DisplayItemInfoContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace UI
|
||||
GameEntry.UI.CloseUIForm(form);
|
||||
}
|
||||
|
||||
private static DisplayItemInfoFormContext BuildContext(DisplayItemInfoFormRawData rawData)
|
||||
private static DisplayItemInfoContext BuildContext(DisplayItemInfoRawData rawData)
|
||||
{
|
||||
if (rawData == null)
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace UI
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DisplayItemInfoFormContext
|
||||
return new DisplayItemInfoContext
|
||||
{
|
||||
Index = rawData.Index,
|
||||
IconAssetName = rawData.IconAssetName,
|
||||
@@ -57,38 +57,42 @@ namespace UI
|
||||
};
|
||||
}
|
||||
|
||||
public int? OpenUI(DisplayItemInfoFormRawData rawData)
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
_locked = false;
|
||||
DisplayItemInfoFormContext context = BuildContext(rawData);
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
_locked = false;
|
||||
if (userData is DisplayItemInfoFormContext context)
|
||||
if (userData is not DisplayItemInfoRawData rawData)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("DisplayItemInfoController.OpenUIAsync() userData type is invalid.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning("DisplayItemInfoController.OpenUIAsync() rawData is required.");
|
||||
}
|
||||
|
||||
if (userData is DisplayItemInfoFormRawData rawData)
|
||||
{
|
||||
return OpenUI(rawData);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("DisplayItemInfoFormController.OpenUI() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return OpenUIInternal(Context);
|
||||
DisplayItemInfoContext context = BuildContext(rawData);
|
||||
if (context == null)
|
||||
{
|
||||
Log.Warning("DisplayItemInfoController.OpenUIAsync() rawData is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
_locked = false;
|
||||
return await OpenFormAsync(context, timeout);
|
||||
}
|
||||
|
||||
public override async UniTask CloseUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
_locked = false;
|
||||
await base.CloseUIAsync(userData, timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (!(useCase is DisplayItemInfoFormUseCase))
|
||||
if (useCase is not DisplayItemInfoUseCase)
|
||||
{
|
||||
Log.Error("DisplayItemInfoForm.BindUseCase() useCase is invalid.");
|
||||
}
|
||||
@@ -113,43 +117,31 @@ namespace UI
|
||||
|
||||
private void DisplayItemInfoLock(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is DisplayItemInfoLockEventArgs))
|
||||
if (e is not DisplayItemInfoLockEventArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Context == null)
|
||||
{
|
||||
Log.Error("DisplayItemInfoFormController.DisplayItemInfoLock() Context is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Form == null)
|
||||
{
|
||||
Log.Error("DisplayItemInfoFormController.DisplayItemInfoLock() Form is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
_locked = true;
|
||||
}
|
||||
|
||||
private void DisplayItemInfoHide(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is DisplayItemInfoHideEventArgs args))
|
||||
if (e is not DisplayItemInfoHideEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (args.Force)
|
||||
{
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.DisplayItemInfoForm);
|
||||
GameEntry.UIRouter.CloseUIAsync(UIFormType.DisplayItemInfoForm).Forget();
|
||||
_locked = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_locked && !args.Force) return;
|
||||
|
||||
GameEntry.UIRouter.CloseUI(UIFormType.DisplayItemInfoForm);
|
||||
|
||||
GameEntry.UIRouter.CloseUIAsync(UIFormType.DisplayItemInfoForm).Forget();
|
||||
_locked = false;
|
||||
}
|
||||
|
||||
+4
-4
@@ -3,7 +3,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DisplayItemInfoForm : UGuiForm
|
||||
{
|
||||
@@ -31,10 +31,10 @@ namespace UI
|
||||
|
||||
[SerializeField] private float _screenEdgePadding = 0f;
|
||||
|
||||
private DisplayItemInfoFormContext _context;
|
||||
private DisplayItemInfoContext _context;
|
||||
private Vector3 _targetPos;
|
||||
|
||||
public void RefreshUI(DisplayItemInfoFormContext context)
|
||||
public void RefreshUI(DisplayItemInfoContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ namespace UI
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (!(userData is DisplayItemInfoFormContext context))
|
||||
if (!(userData is DisplayItemInfoContext context))
|
||||
{
|
||||
Log.Error("DisplayItemInfoFormContext is invalid.");
|
||||
return;
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class HudContext : UIContext
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Definition;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class HudController : UIControllerBase<HudContext, HudForm>
|
||||
{
|
||||
protected override UIFormType UIFormType => UIFormType.HudForm;
|
||||
|
||||
protected override void RefreshUI(HudForm form, HudContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
private static HudContext BuildHudContext()
|
||||
{
|
||||
return new HudContext();
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("HudController.OpenUIAsync() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return await OpenFormAsync(BuildHudContext(), timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
Log.Info("HudFormController doesn't need UseCase");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -5,7 +5,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class HudForm : UGuiForm
|
||||
{
|
||||
@@ -36,7 +36,7 @@ namespace UI
|
||||
[SerializeField] private TMP_Text _enemyCountText;
|
||||
private EnemyManagerComponent _enemy;
|
||||
|
||||
public void RefreshUI(HudFormContext hudFormContext)
|
||||
public void RefreshUI(HudContext hudContext)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class HudFormContext : UIContext
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
using SepCore.Definition;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class HudFormController : UIFormControllerCommonBase<HudFormContext, HudForm>
|
||||
{
|
||||
protected override UIFormType UIFormTypeId => UIFormType.HudForm;
|
||||
|
||||
protected override void RefreshUI(HudForm form, HudFormContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
private static HudFormContext BuildHudFormContext()
|
||||
{
|
||||
return new HudFormContext();
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
if (userData is HudFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("HudFormController.OpenUI() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return OpenUIInternal(BuildHudFormContext());
|
||||
}
|
||||
|
||||
public int? OpenUI(HudFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
Log.Info("HudFormController doesn't need UseCase");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class LevelUpFormContext : UIContext
|
||||
public class LevelUpContext : UIContext
|
||||
{
|
||||
public List<LevelUpRewardItemContext> Props;
|
||||
public int RefreshPrice;
|
||||
+33
-37
@@ -1,19 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Event;
|
||||
using SepCore.Definition;
|
||||
using CustomUtility;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class LevelUpFormController : UIFormControllerCommonBase<LevelUpFormContext, LevelUpForm>
|
||||
public class LevelUpController : UIControllerBase<LevelUpContext, LevelUpForm>
|
||||
{
|
||||
private LevelUpFormUseCase _useCase;
|
||||
private LevelUpUseCase _useCase;
|
||||
|
||||
protected override UIFormType UIFormTypeId => UIFormType.LevelUpForm;
|
||||
protected override UIFormType UIFormType => UIFormType.LevelUpForm;
|
||||
|
||||
protected override void RefreshUI(LevelUpForm form, LevelUpFormContext context)
|
||||
protected override void RefreshUI(LevelUpForm form, LevelUpContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
@@ -30,7 +31,7 @@ namespace UI
|
||||
GameEntry.Event.Unsubscribe(LevelUpPropSelectedEventArgs.EventId, OnLevelUpPropSelected);
|
||||
}
|
||||
|
||||
private static LevelUpFormContext BuildContext(LevelUpFormRawData rawData)
|
||||
private static LevelUpContext BuildContext(LevelUpRawData rawData)
|
||||
{
|
||||
if (rawData == null)
|
||||
{
|
||||
@@ -62,50 +63,45 @@ namespace UI
|
||||
});
|
||||
}
|
||||
|
||||
return new LevelUpFormContext
|
||||
return new LevelUpContext
|
||||
{
|
||||
RefreshPrice = rawData.RefreshPrice,
|
||||
Props = props
|
||||
};
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData is LevelUpFormContext context)
|
||||
if (userData is LevelUpRawData rawData)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData is LevelUpFormRawData rawDataFromUserData)
|
||||
{
|
||||
return OpenUI(rawDataFromUserData);
|
||||
return await OpenUIAsync(rawData, timeout);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("LevelUpFormController.OpenUI() userData type is invalid.");
|
||||
Log.Warning("LevelUpController.OpenUIAsync() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("LevelUpFormController.OpenUI() useCase is null.");
|
||||
Log.Error("LevelUpController.OpenUIAsync() useCase is null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
LevelUpFormRawData rawData = _useCase.CreateInitialModel();
|
||||
return OpenUI(rawData);
|
||||
LevelUpRawData initialRawData = _useCase.CreateInitialModel();
|
||||
return await OpenUIAsync(initialRawData, timeout);
|
||||
}
|
||||
|
||||
public int? OpenUI(LevelUpFormRawData rawData)
|
||||
public async UniTask<int?> OpenUIAsync(LevelUpRawData rawData, float timeout = 30f)
|
||||
{
|
||||
LevelUpFormContext context = BuildContext(rawData);
|
||||
return OpenUIInternal(context);
|
||||
LevelUpContext context = BuildContext(rawData);
|
||||
return await OpenFormAsync(context, timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (!(useCase is LevelUpFormUseCase levelUpFormUseCase))
|
||||
if (useCase is not LevelUpUseCase levelUpFormUseCase)
|
||||
{
|
||||
Log.Error("LevelUpForm.BindUseCase() useCase is invalid.");
|
||||
return;
|
||||
@@ -114,68 +110,68 @@ namespace UI
|
||||
_useCase = levelUpFormUseCase;
|
||||
}
|
||||
|
||||
private void SelectReward(int selectedIndex)
|
||||
private async UniTask SelectRewardAsync(int selectedIndex)
|
||||
{
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("LevelUpFormController.OpenUI() useCase is null.");
|
||||
Log.Error("LevelUpFormController.SelectRewardAsync() useCase is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
LevelUpFormRawData rawData = _useCase.SelectReward(selectedIndex);
|
||||
LevelUpRawData rawData = _useCase.SelectReward(selectedIndex);
|
||||
if (rawData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OpenUI(rawData);
|
||||
await OpenUIAsync(rawData);
|
||||
}
|
||||
|
||||
private void RefreshRewardList(int refreshCost)
|
||||
private async UniTask RefreshRewardListAsync(int refreshCost)
|
||||
{
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("LevelUpFormController.OpenUI() useCase is null.");
|
||||
Log.Error("LevelUpFormController.RefreshRewardListAsync() useCase is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
LevelUpFormRawData rawData = _useCase.TryRefresh(refreshCost);
|
||||
LevelUpRawData rawData = _useCase.TryRefresh(refreshCost);
|
||||
if (rawData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OpenUI(rawData);
|
||||
await OpenUIAsync(rawData);
|
||||
}
|
||||
|
||||
private void OnRefresh(object sender, GameEventArgs e)
|
||||
{
|
||||
if ((LevelUpForm)sender != Form)
|
||||
if (sender is not LevelUpForm levelUpForm || levelUpForm != Form)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e is RefreshEventArgs args))
|
||||
if (e is not RefreshEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RefreshRewardList(args.Cost);
|
||||
RefreshRewardListAsync(args.Cost).Forget();
|
||||
}
|
||||
|
||||
private void OnLevelUpPropSelected(object sender, GameEventArgs e)
|
||||
{
|
||||
if ((LevelUpForm)sender != Form)
|
||||
if (sender is not LevelUpForm levelUpForm || levelUpForm != Form)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e is LevelUpPropSelectedEventArgs args))
|
||||
if (e is not LevelUpPropSelectedEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SelectReward(args.SelectedId);
|
||||
SelectRewardAsync(args.SelectedId).Forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -3,7 +3,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class LevelUpForm : UGuiForm
|
||||
{
|
||||
@@ -11,9 +11,9 @@ namespace UI
|
||||
|
||||
[SerializeField] private TMP_Text _refreshButtonText;
|
||||
|
||||
private LevelUpFormContext _context;
|
||||
private LevelUpContext _context;
|
||||
|
||||
public void RefreshUI(LevelUpFormContext context)
|
||||
public void RefreshUI(LevelUpContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace UI
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (userData is LevelUpFormContext context)
|
||||
if (userData is LevelUpContext context)
|
||||
{
|
||||
RefreshUI(context);
|
||||
return;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class ShopFormContext : UIContext
|
||||
public class ShopContext : UIContext
|
||||
{
|
||||
public int CurrentLevel;
|
||||
public int RefreshPrice;
|
||||
+38
-41
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Event;
|
||||
using SepCore.Definition;
|
||||
using CustomUtility;
|
||||
@@ -7,16 +8,16 @@ using GameFramework.Event;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class ShopFormController : UIFormControllerCommonBase<ShopFormContext, ShopForm>
|
||||
public class ShopController : UIControllerBase<ShopContext, ShopForm>
|
||||
{
|
||||
private ShopFormUseCase _useCase;
|
||||
private ShopFormRawData _rawData;
|
||||
private ShopUseCase _useCase;
|
||||
private ShopRawData _rawData;
|
||||
|
||||
protected override UIFormType UIFormTypeId => UIFormType.ShopForm;
|
||||
protected override UIFormType UIFormType => UIFormType.ShopForm;
|
||||
|
||||
protected override void RefreshUI(ShopForm form, ShopFormContext context)
|
||||
protected override void RefreshUI(ShopForm form, ShopContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
@@ -41,7 +42,7 @@ namespace UI
|
||||
|
||||
#region BuildContext
|
||||
|
||||
private ShopFormContext BuildContext(ShopFormRawData rawData)
|
||||
private ShopContext BuildContext(ShopRawData rawData)
|
||||
{
|
||||
if (rawData == null)
|
||||
{
|
||||
@@ -57,7 +58,7 @@ namespace UI
|
||||
goodsItems.Add(new GoodsItemContext(item));
|
||||
}
|
||||
|
||||
return new ShopFormContext
|
||||
return new ShopContext
|
||||
{
|
||||
CurrentLevel = rawData.CurrentLevel,
|
||||
RefreshPrice = rawData.RefreshPrice,
|
||||
@@ -204,51 +205,47 @@ namespace UI
|
||||
|
||||
#region UI Methods
|
||||
|
||||
public override void CloseUI()
|
||||
public override async UniTask CloseUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
base.CloseUI();
|
||||
GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
|
||||
_rawData = null;
|
||||
await base.CloseUIAsync(userData, timeout);
|
||||
}
|
||||
|
||||
public int? OpenUI(ShopFormRawData rawData)
|
||||
public async UniTask<int?> OpenUIAsync(ShopRawData rawData, float timeout = 30f)
|
||||
{
|
||||
ShopFormContext context = BuildContext(rawData);
|
||||
return OpenUIInternal(context);
|
||||
ShopContext context = BuildContext(rawData);
|
||||
return await OpenFormAsync(context, timeout);
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData is ShopFormContext context)
|
||||
if (userData is ShopRawData rawData)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData is ShopFormRawData rawDataFromUserData)
|
||||
{
|
||||
return OpenUI(rawDataFromUserData);
|
||||
return await OpenUIAsync(rawData, timeout);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("ShopFormController.OpenUI() userData type is invalid.");
|
||||
Log.Warning("ShopController.OpenUIAsync() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("ShopForm.OpenUI():: useCase is null.");
|
||||
Log.Error("ShopController.OpenUIAsync() useCase is null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
ShopFormRawData rawData = _useCase.CreateInitialModel();
|
||||
return OpenUI(rawData);
|
||||
ShopRawData initialRawData = _useCase.CreateInitialModel();
|
||||
return await OpenUIAsync(initialRawData, timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (!(useCase is ShopFormUseCase shopFormUseCase))
|
||||
if (useCase is not ShopUseCase shopFormUseCase)
|
||||
{
|
||||
Log.Error("LevelUpForm.BindUseCase() useCase is invalid.");
|
||||
Log.Error("ShopForm.BindUseCase() useCase is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -348,7 +345,7 @@ namespace UI
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool TryGetWeaponInfoRawData(int index, Vector3 targetPos, out DisplayItemInfoFormRawData rawData)
|
||||
private bool TryGetWeaponInfoRawData(int index, Vector3 targetPos, out DisplayItemInfoRawData rawData)
|
||||
{
|
||||
rawData = null;
|
||||
|
||||
@@ -378,7 +375,7 @@ namespace UI
|
||||
}
|
||||
|
||||
var weaponData = weapon.WeaponData;
|
||||
rawData = new DisplayItemInfoFormRawData
|
||||
rawData = new DisplayItemInfoRawData
|
||||
{
|
||||
TargetPos = targetPos,
|
||||
Index = index,
|
||||
@@ -393,7 +390,7 @@ namespace UI
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryGetPropInfoRawData(int index, Vector3 targetPos, out DisplayItemInfoFormRawData rawData)
|
||||
private bool TryGetPropInfoRawData(int index, Vector3 targetPos, out DisplayItemInfoRawData rawData)
|
||||
{
|
||||
rawData = null;
|
||||
|
||||
@@ -416,7 +413,7 @@ namespace UI
|
||||
return false;
|
||||
}
|
||||
|
||||
rawData = new DisplayItemInfoFormRawData
|
||||
rawData = new DisplayItemInfoRawData
|
||||
{
|
||||
TargetPos = targetPos,
|
||||
Index = index,
|
||||
@@ -437,12 +434,12 @@ namespace UI
|
||||
|
||||
private void Refresh(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is ShopForm))
|
||||
if (sender is not ShopForm)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e is RefreshEventArgs args))
|
||||
if (e is not RefreshEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -458,12 +455,12 @@ namespace UI
|
||||
|
||||
private void ShopPurchase(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is ShopForm))
|
||||
if (sender is not ShopForm)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e is ShopPurchaseEventArgs args))
|
||||
if (e is not ShopPurchaseEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -479,12 +476,12 @@ namespace UI
|
||||
|
||||
private void ShopContinue(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is ShopForm))
|
||||
if (sender is not ShopForm)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(e is ShopContinueEventArgs))
|
||||
if (e is not ShopContinueEventArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -494,7 +491,7 @@ namespace UI
|
||||
|
||||
private void DisplayItemShow(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is DisplayItemShowEventArgs args))
|
||||
if (e is not DisplayItemShowEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -510,7 +507,7 @@ namespace UI
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayItemInfoFormRawData rawData;
|
||||
DisplayItemInfoRawData rawData;
|
||||
bool success = args.IsWeapon
|
||||
? TryGetWeaponInfoRawData(args.Index, args.TargetPos, out rawData)
|
||||
: TryGetPropInfoRawData(args.Index, args.TargetPos, out rawData);
|
||||
@@ -520,12 +517,12 @@ namespace UI
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.DisplayItemInfoForm, rawData);
|
||||
GameEntry.UIRouter.OpenUIAsync(UIFormType.DisplayItemInfoForm, rawData).Forget();
|
||||
}
|
||||
|
||||
private void WeaponRecycle(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is ShopWeaponRecycleEventArgs args))
|
||||
if (e is not ShopWeaponRecycleEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
+4
-4
@@ -5,7 +5,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class ShopForm : UGuiForm
|
||||
{
|
||||
@@ -26,12 +26,12 @@ namespace UI
|
||||
|
||||
[SerializeField] private DisplayListArea _weaponListArea;
|
||||
|
||||
private ShopFormContext _context;
|
||||
private ShopContext _context;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public void RefreshUI(ShopFormContext context)
|
||||
public void RefreshUI(ShopContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace UI
|
||||
|
||||
GameEntry.Event.Subscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
|
||||
|
||||
if (userData is ShopFormContext context)
|
||||
if (userData is ShopContext context)
|
||||
{
|
||||
RefreshUI(context);
|
||||
return;
|
||||
@@ -2,7 +2,7 @@ using SepCore.Event;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DisplayItem : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using GameFramework;
|
||||
using GameFramework.ObjectPool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DisplayItemObject : ObjectBase
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public enum DisplayListAreaType : byte
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class LevelUpRewardItem : MonoBehaviour
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class ShopGoodsItem : MonoBehaviour
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user