DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
OptionSelectorSliderSetup.c
См. документацию.
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);
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 #ifdef PLATFORM_WINDOWS
52 SetFocus(null);
53 #endif
54 }
55
56 return true;
57 }
58
59 override bool OnMouseButtonUp(Widget w, int x, int y, int button)
60 {
61 if (button == MouseState.LEFT && w == m_Slider)
62 {
63 }
64 return false;
65 }
66
67 override bool OnChange(Widget w, int x, int y, bool finished)
68 {
69 if (w == m_Slider)
70 {
71 m_OptionChanged.Invoke(GetValue());
72 return true;
73 }
74 return false;
75 }
76
77 override bool IsFocusable(Widget w)
78 {
79 if (w)
80 {
81 return (w == m_Parent || w == m_Slider);
82 }
83 return false;
84 }
85
86 override bool OnFocus(Widget w, int x, int y)
87 {
88 #ifdef PLATFORM_CONSOLE
89 if (GetFocus() != m_Slider)
90 {
92 m_Parent.Enable(false);
93 }
94
95 return super.OnFocus(m_Parent, x, y);
96
97 #else
98 return false;
99 #endif
100 }
101
102 override bool OnFocusLost(Widget w, int x, int y)
103 {
104 if (w == m_Slider)
105 {
106 m_Parent.Enable(true);
107 return super.OnFocusLost(m_Parent, x, y);
108 }
109 return false;
110 }
111
112 float NormalizeInput(float value)
113 {
114 float ret = (value - m_MinValue) / (m_MaxValue - m_MinValue);
115 return ret;
116 }
117
118 void SetStep(float step)
119 {
120 m_Slider.SetStep(step);
121 }
122
123 void SetValue(float value, bool update = true)
124 {
125 float normalizeValue = NormalizeInput(value);
126 float step = m_Slider.GetStep();
127
128 normalizeValue = Math.Round(normalizeValue / step) * step;
129 m_Slider.SetCurrent(normalizeValue);
130 if (update)
131 m_OptionChanged.Invoke(GetValue());
132 }
133
134 float GetValue()
135 {
136 float current = m_Slider.GetCurrent();
137 float ret = (current * (m_MaxValue - m_MinValue)) + m_MinValue;
138 return ret;
139 }
140
141 void SetMax(float max)
142 {
143 m_MaxValue = max;
144 }
145
146 override void ColorHighlight(Widget w)
147 {
148 if (!w)
149 return;
150
151 if (m_Slider)
152 {
154 m_Slider.SetColor(ARGB(255, 200, 0, 0));
155 }
156
157 super.ColorHighlight(w);
158 }
159
160 override void ColorNormal(Widget w)
161 {
162 if (!w)
163 return;
164
165 if (m_Slider)
166 {
167 m_Slider.SetColor(ARGB(140, 255, 255, 255));
168 }
169
170 super.ColorNormal(w);
171 }
172}
Entity m_Parent
Определения CachedEquipmentStorageBase.c:17
Icon x
Icon y
Widget m_Root
Определения SizeToChild.c:91
float GetValue()
Определения SyncedValue.c:55
Определения EnMath.c:7
void SetStep(float step)
Определения OptionSelectorSliderSetup.c:118
override bool OnFocus(Widget w, int x, int y)
Определения OptionSelectorSliderSetup.c:86
override bool OnChange(Widget w, int x, int y, bool finished)
Определения OptionSelectorSliderSetup.c:67
override bool IsFocusable(Widget w)
Определения OptionSelectorSliderSetup.c:77
override bool OnFocusLost(Widget w, int x, int y)
Определения OptionSelectorSliderSetup.c:102
override void ColorHighlight(Widget w)
Определения OptionSelectorSliderSetup.c:146
SliderWidget m_Slider
Определения OptionSelectorSliderSetup.c:3
override bool OnMouseEnter(Widget w, int x, int y)
Определения OptionSelectorSliderSetup.c:26
float NormalizeInput(float value)
Определения OptionSelectorSliderSetup.c:112
void SetValue(float value, bool update=true)
Определения OptionSelectorSliderSetup.c:123
override void Enable()
Определения OptionSelectorSliderSetup.c:12
override void ColorNormal(Widget w)
Определения OptionSelectorSliderSetup.c:160
override void Disable()
Определения OptionSelectorSliderSetup.c:19
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения OptionSelectorSliderSetup.c:41
override bool OnMouseButtonUp(Widget w, int x, int y, int button)
Определения OptionSelectorSliderSetup.c:59
void SetMax(float max)
Определения OptionSelectorSliderSetup.c:141
void ~OptionSelectorSliderSetup()
Определения OptionSelectorSliderSetup.c:7
override bool OnFocusLost(Widget w, int x, int y)
Определения OptionSelectorSlider.c:176
override bool OnFocus(Widget w, int x, int y)
Определения OptionSelectorSlider.c:161
This Option Selector handles a Slider Marker, which basically has 2 sliders One slider is for selecti...
Определения OptionSelectorLevelMarker.c:7
Определения EnWidgets.c:190
static proto float Round(float f)
Returns mathematical round of value.
MouseState
Определения EnSystem.c:311
WidgetFlags
Определения EnWidgets.c:58
proto native Widget GetFocus()
proto native void SetFocus(Widget w)
int ARGB(int a, int r, int g, int b)
Определения proto.c:322