4 protected string m_sTitleWidgetName;
7 protected string m_sDescriptionWidgetName;
10 protected string m_sIconWidgetName;
13 protected string m_sToggleButtonWidgetName;
16 protected string m_sContextButtonWidgetName;
19 protected string m_sTimeLeftWidgetName;
22 protected string m_sPageWidgetName;
25 protected string m_sVisibilitySelectorName;
28 protected string m_sColorWidgetName;
30 [
Attribute(
"Name of a widget under the same parent in which highlights will be created.\nOptional; when undefined, highlights will be created directly in workspace.")]
31 protected string m_sHighlightParentWidgetName;
33 [
Attribute(uiwidget: UIWidgets.LocaleEditBox)]
36 [
Attribute(uiwidget: UIWidgets.LocaleEditBox)]
39 [
Attribute(
"1",
desc:
"When enabled, the widget will show currently shown hint opn init.\nWhen disabled, currently shown hint will be cleared upon init.")]
40 protected bool m_bPreserveCurrentHint;
43 protected ResourceName m_HighlightLayout;
45 [
Attribute(defvalue:
"0.76078 0.39216 0.07843 1.0", UIWidgets.ColorPicker,
desc:
"Reforger default color")]
46 protected ref Color m_cReforgerColor;
48 [
Attribute(defvalue:
"0.760006 0.392004 0.078004 1.000000", UIWidgets.ColorPicker,
desc:
"Color of the time bar")]
49 protected ref Color m_cTimerColor;
51 protected Widget m_Widget;
52 protected TextWidget m_NameWidget;
53 protected TextWidget m_DescriptionWidget;
54 protected ImageWidget m_IconWidget;
55 protected Widget m_HighlightParentWidget;
56 protected ref array<Widget> m_aHighlightWidgets;
57 protected Widget m_ToggleButtonWidget;
58 protected Widget m_ContextButtonWidget;
59 protected TextWidget m_PageWidget;
60 protected SizeLayoutWidget m_TimeWidget;
62 protected ImageWidget m_BarColor;
64 protected MenuBase m_Menu;
66 protected bool m_bMenuScanned;
67 protected Widget m_VisibilitySelector;
69 protected bool m_bIsHintShown;
78 m_bMenuScanned =
true;
82 m_Widget.SetVisible(
true);
85 m_OnHintShown.Invoke(
true);
87 m_bIsHintShown =
true;
89 if (m_Widget.IsVisibleInHierarchy() && info && info.HasDescription() && (!m_Menu || m_Menu.IsFocused()))
91 bool showName = info.SetNameTo(m_NameWidget);
92 bool showDescription = info.SetDescriptionTo(m_DescriptionWidget);
93 bool showIcon = info.SetIconTo(m_IconWidget);
95 m_NameWidget.SetVisible(showName);
96 m_DescriptionWidget.SetVisible(showDescription);
97 m_IconWidget.SetVisible(showIcon);
101 int sequencePage = info.GetSequencePage();
102 int sequenceCount = info.GetSequenceCount();
104 if (sequenceCount > 1)
106 m_PageWidget.SetTextFormat(m_sPageText, sequencePage, sequenceCount);
107 m_PageWidget.SetVisible(
true);
108 showNextButton = sequenceCount != sequencePage;
112 m_PageWidget.SetVisible(
false);
115 m_ProgressBar.StopProgressAnimation();
118 m_ToggleButton.SetLabel(m_ToggleButtonTextNext);
120 m_ToggleButton.SetLabel(m_ToggleButtonTextHide);
125 WorldTimestamp currentTime = world.GetServerTimestamp();
126 if (info.GetTimeStarted() != 0 || currentTime == info.GetTimeStarted() || info.GetDuration() == -1 || !info.IsTimerVisible())
129 duration = info.GetDuration();
133 int timeDifferenceFromStart = currentTime.DiffMilliseconds(info.GetTimeStarted());
134 startvalue = 1 - timeDifferenceFromStart / info.GetDuration() / 1000;
135 duration = info.GetDuration() - timeDifferenceFromStart / 1000;
138 if (info.IsTimerVisible() && m_TimeWidget)
140 m_TimeWidget.SetVisible(
true);
141 m_BarColor.SetColor(m_cTimerColor);
142 m_ProgressBar.SetValue(startvalue,
false);
143 m_ProgressBar.SetAnimationTime(duration);
144 m_ProgressBar.SetValue(0);
146 else if (m_TimeWidget)
148 m_TimeWidget.SetVisible(
false);
152 m_VisibilitySelector.SetVisible(
false);
154 m_VisibilitySelector.SetVisible(
true);
156 if (info.GetDuration() == -1 || !info.IsTimerVisible())
158 m_BarColor.SetColor(m_cReforgerColor);
159 m_ProgressBar.SetValue(1,
false);
162 AnimateWidget.Opacity(m_Widget, 1,
UIConstants.FADE_RATE_FAST);
165 if (m_HighlightLayout)
166 GetGame().GetCallqueue().CallLater(CreateHighlights, 1,
false, info);
173 OnHintHide(info, isSilent);
180 AnimateWidget.Opacity(m_Widget, 0,
UIConstants.FADE_RATE_DEFAULT,
true);
182 if (m_aHighlightWidgets)
184 foreach (Widget hightlightWidget: m_aHighlightWidgets)
186 if (hightlightWidget)
187 hightlightWidget.RemoveFromHierarchy();
192 m_OnHintShown.Invoke(
false);
194 m_bIsHintShown =
false;
200 if (!m_HighlightParentWidget && m_sHighlightParentWidgetName)
201 m_HighlightParentWidget = m_Widget.GetParent().FindAnyWidget(m_sHighlightParentWidgetName);
203 array<string> hightlightWidgetNames = {};
204 m_aHighlightWidgets = {};
205 Widget hightlightWidget;
206 for (
int i, count = info.GetHighlightWidgetNames(hightlightWidgetNames); i < count; i++)
209 if (hightlightWidget)
210 m_aHighlightWidgets.Insert(hightlightWidget);
215 override bool OnClick(Widget w,
int x,
int y,
int button)
219 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
221 hintManager.Toggle();
225 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
227 hintManager.OpenContext();
234 protected void OnInputDeviceIsGamepad(
bool isGamepad)
236 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
238 hintManager.Refresh();
242 override void HandlerAttached(Widget w)
246 m_ToggleButtonWidget = m_Widget.FindAnyWidget(m_sToggleButtonWidgetName);
249 m_ToggleButton.SetLabel(m_ToggleButtonTextHide);
254 m_Widget.SetOpacity(0);
255 m_Widget.SetVisible(
false);
257 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
261 m_NameWidget = TextWidget.Cast(m_Widget.FindAnyWidget(m_sTitleWidgetName));
262 m_DescriptionWidget = TextWidget.Cast(m_Widget.FindAnyWidget(m_sDescriptionWidgetName));
264 m_ContextButtonWidget = m_Widget.FindAnyWidget(m_sContextButtonWidgetName);
265 m_PageWidget = TextWidget.Cast(m_Widget.FindAnyWidget(m_sPageWidgetName));
266 m_sPageText = m_PageWidget.GetText();
267 m_TimeWidget = SizeLayoutWidget.Cast(m_Widget.FindAnyWidget(m_sTimeLeftWidgetName));
268 m_VisibilitySelector = m_Widget.FindAnyWidget(m_sVisibilitySelectorName);
269 m_BarColor = ImageWidget.Cast(m_Widget.FindAnyWidget(m_sColorWidgetName));
272 hintManager.GetOnHintShow().Insert(OnHintShow);
273 hintManager.GetOnHintHide().Insert(OnHintHide);
278 if (m_bPreserveCurrentHint)
281 OnHintShow(currentHint,
true);
283 else if (!currentHint.IsInSequence())
290 GetGame().OnInputDeviceIsGamepadInvoker().Insert(OnInputDeviceIsGamepad);
294 override void HandlerDeattached(Widget w)
296 GetGame().OnInputDeviceIsGamepadInvoker().Remove(OnInputDeviceIsGamepad);
298 SCR_HintManagerComponent hintManager = SCR_HintManagerComponent.GetInstance();
302 hintManager.GetOnHintShow().Remove(OnHintShow);
303 hintManager.GetOnHintHide().Remove(OnHintHide);
312 return m_OnHintShown;
318 return m_bIsHintShown;