From a22c505984697881f5f911a165ee022087b69e09 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 20 May 2024 22:36:58 +0800 Subject: *rename --- Thronefall_v1.0/Decompile/SettingsUIHelper.cs | 114 ++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Thronefall_v1.0/Decompile/SettingsUIHelper.cs (limited to 'Thronefall_v1.0/Decompile/SettingsUIHelper.cs') diff --git a/Thronefall_v1.0/Decompile/SettingsUIHelper.cs b/Thronefall_v1.0/Decompile/SettingsUIHelper.cs new file mode 100644 index 0000000..1156f53 --- /dev/null +++ b/Thronefall_v1.0/Decompile/SettingsUIHelper.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class SettingsUIHelper : MonoBehaviour +{ + [Serializable] + public class SettingsTab + { + public TFUITextButton parentElement; + + public VerticalLayoutGroup childContainer; + + public void ComputeNavigationForSettingsTab() + { + List list = new List(); + foreach (Transform item in childContainer.transform) + { + list.Add(item.GetComponent()); + } + parentElement.botNav = list[0]; + parentElement.topNav = list[list.Count - 1]; + for (int i = 0; i < list.Count; i++) + { + ThronefallUIElement thronefallUIElement = list[i]; + if (i == 0) + { + thronefallUIElement.topNav = parentElement; + } + else + { + thronefallUIElement.topNav = list[i - 1]; + } + if (i == list.Count - 1) + { + thronefallUIElement.botNav = parentElement; + } + else + { + thronefallUIElement.botNav = list[i + 1]; + } + } + } + } + + public UIFrame targetFrame; + + public SettingsTab videoTab; + + public SettingsTab audioTab; + + public SettingsTab gameplayTab; + + public SettingsTab controlsTab; + + public GameObject dimBG; + + private SettingsTab currentSelectedTab; + + private Dictionary allTabs = new Dictionary(); + + private void Awake() + { + allTabs.Add(videoTab.parentElement, videoTab); + allTabs.Add(audioTab.parentElement, audioTab); + allTabs.Add(gameplayTab.parentElement, gameplayTab); + allTabs.Add(controlsTab.parentElement, controlsTab); + videoTab.childContainer.gameObject.SetActive(value: false); + audioTab.childContainer.gameObject.SetActive(value: false); + gameplayTab.childContainer.gameObject.SetActive(value: false); + controlsTab.childContainer.gameObject.SetActive(value: false); + RecomputeAllNavigation(); + } + + private void RecomputeAllNavigation() + { + videoTab.ComputeNavigationForSettingsTab(); + audioTab.ComputeNavigationForSettingsTab(); + gameplayTab.ComputeNavigationForSettingsTab(); + controlsTab.ComputeNavigationForSettingsTab(); + } + + public void OnShow() + { + if (SceneTransitionManager.instance.CurrentSceneState == SceneTransitionManager.SceneState.MainMenu) + { + dimBG.SetActive(value: false); + } + else + { + dimBG.SetActive(value: true); + } + } + + public void OnSelect() + { + SettingsTab value = null; + if (allTabs.TryGetValue(targetFrame.CurrentSelection, out value)) + { + if (currentSelectedTab != null) + { + currentSelectedTab.childContainer.gameObject.SetActive(value: false); + currentSelectedTab.parentElement.applyOverrideStyle = false; + } + currentSelectedTab = value; + currentSelectedTab.childContainer.gameObject.SetActive(value: true); + } + else if (currentSelectedTab != null) + { + currentSelectedTab.parentElement.applyOverrideStyle = true; + } + } +} -- cgit v1.1-26-g67d0