4 ref SCR_ScriptedWidgetTooltipPreset m_Preset;
6 [
Attribute(
"{87037226B1A2064B}UI/layouts/WidgetLibrary/Buttons/WLib_NavigationButtonSuperSmall.layout",
params:
"layout")]
7 protected ResourceName m_sButtonsLayout;
10 protected ref array<ref SCR_BrowserTooltipButtonPresetData> m_aButtons;
12 [
Attribute(
"1.000000 1.000000 1.000000 1.000000", UIWidgets.ColorPicker)]
13 protected ref Color m_ButtonsColor;
16 protected float m_fButtonsOpacity;
19 protected int m_iButtonsPadding;
21 protected Widget m_wTooltip;
22 protected Widget m_wTooltipContent;
23 protected Widget m_wInputsLayout;
24 protected Widget m_wMessageLayout;
25 protected RichTextWidget m_wMessage;
27 protected ref array<ref SCR_BrowserTooltipButtonPresetData> m_aScriptButtons = {};
28 protected ref map<string, SCR_InputButtonComponent> m_aButtonComponents =
new map<string, SCR_InputButtonComponent>();
32 Widget CreateTooltip()
38 SCR_ETooltipAlignmentVertical verticalAlignment;
39 vector offset = vector.Zero;
62 foreach (SCR_BrowserTooltipButtonPresetData buttonPreset :
m_aButtons)
75 void ForceDeleteTooltip()
81 protected SCR_InputButtonComponent CreateButton(SCR_BrowserTooltipButtonPresetData buttonPreset, Widget buttonContainer,
int padding)
92 AlignableSlot.SetPadding(w, padding, 0, 0, 0);
98 GetGame().GetWorkspace().RemoveChild(w);
102 comp.SetVisible(buttonPreset.m_bShowButton,
false);
103 comp.SetLabel(buttonPreset.m_sLabel);
104 comp.SetAction(buttonPreset.UpdateDisplayedAction());
107 comp.SetEnabled(
false);
125 SCR_BrowserTooltipButtonPresetData FindButtonPresetData(
string tag)
127 foreach (SCR_BrowserTooltipButtonPresetData button : m_aButtons)
129 if (button.m_sTag == tag)
138 SCR_InputButtonComponent AddButton(
string tag,
string label,
string actionName,
string actionNameMouse =
string.Empty,
bool showButton =
true)
144 SCR_BrowserTooltipButtonPresetData buttonPreset =
new SCR_BrowserTooltipButtonPresetData();
145 buttonPreset.SetData(tag, label, actionName, actionNameMouse, showButton);
158 bool RemoveButton(
string tag)
169 m_wTooltip.RemoveChild(button.GetRootWidget());
176 SCR_BrowserTooltipButtonPresetData AddSetupButton(
string tag,
string label,
string actionName,
string actionNameMouse =
string.Empty,
bool showButton =
true)
178 SCR_BrowserTooltipButtonPresetData buttonPreset =
new SCR_BrowserTooltipButtonPresetData;
179 buttonPreset.SetData(tag, label, actionName, actionNameMouse, showButton);
182 foreach (SCR_BrowserTooltipButtonPresetData button : m_aButtons)
184 if (button.m_sTag == tag)
195 bool RemoveSetupButton(
string tag)
197 foreach (SCR_BrowserTooltipButtonPresetData buttonPreset : m_aScriptButtons)
199 if (tag == buttonPreset.m_sTag)
212 void ClearSetupButtons()
214 foreach (SCR_BrowserTooltipButtonPresetData buttonPreset : m_aScriptButtons)
224 void UpdateAllButtonActions()
226 foreach (SCR_BrowserTooltipButtonPresetData buttonData : m_aButtons)
228 UpdateButtonAction(buttonData.m_sTag);
234 void UpdateButtonAction(
string tag)
237 SCR_BrowserTooltipButtonPresetData buttonData = FindButtonPresetData(tag);
242 string actionName = buttonData.UpdateDisplayedAction();
245 button.SetAction(actionName);
256 bool SetMessage(
string message)
264 SetMessageVisible(!message.IsEmpty());
269 bool SetMessageVisible(
bool newVisible)
274 bool visible = newVisible && !GetMessage().IsEmpty();
292 bool IsMessageVisible()
307 class SCR_BrowserTooltipButtonPresetData
309 [
Attribute(
desc:
"Custom tag, used for finding this button at run time")]
318 [
Attribute(
desc:
"Action name the button will display when using mouse")]
319 string m_sActionNameMouse;
324 protected string m_sActionToDisplay;
327 void SetData(
string tag,
string label,
string actionName,
string actionNameMouse,
bool showButton)
332 m_sActionNameMouse = actionNameMouse;
333 m_bShowButton = showButton;
337 string GetDisplayedAction()
339 return m_sActionToDisplay;
343 string UpdateDisplayedAction()
348 EInputDeviceType inputDeviceType =
GetGame().GetInputManager().GetLastUsedInputDevice();
350 if (inputDeviceType == EInputDeviceType.MOUSE && !m_sActionNameMouse.IsEmpty())
351 m_sActionToDisplay = m_sActionNameMouse;
355 return m_sActionToDisplay;