继续重构调整(UI)
- 引入 UniTask 和异步版本的 UIModule - 调整 Runtime/UIBase 和 Presentation 下的脚本命名空间到 SepCore.UI - 将原来的 5 层 UI 迁移到异步实现 - 规范各层的 UI 脚本命名
This commit is contained in:
parent
6b8a6a8789
commit
7bba8bbb80
|
|
@ -22,7 +22,10 @@ namespace UnityGameFramework.Editor
|
|||
"UnityGameFramework.Runtime",
|
||||
#endif
|
||||
"Assembly-CSharp",
|
||||
"VampireLike"
|
||||
"VampireLike",
|
||||
"SepCore.Base",
|
||||
"SepCore.Runtime",
|
||||
"SepCore.Procedure"
|
||||
};
|
||||
|
||||
private static readonly string[] RuntimeOrEditorAssemblyNames =
|
||||
|
|
@ -36,7 +39,11 @@ namespace UnityGameFramework.Editor
|
|||
#endif
|
||||
"Assembly-CSharp-Editor",
|
||||
"VampireLike",
|
||||
"VampireLike.Editor"
|
||||
"VampireLike.Editor",
|
||||
"SepCore.Base",
|
||||
"SepCore.Runtime",
|
||||
"SepCore.Procedure",
|
||||
"SepCore.Editor"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ MonoImporter:
|
|||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: -20
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,66 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: MenuSettings
|
||||
serializedVersion: 6
|
||||
m_GIWorkflowMode: 1
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 0
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 50
|
||||
m_Padding: 2
|
||||
m_LightmapCompression: 0
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 0
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 1
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 1024
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVREnvironmentSampleCount: 512
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentImportanceSampling: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_PVRTiledBaking: 0
|
||||
m_NumRaysToShootPerTexel: -1
|
||||
m_RespectSceneVisibilityWhenBakingGI: 0
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 427f5be66b5f35b4a898d6e812a0e7bc
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 4890085278179872738
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -12,7 +12,7 @@ namespace SepCore.Definition
|
|||
/// </summary>
|
||||
public enum UIFormType : byte
|
||||
{
|
||||
TUIForm = 0,
|
||||
Undefined = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 弹出框。
|
||||
|
|
@ -22,7 +22,7 @@ namespace SepCore.Definition
|
|||
/// <summary>
|
||||
/// 主菜单。
|
||||
/// </summary>
|
||||
MenuForm = 100,
|
||||
MenuForm = 200,
|
||||
|
||||
/// <summary>
|
||||
/// 设置。
|
||||
|
|
@ -34,11 +34,6 @@ namespace SepCore.Definition
|
|||
/// </summary>
|
||||
AboutForm = 102,
|
||||
|
||||
/// <summary>
|
||||
/// 主菜单。
|
||||
/// </summary>
|
||||
StartMenuForm = 200,
|
||||
|
||||
/// <summary>
|
||||
/// 选择角色。
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace SepCore.Event
|
||||
{
|
||||
public class MenuSelectRoleConfirmEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuSelectRoleConfirmEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static MenuSelectRoleConfirmEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<MenuSelectRoleConfirmEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f52f9694158bfda42a01330b373cbfe9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5592c04fe863be843948da5e161ee830
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace SepCore.Event
|
||||
{
|
||||
public class DialogEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(DialogEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public int ButtonId { get; private set; }
|
||||
|
||||
public object UserData { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建 DialogEventArgs 事件示例
|
||||
/// </summary>
|
||||
/// <param name="buttonId">
|
||||
/// <list type="buttet">
|
||||
/// <item>1 为 ConfirmButton</item>
|
||||
/// <item>2 为 CancelButton</item>
|
||||
/// <item>3 为 OtherButton</item>
|
||||
/// </list>
|
||||
/// </param>
|
||||
/// <param name="userData">用户自定义数据</param>
|
||||
/// <returns></returns>
|
||||
public static DialogEventArgs Create(int buttonId, object userData)
|
||||
{
|
||||
DialogEventArgs dialogEventArgs = ReferencePool.Acquire<DialogEventArgs>();
|
||||
dialogEventArgs.ButtonId = buttonId;
|
||||
dialogEventArgs.UserData = userData;
|
||||
return dialogEventArgs;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
UserData = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e9602a461df53c048af85df015fa8cb7
|
||||
guid: e2d4f8127d599534886d1953cfc9e2ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace SepCore.Event
|
||||
{
|
||||
public class SelectRoleConfirmEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(SelectRoleConfirmEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public static SelectRoleConfirmEventArgs Create()
|
||||
{
|
||||
return ReferencePool.Acquire<SelectRoleConfirmEventArgs>();
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,17 +3,17 @@ using GameFramework.Event;
|
|||
|
||||
namespace SepCore.Event
|
||||
{
|
||||
public class MenuSelectRoleSelectedEventArgs : GameEventArgs
|
||||
public class SelectRoleHoverEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuSelectRoleSelectedEventArgs).GetHashCode();
|
||||
public static readonly int EventId = typeof(SelectRoleHoverEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public int RoleId { get; private set; } = -1;
|
||||
|
||||
public static MenuSelectRoleSelectedEventArgs Create(int roleId)
|
||||
public static SelectRoleHoverEventArgs Create(int roleId)
|
||||
{
|
||||
var args = ReferencePool.Acquire<MenuSelectRoleSelectedEventArgs>();
|
||||
var args = ReferencePool.Acquire<SelectRoleHoverEventArgs>();
|
||||
args.RoleId = roleId;
|
||||
return args;
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.CustomComponent;
|
||||
using SepCore.UI;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UIModule.Editor
|
||||
{
|
||||
[CustomEditor(typeof(UIRouterComponent))]
|
||||
public class UIRouterComponentEditor : UnityEditor.Editor
|
||||
{
|
||||
private SerializedProperty _bindingsProperty;
|
||||
private GUIContent[] _controllerDisplayNames;
|
||||
private string[] _controllerTypeNames;
|
||||
private ReorderableList _bindingsList;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_bindingsProperty = serializedObject.FindProperty("_controllerBindings");
|
||||
BuildControllerTypeOptions();
|
||||
BuildReorderableList();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.HelpBox("配置 UIFormType 到 IUIFormController 的映射。运行时 Awake 自动注册。",
|
||||
MessageType.Info);
|
||||
|
||||
if (GUILayout.Button("Refresh Controller List"))
|
||||
{
|
||||
BuildControllerTypeOptions();
|
||||
}
|
||||
|
||||
if (_bindingsList == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Bindings list init failed.", MessageType.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
_bindingsList.DoLayoutList();
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void BuildReorderableList()
|
||||
{
|
||||
if (_bindingsProperty == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_bindingsList = new ReorderableList(serializedObject, _bindingsProperty, true, true, true, true);
|
||||
_bindingsList.drawHeaderCallback = rect => { EditorGUI.LabelField(rect, "Controller Bindings"); };
|
||||
_bindingsList.elementHeight = EditorGUIUtility.singleLineHeight * 2 + 8f;
|
||||
_bindingsList.drawElementCallback = DrawElement;
|
||||
_bindingsList.onAddCallback = list =>
|
||||
{
|
||||
_bindingsProperty.InsertArrayElementAtIndex(_bindingsProperty.arraySize);
|
||||
SerializedProperty item = _bindingsProperty.GetArrayElementAtIndex(_bindingsProperty.arraySize - 1);
|
||||
item.FindPropertyRelative("_controllerTypeName").stringValue = string.Empty;
|
||||
item.FindPropertyRelative("_uiFormType").enumValueIndex = 0;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
};
|
||||
}
|
||||
|
||||
private void BuildControllerTypeOptions()
|
||||
{
|
||||
List<Type> controllerTypes = new();
|
||||
foreach (Type type in TypeCache.GetTypesDerivedFrom<IUIFormController>())
|
||||
{
|
||||
if (type.IsAbstract || type.IsInterface || type.ContainsGenericParameters)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
controllerTypes.Add(type);
|
||||
}
|
||||
|
||||
controllerTypes.Sort((a, b) => string.CompareOrdinal(a.FullName, b.FullName));
|
||||
|
||||
_controllerTypeNames = new string[controllerTypes.Count + 1];
|
||||
_controllerDisplayNames = new GUIContent[controllerTypes.Count + 1];
|
||||
_controllerTypeNames[0] = string.Empty;
|
||||
_controllerDisplayNames[0] = new GUIContent("<None>");
|
||||
|
||||
for (int i = 0; i < controllerTypes.Count; i++)
|
||||
{
|
||||
Type type = controllerTypes[i];
|
||||
_controllerTypeNames[i + 1] = type.AssemblyQualifiedName;
|
||||
_controllerDisplayNames[i + 1] = new GUIContent(type.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
SerializedProperty item = _bindingsProperty.GetArrayElementAtIndex(index);
|
||||
SerializedProperty formTypeProperty = item.FindPropertyRelative("_uiFormType");
|
||||
SerializedProperty controllerTypeProperty = item.FindPropertyRelative("_controllerTypeName");
|
||||
|
||||
Rect row1 = new Rect(rect.x, rect.y + 2f, rect.width, EditorGUIUtility.singleLineHeight);
|
||||
Rect row2 = new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight + 6f, rect.width,
|
||||
EditorGUIUtility.singleLineHeight);
|
||||
|
||||
EditorGUI.PropertyField(row1, formTypeProperty, new GUIContent("UI Form Type"));
|
||||
DrawControllerPopup(row2, controllerTypeProperty);
|
||||
}
|
||||
|
||||
private void DrawControllerPopup(Rect rect, SerializedProperty controllerTypeProperty)
|
||||
{
|
||||
int currentIndex = 0;
|
||||
string currentValue = controllerTypeProperty.stringValue;
|
||||
for (int i = 0; i < _controllerTypeNames.Length; i++)
|
||||
{
|
||||
if (_controllerTypeNames[i] == currentValue)
|
||||
{
|
||||
currentIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int selected =
|
||||
EditorGUI.Popup(rect, new GUIContent("Controller Type"), currentIndex, _controllerDisplayNames);
|
||||
controllerTypeProperty.stringValue = _controllerTypeNames[selected];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bcea24781fc934c42a5aac696d86f98d
|
||||
guid: fa46094acc1cee640828c3adc1f267b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -1,16 +1,9 @@
|
|||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using StarForce;
|
||||
using StarForce;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class AboutForm : UGuiForm
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class RoleItemContext : UIContext
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class RolePropertyAreaContext : UIContext
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
using SepCore.UI;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 对话框显示数据。
|
||||
/// </summary>
|
||||
public class DialogContext : UIContext
|
||||
{
|
||||
/// <summary>
|
||||
/// 模式,即按钮数量。取值 1、2、3。
|
||||
/// </summary>
|
||||
public int Mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标题。
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息内容。
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 弹出窗口时是否暂停游戏。
|
||||
/// </summary>
|
||||
public bool PauseGame { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 确认按钮文本。
|
||||
/// </summary>
|
||||
public string ConfirmText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 取消按钮文本。
|
||||
/// </summary>
|
||||
public string CancelText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 中立按钮文本。
|
||||
/// </summary>
|
||||
public string OtherText { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ad9ca3c36c52b0a4e8b25c8b451966da
|
||||
guid: 8fb06a34d7fb37146a4b9e2f8138a724
|
||||
timeCreated: 1528026160
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DialogController : UIControllerBase<DialogContext, DialogForm>
|
||||
{
|
||||
private GameFrameworkAction<object> _onClickConfirmGFAction;
|
||||
private GameFrameworkAction<object> _onClickCancelGFAction;
|
||||
private GameFrameworkAction<object> _onClickOtherGFAction;
|
||||
private object _currentUserData;
|
||||
|
||||
protected override UIFormType UIFormType => UIFormType.DialogForm;
|
||||
|
||||
protected override void RefreshUI(DialogForm form, DialogContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
protected virtual DialogContext BuildContext(DialogRawData rawData)
|
||||
{
|
||||
if (rawData == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DialogContext
|
||||
{
|
||||
Mode = rawData.Mode,
|
||||
Title = rawData.Title,
|
||||
Message = rawData.Message,
|
||||
PauseGame = rawData.PauseGame,
|
||||
ConfirmText = rawData.ConfirmText,
|
||||
CancelText = rawData.CancelText,
|
||||
OtherText = rawData.OtherText,
|
||||
};
|
||||
}
|
||||
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData is not DialogRawData rawData)
|
||||
{
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("DialogController.OpenUIAsync() userData type is invalid.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning("DialogController.OpenUIAsync() rawData is required.");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
DialogContext context = BuildContext(rawData);
|
||||
if (context == null)
|
||||
{
|
||||
Log.Warning("DialogController.OpenUIAsync() rawData is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
_onClickConfirmGFAction = rawData.OnClickConfirm;
|
||||
_onClickCancelGFAction = rawData.OnClickCancel;
|
||||
_onClickOtherGFAction = rawData.OnClickOther;
|
||||
_currentUserData = rawData.UserData;
|
||||
|
||||
return await OpenFormAsync(context, timeout);
|
||||
}
|
||||
|
||||
public override async UniTask CloseUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
ClearCallbacks();
|
||||
await CloseFormAsync(userData, timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (useCase != null)
|
||||
{
|
||||
Log.Warning("DialogController does not use a use case.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Subscribe(DialogEventArgs.EventId, HandleDialogEventArgs);
|
||||
}
|
||||
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(DialogEventArgs.EventId, HandleDialogEventArgs);
|
||||
}
|
||||
|
||||
private void HandleDialogEventArgs(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not DialogEventArgs args) return;
|
||||
var callback = args.ButtonId switch
|
||||
{
|
||||
1 => _onClickConfirmGFAction,
|
||||
2 => _onClickCancelGFAction,
|
||||
3 => _onClickOtherGFAction,
|
||||
_ => null
|
||||
};
|
||||
object userData = _currentUserData;
|
||||
CloseAndInvokeAsync(callback, userData).Forget();
|
||||
}
|
||||
|
||||
private void ClearCallbacks()
|
||||
{
|
||||
_onClickConfirmGFAction = null;
|
||||
_onClickCancelGFAction = null;
|
||||
_onClickOtherGFAction = null;
|
||||
_currentUserData = null;
|
||||
}
|
||||
|
||||
private async UniTaskVoid CloseAndInvokeAsync(GameFrameworkAction<object> callback, object userData)
|
||||
{
|
||||
try
|
||||
{
|
||||
await CloseUIAsync();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("DialogController.CloseUIAsync() failed: {0}", exception.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
callback?.Invoke(userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 692b282b1ecbf5a44839d5bf4a03a937
|
||||
guid: f9a41ea68676c324091e71f3531a9da2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
using SepCore.Event;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DialogForm : UGuiForm
|
||||
{
|
||||
[SerializeField] private TMP_Text _titleText = null;
|
||||
[SerializeField] private TMP_Text _messageText = null;
|
||||
[SerializeField] private GameObject[] _modeObjects = null;
|
||||
[SerializeField] private TMP_Text[] _confirmTexts = null;
|
||||
[SerializeField] private TMP_Text[] _cancelTexts = null;
|
||||
[SerializeField] private TMP_Text[] _otherTexts = null;
|
||||
|
||||
private int _dialogMode = 1;
|
||||
private bool _pauseGame = false;
|
||||
|
||||
public void OnConfirmButtonClick()
|
||||
{
|
||||
GameEntry.Event.FireNow(this, DialogEventArgs.Create(1, null));
|
||||
}
|
||||
|
||||
public void OnCancelButtonClick()
|
||||
{
|
||||
GameEntry.Event.FireNow(this, DialogEventArgs.Create(2, null));
|
||||
}
|
||||
|
||||
public void OnOtherButtonClick()
|
||||
{
|
||||
GameEntry.Event.FireNow(this, DialogEventArgs.Create(3, null));
|
||||
}
|
||||
|
||||
protected override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (userData is not DialogContext context)
|
||||
{
|
||||
Log.Warning("DialogContext is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
RefreshUI(context);
|
||||
}
|
||||
|
||||
public void RefreshUI(DialogContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
Log.Warning("DialogContext is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
_dialogMode = context.Mode;
|
||||
RefreshDialogMode();
|
||||
|
||||
_titleText.text = context.Title;
|
||||
_messageText.text = context.Message;
|
||||
|
||||
_pauseGame = context.PauseGame;
|
||||
RefreshPauseGame();
|
||||
|
||||
RefreshConfirmText(context.ConfirmText);
|
||||
RefreshCancelText(context.CancelText);
|
||||
RefreshOtherText(context.OtherText);
|
||||
}
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
if (_pauseGame)
|
||||
{
|
||||
GameEntry.Base.ResumeGame();
|
||||
}
|
||||
|
||||
_dialogMode = 1;
|
||||
_titleText.text = string.Empty;
|
||||
_messageText.text = string.Empty;
|
||||
_pauseGame = false;
|
||||
|
||||
RefreshConfirmText(string.Empty);
|
||||
RefreshCancelText(string.Empty);
|
||||
RefreshOtherText(string.Empty);
|
||||
|
||||
base.OnClose(isShutdown, userData);
|
||||
}
|
||||
|
||||
private void RefreshDialogMode()
|
||||
{
|
||||
for (int i = 1; i <= _modeObjects.Length; i++)
|
||||
{
|
||||
_modeObjects[i - 1].SetActive(i == _dialogMode);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshPauseGame()
|
||||
{
|
||||
if (_pauseGame)
|
||||
{
|
||||
GameEntry.Base.PauseGame();
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshConfirmText(string confirmText)
|
||||
{
|
||||
foreach (var text in _confirmTexts)
|
||||
{
|
||||
text.text = confirmText;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshCancelText(string cancelText)
|
||||
{
|
||||
foreach (var text in _cancelTexts)
|
||||
{
|
||||
text.text = cancelText;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshOtherText(string otherText)
|
||||
{
|
||||
foreach (var text in _otherTexts)
|
||||
{
|
||||
text.text = otherText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c04f3be6bab0c7748bc236f9023e47f9
|
||||
guid: e75b6daf7a6651845bdbc6cf9dcaa400
|
||||
timeCreated: 1528026160
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
|
|
@ -1,232 +0,0 @@
|
|||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class DialogForm : UGuiForm
|
||||
{
|
||||
[SerializeField] private TMP_Text _titleText = null;
|
||||
[SerializeField] private TMP_Text _messageText = null;
|
||||
[SerializeField] private GameObject[] _modeObjects = null;
|
||||
[SerializeField] private TMP_Text[] _confirmTexts = null;
|
||||
[SerializeField] private TMP_Text[] _cancelTexts = null;
|
||||
[SerializeField] private TMP_Text[] _otherTexts = null;
|
||||
|
||||
private int _dialogMode = 1;
|
||||
private bool _pauseGame = false;
|
||||
private object _userData = null;
|
||||
private GameFrameworkAction<object> _onClickConfirmGFAction = null;
|
||||
private GameFrameworkAction<object> _onClickCancelGFAction = null;
|
||||
private GameFrameworkAction<object> _onClickOtherGFAction = null;
|
||||
private DialogFormContext _context = null;
|
||||
|
||||
public int DialogMode => _dialogMode;
|
||||
|
||||
public bool PauseGame => _pauseGame;
|
||||
|
||||
public object UserData => _userData;
|
||||
|
||||
public void OnConfirmButtonClick()
|
||||
{
|
||||
Close();
|
||||
|
||||
if (_onClickConfirmGFAction != null)
|
||||
{
|
||||
_onClickConfirmGFAction(_userData);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCancelButtonClick()
|
||||
{
|
||||
Close();
|
||||
|
||||
if (_onClickCancelGFAction != null)
|
||||
{
|
||||
_onClickCancelGFAction(_userData);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnOtherButtonClick()
|
||||
{
|
||||
Close();
|
||||
|
||||
if (_onClickOtherGFAction != null)
|
||||
{
|
||||
_onClickOtherGFAction(_userData);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
protected override void OnOpen(object userData)
|
||||
#else
|
||||
protected internal override void OnOpen(object userData)
|
||||
#endif
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (userData is DialogFormContext context)
|
||||
{
|
||||
RefreshUI(context);
|
||||
return;
|
||||
}
|
||||
|
||||
if (userData is DialogFormRawData dialogParams)
|
||||
{
|
||||
RefreshUI(BuildContext(dialogParams));
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Warning("DialogForm requires DialogFormContext or DialogParams as userData.");
|
||||
}
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
#else
|
||||
protected internal override void OnClose(bool isShutdown, object userData)
|
||||
#endif
|
||||
{
|
||||
if (_pauseGame)
|
||||
{
|
||||
GameEntry.Base.ResumeGame();
|
||||
}
|
||||
|
||||
_dialogMode = 1;
|
||||
_titleText.text = string.Empty;
|
||||
_messageText.text = string.Empty;
|
||||
_pauseGame = false;
|
||||
_userData = null;
|
||||
_context = null;
|
||||
|
||||
RefreshConfirmText(string.Empty);
|
||||
_onClickConfirmGFAction = null;
|
||||
|
||||
RefreshCancelText(string.Empty);
|
||||
_onClickCancelGFAction = null;
|
||||
|
||||
RefreshOtherText(string.Empty);
|
||||
_onClickOtherGFAction = null;
|
||||
|
||||
base.OnClose(isShutdown, userData);
|
||||
}
|
||||
|
||||
public void RefreshUI(DialogFormContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
Log.Warning("DialogForm context is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
_context = context;
|
||||
|
||||
_dialogMode = context.Mode;
|
||||
RefreshDialogMode();
|
||||
|
||||
_titleText.text = context.Title;
|
||||
_messageText.text = context.Message;
|
||||
|
||||
_pauseGame = context.PauseGame;
|
||||
RefreshPauseGame();
|
||||
|
||||
_userData = context.UserData;
|
||||
|
||||
RefreshConfirmText(context.ConfirmText);
|
||||
_onClickConfirmGFAction = context.OnClickConfirm;
|
||||
|
||||
RefreshCancelText(context.CancelText);
|
||||
_onClickCancelGFAction = context.OnClickCancel;
|
||||
|
||||
RefreshOtherText(context.OtherText);
|
||||
_onClickOtherGFAction = context.OnClickOther;
|
||||
}
|
||||
|
||||
private static DialogFormContext BuildContext(DialogFormRawData rawData)
|
||||
{
|
||||
if (rawData == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DialogFormContext
|
||||
{
|
||||
Mode = rawData.Mode,
|
||||
Title = rawData.Title,
|
||||
Message = rawData.Message,
|
||||
PauseGame = rawData.PauseGame,
|
||||
ConfirmText = rawData.ConfirmText,
|
||||
OnClickConfirm = rawData.OnClickConfirm,
|
||||
CancelText = rawData.CancelText,
|
||||
OnClickCancel = rawData.OnClickCancel,
|
||||
OtherText = rawData.OtherText,
|
||||
OnClickOther = rawData.OnClickOther,
|
||||
UserData = rawData.UserData
|
||||
};
|
||||
}
|
||||
|
||||
private void RefreshDialogMode()
|
||||
{
|
||||
for (int i = 1; i <= _modeObjects.Length; i++)
|
||||
{
|
||||
_modeObjects[i - 1].SetActive(i == _dialogMode);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshPauseGame()
|
||||
{
|
||||
if (_pauseGame)
|
||||
{
|
||||
GameEntry.Base.PauseGame();
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshConfirmText(string confirmText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(confirmText))
|
||||
{
|
||||
confirmText = GameEntry.Localization.GetString("Dialog.ConfirmButton");
|
||||
}
|
||||
|
||||
for (int i = 0; i < _confirmTexts.Length; i++)
|
||||
{
|
||||
_confirmTexts[i].text = confirmText;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshCancelText(string cancelText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(cancelText))
|
||||
{
|
||||
cancelText = GameEntry.Localization.GetString("Dialog.CancelButton");
|
||||
}
|
||||
|
||||
for (int i = 0; i < _cancelTexts.Length; i++)
|
||||
{
|
||||
_cancelTexts[i].text = cancelText;
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshOtherText(string otherText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(otherText))
|
||||
{
|
||||
otherText = GameEntry.Localization.GetString("Dialog.OtherButton");
|
||||
}
|
||||
|
||||
for (int i = 0; i < _otherTexts.Length; i++)
|
||||
{
|
||||
_otherTexts[i].text = otherText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
using GameFramework;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class DialogFormContext : UIContext
|
||||
{
|
||||
public int Mode;
|
||||
public string Title;
|
||||
public string Message;
|
||||
public bool PauseGame;
|
||||
public string ConfirmText;
|
||||
public GameFrameworkAction<object> OnClickConfirm;
|
||||
public string CancelText;
|
||||
public GameFrameworkAction<object> OnClickCancel;
|
||||
public string OtherText;
|
||||
public GameFrameworkAction<object> OnClickOther;
|
||||
public object UserData;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
using SepCore.Definition;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class DialogFormController : UIFormControllerCommonBase<DialogFormContext, DialogForm>
|
||||
{
|
||||
protected override UIFormType UIFormTypeId => UIFormType.DialogForm;
|
||||
|
||||
protected override void RefreshUI(DialogForm form, DialogFormContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
protected override void CloseLoadedFormDirect(DialogForm form)
|
||||
{
|
||||
GameEntry.UI.CloseUIForm(form);
|
||||
}
|
||||
|
||||
private static DialogFormContext BuildContext(DialogFormRawData rawData)
|
||||
{
|
||||
if (rawData == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DialogFormContext
|
||||
{
|
||||
Mode = rawData.Mode,
|
||||
Title = rawData.Title,
|
||||
Message = rawData.Message,
|
||||
PauseGame = rawData.PauseGame,
|
||||
ConfirmText = rawData.ConfirmText,
|
||||
OnClickConfirm = rawData.OnClickConfirm,
|
||||
CancelText = rawData.CancelText,
|
||||
OnClickCancel = rawData.OnClickCancel,
|
||||
OtherText = rawData.OtherText,
|
||||
OnClickOther = rawData.OnClickOther,
|
||||
UserData = rawData.UserData
|
||||
};
|
||||
}
|
||||
|
||||
public int? OpenUI(DialogFormRawData rawData)
|
||||
{
|
||||
DialogFormContext context = BuildContext(rawData);
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
if (userData is DialogFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData is DialogFormRawData rawData)
|
||||
{
|
||||
return OpenUI(rawData);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("DialogFormController.OpenUI() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return OpenUIInternal(Context);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (useCase != null)
|
||||
{
|
||||
Log.Warning("DialogFormController does not use a use case.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ using SepCore.Definition;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class IconArea : MonoBehaviour
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ using SepCore.Event;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class RoleItem : MonoBehaviour
|
||||
{
|
||||
|
|
@ -29,12 +29,12 @@ namespace UI
|
|||
public void UpdateShowRole()
|
||||
{
|
||||
int roleId = _context?.RoleId ?? -1;
|
||||
GameEntry.Event.Fire(this, MenuSelectRoleSelectedEventArgs.Create(roleId));
|
||||
GameEntry.Event.Fire(this, SelectRoleHoverEventArgs.Create(roleId));
|
||||
}
|
||||
|
||||
public void OnConfirmRoleClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, MenuSelectRoleConfirmEventArgs.Create());
|
||||
GameEntry.Event.Fire(this, SelectRoleConfirmEventArgs.Create());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ using TMPro;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class RolePropertyArea : MonoBehaviour
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class UpdateResourceForm : MonoBehaviour
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class DisplayItemInfoFormRawData
|
||||
public class DisplayItemInfoContext : UIContext
|
||||
{
|
||||
public int Index;
|
||||
public string IconAssetName;
|
||||
|
|
@ -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)
|
||||
if (userData is not DisplayItemInfoRawData rawData)
|
||||
{
|
||||
_locked = false;
|
||||
if (userData is DisplayItemInfoFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData is DisplayItemInfoFormRawData rawData)
|
||||
{
|
||||
return OpenUI(rawData);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("DisplayItemInfoFormController.OpenUI() userData type is invalid.");
|
||||
Log.Warning("DisplayItemInfoController.OpenUIAsync() userData type is invalid.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning("DisplayItemInfoController.OpenUIAsync() rawData is required.");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
namespace SepCore.UI
|
||||
{
|
||||
public class MenuContext : UIContext
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,16 @@
|
|||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Event;
|
||||
using SepCore.Definition;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class StartMenuFormController : UIFormControllerCommonBase<StartMenuFormContext, StartMenuForm>
|
||||
public class MenuController : UIControllerBase<MenuContext, MenuForm>
|
||||
{
|
||||
protected override UIFormType UIFormTypeId => UIFormType.StartMenuForm;
|
||||
protected override UIFormType UIFormType => UIFormType.MenuForm;
|
||||
|
||||
protected override void RefreshUI(StartMenuForm form, StartMenuFormContext context)
|
||||
protected override void RefreshUI(MenuForm form, MenuContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
|
@ -34,30 +35,20 @@ namespace UI
|
|||
GameEntry.Event.Unsubscribe(MenuAboutButtonClickEventArgs.EventId, OnMenuAboutButtonClick);
|
||||
}
|
||||
|
||||
private static StartMenuFormContext BuildStartMenuFormContext()
|
||||
private static MenuContext BuildMenuContext()
|
||||
{
|
||||
return new StartMenuFormContext();
|
||||
return new MenuContext();
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
public override async UniTask<int?> OpenUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
if (userData is StartMenuFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("StartMenuFormController.OpenUI() userData type is invalid.");
|
||||
Log.Warning("MenuController.OpenUIAsync() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return OpenUIInternal(BuildStartMenuFormContext());
|
||||
}
|
||||
|
||||
public int? OpenUI(StartMenuFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
return await OpenFormAsync(BuildMenuContext(), timeout);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
|
|
@ -67,17 +58,17 @@ namespace UI
|
|||
|
||||
private void OnMenuStartGameButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuStartGameEventArgs))
|
||||
if (sender is not MenuForm || e is not MenuStartGameEventArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.SelectRoleForm);
|
||||
GameEntry.UIRouter.OpenUIAsync(UIFormType.SelectRoleForm).Forget();
|
||||
}
|
||||
|
||||
private void OnMenuFileButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuFileButtonClickEventArgs))
|
||||
if (sender is not MenuForm || e is not MenuFileButtonClickEventArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -87,7 +78,7 @@ namespace UI
|
|||
|
||||
private void OnMenuGuideButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuGuideButtonClickEventArgs))
|
||||
if (sender is not MenuForm || e is not MenuGuideButtonClickEventArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -97,22 +88,22 @@ namespace UI
|
|||
|
||||
private void OnMenuSettingButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuSettingButtonClickEventArgs))
|
||||
if (sender is not MenuForm || e is not MenuSettingButtonClickEventArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.SettingForm);
|
||||
GameEntry.UIRouter.OpenUIAsync(UIFormType.SettingForm).Forget();
|
||||
}
|
||||
|
||||
private void OnMenuQuitButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuQuitButtonClickEventArgs))
|
||||
if (sender is not MenuForm || e is not MenuQuitButtonClickEventArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.DialogForm, new DialogFormRawData
|
||||
GameEntry.UIRouter.OpenUIAsync(UIFormType.DialogForm, new DialogRawData
|
||||
{
|
||||
Mode = 2,
|
||||
Title = GameEntry.Localization.GetString("AskQuitGame.Title"),
|
||||
|
|
@ -121,12 +112,12 @@ namespace UI
|
|||
{
|
||||
UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Quit);
|
||||
}
|
||||
});
|
||||
}).Forget();
|
||||
}
|
||||
|
||||
private void OnMenuAboutButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuAboutButtonClickEventArgs))
|
||||
if (sender is not MenuForm || e is not MenuAboutButtonClickEventArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
using SepCore.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class StartMenuForm : UGuiForm
|
||||
public class MenuForm : UGuiForm
|
||||
{
|
||||
public void RefreshUI(StartMenuFormContext context)
|
||||
public void RefreshUI(MenuContext context)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ namespace UI
|
|||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (userData is StartMenuFormContext context)
|
||||
if (userData is MenuContext context)
|
||||
{
|
||||
RefreshUI(context);
|
||||
return;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
namespace UI
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class SelectRoleFormContext : UIContext
|
||||
public class SelectRoleContext : UIContext
|
||||
{
|
||||
public RoleItemContext[] RoleItemContexts;
|
||||
public RolePropertyAreaContext RolePropertyAreaContext;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue