DayZ 1.24
Loading...
Searching...
No Matches
ScriptConsoleWeatherTab.c
Go to the documentation of this file.
2{
3 protected ref Timer m_RPCTimer = new Timer();
4 protected const int INTERPOLATION_MAX = 920;
5 protected const int DURATION_MAX = 920;
6
7 // FOG
10
12
15
16
19
23
24 protected static float m_FogValue = -1;
25 protected static float m_FogInterpolationTimeValue;
26 protected static float m_FogDurationTimeValue = -1;
27
28
29 // OVERCAST
32
34
37
38
41
45
46 protected static float m_OvercastValue = -1;
47 protected static float m_OvercastInterpolationTimeValue;
48 protected static float m_OvercastDurationTimeValue = -1;
49
50
51 // Rain
54
56
59
60
63
67
68 protected static float m_RainValue = -1;
69 protected static float m_RainInterpolationTimeValue;
70 protected static float m_RainDurationTimeValue = -1;
71
72
73 // Other
77
80
81
99
101 {
102 // FOG
103 m_FogValueSetSlider = SliderWidget.Cast(root.FindAnyWidget("SliderFogValue"));
104 m_FogValueGetSlider = SliderWidget.Cast(root.FindAnyWidget("SliderFogActualValue"));
105 m_FogValueSetText = TextWidget.Cast(root.FindAnyWidget("TextFogValueActual"));
106
107 m_FogInterpolationTimeSlider = SliderWidget.Cast(root.FindAnyWidget("SliderFogTarget"));
108 m_FogDurationTimeSlider = SliderWidget.Cast(root.FindAnyWidget("SliderFogDuration"));
109
110 m_FogInterpolationMaxText = TextWidget.Cast(root.FindAnyWidget("TextMaxFogTarget"));
111 m_FogDurationMaxText = TextWidget.Cast(root.FindAnyWidget("TextMaxFogDuration"));
112
113 m_FogValueEditbox = EditBoxWidget.Cast(root.FindAnyWidget("EditBoxFogValue"));
114 m_FogInterpolationEditbox = EditBoxWidget.Cast(root.FindAnyWidget("EditBoxFogTarget"));
115 m_FogDurationEditbox = EditBoxWidget.Cast(root.FindAnyWidget("EditBoxFogDuration"));
116
117 // OVERCAST
118 m_OvercastValueSetSlider = SliderWidget.Cast(root.FindAnyWidget("SliderOvercastValue"));
119 m_OvercastValueGetSlider = SliderWidget.Cast(root.FindAnyWidget("SliderOvercastActualValue"));
120 m_OvercastValueSetText = TextWidget.Cast(root.FindAnyWidget("TextOvercastValueActual"));
121
122 m_OvercastInterpolationTimeSlider = SliderWidget.Cast(root.FindAnyWidget("SliderOvercastTarget"));
123 m_OvercastDurationTimeSlider = SliderWidget.Cast(root.FindAnyWidget("SliderOvercastDuration"));
124
125 m_OvercastInterpolationMaxText = TextWidget.Cast(root.FindAnyWidget("TextMaxOvercastTarget"));
126 m_OvercastDurationMaxText = TextWidget.Cast(root.FindAnyWidget("TextMaxOvercastDuration"));
127
128 m_OvercastValueEditbox = EditBoxWidget.Cast(root.FindAnyWidget("EditBoxOvercastValue"));
129 m_OvercastInterpolationEditbox = EditBoxWidget.Cast(root.FindAnyWidget("EditBoxOvercastTarget"));
130 m_OvercastDurationEditbox = EditBoxWidget.Cast(root.FindAnyWidget("EditBoxOvercastDuration"));
131
132 // Rain
133 m_RainValueSetSlider = SliderWidget.Cast(root.FindAnyWidget("SliderRainValue"));
134 m_RainValueGetSlider = SliderWidget.Cast(root.FindAnyWidget("SliderRainActualValue"));
135 m_RainValueSetText = TextWidget.Cast(root.FindAnyWidget("TextRainValueActual"));
136
137 m_RainInterpolationTimeSlider = SliderWidget.Cast(root.FindAnyWidget("SliderRainTarget"));
138 m_RainDurationTimeSlider = SliderWidget.Cast(root.FindAnyWidget("SliderRainDuration"));
139
140 m_RainInterpolationMaxText = TextWidget.Cast(root.FindAnyWidget("TextMaxRainTarget"));
141 m_RainDurationMaxText = TextWidget.Cast(root.FindAnyWidget("TextMaxRainDuration"));
142
143 m_RainValueEditbox = EditBoxWidget.Cast(root.FindAnyWidget("EditBoxRainValue"));
144 m_RainInterpolationEditbox = EditBoxWidget.Cast(root.FindAnyWidget("EditBoxRainTarget"));
145 m_RainDurationEditbox = EditBoxWidget.Cast(root.FindAnyWidget("EditBoxRainDuration"));
146
147 //Other
148 m_ResetButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonReset"));
149 m_UpdateButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonUpdate"));
150 m_ApplyButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonApply"));
151
152 m_CopyButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonCopy"));
153 m_PasteButton = ButtonWidget.Cast(root.FindAnyWidget("ButtonPaste"));
154
155
156 InitValues();
157 }
158
159 protected void ResetValues()
160 {
161 // FOG
162 m_FogValueEditbox.SetText("0");
163 m_FogDurationEditbox.SetText(DURATION_MAX.ToString());
164 m_FogInterpolationEditbox.SetText("0");
165
166 // OVERCAST
167 m_OvercastValueEditbox.SetText("0");
168 m_OvercastDurationEditbox.SetText(DURATION_MAX.ToString());
170
171 // Rain
172 m_RainValueEditbox.SetText("0");
173 m_RainDurationEditbox.SetText(DURATION_MAX.ToString());
174 m_RainInterpolationEditbox.SetText("0");
175
177
178 //FOG
179 m_FogValue = 0;
182
183 // OVERCAST
184 m_OvercastValue = 0;
187
188 //RAIN
189 m_RainValue = 0;
192
193
194 }
195
196 protected void InitValues(bool forceCurrent = false)
197 {
198
199 // FOG
200 float fogVal = m_FogValue;
201 if (forceCurrent || m_FogValue == -1)
202 fogVal = GetGame().GetWeather().GetFog().GetActual();
203 m_FogValueEditbox.SetText(fogVal.ToString());
204
206
207 if (m_FogDurationTimeValue == -1)
210
212 m_FogDurationMaxText.SetText(DURATION_MAX.ToString());
213
214
215 // OVERCAST
217 if (forceCurrent || m_OvercastValue == -1)
218 overcastVal = GetGame().GetWeather().GetOvercast().GetActual();
219 m_OvercastValueEditbox.SetText(overcastVal.ToString());
220
222
223
227
229 m_OvercastDurationMaxText.SetText(DURATION_MAX.ToString());
230
231 // RAIN
232 float rainVal = m_RainValue;
233 if (forceCurrent || m_RainValue == -1)
234 rainVal = GetGame().GetWeather().GetRain().GetActual();
235
236 m_RainValueEditbox.SetText(rainVal.ToString());
238
239 if (m_RainDurationTimeValue == -1)
242
244 m_RainDurationMaxText.SetText(DURATION_MAX.ToString());
245
247 }
248
249 protected void PasteValues(string clipboard)
250 {
252 clipboard.Split(" ", values);
253 if (values.Count() != 9)
254 return;
255 // FOG
256 m_FogValueEditbox.SetText(values.Get(0));
257 m_FogInterpolationEditbox.SetText(values.Get(1));
258 m_FogDurationEditbox.SetText(values.Get(2));
259 // OVERCAST
260 m_OvercastValueEditbox.SetText(values.Get(3));
262 m_OvercastDurationEditbox.SetText(values.Get(5));
263 // RAIN
264 m_RainValueEditbox.SetText(values.Get(6));
265 m_RainInterpolationEditbox.SetText(values.Get(7));
266 m_RainDurationEditbox.SetText(values.Get(8));
267 }
268
269 protected string CopyValues()
270 {
271 string output;
272
273 // FOG
274 output += m_FogValueEditbox.GetText();
275 output += " ";
277 output += " ";
278 output += m_FogDurationEditbox.GetText();
279 output += " ";
280 // OVERCAST
281 output += m_OvercastValueEditbox.GetText();
282 output += " ";
284 output += " ";
286 output += " ";
287 // RAIN
288 output += m_RainValueEditbox.GetText();
289 output += " ";
291 output += " ";
292 output += m_RainDurationEditbox.GetText();
293
294 return output;
295 }
296
297 override bool OnChange(Widget w, int x, int y, bool finished)
298 {
300
301 if (rmbDrag)
302 {
303 // first row
304 if (w == m_FogValueSetSlider)
305 {
306 m_OvercastValueSetSlider.SetCurrent(m_FogValueSetSlider.GetCurrent());
307 m_RainValueSetSlider.SetCurrent(m_FogValueSetSlider.GetCurrent());
308 }
309 else if (w == m_OvercastValueSetSlider)
310 {
311 m_FogValueSetSlider.SetCurrent(m_OvercastValueSetSlider.GetCurrent());
312 m_RainValueSetSlider.SetCurrent(m_OvercastValueSetSlider.GetCurrent());
313 }
314
315 else if (w == m_RainValueSetSlider)
316 {
317 m_FogValueSetSlider.SetCurrent(m_RainValueSetSlider.GetCurrent());
318 m_OvercastValueSetSlider.SetCurrent(m_RainValueSetSlider.GetCurrent());
319 }
320 // second row
322 {
325 }
327 {
330 }
331
333 {
336 }
337 // third row
338 else if (w == m_FogDurationTimeSlider)
339 {
340 m_RainDurationTimeSlider.SetCurrent(m_FogDurationTimeSlider.GetCurrent());
342 }
343 else if (w == m_RainDurationTimeSlider)
344 {
345 m_FogDurationTimeSlider.SetCurrent(m_RainDurationTimeSlider.GetCurrent());
347 }
348
350 {
353 }
354
355 }
356
357
359 if (slider)
360 {
361 if (rmbDrag && !m_RPCTimer.IsRunning())
362 {
364 m_RPCTimer.Run(0.25, this, "InvokeSendRPC");
365 }
367 return true;
368 }
370 if (box)
371 {
373 return true;
374 }
375 return false;
376 }
377
379 {
380 //fog
381 float editboxFogValue = m_FogValueEditbox.GetText().ToFloat();
382 m_FogValueSetSlider.SetCurrent(editboxFogValue * 100);
383
384 float editboxFogInterpolation = m_FogInterpolationEditbox.GetText().ToFloat();
386
387 float editboxFogDuration = m_FogDurationEditbox.GetText().ToFloat();
389
390 //overcast
391 float editboxOvercastValue = m_OvercastValueEditbox.GetText().ToFloat();
393
396
397 float editboxOvercastDuration = m_OvercastDurationEditbox.GetText().ToFloat();
399
400 //rain
401 float editboxRainValue = m_RainValueEditbox.GetText().ToFloat();
402 m_RainValueSetSlider.SetCurrent(editboxRainValue * 100);
403
404 float editboxRainInterpolation = m_RainInterpolationEditbox.GetText().ToFloat();
406
407 float editboxRainDuration = m_RainDurationEditbox.GetText().ToFloat();
409 }
410
412 {
413 //fog
416
419
420 m_FogValue = m_FogValueSetSlider.GetCurrent() / 100;
421 m_FogValueEditbox.SetText(m_FogValue.ToString());
422
423 //overcast
426
429
430 m_OvercastValue = m_OvercastValueSetSlider.GetCurrent() / 100;
431 m_OvercastValueEditbox.SetText(m_OvercastValue.ToString());
432
433 //rain
436
439
440 m_RainValue = m_RainValueSetSlider.GetCurrent() / 100;
441 m_RainValueEditbox.SetText(m_RainValue.ToString());
442 }
443
444 override bool OnClick(Widget w, int x, int y, int button)
445 {
446 if (w == m_ApplyButton)
447 {
449 return true;
450 }
451 else if (w == m_UpdateButton)
452 {
453 InitValues(true);
454 return true;
455 }
456 else if (w == m_ResetButton)
457 {
458 ResetValues();
459 InitValues(true);
460 return true;
461 }
462 else if (w == m_CopyButton)
463 {
464 string output = CopyValues();
465 GetGame().CopyToClipboard(output);
466 return true;
467 }
468
469 else if (w == m_PasteButton)
470 {
471 string input;
472 GetGame().CopyFromClipboard(input);
475 return true;
476 }
477
478 return false;
479 }
480
481
482 //RPC data where each value is strickly as shown in the UI on the sliders
484 {
486 // FOG
487 data.m_FogValue = m_FogValueSetSlider.GetCurrent() / 100;
488 data.m_FogInterpolation = m_FogInterpolationTimeValue;
489 data.m_FogDuration = m_FogDurationTimeSlider.GetCurrent() / 100 * 960;
490
491 // Rain
492 data.m_RainValue = m_RainValueSetSlider.GetCurrent() / 100;
493 data.m_RainInterpolation = m_RainInterpolationTimeValue;
494 data.m_RainDuration = m_RainDurationTimeSlider.GetCurrent() / 100 * 960;
495
496 // OVERCAST
497 data.m_OvercastValue = m_OvercastValueSetSlider.GetCurrent() / 100;
498 data.m_OvercastInterpolation = m_OvercastInterpolationTimeValue;
499 data.m_OvercastDuration = m_OvercastDurationTimeSlider.GetCurrent() / 100 * 960;
500
501 return data;
502 }
503
504 //RPC data where the duration and interpolation times are forced(their slider values are ignored) to allow for immediate change and lasting effect
506 {
508 // FOG
509 data.m_FogValue = m_FogValueSetSlider.GetCurrent() / 100;
510 data.m_FogInterpolation = 0;
511 data.m_FogDuration = 960;
512
513 // Rain
514 data.m_RainValue = m_RainValueSetSlider.GetCurrent() / 100;
515 data.m_RainInterpolation = 0;
516 data.m_RainDuration = 960;
517
518 // OVERCAST
519 data.m_OvercastValue = m_OvercastValueSetSlider.GetCurrent() / 100;
520 data.m_OvercastInterpolation = 0;
521 data.m_OvercastDuration = 960;
522
523 return data;
524 }
525
527 {
529 if (GetGame().GetPlayer())
530 identity = GetGame().GetPlayer().GetIdentity();
531
532 GetGame().RPCSingleParam(null, ERPCs.DEV_SET_WEATHER, new Param1<DebugWeatherRPCData>(data), true, identity);
533 }
534
535 protected void InvokeSendRPC()
536 {
538 }
539
540 override void Update(float timeslice)
541 {
542 super.Update(timeslice);
543 float overcast = GetGame().GetWeather().GetOvercast().GetActual();
544 m_OvercastValueGetSlider.SetCurrent(overcast * 100);
545 m_OvercastValueSetText.SetText(overcast.ToString());
546
547 float fog = GetGame().GetWeather().GetFog().GetActual();
548 m_FogValueGetSlider.SetCurrent(fog * 100);
549 m_FogValueSetText.SetText(fog.ToString());
550
551 float rain = GetGame().GetWeather().GetRain().GetActual();
552 m_RainValueGetSlider.SetCurrent(rain * 100);
553 m_RainValueSetText.SetText(rain.ToString());
554 }
555}
void SendRPC()
ERPCs
Definition ERPCs.c:2
Icon x
Icon y
PlayerBase GetPlayer()
override void InitValues()
Definition EnMath.c:7
The class that will be instanced (moddable)
Definition gameplay.c:376
override void Update(float timeslice)
void SendRPC(DebugWeatherRPCData data)
void InitValues(bool forceCurrent=false)
override bool OnChange(Widget w, int x, int y, bool finished)
override bool OnClick(Widget w, int x, int y, int button)
DebugWeatherRPCData GetRPCDataNormal()
DebugWeatherRPCData GetRPCDataImmediate()
void PasteValues(string clipboard)
void ScriptConsoleWeatherTab(Widget root, ScriptConsole console, Widget button, ScriptConsoleTabBase parent=null)
proto native CGame GetGame()
array< string > TStringArray
Definition EnScript.c:666
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
const int MB_EVENT_CLICK
MouseState
Definition EnSystem.c:311
proto native int GetMouseState(MouseState index)