Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_TileBaseComponent.c
Go to the documentation of this file.
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 ImageWidget m_wImage;
22 float m_fAnimationRate;
23
24 bool m_bIsInErrorState;
25
26 ref ScriptInvoker m_OnFocused = new ScriptInvoker();
27 ref ScriptInvoker m_OnFocusLost = new ScriptInvoker();
28
29 //------------------------------------------------------------------------------------------------
30 override void HandlerAttached(Widget w)
31 {
32 super.HandlerAttached(w);
33
34 m_wImage = ImageWidget.Cast(w.FindAnyWidget(m_sContentName));
35
36 SetInitialAnimationRate();
37
38 // Set initial color
39 if (!m_wImage)
40 return;
41
42 m_wImage.SetColor(m_ColorDeselected);
43 m_wImage.SetSaturation(m_fSaturationDeselected);
44 }
45
46 //------------------------------------------------------------------------------------------------
47 private void SetInitialAnimationRate()
48 {
50 GetGame().GetCallqueue().CallLater(SetAnimationRate, SCR_WLibComponentBase.START_ANIMATION_PERIOD);
51 }
52
53 //------------------------------------------------------------------------------------------------
54 private void SetAnimationRate()
55 {
56 if (m_fAnimationTime <= 0)
57 m_fAnimationRate = 1000;
58 else
59 m_fAnimationRate = 1 / m_fAnimationTime;
60 }
61
62 //------------------------------------------------------------------------------------------------
63 override bool OnFocus(Widget w, int x, int y)
64 {
65 if (!m_bIsInErrorState)
66 {
67 AnimateWidget.Saturation(m_wImage, m_fSaturationSelected, m_fAnimationRate);
68 AnimateWidget.Color(m_wImage, m_ColorSelected, m_fAnimationRate);
69 }
70
71 m_OnFocused.Invoke(this);
72 return super.OnFocus(w, x, y);
73 }
74
75 //------------------------------------------------------------------------------------------------
76 override bool OnFocusLost(Widget w, int x, int y)
77 {
78 AnimateWidget.Saturation(m_wImage, m_fSaturationDeselected, m_fAnimationRate);
79 AnimateWidget.Color(m_wImage, m_ColorDeselected, m_fAnimationRate);
80 m_OnFocusLost.Invoke(this);
81 return super.OnFocusLost(w, x, y);
82 }
83}
ArmaReforgerScripted GetGame()
Definition game.c:1398
static WidgetAnimationColor Color(Widget widget, Color color, float speed)
static WidgetAnimationImageSaturation Saturation(Widget widget, float targetValue, float speed)
Definition Color.c:13
Base class for all final Reforger interactive elements.
static const float START_ANIMATION_PERIOD
static const float START_ANIMATION_RATE
SCR_FieldOfViewSettings Attribute
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134