第一批重构,主要是物理迁移脚本和部分命名空间的调整
- 结构上迁移文件,将脚本分成 Base/Runtime/Presentation/Procedure/Editor 五大文件夹 - 调整 DataTable 和 Definition 下脚本的命名空间 - 依据 UI-5层架构设计规范 拆分原先的 UI 到 Runtime 和 Presentation 下
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77da285af8f83814084722c2bbda3198
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using CustomEvent;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class SelectRoleForm : UGuiForm
|
||||
{
|
||||
[SerializeField] private GameObject _randomRoleCard = null;
|
||||
|
||||
[SerializeField] private GameObject _roleCard = null;
|
||||
|
||||
[SerializeField] private RolePropertyArea _propertyArea = null;
|
||||
|
||||
private SelectRoleFormContext _context = null;
|
||||
|
||||
private RoleItem[] _roleItems = null;
|
||||
|
||||
public void RefreshUI(SelectRoleFormContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
||||
int itemIndex = 1, roleIndex = 0;
|
||||
while (itemIndex < _roleItems.Length)
|
||||
{
|
||||
if (roleIndex < _context.RoleItemContexts.Length)
|
||||
{
|
||||
_roleItems[itemIndex].OnInit(_context.RoleItemContexts[roleIndex]);
|
||||
_roleItems[itemIndex].gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_roleItems[itemIndex].gameObject.SetActive(false);
|
||||
_roleItems[itemIndex].OnReset();
|
||||
}
|
||||
|
||||
itemIndex++;
|
||||
roleIndex++;
|
||||
}
|
||||
|
||||
UpdateShowRole(_context.RolePropertyAreaContext);
|
||||
}
|
||||
|
||||
#region FSM
|
||||
|
||||
protected override void OnInit(object userData)
|
||||
{
|
||||
base.OnInit(userData);
|
||||
_roleItems = this.transform.GetComponentsInChildren<RoleItem>();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (userData is SelectRoleFormContext context)
|
||||
{
|
||||
RefreshUI(context);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Warning("SelectRoleForm requires SelectRoleFormContext as userData.");
|
||||
}
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
base.OnClose(isShutdown, userData);
|
||||
|
||||
_context = null;
|
||||
foreach (var item in _roleItems)
|
||||
{
|
||||
item.OnReset();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void UpdateShowRole(RolePropertyAreaContext propertyAreaContext)
|
||||
{
|
||||
if (propertyAreaContext == null)
|
||||
{
|
||||
_randomRoleCard.SetActive(true);
|
||||
_roleCard.SetActive(false);
|
||||
_propertyArea.OnReset();
|
||||
}
|
||||
else
|
||||
{
|
||||
_randomRoleCard.SetActive(false);
|
||||
_propertyArea.OnInit(propertyAreaContext);
|
||||
_roleCard.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnReturnButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, MenuSelectRoleReturnEventArgs.Create());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 665710bc9ed5c5547a40f0cc2d92ba2e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace UI
|
||||
{
|
||||
public class SelectRoleFormContext : UIContext
|
||||
{
|
||||
public RoleItemContext[] RoleItemContexts;
|
||||
public RolePropertyAreaContext RolePropertyAreaContext;
|
||||
public int[] RoleIds;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c34d5aa87925ee41b70887958e7611c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,199 @@
|
||||
using CustomEvent;
|
||||
using SepCore.Definition;
|
||||
using GameFramework.Event;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class SelectRoleFormController : UIFormControllerCommonBase<SelectRoleFormContext, SelectRoleForm>
|
||||
{
|
||||
private SelectRoleFormUseCase _useCase;
|
||||
|
||||
protected override UIFormType UIFormTypeId => UIFormType.SelectRoleForm;
|
||||
|
||||
protected override void RefreshUI(SelectRoleForm form, SelectRoleFormContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
protected override void SubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Subscribe(MenuSelectRoleReturnEventArgs.EventId, OnMenuSelectRoleReturn);
|
||||
GameEntry.Event.Subscribe(MenuSelectRoleSelectedEventArgs.EventId, OnMenuSelectRoleSelected);
|
||||
GameEntry.Event.Subscribe(MenuSelectRoleConfirmEventArgs.EventId, OnMenuSelectRoleConfirm);
|
||||
}
|
||||
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(MenuSelectRoleReturnEventArgs.EventId, OnMenuSelectRoleReturn);
|
||||
GameEntry.Event.Unsubscribe(MenuSelectRoleSelectedEventArgs.EventId, OnMenuSelectRoleSelected);
|
||||
GameEntry.Event.Unsubscribe(MenuSelectRoleConfirmEventArgs.EventId, OnMenuSelectRoleConfirm);
|
||||
}
|
||||
|
||||
private static SelectRoleFormContext BuildContext(SelectRoleFormRawData rawData)
|
||||
{
|
||||
if (rawData == null)
|
||||
{
|
||||
Log.Error("SelectRoleFormController.BuildContext() rawData is null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
int count = rawData.RoleIds?.Length ?? 0;
|
||||
RoleItemContext[] roleItems = new RoleItemContext[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
string iconName = rawData.RoleIconNames != null && i < rawData.RoleIconNames.Length
|
||||
? rawData.RoleIconNames[i]
|
||||
: null;
|
||||
|
||||
roleItems[i] = new RoleItemContext
|
||||
{
|
||||
RoleId = rawData.RoleIds[i],
|
||||
IconName = iconName
|
||||
};
|
||||
}
|
||||
|
||||
RolePropertyAreaContext propertyContext = null;
|
||||
if (rawData.SelectedRoleId >= 0)
|
||||
{
|
||||
propertyContext = new RolePropertyAreaContext
|
||||
{
|
||||
RoleName = rawData.SelectedRoleName,
|
||||
InitialPropertyText = rawData.SelectedRoleInitialPropertyText
|
||||
};
|
||||
}
|
||||
|
||||
return new SelectRoleFormContext
|
||||
{
|
||||
RoleItemContexts = roleItems,
|
||||
RolePropertyAreaContext = propertyContext,
|
||||
RoleIds = rawData.RoleIds
|
||||
};
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
if (userData is SelectRoleFormContext selectRoleFormContext)
|
||||
{
|
||||
return OpenUIInternal(selectRoleFormContext);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("SelectRoleFormController.OpenUI() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("SelectRoleFormController.OpenUI() useCase is null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
SelectRoleFormRawData rawData = _useCase.CreateModel();
|
||||
SelectRoleFormContext context = BuildContext(rawData);
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (!(useCase is SelectRoleFormUseCase selectRoleUseCase))
|
||||
{
|
||||
Log.Error("SelectRoleUseCase.BindUseCase() useCase is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
_useCase = selectRoleUseCase;
|
||||
}
|
||||
|
||||
public void UpdateShowRole(RolePropertyAreaContext rolePropertyAreaContext)
|
||||
{
|
||||
if (Context == null)
|
||||
{
|
||||
Log.Error("SelectRoleFormController.UpdateShowRole() Context is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
Context.RolePropertyAreaContext = rolePropertyAreaContext;
|
||||
|
||||
Form?.UpdateShowRole(rolePropertyAreaContext);
|
||||
}
|
||||
|
||||
private bool IsCurrentFormEventSender(object sender)
|
||||
{
|
||||
if (sender is SelectRoleForm selectRoleForm)
|
||||
{
|
||||
return selectRoleForm == Form;
|
||||
}
|
||||
|
||||
if (sender is Component component && Form != null)
|
||||
{
|
||||
return component.transform.IsChildOf(Form.transform);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnMenuSelectRoleReturn(object sender, GameEventArgs e)
|
||||
{
|
||||
if ((SelectRoleForm)sender != Form || !(e is MenuSelectRoleReturnEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CloseUI();
|
||||
}
|
||||
|
||||
private void OnMenuSelectRoleSelected(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is MenuSelectRoleSelectedEventArgs args))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsCurrentFormEventSender(sender))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("SelectRoleFormController.OnMenuSelectRoleSelected() useCase is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
SelectRoleFormRawData rawData = _useCase.SelectRole(args.RoleId);
|
||||
SelectRoleFormContext context = BuildContext(rawData);
|
||||
if (context == null)
|
||||
{
|
||||
Log.Error("SelectRoleFormController.OnMenuSelectRoleSelected() context build failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
SetContext(context);
|
||||
UpdateShowRole(context.RolePropertyAreaContext);
|
||||
}
|
||||
|
||||
private void OnMenuSelectRoleConfirm(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is MenuSelectRoleConfirmEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsCurrentFormEventSender(sender))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_useCase == null)
|
||||
{
|
||||
Log.Error("SelectRoleFormController.OnMenuSelectRoleConfirm() useCase is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
_useCase.ConfirmSelectedRole();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff46cd6b508b0304a801223cbae79419
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f719ae636cc2724b94a834ae2407353
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,189 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using SepCore.Definition;
|
||||
using GameFramework.Localization;
|
||||
using StarForce;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class SettingForm : UGuiForm
|
||||
{
|
||||
[SerializeField] private Toggle _musicMuteToggle = null;
|
||||
[SerializeField] private Slider _musicVolumeSlider = null;
|
||||
|
||||
[SerializeField] private Toggle _soundMuteToggle = null;
|
||||
[SerializeField] private Slider _soundVolumeSlider = null;
|
||||
|
||||
[SerializeField] private Toggle _uiSoundMuteToggle = null;
|
||||
[SerializeField] private Slider _uiSoundVolumeSlider = null;
|
||||
|
||||
[SerializeField] private CanvasGroup _languageTipsCanvasGroup = null;
|
||||
|
||||
[SerializeField] private Toggle _englishToggle = null;
|
||||
[SerializeField] private Toggle _chineseSimplifiedToggle = null;
|
||||
[SerializeField] private Toggle _chineseTraditionalToggle = null;
|
||||
[SerializeField] private Toggle _koreanToggle = null;
|
||||
|
||||
private Language _selectedLanguage = Language.Unspecified;
|
||||
|
||||
public void OnMusicMuteChanged(bool isOn)
|
||||
{
|
||||
GameEntry.Sound.Mute("Music", !isOn);
|
||||
_musicVolumeSlider.gameObject.SetActive(isOn);
|
||||
}
|
||||
|
||||
public void OnMusicVolumeChanged(float volume)
|
||||
{
|
||||
GameEntry.Sound.SetVolume("Music", volume);
|
||||
}
|
||||
|
||||
public void OnSoundMuteChanged(bool isOn)
|
||||
{
|
||||
GameEntry.Sound.Mute("Sound", !isOn);
|
||||
_soundVolumeSlider.gameObject.SetActive(isOn);
|
||||
}
|
||||
|
||||
public void OnSoundVolumeChanged(float volume)
|
||||
{
|
||||
GameEntry.Sound.SetVolume("Sound", volume);
|
||||
}
|
||||
|
||||
public void OnUISoundMuteChanged(bool isOn)
|
||||
{
|
||||
GameEntry.Sound.Mute("UISound", !isOn);
|
||||
_uiSoundVolumeSlider.gameObject.SetActive(isOn);
|
||||
}
|
||||
|
||||
public void OnUISoundVolumeChanged(float volume)
|
||||
{
|
||||
GameEntry.Sound.SetVolume("UISound", volume);
|
||||
}
|
||||
|
||||
public void OnEnglishSelected(bool isOn)
|
||||
{
|
||||
if (!isOn)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_selectedLanguage = Language.English;
|
||||
RefreshLanguageTips();
|
||||
}
|
||||
|
||||
public void OnChineseSimplifiedSelected(bool isOn)
|
||||
{
|
||||
if (!isOn)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_selectedLanguage = Language.ChineseSimplified;
|
||||
RefreshLanguageTips();
|
||||
}
|
||||
|
||||
public void OnChineseTraditionalSelected(bool isOn)
|
||||
{
|
||||
if (!isOn)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_selectedLanguage = Language.ChineseTraditional;
|
||||
RefreshLanguageTips();
|
||||
}
|
||||
|
||||
public void OnKoreanSelected(bool isOn)
|
||||
{
|
||||
if (!isOn)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_selectedLanguage = Language.Korean;
|
||||
RefreshLanguageTips();
|
||||
}
|
||||
|
||||
public void OnSubmitButtonClick()
|
||||
{
|
||||
if (_selectedLanguage == GameEntry.Localization.Language)
|
||||
{
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Setting.SetString(Constant.Setting.Language, _selectedLanguage.ToString());
|
||||
GameEntry.Setting.Save();
|
||||
|
||||
GameEntry.Sound.StopMusic();
|
||||
UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Restart);
|
||||
}
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
protected override void OnOpen(object userData)
|
||||
#else
|
||||
protected internal override void OnOpen(object userData)
|
||||
#endif
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
_musicMuteToggle.isOn = !GameEntry.Sound.IsMuted("Music");
|
||||
_musicVolumeSlider.value = GameEntry.Sound.GetVolume("Music");
|
||||
|
||||
_soundMuteToggle.isOn = !GameEntry.Sound.IsMuted("Sound");
|
||||
_soundVolumeSlider.value = GameEntry.Sound.GetVolume("Sound");
|
||||
|
||||
_uiSoundMuteToggle.isOn = !GameEntry.Sound.IsMuted("UISound");
|
||||
_uiSoundVolumeSlider.value = GameEntry.Sound.GetVolume("UISound");
|
||||
|
||||
_selectedLanguage = GameEntry.Localization.Language;
|
||||
switch (_selectedLanguage)
|
||||
{
|
||||
case Language.English:
|
||||
_englishToggle.isOn = true;
|
||||
break;
|
||||
|
||||
case Language.ChineseSimplified:
|
||||
_chineseSimplifiedToggle.isOn = true;
|
||||
break;
|
||||
|
||||
case Language.ChineseTraditional:
|
||||
_chineseTraditionalToggle.isOn = true;
|
||||
break;
|
||||
|
||||
case Language.Korean:
|
||||
_koreanToggle.isOn = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_2017_3_OR_NEWER
|
||||
protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
#else
|
||||
protected internal override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
#endif
|
||||
{
|
||||
base.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
|
||||
if (_languageTipsCanvasGroup.gameObject.activeSelf)
|
||||
{
|
||||
_languageTipsCanvasGroup.alpha = 0.5f + 0.5f * Mathf.Sin(Mathf.PI * Time.time);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshLanguageTips()
|
||||
{
|
||||
_languageTipsCanvasGroup.gameObject.SetActive(_selectedLanguage != GameEntry.Localization.Language);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02bbd1c1f00c17842b1449ae2b66a932
|
||||
timeCreated: 1528026161
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88a351268ca28c14fb18659fe3d042d3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using CustomEvent;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class StartMenuForm : UGuiForm
|
||||
{
|
||||
public void RefreshUI(StartMenuFormContext context)
|
||||
{
|
||||
}
|
||||
|
||||
#region Lifecycle
|
||||
|
||||
protected override void OnOpen(object userData)
|
||||
{
|
||||
base.OnOpen(userData);
|
||||
|
||||
if (userData is StartMenuFormContext context)
|
||||
{
|
||||
RefreshUI(context);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Warning("StartMenuForm requires StartMenuFormContext as userData.");
|
||||
}
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
base.OnClose(isShutdown, userData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void OnStartButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, MenuStartGameEventArgs.Create());
|
||||
}
|
||||
|
||||
public void OnFileButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, MenuFileButtonClickEventArgs.Create());
|
||||
}
|
||||
|
||||
public void OnGuideButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, MenuGuideButtonClickEventArgs.Create());
|
||||
}
|
||||
|
||||
public void OnSettingButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, MenuSettingButtonClickEventArgs.Create());
|
||||
}
|
||||
|
||||
public void OnQuitButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, MenuQuitButtonClickEventArgs.Create());
|
||||
}
|
||||
|
||||
public void OnAboutButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, MenuAboutButtonClickEventArgs.Create());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d448bbb919fe8454da81331191044ead
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace UI
|
||||
{
|
||||
public class StartMenuFormContext : UIContext
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77a32872255d9f84b9332418d1352514
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,137 @@
|
||||
using CustomEvent;
|
||||
using SepCore.Definition;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class StartMenuFormController : UIFormControllerCommonBase<StartMenuFormContext, StartMenuForm>
|
||||
{
|
||||
protected override UIFormType UIFormTypeId => UIFormType.StartMenuForm;
|
||||
|
||||
protected override void RefreshUI(StartMenuForm form, StartMenuFormContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
protected override void SubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Subscribe(MenuStartGameEventArgs.EventId, OnMenuStartGameButtonClick);
|
||||
GameEntry.Event.Subscribe(MenuFileButtonClickEventArgs.EventId, OnMenuFileButtonClick);
|
||||
GameEntry.Event.Subscribe(MenuGuideButtonClickEventArgs.EventId, OnMenuGuideButtonClick);
|
||||
GameEntry.Event.Subscribe(MenuSettingButtonClickEventArgs.EventId, OnMenuSettingButtonClick);
|
||||
GameEntry.Event.Subscribe(MenuQuitButtonClickEventArgs.EventId, OnMenuQuitButtonClick);
|
||||
GameEntry.Event.Subscribe(MenuAboutButtonClickEventArgs.EventId, OnMenuAboutButtonClick);
|
||||
}
|
||||
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(MenuStartGameEventArgs.EventId, OnMenuStartGameButtonClick);
|
||||
GameEntry.Event.Unsubscribe(MenuFileButtonClickEventArgs.EventId, OnMenuFileButtonClick);
|
||||
GameEntry.Event.Unsubscribe(MenuGuideButtonClickEventArgs.EventId, OnMenuGuideButtonClick);
|
||||
GameEntry.Event.Unsubscribe(MenuSettingButtonClickEventArgs.EventId, OnMenuSettingButtonClick);
|
||||
GameEntry.Event.Unsubscribe(MenuQuitButtonClickEventArgs.EventId, OnMenuQuitButtonClick);
|
||||
GameEntry.Event.Unsubscribe(MenuAboutButtonClickEventArgs.EventId, OnMenuAboutButtonClick);
|
||||
}
|
||||
|
||||
private static StartMenuFormContext BuildStartMenuFormContext()
|
||||
{
|
||||
return new StartMenuFormContext();
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
if (userData is StartMenuFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("StartMenuFormController.OpenUI() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return OpenUIInternal(BuildStartMenuFormContext());
|
||||
}
|
||||
|
||||
public int? OpenUI(StartMenuFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
Log.Info("StartMenuForm doesn't need UseCase");
|
||||
}
|
||||
|
||||
private void OnMenuStartGameButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuStartGameEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.SelectRoleForm);
|
||||
}
|
||||
|
||||
private void OnMenuFileButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuFileButtonClickEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Warning("Menu file button click is not implemented.");
|
||||
}
|
||||
|
||||
private void OnMenuGuideButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuGuideButtonClickEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Warning("Menu guide button click is not implemented.");
|
||||
}
|
||||
|
||||
private void OnMenuSettingButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuSettingButtonClickEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.SettingForm);
|
||||
}
|
||||
|
||||
private void OnMenuQuitButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuQuitButtonClickEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.DialogForm, new DialogFormRawData
|
||||
{
|
||||
Mode = 2,
|
||||
Title = GameEntry.Localization.GetString("AskQuitGame.Title"),
|
||||
Message = GameEntry.Localization.GetString("AskQuitGame.Message"),
|
||||
OnClickConfirm = delegate(object userData)
|
||||
{
|
||||
UnityGameFramework.Runtime.GameEntry.Shutdown(ShutdownType.Quit);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void OnMenuAboutButtonClick(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is StartMenuForm) || !(e is MenuAboutButtonClickEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Warning("Menu about button click is not implemented.");
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3feee66cf220f6f47b147bca4f7967f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user