Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
optionselectorbase.c
Go to the documentation of this file.
1class OptionSelectorBase extends ScriptedWidgetEventHandler
2{
3 protected int m_SelectorType = 0;
4 protected Widget m_Parent;
5 protected Widget m_Root;
6
7 protected bool m_Enabled;
8
9 protected ScriptedWidgetEventHandler m_ParentClass;
10
11 ref ScriptInvoker m_OptionFocused = new ScriptInvoker;
12 ref ScriptInvoker m_OptionUnfocused = new ScriptInvoker;
13 ref ScriptInvoker m_AttemptOptionChange = new ScriptInvoker;
14 ref ScriptInvoker m_OptionChanged = new ScriptInvoker;
15
17 {
18 delete m_Root;
19 }
20
21 Widget GetParent()
22 {
23 return m_Parent;
24 }
25
26 bool IsFocusable(Widget w)
27 {
28 if (w)
29 {
30 return w == m_Parent;
31 }
32 return false;
33 }
34
35 override bool OnMouseEnter(Widget w, int x, int y)
36 {
37 if (!IsFocusable(w))
38 return true;
39
40 if (m_ParentClass)
41 {
42 m_ParentClass.OnFocus(m_Root.GetParent(), -1, m_SelectorType);
43 #ifndef PLATFORM_CONSOLE
44 m_ParentClass.OnMouseEnter(m_Root.GetParent().GetParent(), x, y);
45 #endif
46 }
47
48 UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
49
50 if (menu && menu.IsInherited(CharacterCreationMenu))
51 {
52 menu.OnFocus(m_Root.GetParent(), -1, m_SelectorType);
53 menu.OnMouseEnter(m_Root.GetParent().GetParent(), x, y);
54 }
55
56 #ifndef PLATFORM_CONSOLE
58 #else
59 ColorHighlightConsole(w);
60 if (m_ParentClass)
61 {
62 m_ParentClass.OnFocus(m_Root.GetParent(), -1, m_SelectorType);
63 }
64 #endif
65
66 return true;
67 }
68
69 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
70 {
71 #ifdef PLATFORM_CONSOLE
72 if (IsFocusable(enterW))
73 return true;
74 #endif
75
76 if (m_ParentClass)
77 {
78 m_ParentClass.OnFocus(null, x, y);
79 #ifndef PLATFORM_CONSOLE
80 m_ParentClass.OnMouseLeave(m_Root.GetParent().GetParent(), enterW, x, y);
81 #endif
82 }
83
84 UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
85
86 if (menu && menu.IsInherited(CharacterCreationMenu))
87 {
88 menu.OnFocus(null, x, y);
89 menu.OnMouseLeave(m_Root.GetParent().GetParent(), enterW, x, y);
90 }
91
92 #ifndef PLATFORM_CONSOLE
93 ColorNormal(w);
94 #else
96 if (m_ParentClass)
97 {
98 m_ParentClass.OnFocusLost(w, x, y);
99 }
100 #endif
101
102 return true;
103 }
104
105 override bool OnFocus(Widget w, int x, int y)
106 {
107 if (IsFocusable(w))
108 {
109 ColorHighlightConsole(w);
110 if (m_ParentClass)
111 {
112 m_ParentClass.OnFocus(m_Root.GetParent(), -1, m_SelectorType);
113 }
114 return true;
115 }
116 return false;
117 }
118
119 override bool OnFocusLost(Widget w, int x, int y)
120 {
122 if (m_ParentClass)
123 {
124 m_ParentClass.OnFocusLost(w, x, y);
125 }
126 return true;
127 }
128
129 void Focus()
130 {
131 #ifndef PLATFORM_CONSOLE
132 SetFocus(m_Root);
133 #else
134 SetFocus(m_Parent);
135 #endif
136 }
137
138 void Enable()
139 {
140 m_Enabled = true;
141
142 m_Parent.ClearFlags(WidgetFlags.IGNOREPOINTER);
143
144 #ifdef PLATFORM_CONSOLE
146 #else
148 #endif
149 }
150
151 void Disable()
152 {
153 m_Enabled = false;
154
155 m_Parent.SetFlags(WidgetFlags.IGNOREPOINTER);
156
157 #ifdef PLATFORM_CONSOLE
159 #else
160 ColorDisabled(m_Parent);
161 #endif
162 }
163
164 void ColorHighlight(Widget w)
165 {
166 if (!w)
167 return;
168
169 ButtonSetColor(w, ARGB(255, 255, 0, 0));
170 }
171
172 void ColorNormal(Widget w)
173 {
174 if (!w)
175 return;
176
177 int color_pnl = ARGB(255, 255, 255, 255);
178 int color_lbl = ARGB(255, 255, 255, 255);
179
180 ButtonSetColor(w, color_pnl);
181
182 Widget title_label = w.FindAnyWidget(w.GetName() + "_label");
183 Widget option_label = w.FindAnyWidget("option_label");
184
185 if (title_label)
186 {
187 title_label.SetColor(color_lbl);
188 }
189
190 if (option_label)
191 {
192 option_label.SetColor(color_lbl);
193 }
194 }
195
196 void ColorDisabled(Widget w)
197 {
198 if (!w)
199 return;
200
201 int color_pnl = ARGB(0, 0, 0, 0);
202 int color_lbl = ARGB(120, 255, 255, 255);
203
204 ButtonSetColor(w, color_pnl);
205
206 Widget title_label = w.FindAnyWidget(w.GetName() + "_label");
207 Widget option_label = w.FindAnyWidget("option_label");
208
209 if (title_label)
210 {
211 title_label.SetColor(color_lbl);
212 }
213
214 if (option_label)
215 {
216 option_label.SetColor(color_lbl);
217 }
218 }
219
220 void ButtonSetColor(Widget w, int color)
221 {
222 Widget option = w.FindAnyWidget(w.GetName() + "_image");
223
224 if (option)
225 {
226 option.SetColor(color);
227 }
228 }
229
230 void ColorHighlightConsole(Widget w)
231 {
232 if (!w)
233 return;
234
235 int color_pnl = ARGB(255, 200, 0, 0);
236 int color_lbl = ARGB(255, 255, 255, 255);
237
238 ButtonSetColorConsole(w, color_pnl);
239 ButtonSetAlphaAnimConsole(null);
240 ButtonSetTextColorConsole(w, color_lbl);
241 }
242
243 void ColorNormalConsole(Widget w)
244 {
245 if (!w)
246 return;
247
248 int color_pnl = ARGB(0, 0, 0, 0);
249 int color_lbl = ARGB(255, 255, 255, 255);
250
251 ButtonSetColorConsole(w, color_pnl);
252 ButtonSetAlphaAnimConsole(null);
253 ButtonSetTextColorConsole(w, color_lbl);
254 }
255
256 void ColorDisabledConsole(Widget w)
257 {
258 if (!w)
259 return;
260
261 int color_pnl = ARGB(0, 0, 0, 0);
262 int color_lbl = ARGB(120, 255, 255, 255);
263
264 ButtonSetColorConsole(w, color_pnl);
265 ButtonSetAlphaAnimConsole(null);
266 ButtonSetTextColorConsole(w, color_lbl);
267 }
268
269 void ButtonSetColorConsole(Widget w, int color)
270 {
271 w.SetColor(color);
272 }
273
274 void ButtonSetAlphaAnimConsole(Widget w)
275 {
276 if (!w)
277 return;
278
279 Widget panel = w.FindAnyWidget(w.GetName() + "_panel");
280
281 if (panel)
282 {
283 //m_Root.SetWidgetAnimAlpha(panel);
284 }
285 }
286
287 void ButtonSetTextColorConsole(Widget w, int color)
288 {
289 if (!w)
290 return;
291
292 TextWidget label = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
293 TextWidget text = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
294 TextWidget text2 = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
295
296 if (label)
297 {
298 label.SetColor(color);
299 }
300
301 if (text)
302 {
303 text.SetColor(color);
304 }
305
306 if (text2)
307 {
308 text2.SetColor(color);
309 }
310 }
311}
override bool OnFocus(Widget w, int x, int y)
override bool IsFocusable(Widget w)
override bool OnFocusLost(Widget w, int x, int y)
override void ColorNormalConsole(Widget w)
override void ColorHighlight(Widget w)
override void ColorDisabledConsole(Widget w)
override bool OnMouseEnter(Widget w, int x, int y)
override void Enable()
override void ColorNormal(Widget w)
override void Disable()
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116
override bool OnMouseEnter(Widget w, int x, int y)
override bool OnFocus(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
bool m_Enabled
Definition traptrigger.c:71
proto native CGame GetGame()
WidgetFlags
Definition enwidgets.c:58
Icon x
Icon y
int ARGB(int a, int r, int g, int b)
Definition proto.c:322
void Focus()
Widget m_Root
Definition sizetochild.c:91
Widget m_Parent
Definition sizetochild.c:92