- 添加 MainForm
- 添加 ResolutionAdapterComponent 进行屏幕分辨率适配
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
using GeometryTD.CustomEvent;
|
||||
using GeometryTD.Definition;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace GeometryTD.UI
|
||||
{
|
||||
public class MainFormController : UIFormControllerCommonBase<MainFormContext, MainForm>
|
||||
{
|
||||
protected override UIFormType UIFormTypeId => UIFormType.MainForm;
|
||||
|
||||
protected override void RefreshUI(MainForm form, MainFormContext context)
|
||||
{
|
||||
form.RefreshUI(context);
|
||||
}
|
||||
|
||||
protected override void SubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Subscribe(ReturnButtonClickedEventArgs.EventId, OnReturnButtonClicked);
|
||||
GameEntry.Event.Subscribe(RepoButtonClickedEventArgs.EventId, OnRepoButtonClicked);
|
||||
}
|
||||
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(ReturnButtonClickedEventArgs.EventId, OnReturnButtonClicked);
|
||||
GameEntry.Event.Unsubscribe(RepoButtonClickedEventArgs.EventId, OnRepoButtonClicked);
|
||||
}
|
||||
|
||||
public override int? OpenUI(object userData = null)
|
||||
{
|
||||
if (userData is MainFormContext context)
|
||||
{
|
||||
return OpenUIInternal(context);
|
||||
}
|
||||
|
||||
if (userData != null)
|
||||
{
|
||||
Log.Warning("MainFormController.OpenUI() userData type is invalid.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return OpenUIInternal(BuildDefaultContext());
|
||||
}
|
||||
|
||||
public override void BindUseCase(IUIUseCase useCase)
|
||||
{
|
||||
if (useCase != null)
|
||||
{
|
||||
Log.Warning("MainFormController does not use a use case.");
|
||||
}
|
||||
}
|
||||
|
||||
private static MainFormContext BuildDefaultContext()
|
||||
{
|
||||
return new MainFormContext();
|
||||
}
|
||||
|
||||
private void OnReturnButtonClicked(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is MainForm) || !(e is ReturnButtonClickedEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO:游戏 UI 返回菜单 UI
|
||||
//GameEntry.UIRouter.CloseUI(UIFormType.MainForm);
|
||||
}
|
||||
|
||||
private void OnRepoButtonClicked(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(sender is MainForm) || !(e is RepoButtonClickedEventArgs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.UIRouter.OpenUI(UIFormType.RepoForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88a17d9010c944a8a0123f31ed09f7d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user