2025-10-03 00:02:43 -04:00
|
|
|
|
using System;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
using Continentis;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
using Continentis.MainGame;
|
|
|
|
|
|
using I2.Loc;
|
2026-04-17 12:01:50 -04:00
|
|
|
|
using SLSUtilities.General;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using UnityEngine;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
using UnityEngine.Serialization;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.Menu
|
|
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
public class MenuManager : Singleton<MenuManager>
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
private const string CombatSceneName = "GameScene";
|
|
|
|
|
|
|
|
|
|
|
|
[Header("主菜单按钮")]
|
|
|
|
|
|
[FormerlySerializedAs("enterGameButton")]
|
|
|
|
|
|
public Button newGameButton;
|
|
|
|
|
|
public Button loadGameButton;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("面板")]
|
|
|
|
|
|
public ConfirmOverrideRunPanel confirmOverrideRunPanel;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("跑局配置")]
|
|
|
|
|
|
[Tooltip("新游戏使用的 RunConfig 资产")]
|
|
|
|
|
|
public RunConfig runConfig;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("语言设置")]
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public string languageToSet;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
|
|
|
|
|
|
// ── 生命周期 ──────────────────────────────────────────────────────
|
|
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
private void Start()
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
if (string.IsNullOrEmpty(languageToSet))
|
|
|
|
|
|
languageToSet = "Simplified Chinese";
|
2025-10-23 00:49:44 -04:00
|
|
|
|
LocalizationManager.CurrentLanguage = languageToSet;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
|
|
|
|
|
|
newGameButton.onClick.AddListener(OnNewGameClicked);
|
|
|
|
|
|
loadGameButton.onClick.AddListener(OnContinueClicked);
|
|
|
|
|
|
|
|
|
|
|
|
RefreshButtons();
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2026-04-01 12:23:27 -04:00
|
|
|
|
|
|
|
|
|
|
// ── 按钮事件 ──────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 新游戏按钮:若已有进行中的跑局则弹出确认框,否则直接开始。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void OnNewGameClicked()
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2026-04-01 12:23:27 -04:00
|
|
|
|
if (SaveManager.Instance.HasActiveRun())
|
|
|
|
|
|
confirmOverrideRunPanel.Show(StartNewRun);
|
|
|
|
|
|
else
|
|
|
|
|
|
StartNewRun();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>继续游戏按钮:设置意图后加载战斗场景。</summary>
|
|
|
|
|
|
private void OnContinueClicked()
|
|
|
|
|
|
{
|
|
|
|
|
|
InfoTransistor.Instance.menuToMainGame.menuIntent = InfoTransistor.Menu.MenuIntent.ContinueRun;
|
|
|
|
|
|
InfoTransistor.Instance.menuToMainGame.pendingRunConfig = null;
|
|
|
|
|
|
SceneManager.LoadScene(CombatSceneName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ── 内部方法 ──────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>根据存档状态刷新按钮可交互性。</summary>
|
|
|
|
|
|
private void RefreshButtons()
|
|
|
|
|
|
{
|
|
|
|
|
|
bool hasActiveRun = SaveManager.Instance.HasActiveRun();
|
|
|
|
|
|
newGameButton.interactable = true;
|
|
|
|
|
|
loadGameButton.interactable = hasActiveRun;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>写入意图并加载战斗场景,由新游戏流程调用。</summary>
|
|
|
|
|
|
private void StartNewRun()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (runConfig == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError("[Menu] 未指定 RunConfig,无法开始新跑局。请在 MenuManager Inspector 中赋值。");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InfoTransistor.Instance.menuToMainGame.menuIntent = InfoTransistor.Menu.MenuIntent.StartNewRun;
|
|
|
|
|
|
InfoTransistor.Instance.menuToMainGame.pendingRunConfig = runConfig;
|
|
|
|
|
|
SceneManager.LoadScene(CombatSceneName);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-04-01 12:23:27 -04:00
|
|
|
|
}
|