继续重构调整(UI)
- 引入 UniTask 和异步版本的 UIModule - 调整 Runtime/UIBase 和 Presentation 下的脚本命名空间到 SepCore.UI - 将原来的 5 层 UI 迁移到异步实现 - 规范各层的 UI 脚本命名
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
using GameFramework.DataTable;
|
||||
using GameFramework.UI;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public static class UIComponentExtension
|
||||
{
|
||||
public static bool HasUIForm(this UIComponent uiComponent, UIFormType uiFormType, string uiGroupName = null)
|
||||
{
|
||||
return uiComponent.HasUIForm((int)uiFormType, uiGroupName);
|
||||
}
|
||||
|
||||
public static bool HasUIForm(this UIComponent uiComponent, int uiFormId, string uiGroupName = null)
|
||||
{
|
||||
IDataTable<DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable<DRUIForm>();
|
||||
DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId);
|
||||
if (drUIForm == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string assetName = AssetUtility.GetUIFormAsset(drUIForm.AssetName);
|
||||
if (string.IsNullOrEmpty(uiGroupName))
|
||||
{
|
||||
return uiComponent.HasUIForm(assetName);
|
||||
}
|
||||
|
||||
IUIGroup uiGroup = uiComponent.GetUIGroup(uiGroupName);
|
||||
if (uiGroup == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return uiGroup.HasUIForm(assetName);
|
||||
}
|
||||
|
||||
public static UGuiForm GetUIForm(this UIComponent uiComponent, UIFormType uiFormType, string uiGroupName = null)
|
||||
{
|
||||
return uiComponent.GetUIForm((int)uiFormType, uiGroupName);
|
||||
}
|
||||
|
||||
public static UGuiForm GetUIForm(this UIComponent uiComponent, int uiFormId, string uiGroupName = null)
|
||||
{
|
||||
IDataTable<DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable<DRUIForm>();
|
||||
DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId);
|
||||
if (drUIForm == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string assetName = AssetUtility.GetUIFormAsset(drUIForm.AssetName);
|
||||
UIForm uiForm = null;
|
||||
if (string.IsNullOrEmpty(uiGroupName))
|
||||
{
|
||||
uiForm = uiComponent.GetUIForm(assetName);
|
||||
if (uiForm == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (UGuiForm)uiForm.Logic;
|
||||
}
|
||||
|
||||
IUIGroup uiGroup = uiComponent.GetUIGroup(uiGroupName);
|
||||
if (uiGroup == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
uiForm = (UIForm)uiGroup.GetUIForm(assetName);
|
||||
if (uiForm == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (UGuiForm)uiForm.Logic;
|
||||
}
|
||||
|
||||
public static void CloseUIForm(this UIComponent uiComponent, UGuiForm uiForm)
|
||||
{
|
||||
uiComponent.CloseUIForm(uiForm.UIForm);
|
||||
}
|
||||
|
||||
public static int? OpenUIForm(this UIComponent uiComponent, UIFormType uiFormType, object userData = null)
|
||||
{
|
||||
return uiComponent.OpenUIForm((int)uiFormType, userData);
|
||||
}
|
||||
|
||||
public static int? OpenUIForm(this UIComponent uiComponent, int uiFormId, object userData = null)
|
||||
{
|
||||
IDataTable<DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable<DRUIForm>();
|
||||
DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId);
|
||||
if (drUIForm == null)
|
||||
{
|
||||
Log.Warning("Can not load UI form '{0}' from data table.", uiFormId.ToString());
|
||||
return null;
|
||||
}
|
||||
|
||||
string assetName = AssetUtility.GetUIFormAsset(drUIForm.AssetName);
|
||||
if (!drUIForm.AllowMultiInstance)
|
||||
{
|
||||
if (uiComponent.IsLoadingUIForm(assetName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (uiComponent.HasUIForm(assetName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return uiComponent.OpenUIForm(assetName, drUIForm.UIGroupName, Constant.AssetPriority.UIFormAsset,
|
||||
drUIForm.PauseCoveredUIForm, userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user