77 lines
2.3 KiB
C#
77 lines
2.3 KiB
C#
|
|
using UnityEngine.UIElements;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using OnlyScove.Scripts;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace Hallucinate.UI
|
||
|
|
{
|
||
|
|
public class PauseMenuController : BaseUIController
|
||
|
|
{
|
||
|
|
private Button _resumeBtn;
|
||
|
|
private Button _quitBtn;
|
||
|
|
|
||
|
|
public override void Initialize(VisualElement uxmlRoot, UIManager manager)
|
||
|
|
{
|
||
|
|
base.Initialize(uxmlRoot, manager);
|
||
|
|
|
||
|
|
_resumeBtn = root.Q<Button>("ResumeBtn");
|
||
|
|
_quitBtn = root.Q<Button>("QuitBtn");
|
||
|
|
|
||
|
|
if (_resumeBtn != null) _resumeBtn.clicked += OnResumeClicked;
|
||
|
|
if (_quitBtn != null) _quitBtn.clicked += OnQuitClicked;
|
||
|
|
|
||
|
|
ApplyLocalization();
|
||
|
|
if (LocalizationManager.Instance != null)
|
||
|
|
LocalizationManager.Instance.OnLanguageChanged += ApplyLocalization;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnDestroy()
|
||
|
|
{
|
||
|
|
if (LocalizationManager.Instance != null)
|
||
|
|
LocalizationManager.Instance.OnLanguageChanged -= ApplyLocalization;
|
||
|
|
}
|
||
|
|
|
||
|
|
private void ApplyLocalization()
|
||
|
|
{
|
||
|
|
if (_resumeBtn != null) _resumeBtn.text = GetLoc("PAUSE_RESUME");
|
||
|
|
if (_quitBtn != null) _quitBtn.text = GetLoc("PAUSE_QUIT");
|
||
|
|
|
||
|
|
var title = root.Q<Label>("PauseTitle");
|
||
|
|
if (title != null) title.text = GetLoc("PAUSE_TITLE");
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnResumeClicked()
|
||
|
|
{
|
||
|
|
uiManager.TogglePauseMenu();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void OnQuitClicked()
|
||
|
|
{
|
||
|
|
Debug.Log("[PauseMenu] Quit clicked - shutting down runner.");
|
||
|
|
if (BasicSpawner.Instance != null && BasicSpawner.Instance.Runner != null)
|
||
|
|
{
|
||
|
|
BasicSpawner.Instance.Runner.Shutdown();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
uiManager.OnBackToMenu();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public override async Task PlayTransitionIn()
|
||
|
|
{
|
||
|
|
Show();
|
||
|
|
root.style.opacity = 0;
|
||
|
|
PrimeTween.Tween.Custom(0f, 1f, duration: 0.2f, onValueChange: val => root.style.opacity = val);
|
||
|
|
await Task.Delay(200);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override async Task PlayTransitionOut()
|
||
|
|
{
|
||
|
|
PrimeTween.Tween.Custom(1f, 0f, duration: 0.2f, onValueChange: val => root.style.opacity = val);
|
||
|
|
await Task.Delay(200);
|
||
|
|
Hide();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|