CTT/Unity/Assets/HotfixView/Helper/SessionComponentHelper.cs

56 lines
2.0 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using ET;
using System;
using System.Collections.Generic;
namespace ET
{
public static class SessionComponentHelper
{
public static async ETTask TipCall<TQuery,TQueryRet, T,TRet>(Scene zoneScene,TQuery query,Func<TQueryRet, (string,T)> queryRet,Action<TRet> retAction)
2021-04-08 20:09:59 +08:00
where TQuery:ET.IRequest
where TQueryRet:ET.IResponse
where T : ET.IRequest
where TRet : ET.IResponse
{
TQueryRet _queryRet =await zoneScene.GetComponent<SessionComponent>().Call<TQueryRet>(query);
2021-04-08 20:09:59 +08:00
if (!_queryRet.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(_queryRet.Message);
return;
}
if (queryRet == null)
return;
2021-04-11 19:50:39 +08:00
(string str, T t) = queryRet.Invoke(_queryRet);
FUI_TipUI tipUI = TipHelper.OpenUI(str, tipType: TipType.Double);
2021-04-08 20:09:59 +08:00
tipUI.m_btnYes.self.onClick.Clear();
tipUI.m_btnYes.self.onClick.Add(async () =>
{
TRet ret = await zoneScene.GetComponent<SessionComponent>().Call<TRet>(t);
2021-04-08 20:09:59 +08:00
if (!ret.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(ret.Message);
return;
}
retAction?.Invoke(ret);
});
}
2021-06-01 00:13:11 +08:00
public static void TipCall<T,TRet>(Scene zoneScene,string tip,T t,Action<TRet> retAction)
where T : ET.IRequest
where TRet : ET.IResponse
{
FUI_TipUI tipUI = TipHelper.OpenUI(tip, tipType: TipType.Double);
tipUI.m_btnYes.self.onClick.Clear();
tipUI.m_btnYes.self.onClick.Add(async () =>
{
TRet ret = await zoneScene.GetComponent<SessionComponent>().Call<TRet>(t);
if (!ret.Message.IsNullOrEmpty())
{
TipHelper.OpenUI(ret.Message);
return;
}
retAction?.Invoke(ret);
});
}
2021-04-08 20:09:59 +08:00
}
}