Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
optionselectorslidersetup.c
Go to the documentation of this file.
2 {
3  protected SliderWidget m_Slider;
4  protected float m_MinValue;
5  protected float m_MaxValue;
6 
8  {
9  delete m_Root;
10  }
11 
12  override void Enable()
13  {
14  super.Enable();
15 
16  m_Slider.ClearFlags(WidgetFlags.IGNOREPOINTER);
17  }
18 
19  override void Disable()
20  {
21  super.Disable();
22 
23  m_Slider.SetFlags(WidgetFlags.IGNOREPOINTER);
24  }
25 
26  override bool OnMouseEnter(Widget w, int x, int y)
27  {
28  if (m_ParentClass)
29  {
30  OnFocus(w, x, y);
31  m_ParentClass.OnFocus(m_Root.GetParent(), -1, m_SelectorType);
32  #ifdef PLATFORM_WINDOWS
33  m_ParentClass.OnMouseEnter(m_Root.GetParent().GetParent(), x, y);
34  ColorHighlight(w);
35  #endif
36  }
37 
38  return true;
39  }
40 
41  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
42  {
43  if (m_ParentClass)
44  {
45  m_ParentClass.OnFocus(null, x, y);
46  #ifdef PLATFORM_WINDOWS
47  m_ParentClass.OnMouseLeave(m_Root.GetParent().GetParent(), enterW, x, y);
48  ColorNormal(w);
49  #endif
50  OnFocusLost(w, x, y);
51  SetFocus(null);
52  }
53 
54  return true;
55  }
56 
57  override bool OnMouseButtonUp(Widget w, int x, int y, int button)
58  {
59  if (button == MouseState.LEFT && w == m_Slider)
60  {
61  }
62  return false;
63  }
64 
65  override bool OnChange(Widget w, int x, int y, bool finished)
66  {
67  if (w == m_Slider)
68  {
69  m_OptionChanged.Invoke(GetValue());
70  return true;
71  }
72  return false;
73  }
74 
75  override bool IsFocusable(Widget w)
76  {
77  if (w)
78  {
79  return (w == m_Parent || w == m_Slider);
80  }
81  return false;
82  }
83 
84  override bool OnFocus(Widget w, int x, int y)
85  {
86  #ifdef PLATFORM_CONSOLE
87  if (GetFocus() != m_Slider)
88  {
89  SetFocus(m_Slider);
90  m_Parent.Enable(false);
91  }
92 
93  return super.OnFocus(m_Parent, x, y);
94 
95  #else
96  return false;
97  #endif
98  }
99 
100  override bool OnFocusLost(Widget w, int x, int y)
101  {
102  if (w == m_Slider)
103  {
104  m_Parent.Enable(true);
105  return super.OnFocusLost(m_Parent, x, y);
106  }
107  return false;
108  }
109 
110  float NormalizeInput(float value)
111  {
112  float ret = (value - m_MinValue) / (m_MaxValue - m_MinValue);
113  return ret;
114  }
115 
116  void SetStep(float step)
117  {
118  m_Slider.SetStep(step);
119  }
120 
121  void SetValue(float value, bool update = true)
122  {
123  m_Slider.SetCurrent(NormalizeInput(value));
124  if (update)
125  m_OptionChanged.Invoke(GetValue());
126  }
127 
128  float GetValue()
129  {
130  float ret = (m_Slider.GetCurrent() * (m_MaxValue - m_MinValue)) + m_MinValue;
131  return ret;
132  }
133 
134  void SetMax(float max)
135  {
136  m_MaxValue = max;
137  }
138 
139  override void ColorHighlight(Widget w)
140  {
141  if (!w)
142  return;
143 
144  if (m_Slider)
145  {
146  SetFocus(m_Slider);
147  m_Slider.SetColor(ARGB(255, 200, 0, 0));
148  }
149 
150  super.ColorHighlight(w);
151  }
152 
153  override void ColorNormal(Widget w)
154  {
155  if (!w)
156  return;
157 
158  if (m_Slider)
159  {
160  m_Slider.SetColor(ARGB(140, 255, 255, 255));
161  }
162 
163  super.ColorNormal(w);
164  }
165 }
OptionSelectorBase
Definition: optionselector.c:1
OptionSelectorSliderSetup
This Option Selector handles a Slider Marker, which basically has 2 sliders One slider is for selecti...
Definition: optionselectorlevelmarker.c:6
GetFocus
proto native Widget GetFocus()
y
Icon y
m_MinValue
float m_MinValue
Definition: staminahandler.c:139
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
OnMouseButtonUp
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Definition: radialmenu.c:668
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
MouseState
MouseState
Definition: ensystem.c:310
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
m_MaxValue
float m_MaxValue
Definition: staminahandler.c:139
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
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