Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
optionselectoreditbox.c
Go to the documentation of this file.
1 class OptionSelectorEditbox extends OptionSelectorBase
2 {
3  protected EditBoxWidget m_EditBox;
4 
5  void OptionSelectorEditbox(Widget parent, string value, ScriptedWidgetEventHandler parent_menu, bool disabled)
6  {
7  m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/option_editbox.layout", parent);
8  #ifdef PLATFORM_CONSOLE
9  m_Parent = parent.GetParent().GetParent();
10  #else
11  #ifdef PLATFORM_WINDOWS
12  m_Parent = parent.GetParent();
13  #endif
14  #endif
15 
16  m_SelectorType = 1;
17  m_ParentClass = parent_menu;
18  m_EditBox = EditBoxWidget.Cast(m_Root.FindAnyWidget("option_value"));
19 
20  SetValue(value);
21  Enable();
22 
23  m_Parent.SetHandler(this);
24  }
25 
26  void ~OptionSelectorEditbox()
27  {
28  delete m_Root;
29  }
30 
31  override void Enable()
32  {
33  super.Enable();
34 
35  m_EditBox.ClearFlags(WidgetFlags.IGNOREPOINTER);
36  }
37 
38  override void Disable()
39  {
40  super.Disable();
41 
42  m_EditBox.SetFlags(WidgetFlags.IGNOREPOINTER);
43  }
44 
45  override bool OnMouseEnter(Widget w, int x, int y)
46  {
47  if (!IsFocusable(w))
48  return true;
49 
50  if (m_ParentClass)
51  {
52  m_ParentClass.OnFocus(m_Root.GetParent(), -1, m_SelectorType);
53  m_ParentClass.OnMouseEnter(m_Root.GetParent().GetParent(), x, y);
54  }
55 
56  UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
57 
58  if (menu && menu.IsInherited(CharacterCreationMenu))
59  {
60  menu.OnFocus(m_Root.GetParent(), -1, m_SelectorType);
61  menu.OnMouseEnter(m_Root.GetParent().GetParent(), x, y);
62  }
63 
64  ColorHighlight(w);
65 
66  return true;
67  }
68 
69  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
70  {
71  if (IsFocusable(enterW))
72  return true;
73 
74  if (m_ParentClass)
75  {
76  m_ParentClass.OnFocus(null, x, y);
77  m_ParentClass.OnMouseLeave(m_Root.GetParent().GetParent(), enterW, x, y);
78  }
79 
80  UIScriptedMenu menu = GetGame().GetUIManager().GetMenu();
81 
82  if (menu && menu.IsInherited(CharacterCreationMenu))
83  {
84  menu.OnFocus(null, x, y);
85  menu.OnMouseLeave(m_Root.GetParent().GetParent(), enterW, x, y);
86  }
87 
88  ColorNormal(w);
89 
90  return true;
91  }
92 
93  override bool OnChange(Widget w, int x, int y, bool finished)
94  {
95  if (w == m_EditBox)
96  {
97  m_OptionChanged.Invoke(GetValue());
98  return true;
99  }
100  return false;
101  }
102 
103  override bool IsFocusable(Widget w)
104  {
105  if (w)
106  {
107  return (w == m_Parent || w == m_EditBox);
108  }
109  return false;
110  }
111 
112  override bool OnFocus(Widget w, int x, int y)
113  {
114  if (GetFocus() != m_EditBox)
115  {
116  SetFocus(m_EditBox);
117  m_Parent.Enable(false);
118  }
119 
120  return super.OnFocus(m_Parent, x, y);
121  }
122 
123  override bool OnFocusLost(Widget w, int x, int y)
124  {
125  if (w == m_EditBox)
126  {
127  m_Parent.Enable(true);
128  return super.OnFocusLost(m_Parent, x, y);
129  }
130  return false;
131  }
132 
133  void SetValue(string value, bool update = true)
134  {
135  m_EditBox.SetText(value);
136  if (update)
137  m_OptionChanged.Invoke(GetValue());
138  }
139 
140  string GetValue()
141  {
142  return m_EditBox.GetText();
143  }
144 
145  override void ColorHighlight(Widget w)
146  {
147  if (!w)
148  return;
149 
150  if (m_EditBox)
151  {
152  SetFocus(m_EditBox);
153  m_EditBox.SetColor(ARGB(255, 200, 0, 0));
154  }
155 
156  super.ColorHighlight(w);
157  }
158 
159  override void ColorNormal(Widget w)
160  {
161  if (!w)
162  return;
163 
164  if (m_EditBox)
165  {
166  m_EditBox.SetColor(ARGB(140, 255, 255, 255));
167  }
168 
169  super.ColorNormal(w);
170  }
171 }
GetGame
proto native CGame GetGame()
UIScriptedMenu
Definition: dayzgame.c:63
OptionSelectorBase
Definition: optionselector.c:1
EditBoxWidget
Definition: enwidgets.c:353
GetFocus
proto native Widget GetFocus()
y
Icon y
m_Parent
protected Widget m_Parent
Definition: sizetochild.c:92
OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition: uihintpanel.c:276
Enable
proto native void Enable(bool enable)
ColorNormal
void ColorNormal(Widget w)
Definition: serverbrowsertab.c:668
ColorHighlight
void ColorHighlight(Widget w)
Definition: serverbrowsertab.c:619
OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition: serverbrowsertab.c:235
GetValue
string GetValue(int pIndex)
Definition: universaltemperaturesource.c:256
SetFocus
proto native void SetFocus(Widget w)
x
Icon x
WidgetFlags
WidgetFlags
Definition: enwidgets.c:57
OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition: serverbrowsertab.c:217
OnChange
bool OnChange(Widget w, int x, int y, bool finished)
Definition: huddebug.c:336
Widget
Definition: enwidgets.c:189
m_Root
protected Widget m_Root
Definition: sizetochild.c:91
OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition: uihintpanel.c:267
ScriptedWidgetEventHandler
map: item x vector(index, width, height)
Definition: enwidgets.c:650
ARGB
int ARGB(int a, int r, int g, int b)
Definition: proto.c:322
SetValue
override void SetValue(int value, bool fire_event=true)
Definition: optionselectormultistate.c:226
IsFocusable
bool IsFocusable(Widget w)
Definition: serverbrowsertab.c:284