From 9800af46062297e12acb6bf98035f79c77ee6bc1 Mon Sep 17 00:00:00 2001 From: Lily Date: Sun, 26 Jun 2022 14:33:51 -0400 Subject: [PATCH] Allow a component's Tooltip to be modified --- UI/QuickMenu/ReMenuButton.cs | 23 +++++++++++++++++------ UI/QuickMenu/ReMenuSlider.cs | 18 +++++++++++++++--- UI/QuickMenu/ReMenuToggle.cs | 18 +++++++++++++++--- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/UI/QuickMenu/ReMenuButton.cs b/UI/QuickMenu/ReMenuButton.cs index 67a2da5..3307180 100644 --- a/UI/QuickMenu/ReMenuButton.cs +++ b/UI/QuickMenu/ReMenuButton.cs @@ -33,6 +33,18 @@ public string Text get => _text.text; set => _text.SetText(value); } + + private VRC.UI.Elements.Tooltips.UiTooltip _tooltip; + + public string Tooltip { + get => _tooltip != null ? _tooltip.field_Public_String_0 : ""; + set + { + if (_tooltip == null) return; + _tooltip.field_Public_String_0 = value; + _tooltip.field_Public_String_1 = value; + } + } private readonly StyleElement _styleElement; private readonly Button _button; @@ -99,20 +111,19 @@ public ReMenuButton(string text, string tooltip, Action onClick, Transform paren Object.DestroyImmediate(RectTransform.Find("Badge_MMJump").gameObject); var uiTooltips = GameObject.GetComponents(); - VRC.UI.Elements.Tooltips.UiTooltip uiTooltip = null; if (uiTooltips.Length > 0) { //Fuck tooltips, all my friends hate tooltips - uiTooltip = uiTooltips[0]; + _tooltip = uiTooltips[0]; - for(int i=1; i _tooltip != null ? _tooltip.field_Public_String_0 : ""; + set + { + if (_tooltip == null) return; + _tooltip.field_Public_String_0 = value; + _tooltip.field_Public_String_1 = value; + } + } public ReMenuSlider(string text, string tooltip, Action onSlide, Transform parent, float defaultValue = 0, float minValue = 0, float maxValue = 10) : base(QuickMenuEx.SliderPrefab, parent, $"Slider_{text}") { @@ -35,9 +47,9 @@ public ReMenuSlider(string text, string tooltip, Action onSlide, Transfor _sliderComponent.maxValue = maxValue; _sliderComponent.value = defaultValue; - var uiTooltip = GameObject.GetComponent(); - uiTooltip.field_Public_String_0 = tooltip; - uiTooltip.field_Public_String_1 = tooltip; + _tooltip = GameObject.GetComponent(); + _tooltip.field_Public_String_0 = tooltip; + _tooltip.field_Public_String_1 = tooltip; Slide(defaultValue,false); diff --git a/UI/QuickMenu/ReMenuToggle.cs b/UI/QuickMenu/ReMenuToggle.cs index 2985d7a..6493984 100644 --- a/UI/QuickMenu/ReMenuToggle.cs +++ b/UI/QuickMenu/ReMenuToggle.cs @@ -43,6 +43,18 @@ public string Text get => _textComponent.text; set => _textComponent.text = value; } + + private VRC.UI.Elements.Tooltips.UiToggleTooltip _tooltip; + + public string Tooltip { + get => _tooltip != null ? _tooltip.field_Public_String_0 : ""; + set + { + if (_tooltip == null) return; + _tooltip.field_Public_String_0 = value; + _tooltip.field_Public_String_1 = value; + } + } public ReMenuToggle(string text, string tooltip, Action onToggle, Transform parent, bool defaultValue = false) : base(QuickMenuEx.TogglePrefab, parent, $"Button_Toggle{text}") { @@ -67,9 +79,9 @@ public ReMenuToggle(string text, string tooltip, Action onToggle, Transfor _textComponent.m_fontColor = new Color(0.4157f, 0.8902f, 0.9765f, 1f); _textComponent.m_htmlColor = new Color(0.4157f, 0.8902f, 0.9765f, 1f); - var uiTooltip = GameObject.GetComponent(); - uiTooltip.field_Public_String_0 = tooltip; - uiTooltip.field_Public_String_1 = tooltip; + _tooltip = GameObject.GetComponent(); + _tooltip.field_Public_String_0 = tooltip; + _tooltip.field_Public_String_1 = tooltip; Toggle(defaultValue,false);