Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WeatherForecastUIComponent.c
Go to the documentation of this file.
2{
3 [Attribute("Current_Icon")]
4 protected string m_sCurrentWeatherIconName;
5
6 [Attribute("Current_Name")]
7 protected string m_sCurrentWeatherTextName;
8
9 [Attribute("Forecast_Icon")]
10 protected string m_sNextWeatherIconName;
11
12 [Attribute("Forecast_Title")]
13 protected string m_sNextWeatherTimeName;
14
15 [Attribute("Forecast_Name")]
16 protected string m_sNextWeatherTextName;
17
18 [Attribute("GameInfo_Weather_Forecast")]
19 protected string m_sNextWeatherHolderName;
20
21 [Attribute("#AR-Weather_Forecast_Looping", uiwidget: UIWidgets.LocaleEditBox)]
23
24 [Attribute("1", "Update freq of weather UI in seconds")]
25 protected float m_fUIUpdateFreq;
26
27 [Attribute("MISSING NAME", desc: "Text shown if weather State has no weather name assigned")]
29
30 [Attribute("{4B4B51FACB828BF9}UI/Textures/Tasks/TaskIcons/96/Icon_Task_Unknown.edds", desc: "Icon used when weather is unknown")]
32
33 protected bool m_bListeningToUpdate;
34
37 protected ref array<ref WeatherState> m_WeatherStates = new array<ref WeatherState>;
38
45 protected Widget m_wRoot;
46
47 //~Todo: Update using TimeAndWeather callback once implemented
48 protected void CheckWeatherUpdate()
49 {
50 if (m_WeatherStateManager.IsPreviewingState())
51 return;
52
53 WeatherState currentWeather = m_WeatherStateManager.GetCurrentState();
54
55 //~ Get weather name
56 string weatherName = currentWeather.GetLocalizedName();
58 weatherName = m_sUnknownWeatherName;
59
60 //~ Get weather Icon
61 string weatherIcon = currentWeather.GetIconPath();
63 weatherIcon = m_sUnknownWeatherIcon;
64
65 m_wCurrentWeatherText.SetText(weatherName);
66 m_wCurrentWeatherIcon.LoadImageTexture(0, weatherIcon);
67
68 WeatherState nextWeather = m_WeatherStateManager.GetNextState();
69 if (!nextWeather)
70 {
71 m_wNextWeatherHolder.SetVisible(false);
72 return;
73 }
74 else
75 {
76 m_wNextWeatherHolder.SetVisible(true);
77 }
78
79
80 //~ Looping weather or Time progression disabled
81 if (m_TimeAndWeatherEntity.IsWeatherLooping() || !m_TimeAndWeatherEntity.GetIsDayAutoAdvanced())
82 {
84 }
85 else
86 {
87 float duration = m_WeatherStateManager.GetTimeLeftUntilNextState();
88 float changeTime = duration + m_TimeAndWeatherEntity.GetTimeOfTheDay();
89 while (changeTime >= 24)
90 changeTime -= 24;
91 int nextWeatherHour = Math.Floor(changeTime);
92 int nextWeatherMinutes = (changeTime - nextWeatherHour) * 60;
93
94 if (nextWeatherMinutes >= 0 && nextWeatherMinutes <= 15)
95 nextWeatherMinutes = 15;
96 else if (nextWeatherMinutes > 15 && nextWeatherMinutes <= 30)
97 nextWeatherMinutes = 30;
98 else if (nextWeatherMinutes > 30 && nextWeatherMinutes <= 45)
99 nextWeatherMinutes = 45;
100 else if (nextWeatherMinutes > 45)
101 {
102 nextWeatherMinutes = 0;
103 nextWeatherHour++;
104
105 if (nextWeatherHour >= 24)
106 nextWeatherHour -= 24;
107 }
108
109 m_wNextWeatherTimeText.SetTextFormat(SCR_FormatHelper.GetTimeFormattingHoursMinutes(nextWeatherHour, nextWeatherMinutes));
110 }
111
112 weatherName = nextWeather.GetLocalizedName();
113 if (SCR_StringHelper.IsEmptyOrWhiteSpace(weatherName))
114 weatherName = m_sUnknownWeatherName;
115
116
117 weatherIcon = nextWeather.GetIconPath();
118 if (SCR_StringHelper.IsEmptyOrWhiteSpace(weatherIcon))
119 weatherIcon = m_sUnknownWeatherIcon;
120
121 m_wNextWeatherText.SetText(weatherName);
122 m_wNextWeatherIcon.LoadImageTexture(0, weatherIcon);
123 }
124
125 protected void ShowWeatherUI(bool show)
126 {
127 m_wRoot.SetVisible(show);
128 }
129
130
131 override void HandlerAttached(Widget w)
132 {
134 return;
135
136 m_wRoot = w;
139
141 {
142 Print("'SCR_WeatherForecastUIComponent' is missing current weather widgets and won't work.", LogLevel.WARNING);
143 return;
144 }
145
149
151 {
152 Print("'SCR_WeatherForecastUIComponent' is missing next weather widgets and won't work.", LogLevel.WARNING);
153 return;
154 }
155
157
158 ChimeraWorld world = GetGame().GetWorld();
159 m_TimeAndWeatherEntity = world.GetTimeAndWeatherManager();
160
162 {
163 ShowWeatherUI(false);
164 return;
165 }
166
167
168 m_TimeAndWeatherEntity.GetWeatherStatesList(m_WeatherStates);
169 if (m_WeatherStates.IsEmpty())
170 {
171 ShowWeatherUI(false);
172 return;
173 }
174
175 m_WeatherStateManager = m_TimeAndWeatherEntity.GetTransitionManager();
176
178 {
179 ShowWeatherUI(false);
180 return;
181 }
182
185 GetGame().GetCallqueue().CallLater(CheckWeatherUpdate, m_fUIUpdateFreq * 1000, true);
186 }
187 override void HandlerDeattached(Widget w)
188 {
190 GetGame().GetCallqueue().Remove(CheckWeatherUpdate);
191 }
192};
ArmaReforgerScripted GetGame()
Definition game.c:1398
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Math.c:13
static string GetTimeFormattingHoursMinutes(int hours, int minutes, ETimeFormatParam hideEmpty=0, ETimeFormatParam hideLeadingZeroes=0)
static bool IsEditMode()
Definition Functions.c:1566
static bool IsEmptyOrWhiteSpace(string input)
TimeAndWeatherManagerEntity m_TimeAndWeatherEntity
BaseWeatherStateTransitionManager m_WeatherStateManager
ref array< ref WeatherState > m_WeatherStates
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute