101 lines
2.8 KiB
C#
101 lines
2.8 KiB
C#
// 文件位置建议: Assets/Scripts/TH1_UI/Controller/UIAnnounceMajorEventController.cs
|
|
|
|
using TH1_Core.Events;
|
|
using TH1_UI.Controller.Base;
|
|
using TH1_UI.View.Info;
|
|
using UnityEngine;
|
|
|
|
// 确保这里引用了View脚本的命名空间
|
|
|
|
namespace TH1_UI.Controller.Info
|
|
{
|
|
/// <summary>
|
|
/// 外交界面控制器 - 支持Esc/右键关闭
|
|
/// </summary>
|
|
public class UIInfoDiplomacyController : ViewController<UIInfoDiplomacyView>, IEscClosable
|
|
{
|
|
|
|
/// <summary>
|
|
/// ✅ 【新增】一个空的构造函数,以满足 ViewControllerManager._CreateView 的 new() 泛型约束。
|
|
/// </summary>
|
|
public UIInfoDiplomacyController() { }
|
|
|
|
protected override void RegisterEventCallback()
|
|
{
|
|
base.RegisterEventCallback();
|
|
if (WindowScript != null)
|
|
{
|
|
WindowScript.OnBtnCloseClick = _OnBtnCloseClick;
|
|
}
|
|
|
|
}
|
|
|
|
protected override void UnregisterEventCallback()
|
|
{
|
|
if (WindowScript != null)
|
|
{
|
|
WindowScript.OnBtnCloseClick = null;
|
|
}
|
|
base.UnregisterEventCallback();
|
|
}
|
|
|
|
protected override void OnOpen()
|
|
{
|
|
base.OnOpen();
|
|
// 检查暂存的参数是否存在且类型正确
|
|
if (_openParameter is ShowUIInfoDiplomacy evt)
|
|
{
|
|
// 使用接收到的数据设置UI内容
|
|
if (WindowScript != null)
|
|
{
|
|
WindowScript.SetContent(evt.Pid);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 如果没有参数或参数类型不符,可以提供默认内容或打印警告
|
|
Debug.LogWarning("[UIInfoDiplomacy] Opened without valid parameters.");
|
|
if (WindowScript != null)
|
|
{
|
|
|
|
//WindowScript.SetContent("警告", "内容未提供");
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool Close()
|
|
{
|
|
//Debug.Log("GetCLose!!!!!!!!!!");
|
|
WindowScript.CloseView();
|
|
return base.Close();
|
|
}
|
|
|
|
|
|
void _OnBtnCloseClick()
|
|
{
|
|
Close();
|
|
}
|
|
|
|
#region IEscClosable Implementation
|
|
|
|
/// <summary>
|
|
/// 外交界面可以通过Esc/右键关闭
|
|
/// </summary>
|
|
public bool CanCloseByEsc()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭外交界面时清理地图高亮
|
|
/// </summary>
|
|
public void CancelMapHighlightsOrDoNothing()
|
|
{
|
|
|
|
// 外交界面没有特殊的地图高亮需要清理
|
|
// 如果需要取消玩家/城市的选中状态,可以在这里添加
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |