Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InputButtonAlphaMaskAnimation.c
Go to the documentation of this file.
1 class SCR_InputButtonAlphaMaskAnimation : WidgetAnimationAlphaMask
2 {
3  protected SCR_InputButtonDisplay m_InputButtonDisplay;
4 
5  protected ImageWidget m_wOutline;
6 
7  protected float m_fAnimationRate;
8  protected bool m_bResetOnComplete;
9 
10  override void SetSpeed(float speed)
11  {
12  m_fSpeed = speed;
13  }
14 
15  //------------------------------------------------------------------------------------------------
16  protected void OnAnimationComplete()
17  {
18  if (m_bResetOnComplete)
19  {
20  SCR_InputButtonAnimations.ButtonColor(m_InputButtonDisplay.GetBackgroundWidget(), Color.FromInt(Color.WHITE), m_fAnimationRate);
21  AnimateWidget.Opacity(m_wOutline, 0, m_fAnimationRate);
22  m_InputButtonDisplay.AnimateHoldComplete();
23 
25  GetGame().GetCallqueue().CallLater(m_InputButtonDisplay.ResetColor, m_fAnimationRate * 300 + 1, false);
26  }
27  else
28  {
29  AnimateWidget.Color(m_InputButtonDisplay.GetBackgroundWidget(), Color.FromInt(Color.WHITE), m_fAnimationRate);
30  }
31 
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  override bool OnUpdate(float timeSlice)
36  {
37  m_fCurrentProgress += timeSlice * m_fSpeed;
38  if (m_fCurrentProgress > 1)
39  m_fCurrentProgress = 1;
40 
41  if (!m_InputButtonDisplay)
42  return false;
43 
44  if (m_fSpeed > 0 && m_fCurrentProgress > 0)
45  m_wOutline.SetColor(Color.FromInt(GUIColors.ENABLED.PackToInt()));
46  else
47  m_wOutline.SetColor(Color.FromInt(UIColors.WARNING.PackToInt()));
48 
49  if (m_fSpeed > 0 && m_fCurrentProgress < 0)
50  return false;
51 
52  m_fValue = GetProgressValue(m_fCurrentProgress);
53 
54  // Perform widget animation
55  Animate(m_fCurrentProgress == 1);
56 
57  if (m_fSpeed < 0 && m_fValue < 0.1)
58  Stop();
59 
60  if (m_fValue >= m_fValueTarget)
61  {
62  Stop();
63  OnAnimationComplete();
64  }
65 
66  if (m_fCurrentProgress < 1)
67  return false;
68 
69  if (m_bRepeat)
70  {
71  m_fCurrentProgress = 0;
72  ReverseDirection();
73 
74  if (m_OnCycleCompleted)
75  m_OnCycleCompleted.Invoke(this);
76 
77  return false;
78  }
79 
80  // Invoke subscribed changes
81  if (m_OnCompleted)
82  m_OnCompleted.Invoke(this);
83 
84  if (m_OnStopped)
85  m_OnStopped.Invoke(this);
86 
87  return true;
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  void SCR_InputButtonAlphaMaskAnimation(Widget w, float speed, float targetValue, bool resetOnComplete)
92  {
93  Widget parent = SCR_WidgetTools.FindWidgetInParents(w, WidgetType.SizeLayoutWidgetTypeID);
94  m_InputButtonDisplay = SCR_InputButtonDisplay.Cast(parent.FindHandler(SCR_InputButtonDisplay));
95 
96  m_wOutline = m_InputButtonDisplay.GetOutlineWidget();
97 
98  if (!m_wOutline || !m_InputButtonDisplay.GetBackgroundWidget())
99  return;
100 
101  m_fAnimationRate = m_InputButtonDisplay.m_fAnimationRate;
102  m_bResetOnComplete = resetOnComplete;
103  m_fValueTarget = targetValue;
104  m_fValueDefault = m_wOutline.GetMaskProgress();
105  m_wOutline.SetMaskProgress(0);
106  m_wOutline.SetOpacity(1);
107  }
108 }
SCR_WidgetTools
Definition: SCR_WidgetTools.c:1
SCR_InputButtonDisplay
Definition: SCR_InputButtonDisplay.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_wOutline
protected ImageWidget m_wOutline
Definition: SCR_InventoryHitZonePointUI.c:378
UIColors
Definition: Constants.c:16
Stop
proto external void Stop(string musicName)
Stops either a specific Music that is playing by name OR stops whatever is currently playing (when th...
SCR_InputButtonAlphaMaskAnimation
Definition: SCR_InputButtonAlphaMaskAnimation.c:1
SCR_InputButtonAnimations
Definition: SCR_InputButtonAnimations.c:1