3 private static const int m_DaysInMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
5 private ButtonWidget m_BtnSave;
6 private ButtonWidget m_BtnCancel;
10 private SliderWidget m_SldStartTime;
12 private SliderWidget m_SldStartDay;
14 private SliderWidget m_SldOvercast;
16 private SliderWidget m_SldRain;
18 private SliderWidget m_SldFog;
20 private SliderWidget m_SldWindForce;
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;
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;
46 void UIPopupScriptSceneSettings(
Widget wgt)
48 m_BtnSave = ButtonWidget.Cast( wgt.FindAnyWidget(
"btn_ppp_st_save") );
49 m_BtnCancel = ButtonWidget.Cast( wgt.FindAnyWidget(
"btn_ppp_st_cancel") );
51 m_TxtWeatherTime =
TextWidget.Cast( wgt.FindAnyWidget(
"txt_ppp_st_w_time_value") );
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") );
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") );
59 m_SldOvercast = SliderWidget.Cast( wgt.FindAnyWidget(
"sld_ppp_st_overcast") );
60 m_TxtOvercastValue =
TextWidget.Cast( wgt.FindAnyWidget(
"txt_ppp_st_overcast_value") );
62 m_SldRain = SliderWidget.Cast( wgt.FindAnyWidget(
"sld_ppp_st_rain") );
63 m_TxtRainValue =
TextWidget.Cast( wgt.FindAnyWidget(
"txt_ppp_st_rain_value") );
65 m_SldFog = SliderWidget.Cast( wgt.FindAnyWidget(
"sld_ppp_st_fog") );
66 m_TxtFogValue =
TextWidget.Cast( wgt.FindAnyWidget(
"txt_ppp_st_fog_value") );
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") );
72 void ~UIPopupScriptSceneSettings()
81 super.OnClick(w,
x,
y, button);
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;
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);
103 else if ( w == m_BtnCancel )
117 if ( w == m_SldStartTime )
119 float slider_value_start_time = m_SldStartTime.GetCurrent() * 0.01;
120 float start_time_f = slider_value_start_time * 1439;
121 int start_time = start_time_f;
122 m_CurrHour = start_time / 60;
123 m_CurrMinute = start_time % 60;
125 UpdateSliderStartTime( m_CurrHour, m_CurrMinute );
127 GetGame().GetWorld().SetDate( m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute );
131 else if ( w == m_SldStartDay )
133 float slider_value_start_day = m_SldStartDay.GetCurrent();
134 float start_day_f = slider_value_start_day * 3.64 + 1;
135 int start_day = start_day_f;
137 for (
int i = 0; i < 12; i++ )
139 int days = m_DaysInMonth[i];
140 if ( start_day <= days )
143 m_CurrDay = start_day;
152 UpdateSliderStartDay( m_CurrMonth, m_CurrDay );
154 GetGame().GetWorld().SetDate( m_CurrYear, m_CurrMonth, m_CurrDay, m_CurrHour, m_CurrMinute );
158 else if ( w == m_SldOvercast )
160 UpdateSliderOvercast();
162 m_CurrOvercast = m_SldOvercast.GetCurrent() * 0.01;
163 GetGame().GetWeather().GetOvercast().Set( m_CurrOvercast, 0, 1000 );
167 else if ( w == m_SldRain )
171 m_CurrRain = m_SldRain.GetCurrent() * 0.01;
172 GetGame().GetWeather().GetRain().Set( m_CurrRain, 0, 1000 );
176 else if ( w == m_SldFog )
180 m_CurrFog = m_SldFog.GetCurrent() * 0.01;
181 GetGame().GetWeather().GetFog().Set( m_CurrFog, 0, 1000 );
185 else if ( w == m_SldWindForce )
187 UpdateSliderWindForce();
189 m_CurrWindForce = m_SldWindForce.GetCurrent() * 0.01;
201 override void OnOpen(
Param param)
203 GetGame().GetWorld().GetDate( m_OrigYear, m_OrigMonth, m_OrigDay, m_OrigHour, m_OrigMinute );
207 m_OrigOvercast = weather.GetOvercast().GetActual();
208 m_OrigRain = weather.GetRain().GetActual();
209 m_OrigFog = weather.GetFog().GetActual();
210 m_OrigWindForce = weather.GetWindSpeed();
212 m_CurrYear = m_OrigYear;
213 m_CurrMonth = m_OrigMonth;
214 m_CurrDay = m_OrigDay;
215 m_CurrHour = m_OrigHour;
216 m_CurrMinute = m_OrigMinute;
217 m_CurrOvercast = m_OrigOvercast;
218 m_CurrRain = m_OrigRain;
219 m_CurrFog = m_OrigFog;
220 m_CurrWindForce = m_OrigWindForce;
233 override void OnClose()
237 GetGame().GetWorld().SetDate( m_OrigYear, m_OrigMonth, m_OrigDay, m_OrigHour, m_OrigMinute );
238 weather.GetOvercast().Set( m_OrigOvercast, 0, 1000 );
239 weather.GetRain().Set( m_OrigRain, 0, 1000 );
240 weather.GetFog().Set( m_OrigFog, 0, 1000 );
257 int year, month, day, hour, minute;
258 GetGame().GetWorld().GetDate( year, month, day, hour, minute );
259 m_SldStartTime.SetCurrent( ((hour * 60) + minute) / 14.39 );
260 UpdateSliderStartTime( hour, minute );
262 float start_day = day;
263 int month_tmp = month;
264 while ( month_tmp > 1 )
267 start_day += m_DaysInMonth[month];
269 m_SldStartDay.SetCurrent( start_day / 3.64 );
270 UpdateSliderStartDay( month, day );
274 m_SldOvercast.SetCurrent(weather.GetOvercast().GetActual() * 100);
275 UpdateSliderOvercast();
277 m_SldRain.SetCurrent(weather.GetRain().GetActual() * 100);
280 m_SldFog.SetCurrent(weather.GetFog().GetActual() * 100);
283 float slider_wind_value = ( weather.GetWindSpeed() / weather.GetWindMaximumSpeed() ) * 100;
284 m_SldWindForce.SetCurrent( slider_wind_value );
285 UpdateSliderWindForce();
288 void UpdateSliderStartTime(
int hour,
int minute )
290 string label_text = hour.ToStringLen(2) +
":" + minute.ToStringLen(2);
291 m_TxtStartTimeValue.SetText( label_text );
294 void UpdateSliderStartDay(
int month,
int day )
296 string label_text = day.ToString() +
"." + month.ToString() +
". " + m_CurrYear.ToString();
297 m_TxtStartDayValue.SetText( label_text );
300 void UpdateSliderOvercast()
302 string label_text = m_SldOvercast.GetCurrent().ToString()+
"%";
303 m_TxtOvercastValue.SetText( label_text );
306 void UpdateSliderRain()
308 string label_text = m_SldRain.GetCurrent().ToString()+
"%";
309 m_TxtRainValue.SetText( label_text );
312 void UpdateSliderFog()
314 string label_text = m_SldFog.GetCurrent().ToString()+
"%";
315 m_TxtFogValue.SetText( label_text );
318 void UpdateSliderWindForce()
320 string label_text = m_SldWindForce.GetCurrent().ToString()+
"%";
321 m_TxtWindForceValue.SetText( label_text );