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_LoadingScreenComponent.c
Go to the documentation of this file.
1
class
SCR_LoadingScreenComponent
:
SCR_BaseLoadingScreenComponent
2
{
3
protected
bool
m_bMissionDataRetrieved
;
4
5
protected
const
string
AUTHOR_FORMAT
=
"#AR-AuthorLoadingScreen"
;
//"Author: "
6
protected
const
string
AUTHOR_UNKNOWN
=
"#AR-Author_Unknown"
;
//"By a community author"
7
8
protected
const
float
MAX_DESCRIPTION_LENGTH
= 1000;
9
protected
const
float
FADE_TIME
= 1;
10
11
private
float
m_fLoadingTime_MissionDataRetrieved;
12
private
float
m_fProgressBar_Progress;
13
private
ref
SCR_LoadingHintComponent
m_LoadingHintComponent;
14
15
protected
Widget
m_wBuildVersion
;
16
17
//---------------------------------------------------------------------------------------------
18
override
protected
void
HandlerAttached
(
Widget
w)
19
{
20
super.HandlerAttached(w);
21
22
m_wRoot
.SetZOrder(10000);
23
}
24
25
//---------------------------------------------------------------------------------------------
26
override
protected
void
InitWidgets
()
27
{
28
super.InitWidgets();
29
30
m_Widgets
.m_wContentOverlay.SetOpacity(0);
31
32
m_Widgets
.m_wContent.SetVisible(
false
);
33
m_Widgets
.m_wPreloadContent.SetVisible(
true
);
34
35
m_Widgets
.m_wContentOverlay.SetVisible(
true
);
36
m_Widgets
.m_wBlackOverlay.SetVisible(
true
);
37
38
#ifdef DEBUG_LOADING_SCREENS
39
m_Widgets
.m_wCrossplayWarning.SetVisible(
true
);
40
m_Widgets
.m_wModdedWarning.SetVisible(
true
);
41
#else
42
m_Widgets
.m_wCrossplayWarning.SetVisible(
false
);
43
m_Widgets
.m_wModdedWarning.SetVisible(
false
);
44
#endif
45
}
46
47
//---------------------------------------------------------------------------------------------
48
void
OnMissionDataRetrieved
(
SCR_MissionHeader
header)
49
{
50
#ifdef DEBUG_LOADING_SCREENS
51
PrintFormat
(
">> %1 >> OnMissionDataRetrieved | header: %2"
,
this
, header);
52
#endif
53
54
// Create a build version layout
55
m_wBuildVersion
=
GetGame
().GetWorkspace().CreateWidgets(
"{B7A765172F0BD4D9}UI/layouts/Common/GameVersionWatermark.layout"
,
m_wRoot
);
56
m_wBuildVersion
.SetZOrder(1);
57
m_wBuildVersion
.SetVisible(
false
);
58
59
// If loading header failed, keep the preloading state
60
if
(!header)
61
return
;
62
63
// Add hint component
64
m_LoadingHintComponent =
new
SCR_LoadingHintComponent
();
65
66
if
(m_LoadingHintComponent)
67
m_Widgets
.m_wHintText.AddHandler(m_LoadingHintComponent);
68
69
// Get description text and check its length
70
string
description = header.m_sDetails;
71
if
(description ==
string
.Empty)
72
description = header.m_sDescription;
73
74
description =
WidgetManager
.Translate(description);
75
76
if
(description.Length() >
MAX_DESCRIPTION_LENGTH
)
77
{
78
description = description.Substring(0,
MAX_DESCRIPTION_LENGTH
);
79
description +=
"..."
;
80
}
81
82
string
image = header.m_sLoadingScreen;
83
if
(image ==
string
.Empty)
84
image = header.m_sIcon;
85
86
if
(
m_Widgets
.m_wTitle)
87
m_Widgets
.m_wTitle.SetText(header.m_sName);
88
89
if
(
m_Widgets
.m_wDescription)
90
m_Widgets
.m_wDescription.SetText(description);
91
92
if
(
m_Widgets
.m_wAuthor)
93
{
94
if
(header.m_sAuthor.IsEmpty())
95
m_Widgets
.m_wAuthor.SetText(
AUTHOR_UNKNOWN
);
96
else
97
{
98
string
author =
WidgetManager
.Translate(
AUTHOR_FORMAT
);
99
m_Widgets
.m_wAuthor.SetText(author + header.m_sAuthor);
100
}
101
}
102
103
if
(
m_Widgets
.m_wLoadingImage)
104
{
105
m_Widgets
.m_wLoadingImage.LoadImageTexture(0, image);
106
}
107
108
// Allow fade-in Update() animations
109
m_bMissionDataRetrieved
=
true
;
110
m_fLoadingTime_MissionDataRetrieved =
m_fLoadingTime
;
111
}
112
113
//---------------------------------------------------------------------------------------------
114
override
void
OnHideInternal
()
115
{
116
if
(
m_bMissionDataRetrieved
)
117
{
118
ResetLoadingTime
();
119
}
120
else
121
{
122
if
(m_LoadingHintComponent)
123
m_LoadingHintComponent.OnLoadingFinished();
124
125
SaveLoadingTime
(
m_fLoadingTime
);
126
}
127
}
128
129
//---------------------------------------------------------------------------------------------
130
override
void
Update
(
float
timeSlice,
float
progress = 0,
float
minDurationRatio = 0)
131
{
132
super.Update(timeSlice, progress, minDurationRatio);
133
134
#ifdef DEBUG_LOADING_SCREENS
135
PrintFormat
(
">> %1 >> Update | timeSlice: %2 | progress: %3 | m_fLoadingTime: %4"
,
this
, timeSlice, progress,
m_fLoadingTime
);
136
#endif
137
138
if
(!
m_bMissionDataRetrieved
)
139
return
;
140
141
// Update loading hints
142
if
(m_LoadingHintComponent)
143
m_LoadingHintComponent.Update(timeSlice);
144
145
// Update progress bar
146
SetProgressBar
(progress);
147
148
// Rotate spinner
149
if
(
m_SpinnerComp
)
150
m_SpinnerComp
.Update(timeSlice);
151
152
// Hiding pre-load conntent
153
if
(
m_fLoadingTime
<= m_fLoadingTime_MissionDataRetrieved +
FADE_TIME
)
154
{
155
Fade
(
m_Widgets
.m_wContentOverlay,
true
,
FADE_TIME
, timeSlice);
156
}
157
// Showing scenario content
158
else
if
(
m_fLoadingTime
<= m_fLoadingTime_MissionDataRetrieved + 2 *
FADE_TIME
)
159
{
160
m_Widgets
.m_wPreloadContent.SetVisible(
false
);
161
m_Widgets
.m_wContent.SetVisible(
true
);
162
m_wBuildVersion
.SetVisible(
true
);
163
164
Fade
(
m_Widgets
.m_wContentOverlay,
false
,
FADE_TIME
, timeSlice);
165
}
166
// Scenario content shown
167
else
168
{
169
m_Widgets
.m_wPreloadContent.SetVisible(
false
);
170
m_Widgets
.m_wContent.SetVisible(
true
);
171
m_Widgets
.m_wContentOverlay.SetOpacity(0);
172
}
173
}
174
175
//---------------------------------------------------------------------------------------------
176
protected
void
SetProgressBar
(
float
progress)
177
{
178
if
(!
m_Widgets
.m_wProgressBarFill || !
m_Widgets
.m_wProgressBarSpace)
179
return
;
180
181
// Make sure progression never goes back
182
if
(progress < m_fProgressBar_Progress)
183
progress = m_fProgressBar_Progress;
184
else
if
(progress > m_fProgressBar_Progress)
185
m_fProgressBar_Progress = progress;
186
187
HorizontalLayoutSlot
.SetFillWeight(
m_Widgets
.m_wProgressBarFill, progress);
188
HorizontalLayoutSlot
.SetFillWeight(
m_Widgets
.m_wProgressBarSpace, 1 - progress);
189
}
190
191
//------------------------------------------------------------------------------------------------
192
void
SetJoiningCrossPlay
(
bool
isCrossPlay)
193
{
194
m_Widgets
.m_wCrossplayWarning.SetVisible(isCrossPlay);
195
}
196
197
//------------------------------------------------------------------------------------------------
198
void
SetLoadingModded
(
bool
isModded)
199
{
200
m_Widgets
.m_wModdedWarning.SetVisible(isModded);
201
}
202
};
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
HorizontalLayoutSlot
Definition
HorizontalLayoutSlot.c:13
SCR_BaseLoadingScreenComponent
Definition
SCR_BaseLoadingScreenComponent.c:4
SCR_BaseLoadingScreenComponent::Fade
void Fade(Widget w, bool show, float length, float timeslice)
Definition
SCR_BaseLoadingScreenComponent.c:111
SCR_BaseLoadingScreenComponent::m_Widgets
ref SCR_ScenarioLoadingScreenWidgets m_Widgets
Definition
SCR_BaseLoadingScreenComponent.c:7
SCR_BaseLoadingScreenComponent::ResetLoadingTime
static void ResetLoadingTime()
Definition
SCR_BaseLoadingScreenComponent.c:76
SCR_BaseLoadingScreenComponent::SaveLoadingTime
void SaveLoadingTime(float loadingTime)
Definition
SCR_BaseLoadingScreenComponent.c:84
SCR_BaseLoadingScreenComponent::m_fLoadingTime
float m_fLoadingTime
Definition
SCR_BaseLoadingScreenComponent.c:12
SCR_BaseLoadingScreenComponent::m_wRoot
Widget m_wRoot
Definition
SCR_BaseLoadingScreenComponent.c:5
SCR_BaseLoadingScreenComponent::m_SpinnerComp
SCR_LoadingSpinner m_SpinnerComp
Definition
SCR_BaseLoadingScreenComponent.c:8
SCR_LoadingHintComponent
Definition
SCR_LoadingHintComponent.c:3
SCR_LoadingScreenComponent
Definition
SCR_LoadingScreenComponent.c:2
SCR_LoadingScreenComponent::m_wBuildVersion
Widget m_wBuildVersion
Definition
SCR_LoadingScreenComponent.c:15
SCR_LoadingScreenComponent::OnHideInternal
override void OnHideInternal()
Definition
SCR_LoadingScreenComponent.c:114
SCR_LoadingScreenComponent::Update
override void Update(float timeSlice, float progress=0, float minDurationRatio=0)
Definition
SCR_LoadingScreenComponent.c:130
SCR_LoadingScreenComponent::SetProgressBar
void SetProgressBar(float progress)
Definition
SCR_LoadingScreenComponent.c:176
SCR_LoadingScreenComponent::AUTHOR_FORMAT
const string AUTHOR_FORMAT
Definition
SCR_LoadingScreenComponent.c:5
SCR_LoadingScreenComponent::SetLoadingModded
void SetLoadingModded(bool isModded)
Definition
SCR_LoadingScreenComponent.c:198
SCR_LoadingScreenComponent::MAX_DESCRIPTION_LENGTH
const float MAX_DESCRIPTION_LENGTH
Definition
SCR_LoadingScreenComponent.c:8
SCR_LoadingScreenComponent::SetJoiningCrossPlay
void SetJoiningCrossPlay(bool isCrossPlay)
Definition
SCR_LoadingScreenComponent.c:192
SCR_LoadingScreenComponent::OnMissionDataRetrieved
void OnMissionDataRetrieved(SCR_MissionHeader header)
Definition
SCR_LoadingScreenComponent.c:48
SCR_LoadingScreenComponent::FADE_TIME
const float FADE_TIME
Definition
SCR_LoadingScreenComponent.c:9
SCR_LoadingScreenComponent::HandlerAttached
void HandlerAttached(Widget w)
Definition
SCR_LoadingScreenComponent.c:18
SCR_LoadingScreenComponent::m_bMissionDataRetrieved
bool m_bMissionDataRetrieved
Definition
SCR_LoadingScreenComponent.c:3
SCR_LoadingScreenComponent::AUTHOR_UNKNOWN
const string AUTHOR_UNKNOWN
Definition
SCR_LoadingScreenComponent.c:6
SCR_LoadingScreenComponent::InitWidgets
void InitWidgets()
Definition
SCR_LoadingScreenComponent.c:26
SCR_MissionHeader
Definition
SCR_MissionHeader.c:2
Widget
Definition
Widget.c:13
WidgetManager
Definition
WidgetManager.c:16
PrintFormat
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
scripts
Game
UI
LoadingScreen
SCR_LoadingScreenComponent.c
Generated by
1.17.0