DayZ 1.24
Loading...
Searching...
No Matches
UIPopupScriptSceneManager.c
Go to the documentation of this file.
1class UIPopupScriptSceneManager extends UIPopupScript
2{
10
11 private static const int m_DaysInMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
12
13 private ButtonWidget m_BtnSave;
14
16
29
30 private int m_OrigYear;
31 private int m_OrigMonth;
32 private int m_OrigDay;
33 private int m_OrigHour;
34 private int m_OrigMinute;
35 private float m_OrigOvercast;
36 private float m_OrigRain;
37 private float m_OrigFog;
38 private float m_OrigWindForce;
39
40 private int m_CurrYear;
41 private int m_CurrMonth;
42 private int m_CurrDay;
43 private int m_CurrHour;
44 private int m_CurrMinute;
45 private float m_CurrOvercast;
46 private float m_CurrRain;
47 private float m_CurrFog;
48 private float m_CurrWindForce;
49
50 //================================================
51 // UIPopupScriptSceneManager
52 //================================================
54 {
55 m_BtnCancel = ButtonWidget.Cast(wgt.FindAnyWidget("btn_ppp_sm_cancel"));
56 m_BtnSceneNew = ButtonWidget.Cast(wgt.FindAnyWidget("btn_ppp_sm_mission_new"));
57 m_BtnSceneLoad = ButtonWidget.Cast(wgt.FindAnyWidget("btn_ppp_sm_mission_load"));
58 m_BtnSceneRename = ButtonWidget.Cast(wgt.FindAnyWidget("btn_ppp_sm_mission_rename"));
59 m_BtnSceneDelete = ButtonWidget.Cast(wgt.FindAnyWidget("btn_ppp_sm_mission_delete"));
60 m_BtnSceneDuplicate = ButtonWidget.Cast(wgt.FindAnyWidget("btn_ppp_sm_mission_duplicate"));
61
62 m_LstListScenes = TextListboxWidget.Cast(wgt.FindAnyWidget("tls_ppp_sm_scene_list"));
63
64 m_BtnSave = ButtonWidget.Cast(wgt.FindAnyWidget("btn_ppp_st_save"));
65
66 m_TxtWeatherTime = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_w_time_value"));
67
68 m_SldStartTime = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_start_time"));
69 m_TxtStartTimeValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_start_time_value"));
70
71 m_SldStartDay = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_start_day"));
72 m_TxtStartDayValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_start_day_value"));
73
74 m_SldOvercast = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_overcast"));
75 m_TxtOvercastValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_overcast_value"));
76
77 m_SldRain = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_rain"));
78 m_TxtRainValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_rain_value"));
79
80 m_SldFog = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_fog"));
81 m_TxtFogValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_fog_value"));
82
83 m_SldWindForce = SliderWidget.Cast(wgt.FindAnyWidget("sld_ppp_st_wind_force"));
84 m_TxtWindForceValue = TextWidget.Cast(wgt.FindAnyWidget("txt_ppp_st_wind_force_value"));
85 }
86
88 {
89 GetGame().GetUpdateQueue(CALL_CATEGORY_SYSTEM).Remove(this.OnUpdate);
90 }
91
92 //================================================
93 // OnClick
94 //================================================
95 override bool OnClick(Widget w, int x, int y, int button)
96 {
97 super.OnClick(w, x, y, button);
98
99 string scene_name;
100 PluginSceneManager editor;
101
102 if (w == m_BtnCancel)
103 {
104 GetGame().GetWorld().SetDate(m_OrigYear, m_OrigMonth, m_OrigDay, m_OrigHour, m_OrigMinute);
105
106 Weather weather = GetGame().GetWeather();
107 weather.GetOvercast().Set(m_OrigOvercast, 0, 1000);
108 weather.GetRain().Set(m_OrigRain, 0, 1000);
109 weather.GetFog().Set(m_OrigFog, 0, 1000);
110 weather.SetWindSpeed(m_OrigWindForce);
111
112 PopupBack();
113 return true;
114 }
115 else if (w == m_BtnSceneNew)
116 {
117 PopupOpen(SceneEditorMenu.POPUP_ID_SCENE_NEW, NULL);
118
119 return true;
120 }
121 else if (w == m_BtnSceneLoad)
122 {
123 if (m_LstListScenes.GetSelectedRow() != -1)
124 {
125 m_LstListScenes.GetItemText(m_LstListScenes.GetSelectedRow(), 0, scene_name);
126 editor = PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
127
128 editor.SceneLoad(scene_name);
129 PopupBack();
130
131 return true;
132 }
133 }
134 else if (w == m_BtnSceneRename)
135 {
136 m_LstListScenes.GetItemText(m_LstListScenes.GetSelectedRow(), 0, scene_name);
137
138 UIPopupScriptSceneRename popup_rename = UIPopupScriptSceneRename.Cast(PopupOpen(SceneEditorMenu.POPUP_ID_SCENE_RENAME, NULL));
139 popup_rename.SetRenameName(scene_name);
140
141 return true;
142 }
143 else if (w == m_BtnSceneDuplicate)
144 {
145 if (m_LstListScenes.GetSelectedRow() != -1)
146 {
147 m_LstListScenes.GetItemText(m_LstListScenes.GetSelectedRow(), 0, scene_name);
148 editor = PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
149
150 editor.SceneDuplicate(scene_name);
152
153 return true;
154 }
155 }
156 else if (w == m_BtnSceneDelete)
157 {
158 if (m_LstListScenes.GetSelectedRow() != -1)
159 {
160 m_LstListScenes.GetItemText(m_LstListScenes.GetSelectedRow(), 0, scene_name);
161 editor = PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
162
163 editor.SceneDelete(scene_name);
164
165 if (editor.SceneCanDelete(scene_name))
166 {
167 UIPopupScriptSceneDelete popup_delete = UIPopupScriptSceneDelete.Cast(PopupOpen(SceneEditorMenu.POPUP_ID_SCENE_DELETE, NULL));
168 popup_delete.SetDeleteName(scene_name);
169 }
170 else
171 {
172 UIPopupScriptNotify popup_notify = UIPopupScriptNotify.Cast(PopupOpen(SceneEditorMenu.POPUP_ID_NOTIFY, NULL));
173 popup_notify.SetLabelText("You cant delete current loaded scene!");
174 }
175
177 return true;
178 }
179 }
180 else if (w == m_BtnSave)
181 {
182 m_OrigYear = m_CurrYear;
183 m_OrigMonth = m_CurrMonth;
184 m_OrigDay = m_CurrDay;
185 m_OrigHour = m_CurrHour;
186 m_OrigMinute = m_CurrMinute;
187 m_OrigOvercast = m_CurrOvercast;
188 m_OrigRain = m_CurrRain;
189 m_OrigFog = m_CurrFog;
190 m_OrigWindForce = m_CurrWindForce;
191
192 editor = PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
193 editor.SetWeather(m_CurrOvercast, m_CurrRain, m_CurrFog, m_CurrWindForce);
194 editor.SetDate(m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute);
195 editor.SceneSave();
196
197 PopupBack();
198
199 return true;
200 }
201
202 return false;
203 }
204
205 override bool OnChange(Widget w, int x, int y, bool finished)
206 {
207 if (w == m_SldStartTime)
208 {
209 float slider_value_start_time = m_SldStartTime.GetCurrent() * 0.01;
212 m_CurrHour = start_time / 60;
213 m_CurrMinute = start_time % 60;
214
215 UpdateSliderStartTime(m_CurrHour, m_CurrMinute);
216
217 GetGame().GetWorld().SetDate(m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute);
218
219 return true;
220 }
221 else if (w == m_SldStartDay)
222 {
223 float slider_value_start_day = m_SldStartDay.GetCurrent();
224 float start_day_f = slider_value_start_day * 3.64 + 1;
226
227 for (int i = 0; i < 12; i++)
228 {
229 int days = m_DaysInMonth[i];
230 if (start_day <= days)
231 {
232 m_CurrMonth = i + 1;
233 m_CurrDay = start_day;
234 break;
235 }
236 else
237 start_day -= days;
238 }
239
240 UpdateSliderStartDay(m_CurrMonth, m_CurrDay);
241
242 GetGame().GetWorld().SetDate(m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute);
243
244 return true;
245 }
246 else if (w == m_SldOvercast)
247 {
248 m_CurrOvercast = m_SldOvercast.GetCurrent() * 0.01;
249 GetGame().GetWeather().GetOvercast().Set(m_CurrOvercast, 0, 1000);
250
252
253 return true;
254 }
255 else if (w == m_SldRain)
256 {
257 m_CurrRain = m_SldRain.GetCurrent() * 0.01;
258 GetGame().GetWeather().GetRain().Set(m_CurrRain, 0, 1000);
259
261
262 return true;
263 }
264 else if (w == m_SldFog)
265 {
266 m_CurrFog = m_SldFog.GetCurrent() * 0.01;
267 GetGame().GetWeather().GetFog().Set(m_CurrFog, 0, 1000);
268
270
271 return true;
272 }
273 else if (w == m_SldWindForce)
274 {
275 float wind_slider = m_SldWindForce.GetCurrent() * 0.01;
276 m_CurrWindForce = GetGame().GetWeather().GetWindMaximumSpeed() * wind_slider;
277 GetGame().GetWeather().SetWindSpeed(m_CurrWindForce);
278
280
281 return true;
282 }
283
284 return false;
285 }
286
287 //================================================
288 // UpdateSceneList
289 //================================================
291 {
292 m_LstListScenes.ClearItems();
293
294 PluginSceneManager editor = PluginSceneManager.Cast(GetPlugin(PluginSceneManager));
295
296 TStringArray scene_list = editor.GetSceneList();
297 string loaded_scene_name = editor.SceneGetName();
298
299 for (int i = 0; i < scene_list.Count(); ++i)
300 {
301 string scene_name = scene_list.Get(i);
302
303 m_LstListScenes.AddItem(scene_name, NULL, 0);
304
306 m_LstListScenes.SelectRow(i);
307 }
308 }
309
310 //================================================
311 // UpdateSceneList
312 //================================================
313 override void OnOpen(Param param)
314 {
315 //Log("Poup Scene Manager OnOpen");
316
318 GetGame().GetWorld().GetDate(m_OrigYear, m_OrigMonth, m_OrigDay, m_OrigHour, m_OrigMinute);
319
320 Weather weather = GetGame().GetWeather();
321 m_OrigOvercast = weather.GetOvercast().GetActual();
322 m_OrigRain = weather.GetRain().GetActual();
323 m_OrigFog = weather.GetFog().GetActual();
324 m_OrigWindForce = weather.GetWindSpeed();
325
326 m_CurrYear = m_OrigYear;
327 m_CurrMonth = m_OrigMonth;
328 m_CurrDay = m_OrigDay;
329 m_CurrHour = m_OrigHour;
330 m_CurrMinute = m_OrigMinute;
331 m_CurrOvercast = m_OrigOvercast;
332 m_CurrRain = m_OrigRain;
333 m_CurrFog = m_OrigFog;
334 m_CurrWindForce = m_OrigWindForce;
335
336 Print("Year");
337 Print(m_CurrYear);
338
339 GetGame().GetUpdateQueue(CALL_CATEGORY_SYSTEM).Insert(this.OnUpdate);
340
341 ResetSliders();
342 }
343
344 //================================================
345 // OnClose
346 //================================================
347 override void OnClose()
348 {
349 GetGame().GetUpdateQueue(CALL_CATEGORY_SYSTEM).Remove(this.OnUpdate);
350 }
351
352 //================================================
353 // OnUpdate
354 //================================================
355 void OnUpdate()
356 {
357 m_TxtWeatherTime.SetText(GetGame().GetWeather().GetTime().ToString());
358 }
359
360 //================================================
361 // ResetSliders
362 //================================================
364 {
365 int year, month, day, hour, minute;
366 GetGame().GetWorld().GetDate(year, month, day, hour, minute);
367 m_SldStartTime.SetCurrent(((hour * 60) + minute) / 14.39);
369
370 float start_day = day;
371 int month_tmp = month;
372 while (month_tmp > 1)
373 {
374 month_tmp--;
375 start_day += m_DaysInMonth[month];
376 }
377 m_SldStartDay.SetCurrent(start_day / 3.64);
379
380 Weather weather = GetGame().GetWeather();
381
382 m_SldOvercast.SetCurrent(weather.GetOvercast().GetActual() * 100);
384
385 m_SldRain.SetCurrent(weather.GetRain().GetActual() * 100);
387
388 m_SldFog.SetCurrent(weather.GetFog().GetActual() * 100);
390
391 float wind_slider = m_SldWindForce.GetCurrent() * 0.01;
392 m_CurrWindForce = weather.GetWindMaximumSpeed() * wind_slider;
393 weather.SetWindSpeed(m_CurrWindForce);
395 }
396
398 {
399 string label_text = hour.ToStringLen(2) + ":" + minute.ToStringLen(2);
400 m_TxtStartTimeValue.SetText(label_text);
401 }
402
404 {
405 string label_text = day.ToString() + "." + month.ToString() + ". " + m_CurrYear.ToString();
406 m_TxtStartDayValue.SetText(label_text);
407 }
408
410 {
411 string label_text = m_SldOvercast.GetCurrent().ToString() + "%";
412 m_TxtOvercastValue.SetText(label_text);
413 }
414
416 {
417 string label_text = m_SldRain.GetCurrent().ToString() + "%";
418 m_TxtRainValue.SetText(label_text);
419 }
420
422 {
423 string label_text = m_SldFog.GetCurrent().ToString() + "%";
424 m_TxtFogValue.SetText(label_text);
425 }
426
428 {
429 string label_text = m_CurrWindForce.ToString() + "ms";
430 m_TxtWindForceValue.SetText(label_text);
431 }
432}
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
void UIPopupScriptSceneManager(Widget wgt)
ButtonWidget m_BtnSceneDelete
override bool OnClick(Widget w, int x, int y, int button)
TextListboxWidget m_LstListScenes
void UpdateSliderStartTime(int hour, int minute)
ButtonWidget m_BtnSceneDuplicate
UIPopupScript PopupBack()
ButtonWidget m_BtnCancel
override void OnOpen(Param param)
UIPopupScript PopupOpen(int popup_id, Param param)
void UpdateSliderStartDay(int month, int day)
ButtonWidget m_BtnSceneRename
override bool OnChange(Widget w, int x, int y, bool finished)
proto string ToString()
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