3 private ButtonWidget m_BtnCancel;
4 private ButtonWidget m_BtnSceneNew;
5 private ButtonWidget m_BtnSceneLoad;
6 private ButtonWidget m_BtnSceneRename;
7 private ButtonWidget m_BtnSceneDuplicate;
8 private ButtonWidget m_BtnSceneDelete;
9 private TextListboxWidget m_LstListScenes;
11 private static const int m_DaysInMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
13 private ButtonWidget m_BtnSave;
17 private SliderWidget m_SldStartTime;
19 private SliderWidget m_SldStartDay;
21 private SliderWidget m_SldOvercast;
23 private SliderWidget m_SldRain;
25 private SliderWidget m_SldFog;
27 private SliderWidget m_SldWindForce;
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;
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;
53 void UIPopupScriptSceneManager(
Widget wgt)
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") );
62 m_LstListScenes = TextListboxWidget.Cast( wgt.FindAnyWidget(
"tls_ppp_sm_scene_list") );
64 m_BtnSave = ButtonWidget.Cast( wgt.FindAnyWidget(
"btn_ppp_st_save") );
66 m_TxtWeatherTime =
TextWidget.Cast( wgt.FindAnyWidget(
"txt_ppp_st_w_time_value") );
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") );
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") );
74 m_SldOvercast = SliderWidget.Cast( wgt.FindAnyWidget(
"sld_ppp_st_overcast") );
75 m_TxtOvercastValue =
TextWidget.Cast( wgt.FindAnyWidget(
"txt_ppp_st_overcast_value") );
77 m_SldRain = SliderWidget.Cast( wgt.FindAnyWidget(
"sld_ppp_st_rain") );
78 m_TxtRainValue =
TextWidget.Cast( wgt.FindAnyWidget(
"txt_ppp_st_rain_value") );
80 m_SldFog = SliderWidget.Cast( wgt.FindAnyWidget(
"sld_ppp_st_fog") );
81 m_TxtFogValue =
TextWidget.Cast( wgt.FindAnyWidget(
"txt_ppp_st_fog_value") );
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") );
87 void ~UIPopupScriptSceneManager()
97 super.OnClick(w,
x,
y, button);
100 PluginSceneManager editor;
102 if ( w == m_BtnCancel )
104 GetGame().GetWorld().SetDate( m_OrigYear, m_OrigMonth, m_OrigDay, m_OrigHour, m_OrigMinute );
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 );
115 else if ( w == m_BtnSceneNew )
117 PopupOpen(SceneEditorMenu.POPUP_ID_SCENE_NEW, NULL);
121 else if ( w == m_BtnSceneLoad )
123 if ( m_LstListScenes.GetSelectedRow() != -1 )
125 m_LstListScenes.GetItemText( m_LstListScenes.GetSelectedRow(), 0, scene_name );
126 editor = PluginSceneManager.Cast(
GetPlugin(PluginSceneManager) );
128 editor.SceneLoad(scene_name);
134 else if ( w == m_BtnSceneRename )
136 m_LstListScenes.GetItemText( m_LstListScenes.GetSelectedRow(), 0, scene_name );
138 UIPopupScriptSceneRename popup_rename = UIPopupScriptSceneRename.Cast( PopupOpen(SceneEditorMenu.POPUP_ID_SCENE_RENAME, NULL) );
139 popup_rename.SetRenameName(scene_name);
143 else if ( w == m_BtnSceneDuplicate )
145 if ( m_LstListScenes.GetSelectedRow() != -1 )
147 m_LstListScenes.GetItemText( m_LstListScenes.GetSelectedRow(), 0, scene_name );
148 editor = PluginSceneManager.Cast(
GetPlugin(PluginSceneManager) );
150 editor.SceneDuplicate(scene_name);
156 else if ( w == m_BtnSceneDelete )
158 if ( m_LstListScenes.GetSelectedRow() != -1 )
160 m_LstListScenes.GetItemText( m_LstListScenes.GetSelectedRow(), 0, scene_name );
161 editor = PluginSceneManager.Cast(
GetPlugin(PluginSceneManager) );
163 editor.SceneDelete(scene_name);
165 if ( editor.SceneCanDelete(scene_name) )
167 UIPopupScriptSceneDelete popup_delete = UIPopupScriptSceneDelete.Cast( PopupOpen(SceneEditorMenu.POPUP_ID_SCENE_DELETE, NULL) );
168 popup_delete.SetDeleteName(scene_name);
172 UIPopupScriptNotify popup_notify = UIPopupScriptNotify.Cast( PopupOpen(SceneEditorMenu.POPUP_ID_NOTIFY, NULL) );
173 popup_notify.SetLabelText(
"You cant delete current loaded scene!");
180 else if ( w == m_BtnSave )
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;
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);
207 if ( w == m_SldStartTime )
209 float slider_value_start_time = m_SldStartTime.GetCurrent() * 0.01;
210 float start_time_f = slider_value_start_time * 1439;
211 int start_time = start_time_f;
212 m_CurrHour = start_time / 60;
213 m_CurrMinute = start_time % 60;
215 UpdateSliderStartTime( m_CurrHour, m_CurrMinute );
217 GetGame().GetWorld().SetDate( m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute );
221 else if ( w == m_SldStartDay )
223 float slider_value_start_day = m_SldStartDay.GetCurrent();
224 float start_day_f = slider_value_start_day * 3.64 + 1;
225 int start_day = start_day_f;
227 for (
int i = 0; i < 12; i++ )
229 int days = m_DaysInMonth[i];
230 if ( start_day <= days )
233 m_CurrDay = start_day;
242 UpdateSliderStartDay( m_CurrMonth, m_CurrDay );
244 GetGame().GetWorld().SetDate( m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute );
248 else if ( w == m_SldOvercast )
250 m_CurrOvercast = m_SldOvercast.GetCurrent() * 0.01;
251 GetGame().GetWeather().GetOvercast().Set( m_CurrOvercast, 0, 1000 );
253 UpdateSliderOvercast();
257 else if ( w == m_SldRain )
259 m_CurrRain = m_SldRain.GetCurrent() * 0.01;
260 GetGame().GetWeather().GetRain().Set( m_CurrRain, 0, 1000 );
266 else if ( w == m_SldFog )
268 m_CurrFog = m_SldFog.GetCurrent() * 0.01;
269 GetGame().GetWeather().GetFog().Set( m_CurrFog, 0, 1000 );
275 else if ( w == m_SldWindForce )
277 float wind_slider = m_SldWindForce.GetCurrent() * 0.01;
278 m_CurrWindForce =
GetGame().GetWeather().GetWindMaximumSpeed() * wind_slider;
279 GetGame().GetWeather().SetWindSpeed( m_CurrWindForce );
281 UpdateSliderWindForce();
292 void UpdateSceneList()
294 m_LstListScenes.ClearItems();
296 PluginSceneManager editor = PluginSceneManager.Cast(
GetPlugin(PluginSceneManager) );
299 string loaded_scene_name = editor.SceneGetName();
301 for (
int i = 0; i < scene_list.Count(); ++i )
303 string scene_name = scene_list.Get(i);
305 m_LstListScenes.AddItem(scene_name, NULL, 0);
307 if ( scene_name == loaded_scene_name )
309 m_LstListScenes.SelectRow(i);
317 override void OnOpen(
Param param)
322 GetGame().GetWorld().GetDate( m_OrigYear, m_OrigMonth, m_OrigDay, m_OrigHour, m_OrigMinute );
325 m_OrigOvercast = weather.GetOvercast().GetActual();
326 m_OrigRain = weather.GetRain().GetActual();
327 m_OrigFog = weather.GetFog().GetActual();
328 m_OrigWindForce = weather.GetWindSpeed();
330 m_CurrYear = m_OrigYear;
331 m_CurrMonth = m_OrigMonth;
332 m_CurrDay = m_OrigDay;
333 m_CurrHour = m_OrigHour;
334 m_CurrMinute = m_OrigMinute;
335 m_CurrOvercast = m_OrigOvercast;
336 m_CurrRain = m_OrigRain;
337 m_CurrFog = m_OrigFog;
338 m_CurrWindForce = m_OrigWindForce;
351 override void OnClose()
369 int year, month, day, hour, minute;
370 GetGame().GetWorld().GetDate( year, month, day, hour, minute );
371 m_SldStartTime.SetCurrent( ((hour * 60) + minute) / 14.39 );
372 UpdateSliderStartTime( hour, minute );
374 float start_day = day;
375 int month_tmp = month;
376 while ( month_tmp > 1 )
379 start_day += m_DaysInMonth[month];
381 m_SldStartDay.SetCurrent( start_day / 3.64 );
382 UpdateSliderStartDay( month, day );
386 m_SldOvercast.SetCurrent(weather.GetOvercast().GetActual() * 100);
387 UpdateSliderOvercast();
389 m_SldRain.SetCurrent(weather.GetRain().GetActual() * 100);
392 m_SldFog.SetCurrent(weather.GetFog().GetActual() * 100);
395 float wind_slider = m_SldWindForce.GetCurrent() * 0.01;
396 m_CurrWindForce = weather.GetWindMaximumSpeed() * wind_slider;
397 weather.SetWindSpeed( m_CurrWindForce );
398 UpdateSliderWindForce();
401 void UpdateSliderStartTime(
int hour,
int minute )
403 string label_text = hour.ToStringLen(2) +
":" + minute.ToStringLen(2);
404 m_TxtStartTimeValue.SetText( label_text );
407 void UpdateSliderStartDay(
int month,
int day )
409 string label_text = day.ToString() +
"." + month.ToString() +
". " + m_CurrYear.ToString();
410 m_TxtStartDayValue.SetText( label_text );
413 void UpdateSliderOvercast()
415 string label_text = m_SldOvercast.GetCurrent().ToString()+
"%";
416 m_TxtOvercastValue.SetText( label_text );
419 void UpdateSliderRain()
421 string label_text = m_SldRain.GetCurrent().ToString()+
"%";
422 m_TxtRainValue.SetText( label_text );
425 void UpdateSliderFog()
427 string label_text = m_SldFog.GetCurrent().ToString()+
"%";
428 m_TxtFogValue.SetText( label_text );
431 void UpdateSliderWindForce()
433 string label_text = m_CurrWindForce.ToString()+
"ms";
434 m_TxtWindForceValue.SetText( label_text );