diff options
Diffstat (limited to 'Client/Assembly-CSharp/StringOption.cs')
-rw-r--r-- | Client/Assembly-CSharp/StringOption.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/StringOption.cs b/Client/Assembly-CSharp/StringOption.cs new file mode 100644 index 0000000..e2faa3e --- /dev/null +++ b/Client/Assembly-CSharp/StringOption.cs @@ -0,0 +1,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; + } +} |