2025-09-29 07:45:07 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class SettingsWindow : UIBaseWindow
|
|
|
|
|
{
|
|
|
|
|
[Header("Panels")]
|
|
|
|
|
public GeneralPanel generalPanel;
|
|
|
|
|
public AudioPanel audioPanel;
|
|
|
|
|
public GraphicsPanel graphicsPanel;
|
|
|
|
|
|
|
|
|
|
[Header("Tab Buttons")]
|
|
|
|
|
public Button generalTab;
|
|
|
|
|
public Button audioTab;
|
|
|
|
|
public Button graphicsTab;
|
|
|
|
|
|
|
|
|
|
[Header("Action Buttons")]
|
|
|
|
|
public Button applyButton;
|
|
|
|
|
public Button cancelButton;
|
|
|
|
|
public Button defaultsButton;
|
|
|
|
|
public Button quitButton;
|
|
|
|
|
|
|
|
|
|
private UIBasePanel currentPanel;
|
|
|
|
|
bool init = false;
|
|
|
|
|
|
|
|
|
|
protected override void OnShow()
|
|
|
|
|
{
|
|
|
|
|
if (!init)
|
|
|
|
|
{
|
|
|
|
|
generalTab.onClick.AddListener(() => SwitchPanel(generalPanel));
|
|
|
|
|
audioTab.onClick.AddListener(() => SwitchPanel(audioPanel));
|
|
|
|
|
graphicsTab.onClick.AddListener(() => SwitchPanel(graphicsPanel));
|
|
|
|
|
|
|
|
|
|
applyButton.onClick.AddListener(ApplyAllSettings);
|
2025-09-29 11:03:26 +08:00
|
|
|
cancelButton.onClick.AddListener(() => { UIManager.Inst.HideWindow(nameof(SettingsWindow)); });
|
2025-09-29 07:45:07 +08:00
|
|
|
defaultsButton.onClick.AddListener(ResetToDefaults);
|
|
|
|
|
quitButton.onClick.AddListener(() => { Application.Quit(); });
|
|
|
|
|
}
|
|
|
|
|
SwitchPanel(generalPanel);
|
|
|
|
|
base.OnShow();
|
2025-10-09 11:54:18 +08:00
|
|
|
GameSystem.Inst.UpdateCursorState(false);
|
|
|
|
|
}
|
|
|
|
|
protected override void OnHide()
|
|
|
|
|
{
|
|
|
|
|
GameSystem.Inst.UpdateCursorState(true);
|
2025-09-29 07:45:07 +08:00
|
|
|
}
|
|
|
|
|
private void SwitchPanel(UIBasePanel newPanel)
|
|
|
|
|
{
|
|
|
|
|
if (currentPanel != null)
|
2025-10-09 07:51:05 +08:00
|
|
|
{
|
|
|
|
|
currentPanel.Hide();
|
|
|
|
|
}
|
|
|
|
|
newPanel.Show();
|
2025-09-29 07:45:07 +08:00
|
|
|
currentPanel = newPanel;
|
|
|
|
|
UpdateTabButtons();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateTabButtons()
|
|
|
|
|
{
|
|
|
|
|
generalTab.interactable = currentPanel != generalPanel;
|
|
|
|
|
audioTab.interactable = currentPanel != audioPanel;
|
|
|
|
|
graphicsTab.interactable = currentPanel != graphicsPanel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ApplyAllSettings()
|
|
|
|
|
{
|
2025-10-09 07:51:05 +08:00
|
|
|
SettingsManager.Inst.ApplyAllSettings();
|
2025-09-29 11:03:26 +08:00
|
|
|
UIManager.Inst.HideWindow(nameof(SettingsWindow));
|
2025-09-29 07:45:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ResetToDefaults()
|
|
|
|
|
{
|
|
|
|
|
SettingsManager.Inst.ResetToDefaultSettings();
|
|
|
|
|
SwitchPanel(currentPanel);
|
|
|
|
|
}
|
|
|
|
|
}
|