DayZ 1.24
Loading...
Searching...
No Matches
ProfileOptionsUI.c
Go to the documentation of this file.
2{
4 {
5 Deattach();
6 }
7
9 {
10 m_profileOption = profileOption;
11 m_widget_array = new array<Widget>;
12 m_widget_array = widget_array;
13
14 for (int i = 0; i < m_widget_array.Count(); i++)
15 {
16 m_widget = m_widget_array.Get(i);
17 if (m_widget)
18 {
19 m_widget.SetHandler(this);
20
21 Init();
22 }
23 }
24 }
25
26 void Deattach()
27 {
28 //m_profileOption = NULL;
29 if (m_widget_array && m_widget_array.Count() > 0)
30 {
31 for (int i = 0; i < m_widget_array.Count(); i++)
32 {
33 m_widget = m_widget_array.Get(i);
34 if (m_widget)
35 {
36 m_widget.SetHandler(NULL);
37 m_widget = NULL;
38 }
39 }
40 }
41 }
42
43 void Init()
44 {
45 int state;
47
48 if (Class.CastTo(button, m_widget))
49 {
50 state = m_widget_array.Find(m_widget);
51 button.SetState(g_Game.GetProfileOption(m_profileOption) == state); //works for bool values only!!!
52 }
53 }
54
55 void SetValue()
56 {
57 int state;
59
60 if (Class.CastTo(button, m_widget))
61 {
62 state = m_widget_array.Find(m_widget);
63 SetButtonStates(state);
64 }
65 }
66
67 override bool OnClick(Widget w, int x, int y, int button)
68 {
69 super.OnClick(w, x, y, button);
70 m_widget = w;
71 SetValue();
72 return false;
73 }
74
75 //TODO check for unnescessary duplicate methods
77 {
79 for (int i = 0; i < m_widget_array.Count(); i++)
80 {
81 button = ButtonWidget.Cast(m_widget_array.Get(i));
82 if (button)
83 button.SetState(i == index);
84 }
85 }
86
88 {
89 return m_widget_array;
90 }
91
93 {
94 return m_profileOption;
95 }
96
100}
DayZGame g_Game
Definition DayZGame.c:3528
override Widget Init()
Definition DayZGame.c:120
Icon x
Icon y
override void SetValue(int value, bool fire_event=true)
Super root of all classes in Enforce script.
Definition EnScript.c:11
map: item x vector(index, width, height)
Definition EnWidgets.c:651
void Attach(int profileOption, array< Widget > widget_array)
ref array< Widget > m_widget_array
override bool OnClick(Widget w, int x, int y, int button)
array< Widget > GetWidgetArray()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.