DayZ 1.24
Loading...
Searching...
No Matches
UIPopupScriptSceneSettings.c
Go to the documentation of this file.
1class UIPopupScriptSceneSettings extends UIPopupScript
2{
3 private static const int m_DaysInMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
4
7
9
16 private SliderWidget m_SldRain;
18 private SliderWidget m_SldFog;
22
23 private int m_OrigYear;
24 private int m_OrigMonth;
25 private int m_OrigDay;
26 private int m_OrigHour;
27 private int m_OrigMinute;
28 private float m_OrigOvercast;
29 private float m_OrigRain;
30 private float m_OrigFog;
31 private float m_OrigWindForce;
32
33 private int m_CurrYear;
34 private int m_CurrMonth;
35 private int m_CurrDay;
36 private int m_CurrHour;
37 private int m_CurrMinute;
38 private float m_CurrOvercast;
39 private float m_CurrRain;
40 private float m_CurrFog;
41 private float m_CurrWindForce;
42
43 //================================================
44 // UIPopupScriptSceneSettings
45 //================================================
47 {
48 m_BtnSave = ButtonWidget.Cast(wgt.FindAnyWidget("btn_ppp_st_save"));
49 m_BtnCancel = ButtonWidget.Cast(wgt.FindAnyWidget("btn_ppp_st_cancel"));
50
51 m_TxtWeatherTime = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_w_time_value"));
52
53 m_SldStartTime = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_start_time"));
54 m_TxtStartTimeValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_start_time_value"));
55
56 m_SldStartDay = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_start_day"));
57 m_TxtStartDayValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_start_day_value"));
58
59 m_SldOvercast = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_overcast"));
60 m_TxtOvercastValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_overcast_value"));
61
62 m_SldRain = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_rain"));
63 m_TxtRainValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_rain_value"));
64
65 m_SldFog = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_fog"));
66 m_TxtFogValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_fog_value"));
67
68 m_SldWindForce = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_wind_force"));
69 m_TxtWindForceValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_wind_force_value"));
70 }
71
73 {
74 GetGame().GetUpdateQueue(CALL_CATEGORY_SYSTEM).Remove(this.OnUpdate);
75 }
76 //================================================
77 // OnClick
78 //================================================
79 override bool OnClick(Widget w, int x, int y, int button)
80 {
81 super.OnClick(w, x, y, button);
82
83 if (w == m_BtnSave)
84 {
85 m_OrigYear = m_CurrYear;
86 m_OrigMonth = m_CurrMonth;
87 m_OrigDay = m_CurrDay;
88 m_OrigHour = m_CurrHour;
89 m_OrigMinute = m_CurrMinute;
90 m_OrigOvercast = m_CurrOvercast;
91 m_OrigRain = m_CurrRain;
92 m_OrigFog = m_CurrFog;
93 m_OrigWindForce = m_CurrWindForce;
94
95 PluginSceneManager editor = PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
96 editor.SetWeather(m_CurrOvercast, m_CurrRain, m_CurrFog, m_CurrWindForce);
97 editor.SetDate(m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute);
98
99 PopupBack();
100
101 return true;
102 }
103 else if (w == m_BtnCancel)
104 {
105
106 PopupBack();
107
108 return true;
109 }
110
111 return false;
112 }
113
114
115 override bool OnChange(Widget w, int x, int y, bool finished)
116 {
117 if (w == m_SldStartTime)
118 {
119 float slider_value_start_time = m_SldStartTime.GetCurrent() * 0.01;
122 m_CurrHour = start_time / 60;
123 m_CurrMinute = start_time % 60;
124
125 UpdateSliderStartTime(m_CurrHour, m_CurrMinute);
126
127 GetGame().GetWorld().SetDate(m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute);
128
129 return true;
130 }
131 else if (w == m_SldStartDay)
132 {
133 float slider_value_start_day = m_SldStartDay.GetCurrent();
134 float start_day_f = slider_value_start_day * 3.64 + 1;
136
137 for (int i = 0; i < 12; i++)
138 {
139 int days = m_DaysInMonth[i];
140 if (start_day <= days)
141 {
142 m_CurrMonth = i + 1;
143 m_CurrDay = start_day;
144 break;
145 }
146 else
147 start_day -= days;
148 }
149
150 UpdateSliderStartDay(m_CurrMonth, m_CurrDay);
151
152 GetGame().GetWorld().SetDate(m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute);
153
154 return true;
155 }
156 else if (w == m_SldOvercast)
157 {
159
160 m_CurrOvercast = m_SldOvercast.GetCurrent() * 0.01;
161 GetGame().GetWeather().GetOvercast().Set(m_CurrOvercast, 0, 1000);
162
163 return true;
164 }
165 else if (w == m_SldRain)
166 {
168
169 m_CurrRain = m_SldRain.GetCurrent() * 0.01;
170 GetGame().GetWeather().GetRain().Set(m_CurrRain, 0, 1000);
171
172 return true;
173 }
174 else if (w == m_SldFog)
175 {
177
178 m_CurrFog = m_SldFog.GetCurrent() * 0.01;
179 GetGame().GetWeather().GetFog().Set(m_CurrFog, 0, 1000);
180
181 return true;
182 }
183 else if (w == m_SldWindForce)
184 {
186
187 m_CurrWindForce = m_SldWindForce.GetCurrent() * 0.01;
188 //GetGame().GetWeather().SetWindSpeed( m_CurrWindForce );
189
190 return true;
191 }
192
193 return false;
194 }
195
196 //================================================
197 // OnOpen
198 //================================================
199 override void OnOpen(Param param)
200 {
201 GetGame().GetWorld().GetDate(m_OrigYear, m_OrigMonth, m_OrigDay, m_OrigHour, m_OrigMinute);
202
203 Weather weather = GetGame().GetWeather();
204
205 m_OrigOvercast = weather.GetOvercast().GetActual();
206 m_OrigRain = weather.GetRain().GetActual();
207 m_OrigFog = weather.GetFog().GetActual();
208 m_OrigWindForce = weather.GetWindSpeed();
209
210 m_CurrYear = m_OrigYear;
211 m_CurrMonth = m_OrigMonth;
212 m_CurrDay = m_OrigDay;
213 m_CurrHour = m_OrigHour;
214 m_CurrMinute = m_OrigMinute;
215 m_CurrOvercast = m_OrigOvercast;
216 m_CurrRain = m_OrigRain;
217 m_CurrFog = m_OrigFog;
218 m_CurrWindForce = m_OrigWindForce;
219
220 Print("Year");
221 Print(m_CurrYear);
222
223 GetGame().GetUpdateQueue(CALL_CATEGORY_SYSTEM).Insert(this.OnUpdate);
224
225 ResetSliders();
226 }
227
228 //================================================
229 // OnClose
230 //================================================
231 override void OnClose()
232 {
233 Weather weather = GetGame().GetWeather();
234
235 GetGame().GetWorld().SetDate(m_OrigYear, m_OrigMonth, m_OrigDay, m_OrigHour, m_OrigMinute);
236 weather.GetOvercast().Set(m_OrigOvercast, 0, 1000);
237 weather.GetRain().Set(m_OrigRain, 0, 1000);
238 weather.GetFog().Set(m_OrigFog, 0, 1000);
239 //weather.SetWindSpeed( m_OrigWindForce );
240 }
241
242 //================================================
243 // OnUpdate
244 //================================================
245 void OnUpdate()
246 {
247 m_TxtWeatherTime.SetText(GetGame().GetWeather().GetTime().ToString());
248 }
249
250 //================================================
251 // ResetSliders
252 //================================================
254 {
255 int year, month, day, hour, minute;
256 GetGame().GetWorld().GetDate(year, month, day, hour, minute);
257 m_SldStartTime.SetCurrent(((hour * 60) + minute) / 14.39);
259
260 float start_day = day;
261 int month_tmp = month;
262 while (month_tmp > 1)
263 {
264 month_tmp--;
265 start_day += m_DaysInMonth[month];
266 }
267 m_SldStartDay.SetCurrent(start_day / 3.64);
269
270 Weather weather = GetGame().GetWeather();
271
272 m_SldOvercast.SetCurrent(weather.GetOvercast().GetActual() * 100);
274
275 m_SldRain.SetCurrent(weather.GetRain().GetActual() * 100);
277
278 m_SldFog.SetCurrent(weather.GetFog().GetActual() * 100);
280
281 float slider_wind_value = (weather.GetWindSpeed() / weather.GetWindMaximumSpeed()) * 100;
282 m_SldWindForce.SetCurrent(slider_wind_value);
284 }
285
287 {
288 string label_text = hour.ToStringLen(2) + ":" + minute.ToStringLen(2);
289 m_TxtStartTimeValue.SetText(label_text);
290 }
291
293 {
294 string label_text = day.ToString() + "." + month.ToString() + ". " + m_CurrYear.ToString();
295 m_TxtStartDayValue.SetText(label_text);
296 }
297
299 {
300 string label_text = m_SldOvercast.GetCurrent().ToString() + "%";
301 m_TxtOvercastValue.SetText(label_text);
302 }
303
305 {
306 string label_text = m_SldRain.GetCurrent().ToString() + "%";
307 m_TxtRainValue.SetText(label_text);
308 }
309
311 {
312 string label_text = m_SldFog.GetCurrent().ToString() + "%";
313 m_TxtFogValue.SetText(label_text);
314 }
315
317 {
318 string label_text = m_SldWindForce.GetCurrent().ToString() + "%";
319 m_TxtWindForceValue.SetText(label_text);
320 }
321}
proto string ToString()
Icon x
Icon y
float GetTime()
PluginBase GetPlugin(typename plugin_type)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
override bool OnClick(Widget w, int x, int y, int button)
void UpdateSliderStartTime(int hour, int minute)
UIPopupScript PopupBack()
ButtonWidget m_BtnCancel
override void OnOpen(Param param)
void UpdateSliderStartDay(int month, int day)
void UIPopupScriptSceneSettings(Widget wgt)
override bool OnChange(Widget w, int x, int y, bool finished)
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
proto native void OnUpdate()
Definition tools.c:333
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8