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

		TextWidget label	= TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
		TextWidget text		= TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text"));
		TextWidget text2	= TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_text_1"));
		
		if (label)
		{
			label.SetColor(color);
		}
		
		if (text)
		{
			text.SetColor(color);
		}
		
		if (text2)
		{
			text2.SetColor(color);
		}
	}
}