TH1/Unity/Assets/Scripts/TH1_UI/Controller/Top/UITopSettingController.cs
2026-04-24 15:05:02 +08:00

92 lines
2.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 文件位置建议: Assets/Scripts/TH1_UI/Controller/UIAnnounceMajorEventController.cs
using TH1_Core.Events;
using TH1_Logic.Core;
using TH1_UI.Controller.Base;
using TH1_UI.View.Bottom;
using TH1_UI.View.Top;
using TH1Renderer;
using UnityEngine;
// 确保这里引用了View脚本的命名空间
namespace TH1_UI.Controller.Top
{
public class UITopSettingController : ViewController<UITopSettingView> // 泛型参数是对应的View脚本
{
/// <summary>
/// ✅ 【新增】一个空的构造函数,以满足 ViewControllerManager._CreateView 的 new() 泛型约束。
/// </summary>
public UITopSettingController() { }
protected override void RegisterEventCallback()
{
base.RegisterEventCallback();
if (WindowScript != null)
{
WindowScript.OnBtnCloseClick += _OnBtnCloseClick;
WindowScript.OnBtnRepairRendererClick += _OnBtnRepairRendererClick;
}
}
protected override void UnregisterEventCallback()
{
if (WindowScript != null)
{
WindowScript.OnBtnCloseClick = null;
WindowScript.OnBtnRepairRendererClick = null;
}
base.UnregisterEventCallback();
}
protected override void OnOpen()
{
base.OnOpen();
//WindowScript.SetContent();
// 检查暂存的参数是否存在且类型正确
if (_openParameter is ShowUITopSetting evt)
{
// 使用接收到的数据设置UI内容
if (WindowScript != null)
{
//Main.PlayerLogic.CalcAllPlayerScore(Main.MapData);
WindowScript.SetContent();
}
}
else
{
// 如果没有参数或参数类型不符,可以提供默认内容或打印警告
Debug.LogWarning("[UIInfoTechTree] Opened without valid parameters.");
if (WindowScript != null)
{
//WindowScript.SetContent("警告", "内容未提供");
}
}
}
public override bool Close()
{
WindowScript?.CloseView();
return base.Close();
}
void _OnBtnCloseClick()
{
Close();
}
// 一键修复画面错误:重建 UnitRenderer / CityInfoRenderer刷新全部 GridRenderer。
// 用于 Unit 贴图未消失、CityInfo 数据不同步等画面与数据层不一致的情况。
void _OnBtnRepairRendererClick()
{
if (MapRenderer.Instance != null)
{
MapRenderer.Instance.RepairAllRenderers();
}
}
}
}