summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/ToggleButtonBehaviour.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-12-30 20:59:04 +0800
committerchai <chaifix@163.com>2020-12-30 20:59:04 +0800
commite9ea621b93fbb58d9edfca8375918791637bbd52 (patch)
tree19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/ToggleButtonBehaviour.cs
+init
Diffstat (limited to 'Client/Assembly-CSharp/ToggleButtonBehaviour.cs')
-rw-r--r--Client/Assembly-CSharp/ToggleButtonBehaviour.cs42
1 files changed, 42 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/ToggleButtonBehaviour.cs b/Client/Assembly-CSharp/ToggleButtonBehaviour.cs
new file mode 100644
index 0000000..4703e3e
--- /dev/null
+++ b/Client/Assembly-CSharp/ToggleButtonBehaviour.cs
@@ -0,0 +1,42 @@
+using System;
+using UnityEngine;
+
+public class ToggleButtonBehaviour : MonoBehaviour, ITranslatedText
+{
+ public StringNames BaseText;
+
+ public TextRenderer Text;
+
+ public SpriteRenderer Background;
+
+ public ButtonRolloverHandler Rollover;
+
+ private bool onState;
+
+ public void Start()
+ {
+ DestroyableSingleton<TranslationController>.Instance.ActiveTexts.Add(this);
+ }
+
+ public void OnDestroy()
+ {
+ DestroyableSingleton<TranslationController>.Instance.ActiveTexts.Remove(this);
+ }
+
+ public void ResetText()
+ {
+ this.Text.Text = DestroyableSingleton<TranslationController>.Instance.GetString(this.BaseText, Array.Empty<object>()) + ": " + DestroyableSingleton<TranslationController>.Instance.GetString(this.onState ? StringNames.SettingsOn : StringNames.SettingsOff, Array.Empty<object>());
+ }
+
+ public void UpdateText(bool on)
+ {
+ this.onState = on;
+ Color color = on ? new Color(0f, 1f, 0.16470589f, 1f) : Color.white;
+ this.Background.color = color;
+ this.ResetText();
+ if (this.Rollover)
+ {
+ this.Rollover.OutColor = color;
+ }
+ }
+}