Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AttributeTickboxUIComponent.c
Go to the documentation of this file.
1
2
5{
6
7 [Attribute()]
8 protected string m_sTickBoxImageName;
9
10 [Attribute()]
11 protected string m_sTickBoxButtonName;
12
13 // Visuals
14 [Attribute()]
16
17 [Attribute()]
19
20 // Reference
22 protected typename m_LinkedOverrideAttributeType = typename.Empty;
23 protected Widget m_Root;
26
27 protected float m_fDisabledAlphaColor = 0.25;
28
29 // States
30 protected bool m_bToggled;
31 protected bool m_bEnabled = true;
32
33 // Events
35
36 //------------------------------------------------------------------------------------------------
39 void ToggleTickbox(bool toggled)
40 {
41 if (!m_bEnabled)
42 return;
43
44 m_bToggled = toggled;
45
47 m_OnToggleChanged.Invoke(toggled);
48
49 if (toggled)
50 {
51 m_TickBoxImage.LoadImageTexture(0, m_sTickBoxImageToggled);
52 m_TickBoxImage.SetImage(0);
53 }
54 else
55 {
56 m_TickBoxImage.LoadImageTexture(0, m_sTickBoxImageUntoggled);
57 m_TickBoxImage.SetImage(0);
58 }
59
60 SCR_AttributesManagerEditorComponent attributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
61 if (!attributesManager)
62 return;
63
64 if (m_LinkedOverrideAttributeType != typename.Empty)
65 {
67 overideValue.SetBool(toggled);
68 attributesManager.SetAttributeVariable(m_LinkedOverrideAttributeType, overideValue);
69 }
70 }
71
72 //------------------------------------------------------------------------------------------------
75 void ToggleEnableByAttribute(bool enabled)
76 {
77 SetEnabled(enabled);
78 }
79
80 //------------------------------------------------------------------------------------------------
81 protected void OnButtonToggle()
82 {
84 }
85
86 //------------------------------------------------------------------------------------------------
90 {
91 return m_bToggled;
92 }
93
94 //------------------------------------------------------------------------------------------------
98 {
99 return m_TickBoxButton.IsEnabled() && m_Root.IsVisible();
100 }
101
102 //------------------------------------------------------------------------------------------------
110
111 //------------------------------------------------------------------------------------------------
115 protected void SetVisible(bool frameVisible, bool buttonVisible)
116 {
117 m_Root.SetVisible(frameVisible);
118 m_TickBoxButton.SetVisible(buttonVisible);
119 }
120
121 //------------------------------------------------------------------------------------------------
122 protected void SetEnabled(bool enabled)
123 {
124 m_bEnabled = enabled;
125
126 //m_TickBoxImage.LoadImageTexture(0, m_sNonConfictingTickBoxImage);
127 Color color = Color.FromInt(m_TickBoxImage.GetColor().PackToInt());
128 if (!enabled)
129 color.SetA(m_fDisabledAlphaColor);
130 else
131 color.SetA(1);
132
133 m_TickBoxImage.SetColor(color);
134
135 m_TickBoxButton.SetEnabled(enabled);
136 }
137
138 //------------------------------------------------------------------------------------------------
142 {
143 return m_bEnabled;
144 }
145
146 //------------------------------------------------------------------------------------------------
152 void InitTickbox(bool toggleState, SCR_BaseEditorAttributeUIComponent attributeUI, typename linkedOverrideAttributeType = typename.Empty)
153 {
154 m_LinkedOverrideAttributeType = linkedOverrideAttributeType;
155
156 SetVisible(true, true);
157 ToggleTickbox(toggleState);
158 m_AttributeUI = attributeUI;
159
160 if (m_AttributeUI)
161 {
162 m_AttributeUI.GetOnEnabledByAttribute().Insert(OnAttributeEnabledByAttribute);
163 SetEnabled(m_AttributeUI.GetAttribute().IsEnabled());
164 }
165 }
166
167 //------------------------------------------------------------------------------------------------
170 {
171 SetVisible(true, true);
172 SetEnabled(false);
173 m_bToggled = true;
174 m_TickBoxImage.LoadImageTexture(0, m_sTickBoxImageToggled);
175 m_TickBoxImage.SetImage(0);
176 }
177
178 //------------------------------------------------------------------------------------------------
179 protected void OnAttributeEnabledByAttribute(bool enabled)
180 {
181 SetEnabled(enabled);
182 }
183
184 //------------------------------------------------------------------------------------------------
185 override void HandlerAttached(Widget w)
186 {
187 m_Root = w;
188
189 m_TickBoxImage = ImageWidget.Cast(w.FindAnyWidget(m_sTickBoxImageName));
190 if (!m_TickBoxImage)
191 return;
192
193 m_TickBoxButton = w.FindAnyWidget(m_sTickBoxButtonName);
194 if (!m_TickBoxButton)
195 return;
196
198 if (onButton) onButton.Insert(OnButtonToggle);
199 }
200
201 //------------------------------------------------------------------------------------------------
202 override void HandlerDeattached(Widget w)
203 {
204 if (m_AttributeUI)
205 m_AttributeUI.GetOnEnabledByAttribute().Remove(OnAttributeEnabledByAttribute);
206 }
207}
ScriptInvokerBase< ScriptInvokerBoolMethod > ScriptInvokerBool
Component to execute action when the button or its shortcut is pressed.
Definition Color.c:13
Using a controller will show/hide the Select button hint if the attribute with this script is focused...
void InitDisabled()
On init as overriding attributes (multiple entities with the same attribute) but non of them are conf...
SCR_BaseEditorAttributeUIComponent m_AttributeUI
void SetVisible(bool frameVisible, bool buttonVisible)
void InitTickbox(bool toggleState, SCR_BaseEditorAttributeUIComponent attributeUI, typename linkedOverrideAttributeType=typename.Empty)
SCR_FieldOfViewSettings Attribute
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134