Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_TileBaseComponent.c
Go to the documentation of this file.
1 class SCR_TileBaseComponent : ScriptedWidgetComponent
2 {
3  [Attribute(UIConstants.ENABLED_WIDGET_SATURATION.ToString())]
4  float m_fSaturationSelected;
5 
6  [Attribute(UIConstants.DISABLED_WIDGET_SATURATION.ToString())]
7  float m_fSaturationDeselected;
8 
9  [Attribute(UIColors.GetColorAttribute(UIColors.NEUTRAL_INFORMATION), UIWidgets.ColorPicker)]
10  ref Color m_ColorSelected;
11 
12  [Attribute("0.5 0.5 0.5 1", UIWidgets.ColorPicker)]
13  ref Color m_ColorDeselected;
14 
15  [Attribute("0.2")]
16  float m_fAnimationTime;
17 
18  [Attribute("Image")]
19  string m_sContentName;
20 
21  Widget m_wRoot;
22  ImageWidget m_wImage;
23  float m_fAnimationRate;
24 
25  bool m_bIsInErrorState;
26 
27  ref ScriptInvoker m_OnFocused = new ScriptInvoker();
28  ref ScriptInvoker m_OnFocusLost = new ScriptInvoker();
29  ref ScriptInvoker m_OnClicked = new ScriptInvoker();
30 
31  //------------------------------------------------------------------------------------------------
32  override void HandlerAttached(Widget w)
33  {
34  m_wRoot = w;
35  m_wImage = ImageWidget.Cast(w.FindAnyWidget(m_sContentName));
36 
37  SetInitialAnimationRate();
38 
39  // Set initial color
40  if (!m_wImage)
41  return;
42 
43  m_wImage.SetColor(m_ColorDeselected);
44  m_wImage.SetSaturation(m_fSaturationDeselected);
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  private void SetInitialAnimationRate()
49  {
50  m_fAnimationRate = SCR_WLibComponentBase.START_ANIMATION_RATE;
51  GetGame().GetCallqueue().CallLater(SetAnimationRate, SCR_WLibComponentBase.START_ANIMATION_PERIOD);
52  }
53 
54  //------------------------------------------------------------------------------------------------
55  private void SetAnimationRate()
56  {
57  if (m_fAnimationTime <= 0)
58  m_fAnimationRate = 1000;
59  else
60  m_fAnimationRate = 1 / m_fAnimationTime;
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  override bool OnFocus(Widget w, int x, int y)
65  {
66  if (!m_bIsInErrorState)
67  {
68  AnimateWidget.Saturation(m_wImage, m_fSaturationSelected, m_fAnimationRate);
69  AnimateWidget.Color(m_wImage, m_ColorSelected, m_fAnimationRate);
70  }
71 
72  m_OnFocused.Invoke(this);
73  return false;
74  }
75 
76  //------------------------------------------------------------------------------------------------
77  override bool OnFocusLost(Widget w, int x, int y)
78  {
79  AnimateWidget.Saturation(m_wImage, m_fSaturationDeselected, m_fAnimationRate);
80  AnimateWidget.Color(m_wImage, m_ColorDeselected, m_fAnimationRate);
81  m_OnFocusLost.Invoke(this);
82  return false;
83  }
84 
85  //------------------------------------------------------------------------------------------------
86  override bool OnClick(Widget w, int x, int y, int button)
87  {
88  m_OnClicked.Invoke(this);
89  return false;
90  }
91 
92  //------------------------------------------------------------------------------------------------
94  Widget GetRootWidget()
95  {
96  return m_wRoot;
97  }
98 }
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
SCR_TileBaseComponent
Definition: SCR_TileBaseComponent.c:1
UIConstants
Definition: Constants.c:130
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_OnFocusLost
ref ScriptInvoker m_OnFocusLost
Definition: SCR_ModularButtonComponent.c:64
Attribute
typedef Attribute
Post-process effect of scripted camera.
UIColors
Definition: Constants.c:16
m_wImage
protected ImageWidget m_wImage
Definition: SCR_BackendImageComponent.c:248
m_OnClicked
ref ScriptInvoker m_OnClicked
Definition: SCR_ModularButtonComponent.c:60