Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
profileoptionsui.c
Go to the documentation of this file.
1 class ProfileOptionsUI extends ScriptedWidgetEventHandler
2 {
3  void ~ProfileOptionsUI()
4  {
5  Deattach();
6  }
7 
8  void Attach(int profileOption, array<Widget> widget_array)
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;
46  ButtonWidget button;
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;
58  ButtonWidget button;
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
76  void SetButtonStates(int index)
77  {
78  ButtonWidget button;
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  {
84  button.SetState( i == index );
85  }
86  }
87  }
88 
89  array<Widget> GetWidgetArray()
90  {
91  return m_widget_array;
92  }
93 
94  int GetProfileOption()
95  {
96  return m_profileOption;
97  }
98 
99  int m_profileOption;
100  Widget m_widget;
101  ref array<Widget> m_widget_array;
102 }
y
Icon y
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
array< Widget >
x
Icon x
Widget
Definition: enwidgets.c:189
OnClick
override bool OnClick(Widget w, int x, int y, int button)
buttons clicks
Definition: dayzgame.c:146
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650
SetValue
override void SetValue(int value, bool fire_event=true)
Definition: optionselectormultistate.c:226