Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_WeatherForecastUIComponent.c
Go to the documentation of this file.
1
class
SCR_WeatherForecastUIComponent
:
ScriptedWidgetComponent
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)]
22
protected
LocalizedString
m_sLoopingWeatherText
;
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"
)]
28
protected
LocalizedString
m_sUnknownWeatherName
;
29
30
[
Attribute
(
"{4B4B51FACB828BF9}UI/Textures/Tasks/TaskIcons/96/Icon_Task_Unknown.edds"
,
desc
:
"Icon used when weather is unknown"
)]
31
protected
ResourceName
m_sUnknownWeatherIcon
;
32
33
protected
bool
m_bListeningToUpdate
;
34
35
protected
TimeAndWeatherManagerEntity
m_TimeAndWeatherEntity
;
36
protected
BaseWeatherStateTransitionManager
m_WeatherStateManager
;
37
protected
ref array<ref WeatherState>
m_WeatherStates
=
new
array<ref WeatherState>;
38
39
protected
ImageWidget
m_wCurrentWeatherIcon
;
40
protected
TextWidget
m_wCurrentWeatherText
;
41
protected
TextWidget
m_wNextWeatherText
;
42
protected
TextWidget
m_wNextWeatherTimeText
;
43
protected
ImageWidget
m_wNextWeatherIcon
;
44
protected
Widget
m_wNextWeatherHolder
;
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();
57
if
(
SCR_StringHelper
.
IsEmptyOrWhiteSpace
(weatherName))
58
weatherName =
m_sUnknownWeatherName
;
59
60
//~ Get weather Icon
61
string
weatherIcon = currentWeather.GetIconPath();
62
if
(
SCR_StringHelper
.
IsEmptyOrWhiteSpace
(weatherIcon))
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
{
83
m_wNextWeatherTimeText
.SetText(
m_sLoopingWeatherText
);
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
{
133
if
(
SCR_Global
.
IsEditMode
())
134
return
;
135
136
m_wRoot
= w;
137
m_wCurrentWeatherIcon
=
ImageWidget
.Cast(w.FindAnyWidget(
m_sCurrentWeatherIconName
));
138
m_wCurrentWeatherText
=
TextWidget
.Cast(w.FindAnyWidget(
m_sCurrentWeatherTextName
));
139
140
if
(!
m_wCurrentWeatherIcon
|| !
m_wCurrentWeatherText
)
141
{
142
Print
(
"'SCR_WeatherForecastUIComponent' is missing current weather widgets and won't work."
,
LogLevel
.WARNING);
143
return
;
144
}
145
146
m_wNextWeatherIcon
=
ImageWidget
.Cast(w.FindAnyWidget(
m_sNextWeatherIconName
));
147
m_wNextWeatherText
=
TextWidget
.Cast(w.FindAnyWidget(
m_sNextWeatherTextName
));
148
m_wNextWeatherTimeText
=
TextWidget
.Cast(w.FindAnyWidget(
m_sNextWeatherTimeName
));
149
150
if
(!
m_wNextWeatherIcon
|| !
m_wNextWeatherText
|| !
m_wNextWeatherTimeText
)
151
{
152
Print
(
"'SCR_WeatherForecastUIComponent' is missing next weather widgets and won't work."
,
LogLevel
.WARNING);
153
return
;
154
}
155
156
m_wNextWeatherHolder
= w.FindAnyWidget(
m_sNextWeatherHolderName
);
157
158
ChimeraWorld
world =
GetGame
().GetWorld();
159
m_TimeAndWeatherEntity
= world.GetTimeAndWeatherManager();
160
161
if
(!
m_TimeAndWeatherEntity
)
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
177
if
(!
m_WeatherStateManager
)
178
{
179
ShowWeatherUI
(
false
);
180
return
;
181
}
182
183
CheckWeatherUpdate
();
184
m_bListeningToUpdate
=
true
;
185
GetGame
().GetCallqueue().CallLater(
CheckWeatherUpdate
,
m_fUIUpdateFreq
* 1000,
true
);
186
}
187
override
void
HandlerDeattached
(
Widget
w)
188
{
189
if
(
m_bListeningToUpdate
)
190
GetGame
().GetCallqueue().Remove(
CheckWeatherUpdate
);
191
}
192
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
BaseWeatherStateTransitionManager
Definition
BaseWeatherStateTransitionManager.c:8
ChimeraWorld
Definition
ChimeraWorld.c:13
ImageWidget
Definition
ImageWidget.c:13
LocalizedString
Definition
LocalizedString.c:22
Math
Definition
Math.c:13
ResourceName
Definition
ResourceName.c:13
SCR_FormatHelper
Definition
SCR_FormatHelper.c:2
SCR_FormatHelper::GetTimeFormattingHoursMinutes
static string GetTimeFormattingHoursMinutes(int hours, int minutes, ETimeFormatParam hideEmpty=0, ETimeFormatParam hideLeadingZeroes=0)
Definition
SCR_FormatHelper.c:220
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
SCR_StringHelper
Definition
SCR_StringHelper.c:2
SCR_StringHelper::IsEmptyOrWhiteSpace
static bool IsEmptyOrWhiteSpace(string input)
Definition
SCR_StringHelper.c:594
SCR_WeatherForecastUIComponent
Definition
SCR_WeatherForecastUIComponent.c:2
SCR_WeatherForecastUIComponent::m_wCurrentWeatherIcon
ImageWidget m_wCurrentWeatherIcon
Definition
SCR_WeatherForecastUIComponent.c:39
SCR_WeatherForecastUIComponent::m_sNextWeatherIconName
string m_sNextWeatherIconName
Definition
SCR_WeatherForecastUIComponent.c:10
SCR_WeatherForecastUIComponent::m_wRoot
Widget m_wRoot
Definition
SCR_WeatherForecastUIComponent.c:45
SCR_WeatherForecastUIComponent::ShowWeatherUI
void ShowWeatherUI(bool show)
Definition
SCR_WeatherForecastUIComponent.c:125
SCR_WeatherForecastUIComponent::m_sCurrentWeatherTextName
string m_sCurrentWeatherTextName
Definition
SCR_WeatherForecastUIComponent.c:7
SCR_WeatherForecastUIComponent::m_wNextWeatherText
TextWidget m_wNextWeatherText
Definition
SCR_WeatherForecastUIComponent.c:41
SCR_WeatherForecastUIComponent::m_TimeAndWeatherEntity
TimeAndWeatherManagerEntity m_TimeAndWeatherEntity
Definition
SCR_WeatherForecastUIComponent.c:35
SCR_WeatherForecastUIComponent::m_sLoopingWeatherText
LocalizedString m_sLoopingWeatherText
Definition
SCR_WeatherForecastUIComponent.c:22
SCR_WeatherForecastUIComponent::m_wNextWeatherTimeText
TextWidget m_wNextWeatherTimeText
Definition
SCR_WeatherForecastUIComponent.c:42
SCR_WeatherForecastUIComponent::CheckWeatherUpdate
void CheckWeatherUpdate()
Definition
SCR_WeatherForecastUIComponent.c:48
SCR_WeatherForecastUIComponent::m_sCurrentWeatherIconName
string m_sCurrentWeatherIconName
Definition
SCR_WeatherForecastUIComponent.c:4
SCR_WeatherForecastUIComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_WeatherForecastUIComponent.c:187
SCR_WeatherForecastUIComponent::m_WeatherStateManager
BaseWeatherStateTransitionManager m_WeatherStateManager
Definition
SCR_WeatherForecastUIComponent.c:36
SCR_WeatherForecastUIComponent::m_bListeningToUpdate
bool m_bListeningToUpdate
Definition
SCR_WeatherForecastUIComponent.c:33
SCR_WeatherForecastUIComponent::m_wNextWeatherHolder
Widget m_wNextWeatherHolder
Definition
SCR_WeatherForecastUIComponent.c:44
SCR_WeatherForecastUIComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_WeatherForecastUIComponent.c:131
SCR_WeatherForecastUIComponent::m_sUnknownWeatherIcon
ResourceName m_sUnknownWeatherIcon
Definition
SCR_WeatherForecastUIComponent.c:31
SCR_WeatherForecastUIComponent::m_WeatherStates
ref array< ref WeatherState > m_WeatherStates
Definition
SCR_WeatherForecastUIComponent.c:37
SCR_WeatherForecastUIComponent::m_wNextWeatherIcon
ImageWidget m_wNextWeatherIcon
Definition
SCR_WeatherForecastUIComponent.c:43
SCR_WeatherForecastUIComponent::m_sNextWeatherTimeName
string m_sNextWeatherTimeName
Definition
SCR_WeatherForecastUIComponent.c:13
SCR_WeatherForecastUIComponent::m_sNextWeatherHolderName
string m_sNextWeatherHolderName
Definition
SCR_WeatherForecastUIComponent.c:19
SCR_WeatherForecastUIComponent::m_wCurrentWeatherText
TextWidget m_wCurrentWeatherText
Definition
SCR_WeatherForecastUIComponent.c:40
SCR_WeatherForecastUIComponent::m_sUnknownWeatherName
LocalizedString m_sUnknownWeatherName
Definition
SCR_WeatherForecastUIComponent.c:28
SCR_WeatherForecastUIComponent::m_sNextWeatherTextName
string m_sNextWeatherTextName
Definition
SCR_WeatherForecastUIComponent.c:16
SCR_WeatherForecastUIComponent::m_fUIUpdateFreq
float m_fUIUpdateFreq
Definition
SCR_WeatherForecastUIComponent.c:25
ScriptedWidgetComponent
Definition
ScriptedWidgetComponent.c:13
TextWidget
Definition
TextWidget.c:16
TimeAndWeatherManagerEntity
Definition
TimeAndWeatherManagerEntity.c:26
UIWidgets
Definition
attributes.c:40
WeatherState
Definition
WeatherState.c:8
Widget
Definition
Widget.c:13
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
Components
SCR_WeatherForecastUIComponent.c
Generated by
1.17.0