4 protected const int INTERPOLATION_MAX = 920;
5 protected const int DURATION_MAX = 920;
8 protected SliderWidget m_FogValueSetSlider;
9 protected SliderWidget m_FogValueGetSlider;
13 protected SliderWidget m_FogInterpolationTimeSlider;
14 protected SliderWidget m_FogDurationTimeSlider;
17 protected TextWidget m_FogInterpolationMaxText;
24 protected static float m_FogValue = -1;
25 protected static float m_FogInterpolationTimeValue;
26 protected static float m_FogDurationTimeValue = -1;
30 protected SliderWidget m_OvercastValueSetSlider;
31 protected SliderWidget m_OvercastValueGetSlider;
35 protected SliderWidget m_OvercastInterpolationTimeSlider;
36 protected SliderWidget m_OvercastDurationTimeSlider;
39 protected TextWidget m_OvercastInterpolationMaxText;
40 protected TextWidget m_OvercastDurationMaxText;
46 protected static float m_OvercastValue = -1;
47 protected static float m_OvercastInterpolationTimeValue;
48 protected static float m_OvercastDurationTimeValue = -1;
52 protected SliderWidget m_RainValueSetSlider;
53 protected SliderWidget m_RainValueGetSlider;
57 protected SliderWidget m_RainInterpolationTimeSlider;
58 protected SliderWidget m_RainDurationTimeSlider;
61 protected TextWidget m_RainInterpolationMaxText;
68 protected static float m_RainValue = -1;
69 protected static float m_RainInterpolationTimeValue;
70 protected static float m_RainDurationTimeValue = -1;
74 protected ButtonWidget m_ResetButton;
75 protected ButtonWidget m_UpdateButton;
76 protected ButtonWidget m_ApplyButton;
78 protected ButtonWidget m_CopyButton;
79 protected ButtonWidget m_PasteButton;
86 m_FogValue = m_FogValueSetSlider.GetCurrent() / 100;
87 m_FogInterpolationTimeValue = m_FogInterpolationTimeSlider.GetCurrent() / 100 * INTERPOLATION_MAX;
88 m_FogDurationTimeValue = m_FogDurationTimeSlider.GetCurrent() / 100 * DURATION_MAX;
91 m_OvercastValue = m_OvercastValueSetSlider.GetCurrent() / 100;
92 m_OvercastInterpolationTimeValue = m_OvercastInterpolationTimeSlider.GetCurrent() / 100 * INTERPOLATION_MAX;
93 m_OvercastDurationTimeValue = m_OvercastDurationTimeSlider.GetCurrent() / 100 * DURATION_MAX;
96 m_RainValue = m_RainValueSetSlider.GetCurrent() / 100;
97 m_RainInterpolationTimeValue = m_RainInterpolationTimeSlider.GetCurrent() / 100 * INTERPOLATION_MAX;
98 m_RainDurationTimeValue = m_RainDurationTimeSlider.GetCurrent() / 100 * DURATION_MAX;
104 m_FogValueSetSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderFogValue"));
105 m_FogValueGetSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderFogActualValue"));
106 m_FogValueSetText =
TextWidget.Cast(root.FindAnyWidget(
"TextFogValueActual"));
108 m_FogInterpolationTimeSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderFogTarget"));
109 m_FogDurationTimeSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderFogDuration"));
111 m_FogInterpolationMaxText =
TextWidget.Cast(root.FindAnyWidget(
"TextMaxFogTarget"));
112 m_FogDurationMaxText =
TextWidget.Cast(root.FindAnyWidget(
"TextMaxFogDuration"));
114 m_FogValueEditbox =
EditBoxWidget.Cast(root.FindAnyWidget(
"EditBoxFogValue"));
115 m_FogInterpolationEditbox =
EditBoxWidget.Cast(root.FindAnyWidget(
"EditBoxFogTarget"));
116 m_FogDurationEditbox =
EditBoxWidget.Cast(root.FindAnyWidget(
"EditBoxFogDuration"));
119 m_OvercastValueSetSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderOvercastValue"));
120 m_OvercastValueGetSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderOvercastActualValue"));
121 m_OvercastValueSetText =
TextWidget.Cast(root.FindAnyWidget(
"TextOvercastValueActual"));
123 m_OvercastInterpolationTimeSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderOvercastTarget"));
124 m_OvercastDurationTimeSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderOvercastDuration"));
126 m_OvercastInterpolationMaxText =
TextWidget.Cast(root.FindAnyWidget(
"TextMaxOvercastTarget"));
127 m_OvercastDurationMaxText =
TextWidget.Cast(root.FindAnyWidget(
"TextMaxOvercastDuration"));
129 m_OvercastValueEditbox =
EditBoxWidget.Cast(root.FindAnyWidget(
"EditBoxOvercastValue"));
130 m_OvercastInterpolationEditbox =
EditBoxWidget.Cast(root.FindAnyWidget(
"EditBoxOvercastTarget"));
131 m_OvercastDurationEditbox =
EditBoxWidget.Cast(root.FindAnyWidget(
"EditBoxOvercastDuration"));
134 m_RainValueSetSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderRainValue"));
135 m_RainValueGetSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderRainActualValue"));
136 m_RainValueSetText =
TextWidget.Cast(root.FindAnyWidget(
"TextRainValueActual"));
138 m_RainInterpolationTimeSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderRainTarget"));
139 m_RainDurationTimeSlider = SliderWidget.Cast(root.FindAnyWidget(
"SliderRainDuration"));
141 m_RainInterpolationMaxText =
TextWidget.Cast(root.FindAnyWidget(
"TextMaxRainTarget"));
142 m_RainDurationMaxText =
TextWidget.Cast(root.FindAnyWidget(
"TextMaxRainDuration"));
144 m_RainValueEditbox =
EditBoxWidget.Cast(root.FindAnyWidget(
"EditBoxRainValue"));
145 m_RainInterpolationEditbox =
EditBoxWidget.Cast(root.FindAnyWidget(
"EditBoxRainTarget"));
146 m_RainDurationEditbox =
EditBoxWidget.Cast(root.FindAnyWidget(
"EditBoxRainDuration"));
149 m_ResetButton = ButtonWidget.Cast(root.FindAnyWidget(
"ButtonReset"));
150 m_UpdateButton = ButtonWidget.Cast(root.FindAnyWidget(
"ButtonUpdate"));
151 m_ApplyButton = ButtonWidget.Cast(root.FindAnyWidget(
"ButtonApply"));
153 m_CopyButton = ButtonWidget.Cast(root.FindAnyWidget(
"ButtonCopy"));
154 m_PasteButton = ButtonWidget.Cast(root.FindAnyWidget(
"ButtonPaste"));
160 protected void ResetValues()
163 m_FogValueEditbox.SetText(
"0");
164 m_FogDurationEditbox.SetText(DURATION_MAX.ToString());
165 m_FogInterpolationEditbox.SetText(
"0");
168 m_OvercastValueEditbox.SetText(
"0");
169 m_OvercastDurationEditbox.SetText(DURATION_MAX.ToString());
170 m_OvercastInterpolationEditbox.SetText(
"0");
173 m_RainValueEditbox.SetText(
"0");
174 m_RainDurationEditbox.SetText(DURATION_MAX.ToString());
175 m_RainInterpolationEditbox.SetText(
"0");
177 UpdateSliderValues();
181 m_FogInterpolationTimeValue = 0;
182 m_FogDurationTimeValue = DURATION_MAX;
186 m_OvercastInterpolationTimeValue = 0;
187 m_OvercastDurationTimeValue = DURATION_MAX;
191 m_RainInterpolationTimeValue = 0;
192 m_RainDurationTimeValue = DURATION_MAX;
197 protected void InitValues(
bool forceCurrent =
false)
201 float fogVal = m_FogValue;
202 if (forceCurrent || m_FogValue == -1)
204 fogVal =
GetGame().GetWeather().GetFog().GetActual();
206 m_FogValueEditbox.SetText(fogVal.ToString());
208 m_FogInterpolationEditbox.SetText(m_FogInterpolationTimeValue.ToString());
210 if (m_FogDurationTimeValue == -1)
211 m_FogDurationTimeValue = DURATION_MAX;
212 m_FogDurationEditbox.SetText(m_FogDurationTimeValue.ToString());
214 m_FogInterpolationMaxText.SetText(INTERPOLATION_MAX.ToString());
215 m_FogDurationMaxText.SetText(DURATION_MAX.ToString());
219 float overcastVal = m_OvercastValue;
220 if (forceCurrent || m_OvercastValue == -1)
222 overcastVal =
GetGame().GetWeather().GetOvercast().GetActual();
224 m_OvercastValueEditbox.SetText(overcastVal.ToString());
226 m_OvercastInterpolationEditbox.SetText(m_OvercastInterpolationTimeValue.ToString());
229 if (m_OvercastDurationTimeValue == -1)
230 m_OvercastDurationTimeValue = DURATION_MAX;
231 m_OvercastDurationEditbox.SetText(m_OvercastDurationTimeValue.ToString());
233 m_OvercastInterpolationMaxText.SetText(INTERPOLATION_MAX.ToString());
234 m_OvercastDurationMaxText.SetText(DURATION_MAX.ToString());
237 float rainVal = m_RainValue;
238 if (forceCurrent || m_RainValue == -1)
240 rainVal =
GetGame().GetWeather().GetRain().GetActual();
243 m_RainValueEditbox.SetText(rainVal.ToString());
244 m_RainInterpolationEditbox.SetText(m_RainInterpolationTimeValue.ToString());
246 if (m_RainDurationTimeValue == -1)
247 m_RainDurationTimeValue = DURATION_MAX;
248 m_RainDurationEditbox.SetText(m_RainDurationTimeValue.ToString());
250 m_RainInterpolationMaxText.SetText(INTERPOLATION_MAX.ToString());
251 m_RainDurationMaxText.SetText(DURATION_MAX.ToString());
253 UpdateSliderValues();
256 protected void PasteValues(
string clipboard)
259 clipboard.Split(
" ", values);
260 if (values.Count() != 9)
263 m_FogValueEditbox.SetText(values.Get(0));
264 m_FogInterpolationEditbox.SetText(values.Get(1));
265 m_FogDurationEditbox.SetText(values.Get(2));
267 m_OvercastValueEditbox.SetText(values.Get(3));
268 m_OvercastInterpolationEditbox.SetText(values.Get(4));
269 m_OvercastDurationEditbox.SetText(values.Get(5));
271 m_RainValueEditbox.SetText(values.Get(6));
272 m_RainInterpolationEditbox.SetText(values.Get(7));
273 m_RainDurationEditbox.SetText(values.Get(8));
276 protected string CopyValues()
281 output += m_FogValueEditbox.GetText();
283 output += m_FogInterpolationEditbox.GetText();
285 output += m_FogDurationEditbox.GetText();
288 output += m_OvercastValueEditbox.GetText();
290 output += m_OvercastInterpolationEditbox.GetText();
292 output += m_OvercastDurationEditbox.GetText();
295 output += m_RainValueEditbox.GetText();
297 output += m_RainInterpolationEditbox.GetText();
299 output += m_RainDurationEditbox.GetText();
304 override bool OnChange(
Widget w,
int x,
int y,
bool finished)
311 if (w == m_FogValueSetSlider)
313 m_OvercastValueSetSlider.SetCurrent(m_FogValueSetSlider.GetCurrent());
314 m_RainValueSetSlider.SetCurrent(m_FogValueSetSlider.GetCurrent());
316 else if (w == m_OvercastValueSetSlider)
318 m_FogValueSetSlider.SetCurrent(m_OvercastValueSetSlider.GetCurrent());
319 m_RainValueSetSlider.SetCurrent(m_OvercastValueSetSlider.GetCurrent());
322 else if (w == m_RainValueSetSlider)
324 m_FogValueSetSlider.SetCurrent(m_RainValueSetSlider.GetCurrent());
325 m_OvercastValueSetSlider.SetCurrent(m_RainValueSetSlider.GetCurrent());
328 else if (w == m_FogInterpolationTimeSlider)
330 m_OvercastInterpolationTimeSlider.SetCurrent(m_FogInterpolationTimeSlider.GetCurrent());
331 m_RainInterpolationTimeSlider.SetCurrent(m_FogInterpolationTimeSlider.GetCurrent());
333 else if (w == m_OvercastInterpolationTimeSlider)
335 m_FogInterpolationTimeSlider.SetCurrent(m_OvercastInterpolationTimeSlider.GetCurrent());
336 m_RainInterpolationTimeSlider.SetCurrent(m_OvercastInterpolationTimeSlider.GetCurrent());
339 else if (w == m_RainInterpolationTimeSlider)
341 m_OvercastInterpolationTimeSlider.SetCurrent(m_RainInterpolationTimeSlider.GetCurrent());
342 m_FogInterpolationTimeSlider.SetCurrent(m_RainInterpolationTimeSlider.GetCurrent());
345 else if (w == m_FogDurationTimeSlider)
347 m_RainDurationTimeSlider.SetCurrent(m_FogDurationTimeSlider.GetCurrent());
348 m_OvercastDurationTimeSlider.SetCurrent(m_FogDurationTimeSlider.GetCurrent());
350 else if (w == m_RainDurationTimeSlider)
352 m_FogDurationTimeSlider.SetCurrent(m_RainDurationTimeSlider.GetCurrent());
353 m_OvercastDurationTimeSlider.SetCurrent(m_RainDurationTimeSlider.GetCurrent());
356 else if (w == m_OvercastDurationTimeSlider)
358 m_RainDurationTimeSlider.SetCurrent(m_OvercastDurationTimeSlider.GetCurrent());
359 m_FogDurationTimeSlider.SetCurrent(m_OvercastDurationTimeSlider.GetCurrent());
365 SliderWidget slider = SliderWidget.Cast(w);
368 if (rmbDrag && !m_RPCTimer.IsRunning())
370 if (w == m_OvercastValueSetSlider || w == m_RainValueSetSlider || w == m_FogValueSetSlider)
371 m_RPCTimer.Run(0.25,
this,
"InvokeSendRPC");
373 UpdateEditboxValues();
379 UpdateSliderValues();
385 void UpdateSliderValues()
388 float editboxFogValue = m_FogValueEditbox.GetText().ToFloat();
389 m_FogValueSetSlider.SetCurrent(editboxFogValue * 100);
391 float editboxFogInterpolation = m_FogInterpolationEditbox.GetText().ToFloat();
392 m_FogInterpolationTimeSlider.SetCurrent(
Math.InverseLerp(0,INTERPOLATION_MAX,editboxFogInterpolation) * 100);
394 float editboxFogDuration = m_FogDurationEditbox.GetText().ToFloat();
395 m_FogDurationTimeSlider.SetCurrent(
Math.InverseLerp(0,INTERPOLATION_MAX,editboxFogDuration) * 100);
398 float editboxOvercastValue = m_OvercastValueEditbox.GetText().ToFloat();
399 m_OvercastValueSetSlider.SetCurrent(editboxOvercastValue * 100);
401 float editboxOvercastInterpolation = m_OvercastInterpolationEditbox.GetText().ToFloat();
402 m_OvercastInterpolationTimeSlider.SetCurrent(
Math.InverseLerp(0,INTERPOLATION_MAX,editboxOvercastInterpolation) * 100);
404 float editboxOvercastDuration = m_OvercastDurationEditbox.GetText().ToFloat();
405 m_OvercastDurationTimeSlider.SetCurrent(
Math.InverseLerp(0,INTERPOLATION_MAX,editboxOvercastDuration) * 100);
408 float editboxRainValue = m_RainValueEditbox.GetText().ToFloat();
409 m_RainValueSetSlider.SetCurrent(editboxRainValue * 100);
411 float editboxRainInterpolation = m_RainInterpolationEditbox.GetText().ToFloat();
412 m_RainInterpolationTimeSlider.SetCurrent(
Math.InverseLerp(0,INTERPOLATION_MAX,editboxRainInterpolation) * 100);
414 float editboxRainDuration = m_RainDurationEditbox.GetText().ToFloat();
415 m_RainDurationTimeSlider.SetCurrent(
Math.InverseLerp(0,INTERPOLATION_MAX,editboxRainDuration) * 100);
418 void UpdateEditboxValues()
421 m_FogInterpolationTimeValue = m_FogInterpolationTimeSlider.GetCurrent() / 100 * INTERPOLATION_MAX;
422 m_FogInterpolationEditbox.SetText(m_FogInterpolationTimeValue.ToString());
424 m_FogDurationTimeValue = m_FogDurationTimeSlider.GetCurrent() / 100 * DURATION_MAX;
425 m_FogDurationEditbox.SetText(m_FogDurationTimeValue.ToString());
427 m_FogValue = m_FogValueSetSlider.GetCurrent() / 100;
428 m_FogValueEditbox.SetText(m_FogValue.ToString());
431 m_OvercastInterpolationTimeValue = m_OvercastInterpolationTimeSlider.GetCurrent() / 100 * INTERPOLATION_MAX;
432 m_OvercastInterpolationEditbox.SetText(m_OvercastInterpolationTimeValue.ToString());
434 m_OvercastDurationTimeValue = m_OvercastDurationTimeSlider.GetCurrent() / 100 * DURATION_MAX;
435 m_OvercastDurationEditbox.SetText(m_OvercastDurationTimeValue.ToString());
437 m_OvercastValue = m_OvercastValueSetSlider.GetCurrent() / 100;
438 m_OvercastValueEditbox.SetText(m_OvercastValue.ToString());
441 m_RainInterpolationTimeValue = m_RainInterpolationTimeSlider.GetCurrent() / 100 * INTERPOLATION_MAX;
442 m_RainInterpolationEditbox.SetText(m_RainInterpolationTimeValue.ToString());
444 m_RainDurationTimeValue = m_RainDurationTimeSlider.GetCurrent() / 100 * DURATION_MAX;
445 m_RainDurationEditbox.SetText(m_RainDurationTimeValue.ToString());
447 m_RainValue = m_RainValueSetSlider.GetCurrent() / 100;
448 m_RainValueEditbox.SetText(m_RainValue.ToString());
451 override bool OnClick(
Widget w,
int x,
int y,
int button)
453 if (w == m_ApplyButton)
455 SendRPC(GetRPCDataNormal());
458 else if (w == m_UpdateButton)
463 else if (w == m_ResetButton)
469 else if (w == m_CopyButton)
471 string output = CopyValues();
472 GetGame().CopyToClipboard(output);
476 else if (w == m_PasteButton)
479 GetGame().CopyFromClipboard(input);
481 UpdateSliderValues();
495 data.m_FogValue = m_FogValueSetSlider.GetCurrent() / 100;
496 data.m_FogInterpolation = m_FogInterpolationTimeValue;
497 data.m_FogDuration = m_FogDurationTimeSlider.GetCurrent() / 100 * 960;
500 data.m_RainValue = m_RainValueSetSlider.GetCurrent() / 100;
501 data.m_RainInterpolation = m_RainInterpolationTimeValue;
502 data.m_RainDuration = m_RainDurationTimeSlider.GetCurrent() / 100 * 960;
505 data.m_OvercastValue = m_OvercastValueSetSlider.GetCurrent() / 100;
506 data.m_OvercastInterpolation = m_OvercastInterpolationTimeValue;
507 data.m_OvercastDuration = m_OvercastDurationTimeSlider.GetCurrent() / 100 * 960;
517 data.m_FogValue = m_FogValueSetSlider.GetCurrent() / 100;
518 data.m_FogInterpolation = 0;
519 data.m_FogDuration = 960;
522 data.m_RainValue = m_RainValueSetSlider.GetCurrent() / 100;
523 data.m_RainInterpolation = 0;
524 data.m_RainDuration = 960;
527 data.m_OvercastValue = m_OvercastValueSetSlider.GetCurrent() / 100;
528 data.m_OvercastInterpolation = 0;
529 data.m_OvercastDuration = 960;
539 identity =
GetGame().GetPlayer().GetIdentity();
542 GetGame().RPCSingleParam(
null,
ERPCs.DEV_SET_WEATHER,
new Param1<DebugWeatherRPCData>(data),
true, identity);
545 protected void InvokeSendRPC()
547 SendRPC(GetRPCDataImmediate());
550 override void Update(
float timeslice)
552 super.Update(timeslice);
553 float overcast =
GetGame().GetWeather().GetOvercast().GetActual();
554 m_OvercastValueGetSlider.SetCurrent(overcast * 100);
555 m_OvercastValueSetText.SetText(overcast.ToString());
557 float fog =
GetGame().GetWeather().GetFog().GetActual();
558 m_FogValueGetSlider.SetCurrent(fog * 100);
559 m_FogValueSetText.SetText(fog.ToString());
561 float rain =
GetGame().GetWeather().GetRain().GetActual();
562 m_RainValueGetSlider.SetCurrent(rain * 100);
563 m_RainValueSetText.SetText(rain.ToString());