Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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
5 private ButtonWidget m_BtnSave;
6 private ButtonWidget m_BtnCancel;
7
8 private TextWidget m_TxtWeatherTime;
9
10 private SliderWidget m_SldStartTime;
11 private TextWidget m_TxtStartTimeValue;
12 private SliderWidget m_SldStartDay;
13 private TextWidget m_TxtStartDayValue;
14 private SliderWidget m_SldOvercast;
15 private TextWidget m_TxtOvercastValue;
16 private SliderWidget m_SldRain;
17 private TextWidget m_TxtRainValue;
18 private SliderWidget m_SldFog;
19 private TextWidget m_TxtFogValue;
20 private SliderWidget m_SldWindForce;
21 private TextWidget m_TxtWindForceValue;
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 g_Game.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 {
94
95 PluginSceneManager editor = PluginSceneManager.Cast( GetPlugin(PluginSceneManager) );
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;
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;
124
126
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;
135 int start_day = start_day_f;
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 {
148 start_day -= days;
149 }
150 }
151
153
155
156 return true;
157 }
158 else if ( w == m_SldOvercast )
159 {
161
162 m_CurrOvercast = m_SldOvercast.GetCurrent() * 0.01;
163 g_Game.GetWeather().GetOvercast().Set( m_CurrOvercast, 0, 1000 );
164
165 return true;
166 }
167 else if ( w == m_SldRain )
168 {
170
171 m_CurrRain = m_SldRain.GetCurrent() * 0.01;
172 g_Game.GetWeather().GetRain().Set( m_CurrRain, 0, 1000 );
173
174 return true;
175 }
176 else if ( w == m_SldFog )
177 {
179
180 m_CurrFog = m_SldFog.GetCurrent() * 0.01;
181 g_Game.GetWeather().GetFog().Set( m_CurrFog, 0, 1000 );
182
183 return true;
184 }
185 else if ( w == m_SldWindForce )
186 {
188
189 m_CurrWindForce = m_SldWindForce.GetCurrent() * 0.01;
190 //g_Game.GetWeather().SetWindSpeed( m_CurrWindForce );
191
192 return true;
193 }
194
195 return false;
196 }
197
198 //================================================
199 // OnOpen
200 //================================================
201 override void OnOpen(Param param)
202 {
204
205 Weather weather = g_Game.GetWeather();
206
208 m_OrigRain = weather.GetRain().GetActual();
209 m_OrigFog = weather.GetFog().GetActual();
210 m_OrigWindForce = weather.GetWindSpeed();
211
221
222 Print( "Year" );
223 Print( m_CurrYear );
224
225 g_Game.GetUpdateQueue(CALL_CATEGORY_SYSTEM).Insert(this.OnUpdate);
226
227 ResetSliders();
228 }
229
230 //================================================
231 // OnClose
232 //================================================
233 override void OnClose()
234 {
235 Weather weather = g_Game.GetWeather();
236
238 weather.GetOvercast().Set( m_OrigOvercast, 0, 1000 );
239 weather.GetRain().Set( m_OrigRain, 0, 1000 );
240 weather.GetFog().Set( m_OrigFog, 0, 1000 );
241 //weather.SetWindSpeed( m_OrigWindForce );
242 }
243
244 //================================================
245 // OnUpdate
246 //================================================
247 void OnUpdate()
248 {
249 m_TxtWeatherTime.SetText(g_Game.GetWeather().GetTime().ToString());
250 }
251
252 //================================================
253 // ResetSliders
254 //================================================
256 {
257 int year, month, day, hour, minute;
258 g_Game.GetWorld().GetDate( year, month, day, hour, minute );
259 m_SldStartTime.SetCurrent( ((hour * 60) + minute) / 14.39 );
260 UpdateSliderStartTime( hour, minute );
261
262 float start_day = day;
263 int month_tmp = month;
264 while ( month_tmp > 1 )
265 {
266 month_tmp--;
267 start_day += m_DaysInMonth[month];
268 }
269 m_SldStartDay.SetCurrent( start_day / 3.64 );
270 UpdateSliderStartDay( month, day );
271
272 Weather weather = g_Game.GetWeather();
273
274 m_SldOvercast.SetCurrent(weather.GetOvercast().GetActual() * 100);
276
277 m_SldRain.SetCurrent(weather.GetRain().GetActual() * 100);
279
280 m_SldFog.SetCurrent(weather.GetFog().GetActual() * 100);
282
283 float slider_wind_value = ( weather.GetWindSpeed() / weather.GetWindMaximumSpeed() ) * 100;
284 m_SldWindForce.SetCurrent( slider_wind_value );
286 }
287
288 void UpdateSliderStartTime( int hour, int minute )
289 {
290 string label_text = hour.ToStringLen(2) + ":" + minute.ToStringLen(2);
291 m_TxtStartTimeValue.SetText( label_text );
292 }
293
294 void UpdateSliderStartDay( int month, int day )
295 {
296 string label_text = day.ToString() + "." + month.ToString() + ". " + m_CurrYear.ToString();
297 m_TxtStartDayValue.SetText( label_text );
298 }
299
301 {
302 string label_text = m_SldOvercast.GetCurrent().ToString()+"%";
303 m_TxtOvercastValue.SetText( label_text );
304 }
305
307 {
308 string label_text = m_SldRain.GetCurrent().ToString()+"%";
309 m_TxtRainValue.SetText( label_text );
310 }
311
313 {
314 string label_text = m_SldFog.GetCurrent().ToString()+"%";
315 m_TxtFogValue.SetText( label_text );
316 }
317
319 {
320 string label_text = m_SldWindForce.GetCurrent().ToString()+"%";
321 m_TxtWindForceValue.SetText( label_text );
322 }
323}
Base Param Class with no parameters.
Definition param.c:12
override bool OnChange(Widget w, int x, int y, bool finished)
void UpdateSliderStartDay(int month, int day)
override void OnOpen(Param param)
void UIPopupScriptSceneSettings(Widget wgt)
ButtonWidget m_BtnCancel
static const int m_DaysInMonth[12]
void UpdateSliderStartTime(int hour, int minute)
override bool OnClick(Widget w, int x, int y, int button)
UIPopupScript PopupBack()
Weather controller.
Definition weather.c:168
proto native float GetWindMaximumSpeed()
Returns maximal wind speed in metre per second.
proto native Overcast GetOvercast()
Returns an overcast phenomenon object.
proto native float GetWindSpeed()
Returns actual wind speed in metre per second.
proto native Rain GetRain()
Returns a rain phenomenon object.
proto native Fog GetFog()
Returns a fog phenomenon object.
proto native void Set(float forecast, float time=0, float minDuration=0)
Sets the forecast.
proto native float GetActual()
Returns actual value of phenomenon in range <0, 1>. (does not apply for Wind, which always returns th...
DayZGame g_Game
Definition dayzgame.c:3942
proto void Print(void var)
Prints content of variable to console/log.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
Icon x
Icon y
PluginBase GetPlugin(typename plugin_type)