Init
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SettingsWindow : MonoBehaviour
|
||||
{
|
||||
[Header("Panels")]
|
||||
public GameObject generalPanel;
|
||||
public GameObject audioPanel;
|
||||
public GameObject graphicsPanel;
|
||||
public GameObject displayPanel;
|
||||
|
||||
[Header("Tab Buttons")]
|
||||
public Button generalTab;
|
||||
public Button audioTab;
|
||||
public Button graphicsTab;
|
||||
public Button displayTab;
|
||||
|
||||
[Header("Action Buttons")]
|
||||
public Button applyButton;
|
||||
public Button cancelButton;
|
||||
public Button defaultsButton;
|
||||
public Button quitButton;
|
||||
|
||||
private GameObject currentPanel;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ǩҳ<C7A9><D2B3>ť
|
||||
generalTab.onClick.AddListener(() => SwitchPanel(generalPanel));
|
||||
audioTab.onClick.AddListener(() => SwitchPanel(audioPanel));
|
||||
graphicsTab.onClick.AddListener(() => SwitchPanel(graphicsPanel));
|
||||
displayTab.onClick.AddListener(() => SwitchPanel(displayPanel));
|
||||
|
||||
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
|
||||
applyButton.onClick.AddListener(ApplyAllSettings);
|
||||
cancelButton.onClick.AddListener(CloseWindow);
|
||||
defaultsButton.onClick.AddListener(ResetToDefaults);
|
||||
quitButton.onClick.AddListener(() => { Application.Quit(); });
|
||||
|
||||
// Ĭ<>ϴ<CFB4>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SwitchPanel(generalPanel);
|
||||
}
|
||||
|
||||
private void SwitchPanel(GameObject newPanel)
|
||||
{
|
||||
if (currentPanel != null)
|
||||
currentPanel.SetActive(false);
|
||||
|
||||
newPanel.SetActive(true);
|
||||
currentPanel = newPanel;
|
||||
UpdateTabButtons();
|
||||
}
|
||||
|
||||
private void UpdateTabButtons()
|
||||
{
|
||||
generalTab.interactable = currentPanel != generalPanel;
|
||||
audioTab.interactable = currentPanel != audioPanel;
|
||||
graphicsTab.interactable = currentPanel != graphicsPanel;
|
||||
displayTab.interactable = currentPanel != displayPanel;
|
||||
}
|
||||
|
||||
public void ApplyAllSettings()
|
||||
{
|
||||
// Ӧ<><D3A6><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ִ<EFBFBD>У<EFBFBD>
|
||||
displayPanel.GetComponent<DisplayPanel>().ApplySettings();
|
||||
|
||||
// Ӧ<><D3A6>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
graphicsPanel.GetComponent<GraphicsPanel>().ApplySettings();
|
||||
|
||||
// Ӧ<><D3A6><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>
|
||||
audioPanel.GetComponent<AudioPanel>().ApplySettings();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SettingsManager.Instance.SaveSettings();
|
||||
|
||||
CloseWindow();
|
||||
}
|
||||
|
||||
public void CloseWindow()
|
||||
{
|
||||
// <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
|
||||
SettingsManager.Instance.LoadSettings();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
public void ResetToDefaults()
|
||||
{
|
||||
SettingsManager.Instance.ResetToDefaultSettings();
|
||||
SwitchPanel(currentPanel); // ˢ<>µ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user