Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ButtonEffectColor.c
Go to the documentation of this file.
1 [BaseContainerProps(configRoot : true), SCR_ButtonEffectTitleAttribute("Color", "m_sWidgetName")]
3 class SCR_ButtonEffectColor : SCR_ButtonEffectWidgetBase
4 {
5  // Attributes
6 
7  [Attribute(defvalue: "0.2", UIWidgets.EditBox, "How fast each animation proceeds")]
8  protected float m_fAnimationTime;
9 
10  [Attribute()]
11  ref Color m_cDefault;
12 
13  [Attribute()]
14  ref Color m_cHovered;
15 
16  [Attribute()]
17  ref Color m_cActivated;
18 
19  [Attribute()]
20  ref Color m_cActivatedHovered;
21 
22  [Attribute()]
23  ref Color m_cDisabled;
24 
25  [Attribute()]
26  ref Color m_cDisabledActivated;
27 
28  [Attribute()]
29  ref Color m_cClicked;
30 
31  [Attribute()]
32  ref Color m_cFocusGained;
33 
34  [Attribute()]
35  ref Color m_cFocusLost;
36 
37  [Attribute()]
38  ref Color m_cToggledOn;
39 
40  [Attribute()]
41  ref Color m_cToggledOff;
42 
43  //TODO: focus should probably be a state, not events
44  //TODO: Fix colors not matching the button's current state
45 
46  //------------------------------------------------------------------------------------------------
47  override void OnStateDefault(bool instant)
48  {
49  // This can get triggered on mouse leave while the button remains focused. The focus color must then have priority, as it is integral to gamepad navigation
50  Color color = m_cDefault;
51  if ((m_eEvents & EModularButtonEventFlag.EVENT_FOCUS_GAINED) && m_Button.GetFocused())
52  color = m_cFocusGained;
53 
54  Apply(color, instant);
55  }
56 
57  //------------------------------------------------------------------------------------------------
58  override void OnStateHovered(bool instant)
59  {
60  Apply(m_cHovered, instant);
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  override void OnStateActivated(bool instant)
65  {
66  // If the modular button is toggled while focused, the focus state must have priority, as it is integral to gamepad navigation
67  Color color = m_cActivated;
68  if ((m_eEvents & EModularButtonEventFlag.EVENT_FOCUS_GAINED) && m_Button.GetFocused())
69  color = m_cFocusGained;
70 
71  Apply(color, instant);
72  }
73 
74  //------------------------------------------------------------------------------------------------
75  override void OnStateDisabled(bool instant)
76  {
77  Apply(m_cDisabled, instant);
78  }
79 
80  //------------------------------------------------------------------------------------------------
81  override void OnStateDisabledActivated(bool instant)
82  {
83  Apply(m_cDisabledActivated, instant);
84  }
85 
86  //------------------------------------------------------------------------------------------------
87  override void OnStateActivatedHovered(bool instant)
88  {
89  Apply(m_cActivatedHovered, instant);
90  }
91 
92  //------------------------------------------------------------------------------------------------
93  override void OnClicked(bool instant)
94  {
95  Apply(m_cClicked, instant);
96  }
97 
98  //------------------------------------------------------------------------------------------------
99  override void OnFocusGained(bool instant)
100  {
101  Apply(m_cFocusGained, instant);
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  override void OnFocusLost(bool instant)
106  {
107  // Focusing away from an activated modular button must give priority to it's activated state color
108  Color color = m_cFocusLost;
109  if ((m_eEvents & EModularButtonEventFlag.STATE_ACTIVATED) && m_Button.GetToggled())
110  color = m_cActivated;
111 
112  //TODO: handle focus lost on activated hovered
113  Apply(color, instant);
114  }
115 
116  //------------------------------------------------------------------------------------------------
117  override void OnToggledOn(bool instant)
118  {
119  Apply(m_cToggledOn, instant);
120  }
121 
122  //------------------------------------------------------------------------------------------------
123  override void OnToggledOff(bool instant)
124  {
125  Apply(m_cToggledOff, instant);
126  }
127 
128  //------------------------------------------------------------------------------------------------
129  // Called when effect is disabled. Here you should stop all running effects.
130  override void OnDisabled()
131  {
132  AnimateWidget.StopAnimation(m_wTarget, WidgetAnimationColor);
133  }
134 
135  //------------------------------------------------------------------------------------------------
136  protected void Apply(Color color, bool instant)
137  {
138  if (color && m_wTarget)
139  {
140  if (!instant && m_fAnimationTime != 0)
141  {
142  AnimateWidget.Color(m_wTarget, color, 1 / m_fAnimationTime);
143  }
144  else
145  {
146  AnimateWidget.StopAnimation(m_wTarget, WidgetAnimationColor);
147  m_wTarget.SetColor(color);
148  }
149  }
150  }
151 }
EModularButtonEventFlag
EModularButtonEventFlag
Definition: SCR_ButtonEffectBase.c:5
SCR_ButtonEffectColor
Effect which colorizes a widget with given name.
Definition: SCR_ButtonEffectColor.c:3
Attribute
typedef Attribute
Post-process effect of scripted camera.
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468