第一批重构,主要是物理迁移脚本和部分命名空间的调整
- 结构上迁移文件,将脚本分成 Base/Runtime/Presentation/Procedure/Editor 五大文件夹 - 调整 DataTable 和 Definition 下脚本的命名空间 - 依据 UI-5层架构设计规范 拆分原先的 UI 到 Runtime 和 Presentation 下
This commit is contained in:
@@ -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