调整 UIRouter 的打开关闭 UI 的返回值,统一成 UniTask
This commit is contained in:
parent
fbb9e1e068
commit
3b61e263cc
|
|
@ -41,7 +41,7 @@ namespace SepCore.UI
|
|||
};
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData is not DialogRawData rawData)
|
||||
{
|
||||
|
|
@ -54,14 +54,14 @@ namespace SepCore.UI
|
|||
Log.Warning("DialogController.OpenUIAsync() rawData is required.");
|
||||
}
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
DialogContext context = BuildContext(rawData);
|
||||
if (context == null)
|
||||
{
|
||||
Log.Warning("DialogController.OpenUIAsync() rawData is invalid.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
_onClickConfirmGFAction = rawData.OnClickConfirm;
|
||||
|
|
@ -69,7 +69,7 @@ namespace SepCore.UI
|
|||
_onClickOtherGFAction = rawData.OnClickOther;
|
||||
_currentUserData = rawData.UserData;
|
||||
|
||||
return await OpenFormAsync(context, timeout);
|
||||
await OpenFormAsync(context, timeout);
|
||||
}
|
||||
|
||||
public override async UniTask CloseUIAsync(object userData = null, float timeout = 30f)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace SepCore.UI
|
|||
return new DisplayItemInfoContext(rawData);
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData is not DisplayItemInfoRawData rawData)
|
||||
{
|
||||
|
|
@ -59,18 +59,18 @@ namespace SepCore.UI
|
|||
Log.Warning("DisplayItemInfoController.OpenUIAsync() rawData is required.");
|
||||
}
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayItemInfoContext context = BuildContext(rawData);
|
||||
if (context == null)
|
||||
{
|
||||
Log.Warning("DisplayItemInfoController.OpenUIAsync() rawData is invalid.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
_locked = false;
|
||||
return await OpenFormAsync(context, timeout);
|
||||
await OpenFormAsync(context, timeout);
|
||||
}
|
||||
|
||||
public override async UniTask CloseUIAsync(object userData = null, float timeout = 30f)
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@ namespace SepCore.UI
|
|||
return new HudContext();
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("HudController.OpenUIAsync() userData type is invalid.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
return await OpenFormAsync(BuildHudContext(), timeout);
|
||||
await OpenFormAsync(BuildHudContext(), timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
|
|
|
|||
|
|
@ -70,27 +70,27 @@ namespace SepCore.UI
|
|||
};
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData is LevelUpRawData rawData)
|
||||
{
|
||||
return await OpenUIAsync(rawData, timeout);
|
||||
await OpenUIAsync(rawData, timeout);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("LevelUpController.OpenUIAsync() userData type is invalid.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("LevelUpController.OpenUIAsync() useCase is null.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
LevelUpRawData initialRawData = _useCase.CreateInitialModel();
|
||||
return await OpenUIAsync(initialRawData, timeout);
|
||||
await OpenUIAsync(initialRawData, timeout);
|
||||
}
|
||||
|
||||
public async UniTask<int?> OpenUIAsync(LevelUpRawData rawData, float timeout = 30f)
|
||||
|
|
|
|||
|
|
@ -218,27 +218,27 @@ namespace SepCore.UI
|
|||
return await OpenFormAsync(context, timeout);
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData is ShopRawData rawData)
|
||||
{
|
||||
return await OpenUIAsync(rawData, timeout);
|
||||
await OpenUIAsync(rawData, timeout);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("ShopController.OpenUIAsync() userData type is invalid.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("ShopController.OpenUIAsync() useCase is null.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
ShopRawData initialRawData = _useCase.CreateInitialModel();
|
||||
return await OpenUIAsync(initialRawData, timeout);
|
||||
await OpenUIAsync(initialRawData, timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
|
|
@ -272,7 +272,8 @@ namespace SepCore.UI
|
|||
|
||||
for (int i = 0; i < result.GoodsItems.Count; i++)
|
||||
{
|
||||
if (i < Context.GoodsItems.Count) Context.GoodsItems[i] = await GoodsItemContext.CreateAsync(result.GoodsItems[i]);
|
||||
if (i < Context.GoodsItems.Count)
|
||||
Context.GoodsItems[i] = await GoodsItemContext.CreateAsync(result.GoodsItems[i]);
|
||||
else Context.GoodsItems.Add(await GoodsItemContext.CreateAsync(result.GoodsItems[i]));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,15 +40,15 @@ namespace SepCore.UI
|
|||
return new MenuContext();
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("MenuController.OpenUIAsync() userData type is invalid.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
return await OpenFormAsync(BuildMenuContext(), timeout);
|
||||
await OpenFormAsync(BuildMenuContext(), timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
|
|
|
|||
|
|
@ -73,27 +73,27 @@ namespace SepCore.UI
|
|||
};
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
public override async UniTask OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData is SelectRoleRawData rawData)
|
||||
{
|
||||
return await OpenUIAsync(rawData, timeout);
|
||||
await OpenUIAsync(rawData, timeout);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("SelectRoleController.OpenUIAsync() userData type is invalid.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("SelectRoleController.OpenUIAsync() useCase is null.");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
SelectRoleRawData initialRawData = _useCase.CreateModel();
|
||||
return await OpenUIAsync(initialRawData, timeout);
|
||||
await OpenUIAsync(initialRawData, timeout);
|
||||
}
|
||||
|
||||
public async UniTask<int?> OpenUIAsync(SelectRoleRawData rawData, float timeout = 30f)
|
||||
|
|
|
|||
|
|
@ -23,11 +23,11 @@ namespace SepCore.Procedure
|
|||
|
||||
#region FSM
|
||||
|
||||
protected override async void OnEnter(ProcedureOwner procedureOwner)
|
||||
protected override void OnEnter(ProcedureOwner procedureOwner)
|
||||
{
|
||||
base.OnEnter(procedureOwner);
|
||||
|
||||
await GameEntry.UIRouter.OpenUIAsync(UIFormType.MenuForm);
|
||||
GameEntry.UIRouter.OpenUIAsync(UIFormType.MenuForm);
|
||||
|
||||
var useCase = new SelectRoleUseCase(StartGame);
|
||||
GameEntry.UIRouter.BindUIUseCase(UIFormType.SelectRoleForm, useCase);
|
||||
|
|
|
|||
|
|
@ -66,12 +66,12 @@ namespace SepCore.UIRouter
|
|||
controller.BindUseCase(useCase);
|
||||
}
|
||||
|
||||
public UniTask<int?> OpenUIAsync(UIFormType uiFormType, object userData = null, float timeout = 30f)
|
||||
public UniTask OpenUIAsync(UIFormType uiFormType, object userData = null, float timeout = 30f)
|
||||
{
|
||||
IUIFormController controller = GetOrCreateController(uiFormType);
|
||||
if (controller == null)
|
||||
{
|
||||
return UniTask.FromResult<int?>(null);
|
||||
return default;
|
||||
}
|
||||
|
||||
return controller.OpenUIAsync(userData, timeout);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace SepCore.UI
|
|||
{
|
||||
public interface IUIFormController
|
||||
{
|
||||
UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f);
|
||||
UniTask OpenUIAsync(object userData = null, float timeout = 30f);
|
||||
|
||||
UniTask CloseUIAsync(object userData = null, float timeout = 30f);
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace SepCore.UI
|
|||
}
|
||||
}
|
||||
|
||||
public abstract UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f);
|
||||
public abstract UniTask OpenUIAsync(object userData = null, float timeout = 30f);
|
||||
|
||||
public virtual UniTask CloseUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue