summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/OptionsMenuBehaviour.cs
blob: fffe2b4e24eaf6172e585e903e69a5f3349ec95d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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);
	}
}