summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/OptionsMenuBehaviour.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/OptionsMenuBehaviour.cs')
-rw-r--r--Client/Assembly-CSharp/OptionsMenuBehaviour.cs200
1 files changed, 200 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/OptionsMenuBehaviour.cs b/Client/Assembly-CSharp/OptionsMenuBehaviour.cs
new file mode 100644
index 0000000..fffe2b4
--- /dev/null
+++ b/Client/Assembly-CSharp/OptionsMenuBehaviour.cs
@@ -0,0 +1,200 @@
+using System;
+using UnityEngine;
+
+public class OptionsMenuBehaviour : MonoBehaviour, ITranslatedText
+{
+ public bool IsOpen
+ {
+ get
+ {
+ return base.isActiveAndEnabled;
+ }
+ }
+
+ public SpriteRenderer Background;
+
+ public SpriteRenderer JoystickButton;
+
+ public SpriteRenderer TouchButton;
+
+ public SlideBar JoystickSizeSlider;
+
+ public FloatRange JoystickSizes = new FloatRange(0.5f, 1.5f);
+
+ public SlideBar SoundSlider;
+
+ public SlideBar MusicSlider;
+
+ public ToggleButtonBehaviour SendTelemButton;
+
+ public ToggleButtonBehaviour PersonalizedAdsButton;
+
+ public ToggleButtonBehaviour CensorChatButton;
+
+ public bool Toggle = true;
+
+ public TabGroup[] Tabs;
+
+ public void OpenTabGroup(TabGroup selected)
+ {
+ selected.Open();
+ for (int i = 0; i < this.Tabs.Length; i++)
+ {
+ TabGroup tabGroup = this.Tabs[i];
+ if (!(tabGroup == selected))
+ {
+ tabGroup.Close();
+ }
+ }
+ }
+
+ private void Update()
+ {
+ if (Input.GetKeyUp(KeyCode.Escape))
+ {
+ this.Close();
+ }
+ }
+
+ public void Start()
+ {
+ DestroyableSingleton<TranslationController>.Instance.ActiveTexts.Add(this);
+ }
+
+ public void OnDestroy()
+ {
+ DestroyableSingleton<TranslationController>.Instance.ActiveTexts.Remove(this);
+ }
+
+ public void ResetText()
+ {
+ this.JoystickButton.transform.parent.GetComponentInChildren<TextRenderer>().Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.SettingsMouseMode, Array.Empty<object>());
+ this.TouchButton.transform.parent.GetComponentInChildren<TextRenderer>().Text = DestroyableSingleton<TranslationController>.Instance.GetString(StringNames.SettingsKeyboardMode, Array.Empty<object>());
+ this.JoystickSizeSlider.gameObject.SetActive(false);
+ }
+
+ public void Open()
+ {
+ this.ResetText();
+ if (base.gameObject.activeSelf)
+ {
+ if (this.Toggle)
+ {
+ base.GetComponent<TransitionOpen>().Close();
+ }
+ return;
+ }
+ this.OpenTabGroup(this.Tabs[0]);
+ this.UpdateButtons();
+ base.gameObject.SetActive(true);
+ }
+
+ public void SetControlType(int i)
+ {
+ SaveManager.TouchConfig = i;
+ this.UpdateButtons();
+ if (DestroyableSingleton<HudManager>.InstanceExists)
+ {
+ DestroyableSingleton<HudManager>.Instance.SetTouchType(i);
+ }
+ }
+
+ public void UpdateJoystickSize(SlideBar slider)
+ {
+ SaveManager.JoystickSize = this.JoystickSizes.Lerp(slider.Value);
+ if (DestroyableSingleton<HudManager>.InstanceExists)
+ {
+ DestroyableSingleton<HudManager>.Instance.SetJoystickSize(SaveManager.JoystickSize);
+ }
+ }
+
+ public void ToggleSendTelemetry()
+ {
+ SaveManager.SendTelemetry = !SaveManager.SendTelemetry;
+ this.UpdateButtons();
+ }
+
+ public void ToggleSendName()
+ {
+ SaveManager.SendName = !SaveManager.SendName;
+ this.UpdateButtons();
+ }
+
+ public void UpdateSfxVolume(SlideBar button)
+ {
+ SaveManager.SfxVolume = button.Value;
+ SoundManager.Instance.ChangeSfxVolume(button.Value);
+ }
+
+ public void UpdateMusicVolume(SlideBar button)
+ {
+ SaveManager.MusicVolume = button.Value;
+ SoundManager.Instance.ChangeMusicVolume(button.Value);
+ }
+
+ public void TogglePersonalizedAd()
+ {
+ ShowAdsState showAdsState = SaveManager.ShowAdsScreen & (ShowAdsState)127;
+ if (showAdsState != ShowAdsState.Personalized)
+ {
+ if (showAdsState == ShowAdsState.NonPersonalized)
+ {
+ SaveManager.ShowAdsScreen = ShowAdsState.Accepted;
+ goto IL_30;
+ }
+ if (showAdsState == ShowAdsState.Purchased)
+ {
+ goto IL_30;
+ }
+ }
+ SaveManager.ShowAdsScreen = (ShowAdsState)129;
+ IL_30:
+ this.UpdateButtons();
+ }
+
+ public void ToggleCensorChat()
+ {
+ SaveManager.CensorChat = !SaveManager.CensorChat;
+ this.UpdateButtons();
+ }
+
+ public void UpdateButtons()
+ {
+ if (SaveManager.TouchConfig == 0)
+ {
+ this.JoystickButton.color = new Color32(0, byte.MaxValue, 42, byte.MaxValue);
+ this.TouchButton.color = Color.white;
+ this.JoystickSizeSlider.enabled = true;
+ this.JoystickSizeSlider.OnEnable();
+ }
+ else
+ {
+ this.JoystickButton.color = Color.white;
+ this.TouchButton.color = new Color32(0, byte.MaxValue, 42, byte.MaxValue);
+ this.JoystickSizeSlider.enabled = false;
+ this.JoystickSizeSlider.OnDisable();
+ }
+ this.JoystickSizeSlider.Value = this.JoystickSizes.ReverseLerp(SaveManager.JoystickSize);
+ this.SoundSlider.Value = SaveManager.SfxVolume;
+ this.MusicSlider.Value = SaveManager.MusicVolume;
+ if (this.SendTelemButton)
+ {
+ this.SendTelemButton.UpdateText(SaveManager.SendTelemetry);
+ }
+ this.CensorChatButton.UpdateText(SaveManager.CensorChat);
+ if (this.PersonalizedAdsButton)
+ {
+ if (SaveManager.ShowAdsScreen.HasFlag(ShowAdsState.Purchased) || SaveManager.BoughtNoAds)
+ {
+ this.PersonalizedAdsButton.transform.parent.gameObject.SetActive(false);
+ return;
+ }
+ this.PersonalizedAdsButton.UpdateText(!SaveManager.ShowAdsScreen.HasFlag(ShowAdsState.NonPersonalized));
+ }
+ }
+
+ public void Close()
+ {
+ base.gameObject.SetActive(false);
+ }
+}