From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/ToggleButtonBehaviour.cs | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Client/Assembly-CSharp/ToggleButtonBehaviour.cs (limited to 'Client/Assembly-CSharp/ToggleButtonBehaviour.cs') 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.Instance.ActiveTexts.Add(this); + } + + public void OnDestroy() + { + DestroyableSingleton.Instance.ActiveTexts.Remove(this); + } + + public void ResetText() + { + this.Text.Text = DestroyableSingleton.Instance.GetString(this.BaseText, Array.Empty()) + ": " + DestroyableSingleton.Instance.GetString(this.onState ? StringNames.SettingsOn : StringNames.SettingsOff, Array.Empty()); + } + + 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; + } + } +} -- cgit v1.1-26-g67d0