Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InputButtonDisplay.c
Go to the documentation of this file.
1 class SCR_InputButtonDisplay : ScriptedWidgetComponent
2 {
3  protected const float HOLD_ANIMATION_FAILED_ANIMATION_SPEED = -2.5;
4 
5  //Key data
6  protected BaseContainer m_KeyData;
7  protected string m_sButtonText;
8  protected ref array<ref SCR_ButtonTexture> m_aButtonTextures = {};
9  protected SCR_EButtonSize m_eButtonType;
10  protected ResourceName m_sButtonLayoutConfig;
11  protected SCR_InputButtonStyle m_ButtonLayout;
12 
13  protected ref array<ImageWidget> m_aAdditionalWidgets = {};
14 
15  protected int m_iWidth;
16  protected float m_fMediumButtonWidhtModifier = 1.5;
17  protected float m_fLargeButtonWidhtModifier = 1.78;
18  protected float m_fButtonTextSizeModifier = 3;
19 
20  float m_fAnimationRate;
21  float m_fAnimationTime;
22  protected float m_fMaxHoldtime;
23  protected float m_fDoubleTapTime;
24  protected float m_fHoldIndicatorDefaultPosition[2];
25  protected float m_fHoldIndicatorAnimationPosition[2];
26 
27  protected bool m_bIsHoldAction;
28  protected bool m_bIsHoldActionOnce;
29  protected bool m_bIsDoubleTapAction;
30  protected bool m_bPressedInput;
31  protected bool m_bCanBeToggled;
32  protected bool m_bIsContinuous;
33  protected bool m_bIsToggled;
34  protected bool m_bIsOverwritten;
35 
36  protected SCR_InputButtonComponent m_InputButtonComp;
37  protected WidgetAnimationAlphaMask m_HoldingAnimation;
38  protected WidgetAnimationPosition m_HoldIndicatorAnimation;
39 
40  protected Widget m_wRoot;
41  protected Widget m_wParent;
42 
43  protected OverlayWidget m_wOverlay;
44  protected OverlayWidget m_wShadowOverlay;
45  protected ImageWidget m_wGlow;
46  protected ImageWidget m_wOutlineClear;
47  protected ImageWidget m_wOutline;
48  protected ImageWidget m_wKeyBG;
49  protected ImageWidget m_wDoubleTabIndicator;
50  protected ImageWidget m_wButtonImgGlow;
51  protected ImageWidget m_wButtonImg;
52  protected ImageWidget m_wHoldIndicator;
53  protected RichTextWidget m_wButtonText;
54 
55  //------------------------------------------------------------------------------------------------
56  override void HandlerAttached(Widget w)
57  {
58  super.HandlerAttached(w);
59 
60  m_wRoot = w;
61 
62  m_wOverlay = OverlayWidget.Cast(m_wRoot.FindAnyWidget("m_Overlay"));
63  m_wShadowOverlay = OverlayWidget.Cast(m_wRoot.FindAnyWidget("Shadow_Overlay"));
64  m_wGlow = ImageWidget.Cast(m_wRoot.FindAnyWidget("m_Glow"));
65  m_wOutlineClear = ImageWidget.Cast(m_wRoot.FindAnyWidget("m_OutlineClear"));
66  m_wOutline = ImageWidget.Cast(m_wRoot.FindAnyWidget("m_Outline"));
67  m_wKeyBG = ImageWidget.Cast(m_wRoot.FindAnyWidget("m_KeyBG"));
68  m_wDoubleTabIndicator = ImageWidget.Cast(m_wRoot.FindAnyWidget("m_DoubleTabIndicator"));
69  m_wButtonImgGlow = ImageWidget.Cast(m_wRoot.FindAnyWidget("m_ButtonImgGlow"));
70  m_wButtonImg = ImageWidget.Cast(m_wRoot.FindAnyWidget("m_ButtonImg"));
71  m_wHoldIndicator = ImageWidget.Cast(m_wRoot.FindAnyWidget("m_HoldIndicator"));
72  m_wButtonText = RichTextWidget.Cast(m_wRoot.FindAnyWidget("m_ButtonText"));
73  }
74 
75  //------------------------------------------------------------------------------------------------
78  void Init(Widget parent)
79  {
80  m_wParent = parent;
81  if (!m_wParent)
82  return;
83 
84  m_InputButtonComp = SCR_InputButtonComponent.Cast(m_wParent.FindHandler(SCR_InputButtonComponent));
85  if (!m_InputButtonComp)
86  return;
87 
88  m_fAnimationRate = m_InputButtonComp.GetAnimationRate();
89  m_fAnimationTime = m_InputButtonComp.GetAnimationTime();
90 
91  m_InputButtonComp.GetOnAnimateHover().Insert(AnimateHover);
92  m_InputButtonComp.GetOnUpdateEnableColor().Insert(UpdateEnableColor);
93  m_InputButtonComp.GetOnHoldAnimComplete().Insert(AnimateClick);
94  }
95 
96  //------------------------------------------------------------------------------------------------
101  bool SetAction(BaseContainer data, BaseContainer filter)
102  {
103  GetFilter(filter);
104 
105  data.Get("m_sText", m_sButtonText);
106  data.Get("m_aTextures", m_aButtonTextures);
107  data.Get("m_eType", m_eButtonType);
108 
109  GameProject.GetModuleConfig("ChimeraGlobalConfig").Get("InputButtonLayoutConfig", m_sButtonLayoutConfig);
110 
111  Resource resource = BaseContainerTools.LoadContainer(m_sButtonLayoutConfig);
112  if (!resource || !resource.IsValid())
113  {
114  Print("Cannot load " + m_sButtonLayoutConfig + " | " + FilePath.StripPath(__FILE__) + ":" + __LINE__, LogLevel.WARNING);
115  return false;
116  }
117 
118  SCR_InputButtonLayoutConfig m_cInput = SCR_InputButtonLayoutConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(resource.GetResource().ToBaseContainer()));
119 
120  m_ButtonLayout = m_cInput.GetButtonSize(m_eButtonType);
121 
122  m_fHoldIndicatorDefaultPosition = {0, m_InputButtonComp.m_fHoldIndicatorDefaultPosition};
123  m_fHoldIndicatorAnimationPosition = {0, m_InputButtonComp.m_fHoldIndicatorHoldPosition};
124 
125  if (!m_ButtonLayout || m_bIsOverwritten)
126  return false;
127 
129  ApplyTextureToButton();
130 
131  m_wOutline.SetVisible(m_bIsHoldAction);
132  m_wHoldIndicator.SetVisible(m_bIsHoldAction);
133  m_wOutlineClear.SetVisible(m_bIsHoldAction);
134  m_wDoubleTabIndicator.SetVisible(m_bIsDoubleTapAction);
135 
137  GetGame().GetCallqueue().Call(UpdateEnableColor);
138 
139  return false;
140  }
141 
142  //------------------------------------------------------------------------------------------------
145  void OverrideTexture(string imagePath, string image = string.Empty, Color color = Color.White)
146  {
147  m_bIsOverwritten = true;
148 
149  GameProject.GetModuleConfig("ChimeraGlobalConfig").Get("InputButtonLayoutConfig", m_sButtonLayoutConfig);
150 
151  Resource resource = BaseContainerTools.LoadContainer(m_sButtonLayoutConfig);
152  if (!resource || !resource.IsValid())
153  {
154  Print("Cannot load " + m_sButtonLayoutConfig + " | " + FilePath.StripPath(__FILE__) + ":" + __LINE__, LogLevel.WARNING);
155  return;
156  }
157 
158  SCR_InputButtonLayoutConfig m_cInput = SCR_InputButtonLayoutConfig.Cast(BaseContainerTools.CreateInstanceFromContainer(resource.GetResource().ToBaseContainer()));
159  if (!m_cInput)
160  {
161  Print("Wrong config type " + m_sButtonLayoutConfig + " | " + FilePath.StripPath(__FILE__) + ":" + __LINE__, LogLevel.WARNING);
162  return;
163  }
164 
165  m_eButtonType = SCR_EButtonSize.KEYBOARD_MEDIUM;
166  m_ButtonLayout = m_cInput.GetButtonSize(m_eButtonType);
167 
168  if (!m_ButtonLayout)
169  return;
170 
171  DeleteAdditionalWidgets();
172 
173  m_wKeyBG.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sKeyBackground);
174  m_wOutline.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sKeyOutline);
175  m_wOutlineClear.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sKeyOutline);
176  m_wGlow.LoadImageFromSet(0, m_ButtonLayout.m_sGlowImageSet, m_ButtonLayout.m_sGlow);
177  m_wHoldIndicator.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sHoldIndicator);
178 
179  GetWidth();
180 
181  m_wKeyBG.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
182  m_wOutline.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
183  m_wOutlineClear.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
184  m_wGlow.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
185  m_wHoldIndicator.SetSize(m_InputButtonComp.m_iHeightInPixel, (m_InputButtonComp.m_iHeightInPixel * 0.5));
186 
187  m_wButtonText.SetVisible(false);
188 
189  if (image)
190  m_wButtonImg.LoadImageFromSet(0, imagePath, image);
191  else
192  m_wButtonImg.LoadImageTexture(0, imagePath);
193 
194  m_wButtonImg.SetColor(Color.FromInt(color.PackToInt()));
195  m_wButtonImg.SetVisible(true);
196  m_wButtonImg.SetSize(m_InputButtonComp.m_iHeightInPixel * 0.5, m_InputButtonComp.m_iHeightInPixel * 0.5);
197  }
198 
199  //------------------------------------------------------------------------------------------------
202  void Resize()
203  {
204  GetWidth();
205 
206  m_wKeyBG.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
207  m_wOutline.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
208  m_wOutlineClear.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
209  m_wGlow.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
210  m_wHoldIndicator.SetSize(m_InputButtonComp.m_iHeightInPixel, (m_InputButtonComp.m_iHeightInPixel * 0.5));
211 
212  if (m_bIsOverwritten)
213  {
214  m_wButtonImg.SetSize(m_InputButtonComp.m_iHeightInPixel * 0.5, m_InputButtonComp.m_iHeightInPixel * 0.5);
215  }
216  else
217  {
218  m_wButtonImg.SetSize(m_InputButtonComp.m_iHeightInPixel, m_InputButtonComp.m_iHeightInPixel);
219  m_wButtonImgGlow.SetSize(m_InputButtonComp.m_iHeightInPixel, m_InputButtonComp.m_iHeightInPixel);
220  }
221 
222  m_wButtonText.SetDesiredFontSize((int)m_InputButtonComp.m_iHeightInPixel / m_fButtonTextSizeModifier);
223 
224 
225  if (m_aAdditionalWidgets && !m_aButtonTextures.IsEmpty())
226  {
227  foreach (ImageWidget widget : m_aAdditionalWidgets)
228  {
229  widget.SetSize(m_InputButtonComp.m_iHeightInPixel, m_InputButtonComp.m_iHeightInPixel);
230  }
231  }
232  }
233 
234  //------------------------------------------------------------------------------------------------
235  protected void GetFilter(BaseContainer filter)
236  {
237  m_bIsHoldAction = false;
238  m_bIsHoldActionOnce = false;
239  m_bIsDoubleTapAction = false;
240  m_bPressedInput = false;
241  m_bCanBeToggled = false;
242  m_bIsContinuous = false;
243 
244  if (!filter)
245  return;
246 
247  switch (filter.GetClassName())
248  {
249  case "InputFilterHold":
250  m_bIsHoldAction = true;
251  break;
252  case "InputFilterHoldOnce":
253  {
254  m_bIsHoldActionOnce = true;
255  m_bIsHoldAction = true;
256  break;
257  }
258  case "InputFilterDoubleClick":
259  m_bIsDoubleTapAction = true;
260  break;
261  case "InputFilterPressed":
262  m_bPressedInput = true;
263  break;
264  case "InputFilterToggle":
265  m_bCanBeToggled = true;
266  break;
267  case "InputFilterValue":
268  m_bIsContinuous = true;
269  break;
270  }
271  }
272 
273  //------------------------------------------------------------------------------------------------
276  protected bool ApplyTextureToButton()
277  {
278  m_wKeyBG.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sKeyBackground);
279  m_wOutline.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sKeyOutline);
280  m_wOutlineClear.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sKeyOutline);
281  m_wHoldIndicator.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sHoldIndicator);
282 
283 
284  if (m_bIsHoldAction)
285  {
286  m_wGlow.LoadImageFromSet(0, m_ButtonLayout.m_sGlowImageSet, m_ButtonLayout.m_sGlowOutline);
287  m_wOutline.LoadMaskFromSet(m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sAlphaMask);
288  }
289  else
290  {
291  m_wGlow.LoadImageFromSet(0, m_ButtonLayout.m_sGlowImageSet, m_ButtonLayout.m_sGlow);
292  }
293 
294  m_wDoubleTabIndicator.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_ButtonLayout.m_sDoubleTabText);
295 
296  GetWidth();
297 
298  m_wKeyBG.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
299  m_wOutline.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
300  m_wOutlineClear.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
301  m_wGlow.SetSize(m_iWidth, m_InputButtonComp.m_iHeightInPixel);
302  m_wDoubleTabIndicator.SetSize(m_InputButtonComp.m_iHeightInPixel, m_InputButtonComp.m_iHeightInPixel);
303  m_wHoldIndicator.SetSize(m_InputButtonComp.m_iHeightInPixel, (m_InputButtonComp.m_iHeightInPixel * 0.5));
304 
306  if (m_aButtonTextures && !m_aButtonTextures.IsEmpty())
307  {
308  m_wButtonImg.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_aButtonTextures[0].m_sTexture);
309  m_wButtonImg.SetColor(m_aButtonTextures[0].m_Color);
310  m_wButtonImg.SetVisible(true);
311 
312  if (m_aButtonTextures[0].m_bHasShadow)
313  {
314  m_wButtonImgGlow.LoadImageFromSet(0, m_ButtonLayout.m_sGlowImageSet, m_aButtonTextures[0].m_sTexture);
315  m_wButtonImgGlow.SetVisible(true);
316  }
317  else
318  {
319  m_wButtonImgGlow.SetVisible(false);
320  }
321 
322  m_wButtonImg.SetSize(m_InputButtonComp.m_iHeightInPixel, m_InputButtonComp.m_iHeightInPixel);
323  m_wButtonImgGlow.SetSize(m_InputButtonComp.m_iHeightInPixel, m_InputButtonComp.m_iHeightInPixel);
325  if (!m_aAdditionalWidgets.IsEmpty())
326  DeleteAdditionalWidgets();
327 
328  if (m_aButtonTextures.Count() > 1)
329  CreateAdditionalWidgets();
330  }
331  else
332  {
333  m_wButtonText.SetVisible(true);
334  m_wButtonImg.SetVisible(false);
335  m_wButtonImgGlow.SetVisible(false);
337  if (!m_aAdditionalWidgets.IsEmpty())
338  DeleteAdditionalWidgets();
339  }
340 
341  m_wButtonText.SetText(m_sButtonText);
342  m_wButtonText.SetDesiredFontSize((int)m_InputButtonComp.m_iHeightInPixel / m_fButtonTextSizeModifier);
343 
344  m_wOutlineClear.SetColor(m_ButtonLayout.m_OutlineColor);
345 
346  return false;
347  }
348 
349  //------------------------------------------------------------------------------------------------
350  protected void GetWidth()
351  {
353  int sx, sy;
354  switch (m_eButtonType)
355  {
356  case SCR_EButtonSize.KEYBOARD_MEDIUM:
357  m_iWidth = m_InputButtonComp.m_iHeightInPixel * m_fMediumButtonWidhtModifier;
358  break;
359  case SCR_EButtonSize.KEYBOARD_BIG:
360  m_iWidth = m_InputButtonComp.m_iHeightInPixel * m_fLargeButtonWidhtModifier;
361  break;
362  //Square keyboard button + Gamepad / Mouse buttons
363  default:
364  m_iWidth = m_InputButtonComp.m_iHeightInPixel;
365  break;
366  }
367  }
368 
369  //------------------------------------------------------------------------------------------------
372  protected bool CreateAdditionalWidgets()
373  {
374  for (int i = 1, count = m_aButtonTextures.Count(); i < count; i++)
375  {
377  if (m_aButtonTextures[i].m_bHasShadow)
378  {
379  Widget w_additionalShadow = GetGame().GetWorkspace().CreateWidget(WidgetType.ImageWidgetTypeID, WidgetFlags.VISIBLE | WidgetFlags.BLEND | WidgetFlags.STRETCH | WidgetFlags.IGNORE_CURSOR | WidgetFlags.INHERIT_CLIPPING, new Color(0.000000, 0.000000, 0.000000, 0.502007), 0, m_wShadowOverlay);
380  ImageWidget additionalWidgetshadow = ImageWidget.Cast(w_additionalShadow);
381  additionalWidgetshadow.LoadImageFromSet(0, m_ButtonLayout.m_sGlowImageSet, m_aButtonTextures[i].m_sTexture);
382  additionalWidgetshadow.SetSize(m_InputButtonComp.m_iHeightInPixel, m_InputButtonComp.m_iHeightInPixel);
383  m_aAdditionalWidgets.Insert(additionalWidgetshadow);
384  }
385 
386  Widget w_additional = GetGame().GetWorkspace().CreateWidget(WidgetType.ImageWidgetTypeID, WidgetFlags.VISIBLE | WidgetFlags.BLEND | WidgetFlags.STRETCH | WidgetFlags.IGNORE_CURSOR | WidgetFlags.INHERIT_CLIPPING, m_aButtonTextures[i].m_Color, 0, m_wOverlay);
387  ImageWidget additionalWidget = ImageWidget.Cast(w_additional);
388  additionalWidget.LoadImageFromSet(0, m_ButtonLayout.m_sImageSet, m_aButtonTextures[i].m_sTexture);
389  additionalWidget.SetSize(m_InputButtonComp.m_iHeightInPixel, m_InputButtonComp.m_iHeightInPixel);
390  m_aAdditionalWidgets.Insert(additionalWidget);
391  }
392  return false;
393  }
394 
395  //------------------------------------------------------------------------------------------------
397  protected bool DeleteAdditionalWidgets()
398  {
399  foreach (ImageWidget img : m_aAdditionalWidgets)
400  {
401  if (img)
402  img.RemoveFromHierarchy();
403  }
404 
405  m_aAdditionalWidgets.Clear();
406  return false;
407  }
408 
409  //------------------------------------------------------------------------------------------------
412  void ActionPressed(bool isHoldAction = false)
413  {
414  if (m_bIsHoldAction)
415  {
416  AnimateHold();
417  return;
418  }
419 
420  if (isHoldAction)
421  return;
422 
423  if (m_bCanBeToggled)
424  {
425  SetToggled(!m_bIsToggled);
426  return;
427  }
428 
429  if (m_bIsDoubleTapAction)
430  {
431  OnDoubleTap();
432  return;
433  }
434 
435  if (m_bIsContinuous)
436  {
437  AnimateContinous();
438  return;
439  }
440 
441  AnimateClick();
442  }
443 
444  //------------------------------------------------------------------------------------------------
446  void ActionReleased()
447  {
448  if (m_bIsContinuous)
449  ResetColor();
450 
451  if (m_bIsHoldAction)
452  {
453  if (!m_HoldIndicatorAnimation)
454  AnimateWidget.StopAnimation(m_wHoldIndicator, WidgetAnimationPosition);
455 
456  AnimateWidget.Position(m_wHoldIndicator, m_fHoldIndicatorDefaultPosition, (1 / m_InputButtonComp.m_fHoldIndicatorAnimationTime));
457 
459  if (m_HoldingAnimation && m_HoldingAnimation.GetValue() < 1)
460  {
462  m_HoldingAnimation.SetSpeed(HOLD_ANIMATION_FAILED_ANIMATION_SPEED);
463  }
464  else
465  {
466  ResetColor();
467  AnimateWidget.Opacity(m_wOutline, 0, m_fAnimationRate);
468  }
469 
470  }
471  }
472 
473  //------------------------------------------------------------------------------------------------
474  protected void SetToggled(bool toggled, bool animate = true, bool invokeChange = true)
475  {
476  if (!m_bCanBeToggled)
477  return;
478 
479  m_bIsToggled = toggled;
480  m_InputButtonComp.PlaySoundClicked();
481 
482  AnimateClick();
483 
484  if (m_bIsToggled)
485  AnimateToggle();
486  else
487  ResetColor();
488  }
489 
490  //------------------------------------------------------------------------------------------------
492  void OnDoubleTap()
493  {
494  ChimeraWorld world = GetGame().GetWorld();
495  WorldTimestamp replicationTime = world.GetServerTimestamp();
496 
497  if (!m_InputButtonComp.m_bIsDoubleTapStated)
498  {
499  AnimateDoubleTab();
500  m_fDoubleTapTime = replicationTime.DiffMilliseconds(replicationTime);
501  !m_InputButtonComp.m_bIsDoubleTapStated = true;
502  }
503  else
504  {
505  if (replicationTime.DiffMilliseconds(replicationTime) - m_fDoubleTapTime <= m_InputButtonComp.m_iDoubleTapThreshold)
506  {
507  AnimateDoubleTab();
508  }
509  else
510  {
511  ResetColor();
512  }
513 
514  !m_InputButtonComp.m_bIsDoubleTapStated = false;
515  }
516  }
517 
518  //------------------------------------------------------------------------------------------------
519  ImageWidget GetOutlineWidget()
520  {
521  return m_wOutline;
522  }
523 
524  //------------------------------------------------------------------------------------------------
525  ImageWidget GetBackgroundWidget()
526  {
527  return m_wKeyBG;
528  }
529 
530  //------------------------------------------------------------------------------------------------
532  protected void AnimateHover()
533  {
534  if (AnimateWidget.IsAnimating(m_wKeyBG))
535  return;
536 
537  if (m_InputButtonComp.m_bIsHovered)
538  {
539  AnimateWidget.Color(m_wKeyBG, m_InputButtonComp.m_ActionHovered, m_fAnimationRate);
540  }
541  else
542  {
543  if (m_bIsToggled)
544  AnimateToggle();
545  else
546  ResetColor();
547  }
548  }
549 
550  //------------------------------------------------------------------------------------------------
552  protected void AnimateClick()
553  {
554  if (m_bCanBeToggled)
555  return;
556 
557  if (!m_bIsDoubleTapAction && !m_bPressedInput)
558  {
559  AnimateWidget.StopAnimation(m_wKeyBG, WidgetAnimationColor);
560  AnimateWidget.Color(m_wKeyBG, Color.FromInt(Color.WHITE), m_fAnimationRate);
561 
563  GetGame().GetCallqueue().CallLater(ResetColor, m_fAnimationTime * 600 + 1, false);
564  }
565  }
566 
567  //------------------------------------------------------------------------------------------------
568  void AnimateHold()
569  {
570  m_wOutline.SetMaskProgress(0);
571 
572  if (m_bIsHoldActionOnce)
573  m_HoldingAnimation = SCR_InputButtonAnimations.ButtonAlphaMask(m_wOutline, 1, (1 / m_InputButtonComp.m_fMaxHoldtime), true);
574  else
575  m_HoldingAnimation = SCR_InputButtonAnimations.ButtonAlphaMask(m_wOutline, 1, (1 / m_InputButtonComp.m_fMaxHoldtime), false);
576 
577  m_HoldIndicatorAnimation = AnimateWidget.Position(m_wHoldIndicator, m_fHoldIndicatorAnimationPosition, (1 / m_InputButtonComp.m_fHoldIndicatorAnimationTime));
578  }
579 
580  //------------------------------------------------------------------------------------------------
581  void AnimateHoldComplete()
582  {
583  if (!m_HoldIndicatorAnimation)
584  AnimateWidget.StopAnimation(m_wHoldIndicator, WidgetAnimationPosition);
585 
586  AnimateWidget.Position(m_wHoldIndicator, m_fHoldIndicatorDefaultPosition, (1 / m_InputButtonComp.m_fHoldIndicatorAnimationTime));
587 
588  m_InputButtonComp.GetOnHoldAnimComplete().Invoke(this);
589  }
590 
591  //------------------------------------------------------------------------------------------------
592  protected void AnimateDoubleTab()
593  {
594  if (!m_InputButtonComp.m_bIsDoubleTapStated)
595  {
596  AnimateWidget.StopAnimation(m_wKeyBG, WidgetAnimationColor);
597 
598  m_wKeyBG.SetColor(m_InputButtonComp.m_ActionHovered);
600  GetGame().GetCallqueue().CallLater(ResetColor, m_fAnimationTime * 300 + 1, false);
601  }
602  else
603  {
604  AnimateWidget.StopAnimation(m_wKeyBG, WidgetAnimationColor);
605  m_wKeyBG.SetColor(Color.FromInt(Color.WHITE));
607  GetGame().GetCallqueue().CallLater(ResetColor, m_fAnimationTime * 300 + 1, false);
608  }
609  }
610 
611  //------------------------------------------------------------------------------------------------
612  protected void AnimateToggle()
613  {
614  AnimateWidget.Color(m_wKeyBG, m_InputButtonComp.m_ActionToggled, m_fAnimationRate);
615  }
616 
617  //------------------------------------------------------------------------------------------------
618  protected void AnimateContinous()
619  {
620  AnimateWidget.StopAnimation(m_wKeyBG, WidgetAnimationColor);
621  AnimateWidget.Color(m_wKeyBG, Color.FromInt(Color.WHITE), m_fAnimationRate);
622  }
623 
624  //------------------------------------------------------------------------------------------------
626  void ResetColor()
627  {
628  AnimateWidget.StopAnimation(m_wKeyBG, WidgetAnimationColor);
629 
630  if (!m_wParent.IsEnabled())
631  {
632  UpdateEnableColor();
633  }
634  else
635  {
636  if (m_InputButtonComp.m_bIsHovered)
637  AnimateHover();
638  else
639  AnimateWidget.Color(m_wKeyBG, m_InputButtonComp.m_ActionDefault, m_fAnimationRate);
640  }
641 
642 
643  GetGame().GetCallqueue().Remove(ResetColor);
644  }
645 
646  //------------------------------------------------------------------------------------------------
648  protected void UpdateEnableColor()
649  {
650  Color color;
651  if (!m_wParent.IsEnabled() && m_InputButtonComp.m_bCanBeDisabled)
652  {
653  color = Color.FromInt(m_InputButtonComp.m_ActionDisabled.PackToInt());
654  if (m_InputButtonComp.m_bChangeLabelColorOnDisabled)
655  m_InputButtonComp.SetLabelColor(color);
656  }
657  else
658  {
659  color = m_InputButtonComp.m_ActionDefault;
660  m_InputButtonComp.SetLabelColor(Color.FromInt(m_InputButtonComp.m_LabelDefault.PackToInt()));
661  }
662 
663  AnimateWidget.StopAnimation(m_wKeyBG, WidgetAnimationColor);
664  m_wKeyBG.SetColor(color);
665 
666  if (m_bIsDoubleTapAction)
667  {
668  if (m_wParent.IsEnabled())
669  m_wDoubleTabIndicator.SetColor(Color.FromInt(Color.WHITE));
670  else if (m_InputButtonComp.m_bCanBeDisabled)
671  m_wDoubleTabIndicator.SetColor(Color.FromInt(m_InputButtonComp.m_ActionDisabled.PackToInt()));
672  }
673  }
674 
675  //------------------------------------------------------------------------------------------------
676  float GetTextSizeModifier()
677  {
678  return m_fButtonTextSizeModifier;
679  }
680 
681  //------------------------------------------------------------------------------------------------
682  bool GetIsOverwritten()
683  {
684  return m_bIsOverwritten;
685  }
686 
687  //------------------------------------------------------------------------------------------------
688  void SetIsOverwritten(bool setOverride)
689  {
690  m_bIsOverwritten = setOverride;
691  }
692 }
ChimeraWorld
Definition: ChimeraWorld.c:12
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_InputButtonDisplay
Definition: SCR_InputButtonDisplay.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_bCanBeToggled
protected bool m_bCanBeToggled
Definition: SCR_ModularButtonComponent.c:41
m_wOutline
protected ImageWidget m_wOutline
Definition: SCR_InventoryHitZonePointUI.c:378
SCR_EButtonSize
SCR_EButtonSize
Definition: SCR_InputButtonEnums.c:1
SCR_InputButtonAnimations
Definition: SCR_InputButtonAnimations.c:1
m_Color
ref Color m_Color
Definition: SCR_GeneratorBaseEntity.c:3
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
m_wOverlay
private Widget m_wOverlay
Definition: SCR_AISettingsComponent.c:46
SCR_InputButtonStyle
Definition: SCR_InputButtonLayoutConfig.c:27
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
SCR_InputButtonLayoutConfig
Definition: SCR_InputButtonLayoutConfig.c:2