summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/StringOption.cs
blob: e2faa3e5f5ece0b434fb2696fa336431d739c332 (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
using System;
using UnityEngine;

public class StringOption : OptionBehaviour
{
	public TextRenderer TitleText;

	public TextRenderer ValueText;

	public string[] Values;

	public int Value;

	private int oldValue = -1;

	public void OnEnable()
	{
		this.TitleText.Text = DestroyableSingleton<TranslationController>.Instance.GetString(this.Title, Array.Empty<object>());
		this.ValueText.Text = this.Values[this.Value];
		GameOptionsData gameOptions = PlayerControl.GameOptions;
		StringNames title = this.Title;
		if (title == StringNames.GameMapName)
		{
			this.Value = (int)gameOptions.MapId;
			return;
		}
		if (title == StringNames.GameKillDistance)
		{
			this.Value = gameOptions.KillDistance;
			return;
		}
		Debug.Log("Ono, unrecognized setting: " + this.Title);
	}

	private void FixedUpdate()
	{
		if (this.oldValue != this.Value)
		{
			this.oldValue = this.Value;
			this.ValueText.Text = this.Values[this.Value];
		}
	}

	public void Increase()
	{
		this.Value = Mathf.Clamp(this.Value + 1, 0, this.Values.Length - 1);
		this.OnValueChanged(this);
	}

	public void Decrease()
	{
		this.Value = Mathf.Clamp(this.Value - 1, 0, this.Values.Length - 1);
		this.OnValueChanged(this);
	}

	public override int GetInt()
	{
		return this.Value;
	}
}