From 8b1fc7063b387542803c6bc214ccf8acb32870bd Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Sun, 19 May 2024 16:46:27 +0800 Subject: * rename --- .../Decompile/PerkSelectionTooltipHelper.cs | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Thronefall_1_0/Decompile/PerkSelectionTooltipHelper.cs (limited to 'Thronefall_1_0/Decompile/PerkSelectionTooltipHelper.cs') diff --git a/Thronefall_1_0/Decompile/PerkSelectionTooltipHelper.cs b/Thronefall_1_0/Decompile/PerkSelectionTooltipHelper.cs new file mode 100644 index 0000000..9ea47af --- /dev/null +++ b/Thronefall_1_0/Decompile/PerkSelectionTooltipHelper.cs @@ -0,0 +1,115 @@ +using I2.Loc; +using MPUIKIT; +using TMPro; +using UnityEngine; +using UnityEngine.UI; + +public class PerkSelectionTooltipHelper : MonoBehaviour +{ + public UIFrame targetFrame; + + public TextMeshProUGUI selectionTitle; + + public TextMeshProUGUI selectionDescription; + + public Image selectionIcon; + + public MPImageBasic background; + + public UIParentResizer sizer; + + public bool disableOnNullSelect; + + public GameObject tooltipParent; + + private TFUIEquippable currentElement; + + public void OnSelection() + { + if (targetFrame.CurrentSelection == null) + { + return; + } + TFUIEquippable tFUIEquippable = targetFrame.CurrentSelection as TFUIEquippable; + if (tFUIEquippable == null) + { + if (disableOnNullSelect) + { + tooltipParent.SetActive(value: false); + } + return; + } + if ((bool)tooltipParent) + { + tooltipParent.SetActive(value: true); + } + currentElement = tFUIEquippable; + UpdateTooltip(); + } + + public void OnFocus() + { + if (targetFrame.CurrentFocus == null) + { + OnSelection(); + return; + } + if ((bool)tooltipParent) + { + tooltipParent.SetActive(value: true); + } + TFUIEquippable tFUIEquippable = targetFrame.CurrentFocus as TFUIEquippable; + if (tFUIEquippable == null) + { + if (disableOnNullSelect) + { + tooltipParent.SetActive(value: false); + } + } + else + { + currentElement = tFUIEquippable; + UpdateTooltip(); + } + } + + public void UpdateTooltip() + { + if (currentElement == null) + { + return; + } + string text = ""; + string text2 = ""; + Equippable data = currentElement.Data; + if (currentElement.Locked) + { + text = LocalizationManager.GetTranslation("Menu/Locked"); + text2 = LocalizationManager.GetTranslation("Menu/Locked Choice Description"); + if (data is EquippableWeapon) + { + text2 = LocalizationManager.GetTranslation("Menu/Locked Weapon Description"); + } + else if (data is EquippablePerk) + { + text2 = LocalizationManager.GetTranslation("Menu/Locked Perk Description"); + } + else if (data is EquippableMutation) + { + text2 = LocalizationManager.GetTranslation("Menu/Locked Mutator Description"); + } + selectionIcon.sprite = currentElement.IconImg.sprite; + } + else + { + text = LocalizationManager.GetTranslation(data.LOCIDENTIFIER_NAME); + text2 = LocalizationManager.GetTranslation(data.LOCIDENTIFIER_DESCRIPTION); + selectionIcon.sprite = data.icon; + } + selectionTitle.text = text; + selectionDescription.text = text2; + background.color = currentElement.GetBackgroundColor; + selectionIcon.color = currentElement.GetIconColor; + sizer.Trigger(); + } +} -- cgit v1.1-26-g67d0