合并 MenuForm 的 6 个按钮事件为 MenuButtonClickEventArgs
新增 MenuButtonId 枚举区分按钮来源,MenuController 改为单订阅 + switch 分派,删除 Menu{StartGame,File,Guide,Setting,Quit,About}EventArgs 及其 meta。MenuForm 的 OnXxxButtonClick 方法名按 prefab 反射绑定保留,仅薄薄转发到统一事件。
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.Event
|
||||
{
|
||||
/// <summary>
|
||||
/// MenuForm 上所有按钮共用的点击事件,按 <see cref="Button"/> 区分来源。
|
||||
/// 每新增按钮请同步扩展 <see cref="MenuButtonId"/>,并在 MenuController 中处理。
|
||||
/// </summary>
|
||||
public class MenuButtonClickEventArgs : GameEventArgs
|
||||
{
|
||||
public static readonly int EventId = typeof(MenuButtonClickEventArgs).GetHashCode();
|
||||
|
||||
public override int Id => EventId;
|
||||
|
||||
public MenuButtonId Button { get; private set; }
|
||||
|
||||
public static MenuButtonClickEventArgs Create(MenuButtonId button)
|
||||
{
|
||||
var args = ReferencePool.Acquire<MenuButtonClickEventArgs>();
|
||||
args.Button = button;
|
||||
return args;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
Button = MenuButtonId.Undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user