Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ButtonLegendComponent .c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  [Attribute()]
5  protected LocalizedString m_sSpecializationText;
6 
7  protected TextWidget m_wSpecializationText;
8  protected ImageWidget m_wSpecializationCoreImage;
9  protected ImageWidget m_wSpecializationBackgroundImage;
10  protected ImageWidget m_wSpecializationBorderImage;
11 
12  protected ImageWidget m_wChangeSpLeft;
13  protected ImageWidget m_wChangeSpRight;
14  protected Widget m_wChangeSpLeftLayout;
15  protected Widget m_wChangeSpRightLayout;
16 
17  protected int m_ibuttonId;
18 
19  [Attribute()]
20  protected bool m_bIsActive;
21 
22  [Attribute("0 0 0 1", UIWidgets.ColorPicker)]
23  protected ref Color m_ColorInactive;
24 
25  [Attribute("0 0 0 0.5", UIWidgets.ColorPicker)]
26  protected ref Color m_ColorInactiveHovered;
27 
28  [Attribute("0.898 0.541 0.184 1", UIWidgets.ColorPicker)]
29  protected ref Color m_ColorActive;
30 
31  [Attribute("1 1 1 1", UIWidgets.ColorPicker)]
32  protected ref Color m_ColorBackgroundInactive;
33 
34  [Attribute("0 0 0 1", UIWidgets.ColorPicker)]
35  protected ref Color m_ColorBackgroundActive;
36 
37  [Attribute("{FDD5423E69D007F8}UI/Textures/Icons/icons_wrapperUI-128.imageset", UIWidgets.ResourcePickerThumbnail)]
38  protected ResourceName m_TextureLegendButton;
39 
40  [Attribute("career_traits")]
41  protected string m_StringCoreImageLegendButton;
42 
43  [Attribute("careerCircle")]
44  protected string m_StringBackgroundImageLegendButton;
45 
46  [Attribute("careerCircleOutline")]
47  protected string m_StringNotSelectedImageLegendButton;
48 
49  [Attribute("careerCircleSelected")]
50  protected string m_StringSelectedImageLegendButton;
51 
52  /*
53  [Attribute("{F7FD1672FECA05E8}UI/Textures/Icons/icons_gamepad_64.imageset", UIWidgets.ResourcePickerThumbnail)]
54  protected ResourceName m_TextureChangeSpButtonKeyboard;
55 
56  [Attribute("DPAD_left")]
57  protected string m_StringChangeSpLeft;
58 
59  [Attribute("DPAD_right")]
60  protected string m_StringChangeSpRight;
61  */
62 
63  [Attribute("{3093C92AE673BC5E}UI/Textures/Workshop/PagingArrow_UI.edds", UIWidgets.ResourcePickerThumbnail)]
64  protected ResourceName m_PagingArrow;
65 
66  protected bool m_bLeftAndRightUI;
67 
68  // Arguments passed: this
69  protected ref ScriptInvoker m_OnClicked = new ScriptInvoker();
70  protected ref ScriptInvoker m_OnMouseEnter = new ScriptInvoker();
71  protected ref ScriptInvoker m_OnMouseLeave = new ScriptInvoker();
72 
73  //------------------------------------------------------------------------------------------------
74  protected override void HandlerAttached(Widget w)
75  {
76  super.HandlerAttached(w);
77 
78  m_wSpecializationText = TextWidget.Cast(w.FindAnyWidget("SpecializationText"));
79  if (m_wSpecializationText)
80  {
81  m_wSpecializationText.SetText(m_sSpecializationText);
82  m_wSpecializationText.SetColor(m_ColorInactive);
83  }
84 
85  m_wSpecializationCoreImage = ImageWidget.Cast(w.FindAnyWidget("SpecializationCoreImage"));
86  m_wSpecializationBorderImage = ImageWidget.Cast(w.FindAnyWidget("SpecializationBorderImage"));
87  m_wSpecializationBackgroundImage = ImageWidget.Cast(w.FindAnyWidget("SpecializationBackgroundImage"));
88  if (m_wSpecializationCoreImage && m_wSpecializationBorderImage && m_wSpecializationBackgroundImage)
89  {
90  SetTexture(m_wSpecializationCoreImage, m_TextureLegendButton, m_StringCoreImageLegendButton+"1");
91  SetTexture(m_wSpecializationBorderImage, m_TextureLegendButton, m_StringNotSelectedImageLegendButton);
92  SetTexture(m_wSpecializationBackgroundImage, m_TextureLegendButton, m_StringBackgroundImageLegendButton);
93  m_wSpecializationCoreImage.SetColor(m_ColorInactive);
94  m_wSpecializationBorderImage.SetColor(m_ColorInactive);
95  m_wSpecializationBackgroundImage.SetColor(m_ColorBackgroundInactive);
96  }
97 
98  m_wChangeSpLeftLayout = Widget.Cast(w.FindAnyWidget("ChangeSpLeftSizeLayout"));
99  m_wChangeSpLeft = ImageWidget.Cast(w.FindAnyWidget("ChangeSpLeft"));
100  m_wChangeSpRight = ImageWidget.Cast(w.FindAnyWidget("ChangeSpRight"));
101  m_wChangeSpRightLayout = Widget.Cast(w.FindAnyWidget("ChangeSpRightSizeLayout"));
102 
103  //Buttons on the sides of the legend
104  m_bLeftAndRightUI = false;
105 
106  if (m_wChangeSpLeft && m_wChangeSpRight && m_wChangeSpLeftLayout && m_wChangeSpRightLayout)
107  {
108  /*
109  SetTexture(m_wChangeSpLeft, m_TextureChangeSpButtonKeyboard, m_StringChangeSpLeft);
110  SetTexture(m_wChangeSpRight, m_TextureChangeSpButtonKeyboard, m_StringChangeSpRight);
111  */
112  SetTexture(m_wChangeSpLeft, m_PagingArrow);
113  SetTexture(m_wChangeSpRight, m_PagingArrow);
114 
115  m_wChangeSpLeft.SetColor(m_ColorActive);
116  m_wChangeSpRight.SetColor(m_ColorActive);
117  m_wChangeSpLeftLayout.SetVisible(false);
118  m_wChangeSpRightLayout.SetVisible(false);
119  }
120  }
121 
122  //------------------------------------------------------------------------------------------------
123  ScriptInvoker GetOnClicked()
124  {
125  return m_OnClicked;
126  }
127 
128  //------------------------------------------------------------------------------------------------
129  ScriptInvoker GetOnMouseEnter()
130  {
131  return m_OnMouseEnter;
132  }
133 
134  //------------------------------------------------------------------------------------------------
135  ScriptInvoker GetOnMouseLeave()
136  {
137  return m_OnMouseLeave;
138  }
139 
140  //------------------------------------------------------------------------------------------------
141  protected override bool OnClick(Widget w, int x, int y, int button)
142  {
143  super.OnClick(w, x, y, button);
144  if (button != 0)
145  return false;
146 
147  m_OnClicked.Invoke(this);
148 
149  return false;
150  }
151 
152  //------------------------------------------------------------------------------------------------
153  override bool OnFocus(Widget w, int x, int y)
154  {
155  return false;
156  return OnClick(w, x, y, 0);
157  }
158 
159  //------------------------------------------------------------------------------------------------
160  protected override bool OnMouseEnter(Widget w, int x, int y)
161  {
162  super.OnMouseEnter(w, x, y);
163 
164  m_OnMouseEnter.Invoke(this);
165  return false;
166  }
167 
168  //------------------------------------------------------------------------------------------------
169  protected override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
170  {
171  super.OnMouseLeave(w, enterW, x, y);
172 
173  m_OnMouseLeave.Invoke(this);
174  return false;
175  }
176 
177  //------------------------------------------------------------------------------------------------
178  void Activate(bool animate = true, bool playsound = true)
179  {
180  if (m_bIsActive)
181  return;
182 
183  m_bIsActive = true;
184  if (playsound)
185  PlaySound(m_sSoundClicked);
186 
187  if (animate)
188  {
189  if (m_wSpecializationCoreImage)
190  AnimateWidget.Color(m_wSpecializationCoreImage, m_ColorActive, m_fAnimationRate);
191 
192  if (m_wSpecializationBorderImage)
193  AnimateWidget.Color(m_wSpecializationBorderImage, m_ColorActive, m_fAnimationRate);
194 
195  if (m_wSpecializationBackgroundImage)
196  AnimateWidget.Color(m_wSpecializationBackgroundImage, m_ColorBackgroundActive, m_fAnimationRate);
197 
198  if (m_wSpecializationText)
199  AnimateWidget.Color(m_wSpecializationText, m_ColorActive, m_fAnimationRate);
200  }
201  else
202  {
203  if (m_wSpecializationCoreImage)
204  {
205  AnimateWidget.StopAnimation(m_wSpecializationCoreImage, WidgetAnimationColor);
206  m_wSpecializationCoreImage.SetColor(m_ColorActive);
207  }
208 
209  if (m_wSpecializationBorderImage)
210  {
211  AnimateWidget.StopAnimation(m_wSpecializationBorderImage, WidgetAnimationColor);
212  m_wSpecializationBorderImage.SetColor(m_ColorActive);
213  SetTexture(m_wSpecializationBorderImage, m_TextureLegendButton, m_StringSelectedImageLegendButton);
214  }
215 
216  if (m_wSpecializationBackgroundImage)
217  {
218  AnimateWidget.StopAnimation(m_wSpecializationBackgroundImage, WidgetAnimationColor);
219  m_wSpecializationBackgroundImage.SetColor(m_ColorBackgroundActive);
220  }
221 
222  if (m_wSpecializationText)
223  {
224  AnimateWidget.StopAnimation(m_wSpecializationText, WidgetAnimationColor);
225  m_wSpecializationText.SetColor(m_ColorActive);
226  }
227  }
228 
229  if (m_bLeftAndRightUI && m_wChangeSpLeft && m_wChangeSpRight && m_wChangeSpLeftLayout && m_wChangeSpRightLayout)
230  {
231  m_wChangeSpLeftLayout.SetVisible(true);
232  m_wChangeSpRightLayout.SetVisible(true);
233  }
234  }
235 
236  //------------------------------------------------------------------------------------------------
237  void Deactivate(bool animate = true, bool playsound = true)
238  {
239  if (!m_bIsActive)
240  return;
241 
242  m_bIsActive = false;
243  if (playsound)
244  PlaySound(m_sSoundClicked);
245 
246  if (animate)
247  {
248  if (m_wSpecializationCoreImage)
249  AnimateWidget.Color(m_wSpecializationCoreImage, m_ColorInactive, m_fAnimationRate);
250 
251  if (m_wSpecializationBorderImage)
252  AnimateWidget.Color(m_wSpecializationBorderImage, m_ColorInactive, m_fAnimationRate);
253 
254  if (m_wSpecializationBackgroundImage)
255  AnimateWidget.Color(m_wSpecializationBackgroundImage, m_ColorBackgroundInactive, m_fAnimationRate);
256 
257  if (m_wSpecializationText)
258  AnimateWidget.Color(m_wSpecializationText, m_ColorInactive, m_fAnimationRate);
259  }
260  else
261  {
262  if (m_wSpecializationCoreImage)
263  {
264  AnimateWidget.StopAnimation(m_wSpecializationCoreImage, WidgetAnimationColor);
265  m_wSpecializationCoreImage.SetColor(m_ColorInactive);
266  }
267 
268  if (m_wSpecializationBorderImage)
269  {
270  AnimateWidget.StopAnimation(m_wSpecializationBorderImage, WidgetAnimationColor);
271  m_wSpecializationBorderImage.SetColor(m_ColorInactive);
272  SetTexture(m_wSpecializationBorderImage, m_TextureLegendButton, m_StringNotSelectedImageLegendButton);
273  }
274 
275  if (m_wSpecializationBackgroundImage)
276  {
277  AnimateWidget.StopAnimation(m_wSpecializationBackgroundImage, WidgetAnimationColor);
278  m_wSpecializationCoreImage.SetColor(m_ColorBackgroundInactive);
279  }
280 
281  if (m_wSpecializationText)
282  {
283  AnimateWidget.StopAnimation(m_wSpecializationText, WidgetAnimationColor);
284  m_wSpecializationText.SetColor(m_ColorInactive);
285  }
286  }
287 
288  if (m_wChangeSpLeft && m_wChangeSpRight && m_wChangeSpLeftLayout && m_wChangeSpRightLayout)
289  {
290  m_wChangeSpLeftLayout.SetVisible(false);
291  m_wChangeSpRightLayout.SetVisible(false);
292  }
293  }
294 
295  //------------------------------------------------------------------------------------------------
296  void SetOnHover(bool OnHover = true)
297  {
298  if (m_bIsActive)
299  return;
300 
301  if (OnHover)
302  {
303  if (m_wSpecializationCoreImage)
304  AnimateWidget.Color(m_wSpecializationCoreImage, m_ColorInactiveHovered, m_fAnimationRate);
305 
306  if (m_wSpecializationBorderImage)
307  AnimateWidget.Color(m_wSpecializationBorderImage, m_ColorInactiveHovered, m_fAnimationRate);
308 
309  if (m_wSpecializationText)
310  AnimateWidget.Color(m_wSpecializationText, m_ColorInactiveHovered, m_fAnimationRate);
311  return;
312  }
313 
314  if (m_wSpecializationCoreImage)
315  AnimateWidget.Color(m_wSpecializationCoreImage, m_ColorInactive, m_fAnimationRate);
316 
317  if (m_wSpecializationBorderImage)
318  AnimateWidget.Color(m_wSpecializationBorderImage, m_ColorInactive, m_fAnimationRate);
319 
320  if (m_wSpecializationText)
321  AnimateWidget.Color(m_wSpecializationText, m_ColorInactive, m_fAnimationRate);
322  }
323 
324  //------------------------------------------------------------------------------------------------
325  void Hide()
326  {
327  m_wRoot.SetOpacity(0);
328  }
329 
330  //------------------------------------------------------------------------------------------------
331  void Unhide()
332  {
333  m_wRoot.SetOpacity(255);
334  }
335 
336  //------------------------------------------------------------------------------------------------
337  bool IsActive()
338  {
339  return m_bIsActive;
340  }
341 
342  //------------------------------------------------------------------------------------------------
343  void SetText(string text)
344  {
345  if (!m_wSpecializationText)
346  return;
347 
348  if (m_sSpecializationText == text)
349  return;
350 
351  m_sSpecializationText = text;
352  m_wSpecializationText.SetText(text);
353  }
354 
355  //------------------------------------------------------------------------------------------------
356  string GetText()
357  {
358  return m_sSpecializationText;
359  }
360 
361  //------------------------------------------------------------------------------------------------
362  TextWidget GetTextWidget()
363  {
364  return m_wSpecializationText;
365  }
366 
367  //------------------------------------------------------------------------------------------------
368  ImageWidget GetCoreImageWidget()
369  {
370  return m_wSpecializationCoreImage;
371  }
372 
373  //------------------------------------------------------------------------------------------------
374  ImageWidget GetBorderImageWidget()
375  {
376  return m_wSpecializationBorderImage;
377  }
378 
379  //------------------------------------------------------------------------------------------------
380  ImageWidget GetChangeSpLeftImageWidget()
381  {
382  return m_wChangeSpLeft;
383  }
384 
385  //------------------------------------------------------------------------------------------------
386  ImageWidget GetChangeSpRightImageWidget()
387  {
388  return m_wChangeSpRight;
389  }
390 
391  //------------------------------------------------------------------------------------------------
392  bool GetLeftAndRightSelectedUI()
393  {
394  return m_bLeftAndRightUI;
395  }
396 
397  void SetLeftAndRightUIActivate(bool flag)
398  {
399  m_bLeftAndRightUI = flag;
400  }
401 
402  //------------------------------------------------------------------------------------------------
403  void SetButtonId(int n)
404  {
405  if (m_wSpecializationCoreImage)
406  SetTexture(m_wSpecializationCoreImage, m_TextureLegendButton, m_StringCoreImageLegendButton+(n+1));
407  m_ibuttonId = n;
408  }
409 
410  //------------------------------------------------------------------------------------------------
411  void SetFocus()
412  {
413  WorkspaceWidget workspace = GetGame().GetWorkspace();
414  if (!workspace)
415  return;
416 
417  GetGame().GetCallqueue().CallLater(workspace.SetFocusedWidget, 1000, false, m_wRoot, true);
418  }
419 
420  //------------------------------------------------------------------------------------------------
421  int GetButtonId()
422  {
423  return m_ibuttonId;
424  }
425 };
PlaySound
SCR_ParticleContactComponentClass ScriptComponentClass PlaySound(IEntity owner, SCR_ParticleContactComponentClass prefabData, Contact contact)
Definition: SCR_ParticleContactComponent.c:38
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_WLibComponentBase
Base class for all final Reforger interactive elements.
Definition: SCR_WLibComponentBase.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
OnHover
protected void OnHover(EEditableEntityState state, set< SCR_EditableEntityComponent > entitiesInsert, set< SCR_EditableEntityComponent > entitiesRemove)
Definition: SCR_TooltipManagerEditorUIComponent.c:154
m_OnMouseEnter
ref ScriptInvoker m_OnMouseEnter
Definition: SCR_ModularButtonComponent.c:65
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_bIsActive
SCR_HintSequenceComponentClass m_bIsActive
LocalizedString
Definition: LocalizedString.c:21
m_OnClicked
ref ScriptInvoker m_OnClicked
Definition: SCR_ModularButtonComponent.c:60
SCR_ButtonLegendComponent
Definition: SCR_ButtonLegendComponent .c:2
m_OnMouseLeave
ref ScriptInvoker m_OnMouseLeave
Definition: SCR_ModularButtonComponent.c:66