- 添加对话表结构
- 调整部分类的命名空间 - 引入 EnumUtility 用于string与enum的转换
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
using CustomComponent;
|
||||
using GameFramework.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class CombineFormController : IFormController<CombineFormContext>
|
||||
{
|
||||
private CombineComponent _controller;
|
||||
|
||||
private CombineForm _combineForm;
|
||||
|
||||
private int? _formSerialId;
|
||||
|
||||
private CombineFormContext _context;
|
||||
|
||||
public CombineFormController(CombineComponent controller)
|
||||
{
|
||||
_controller = controller;
|
||||
|
||||
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||
GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||
}
|
||||
|
||||
public int? OpenUI(CombineFormContext context)
|
||||
{
|
||||
if (_controller == null)
|
||||
{
|
||||
_controller = GameEntry.Combine;
|
||||
}
|
||||
|
||||
if (_controller == null)
|
||||
{
|
||||
Log.Warning("CombineFormController open failed. Controller is null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
_controller.SetFormContext(context);
|
||||
}
|
||||
|
||||
_context = _controller.GetFormContext();
|
||||
if (_context == null)
|
||||
{
|
||||
Log.Warning("CombineFormController open failed. Form context is null.");
|
||||
return null;
|
||||
}
|
||||
|
||||
_formSerialId = GameEntry.UI.OpenUIForm(UIFormId.CombineForm, _context);
|
||||
return _formSerialId;
|
||||
}
|
||||
|
||||
public void CloseUI()
|
||||
{
|
||||
if (_formSerialId.HasValue)
|
||||
{
|
||||
GameEntry.UI.CloseUIForm(_formSerialId.Value);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_combineForm != null)
|
||||
{
|
||||
_combineForm.Close();
|
||||
}
|
||||
}
|
||||
|
||||
~CombineFormController()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
|
||||
GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
|
||||
}
|
||||
|
||||
private void OpenUIFormSuccess(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is OpenUIFormSuccessEventArgs args)) return;
|
||||
|
||||
if (args.UserData == _context)
|
||||
{
|
||||
_combineForm = args.UIForm.Logic as CombineForm;
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseUIFormComplete(object sender, GameEventArgs e)
|
||||
{
|
||||
if (!(e is CloseUIFormCompleteEventArgs args)) return;
|
||||
|
||||
if (args.SerialId == _formSerialId)
|
||||
{
|
||||
_combineForm = null;
|
||||
_formSerialId = null;
|
||||
_context = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff5681c108fbc6c4680287e385ddaa12
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user