DayZ 1.24
Loading...
Searching...
No Matches
OptionSelectorSliderSetup.c
Go to the documentation of this file.
2{
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);
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);
49#endif
50 OnFocusLost(w, x, y);
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 return (w == m_Parent || w == m_Slider);
79 return false;
80 }
81
82 override bool OnFocus(Widget w, int x, int y)
83 {
84#ifdef PLATFORM_CONSOLE
85 if (GetFocus() != m_Slider)
86 {
87 SetFocus(m_Slider);
88 m_Parent.Enable(false);
89 }
90
91 return super.OnFocus(m_Parent, x, y);
92
93#else
94 return false;
95#endif
96 }
97
98 override bool OnFocusLost(Widget w, int x, int y)
99 {
100 if (w == m_Slider)
101 {
102 m_Parent.Enable(true);
103 return super.OnFocusLost(m_Parent, x, y);
104 }
105 return false;
106 }
107
109 {
110 float ret = (value - m_MinValue) / (m_MaxValue - m_MinValue);
111 return ret;
112 }
113
114 void SetStep(float step)
115 {
116 m_Slider.SetStep(step);
117 }
118
119 void SetValue(float value, bool update = true)
120 {
121 m_Slider.SetCurrent(NormalizeInput(value));
122 if (update)
123 m_OptionChanged.Invoke(GetValue());
124 }
125
126 float GetValue()
127 {
128 float ret = (m_Slider.GetCurrent() * (m_MaxValue - m_MinValue)) + m_MinValue;
129 return ret;
130 }
131
132 void SetMax(float max)
133 {
134 m_MaxValue = max;
135 }
136
137 override void ColorHighlight(Widget w)
138 {
139 if (!w)
140 return;
141
142 if (m_Slider)
143 {
144 SetFocus(m_Slider);
145 m_Slider.SetColor(ARGB(255, 200, 0, 0));
146 }
147
148 super.ColorHighlight(w);
149 }
150
151 override void ColorNormal(Widget w)
152 {
153 if (!w)
154 return;
155
156 if (m_Slider)
157 m_Slider.SetColor(ARGB(140, 255, 255, 255));
158
159 super.ColorNormal(w);
160 }
161}
Icon x
Icon y
void ColorNormal(Widget w)
override bool OnFocusLost(Widget w, int x, int y)
void ColorHighlight(Widget w)
override bool OnFocus(Widget w, int x, int y)
Widget m_Root
Definition SizeToChild.c:85
Widget m_Parent
Definition SizeToChild.c:86
float m_MaxValue
float m_MinValue
float GetValue()
Definition SyncedValue.c:55
override bool OnFocus(Widget w, int x, int y)
override bool OnChange(Widget w, int x, int y, bool finished)
override bool IsFocusable(Widget w)
override bool OnFocusLost(Widget w, int x, int y)
override void ColorHighlight(Widget w)
override bool OnMouseEnter(Widget w, int x, int y)
float NormalizeInput(float value)
void SetValue(float value, bool update=true)
override void ColorNormal(Widget w)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
This Option Selector handles a Slider Marker, which basically has 2 sliders One slider is for selecti...
MouseState
Definition EnSystem.c:311
WidgetFlags
Definition EnWidgets.c:58
proto native Widget GetFocus()
proto native void SetFocus(Widget w)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322