Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseLoadingScreenComponent.c
Go to the documentation of this file.
1//#define DEBUG_LOADING_SCREENS
2
4{
5 protected Widget m_wRoot;
6
9
10 protected static const float FADE_TIME_BLACK_OVERLAY = 1;
11
12 protected float m_fLoadingTime;
13
14 //------------------------------------------------------------------------------------------------
15 override protected void HandlerAttached(Widget w)
16 {
17 #ifdef DEBUG_LOADING_SCREENS
18 PrintFormat(">> %1 >> HandlerAttached | widget: %2", this, w);
19 #endif
20
21 m_wRoot = w;
22
24 m_Widgets.Init(m_wRoot);
25
26 // Get spinner component
27 if (m_Widgets.m_wSpinner)
28 {
29 Widget compWidget = m_Widgets.m_wSpinner.FindAnyWidget("Spinner");
30
31 if (compWidget)
32 m_SpinnerComp = SCR_LoadingSpinner.Cast(compWidget.FindHandler(SCR_LoadingSpinner));
33 }
34
36
37 // Get total elapsed loading time & set the animations progress
39
40 #ifdef DEBUG_LOADING_SCREENS
41 PrintFormat(">> %1 >> HandlerAttached | widget: %2 | m_fLoadingTime: %3", this, w, m_fLoadingTime);
42 #endif
43
45 }
46
47 //------------------------------------------------------------------------------------------------
48 protected void InitWidgets()
49 {
50 m_Widgets.m_wContent.SetVisible(true);
51 m_Widgets.m_wContentOverlay.SetVisible(true);
52 m_Widgets.m_wPreloadContent.SetVisible(true);
53 m_Widgets.m_wBlackOverlay.SetVisible(true);
54 }
55
56 //------------------------------------------------------------------------------------------------
61 void Update(float timeSlice, float progress = 0, float minDurationRatio = 0)
62 {
63 m_fLoadingTime += timeSlice;
64
65 Fade(m_Widgets.m_wBlackOverlay, false, FADE_TIME_BLACK_OVERLAY, timeSlice);
66 }
67
68 //------------------------------------------------------------------------------------------------
73
74 //------------------------------------------------------------------------------------------------
76 static void ResetLoadingTime()
77 {
78 GameSessionStorage.s_Data["m_fLoadingTime"] = "0";
79 }
80
81 //------------------------------------------------------------------------------------------------
84 void SaveLoadingTime(float loadingTime)
85 {
86 GameSessionStorage.s_Data["m_fLoadingTime"] = loadingTime.ToString();
87 }
88
89 //------------------------------------------------------------------------------------------------
92 {
93 // Get count
94 string sLoadingTime = GameSessionStorage.s_Data["m_fLoadingTime"];
95 float fLoadingTime = 0;
96
97 // Setup number
98 if (sLoadingTime.IsEmpty())
99 {
100 GameSessionStorage.s_Data["m_fLoadingTime"] = "0";
101 }
102 else
103 {
104 fLoadingTime = sLoadingTime.ToFloat();
105 }
106
107 return fLoadingTime;
108 }
109
110 //------------------------------------------------------------------------------------------------
111 protected void Fade(Widget w, bool show, float length, float timeslice)
112 {
113 if (length <= 0)
114 {
115 w.SetOpacity(show);
116 return;
117 }
118
119 float opacityCurrent = w.GetOpacity();
120
121 if (opacityCurrent == show)
122 return;
123
124 float progressDelta = timeslice / length;
125
126 if (!show)
127 progressDelta = -progressDelta;
128
129 float progress = opacityCurrent + progressDelta;
130
131 progress = Math.Clamp(progress, 0, 1);
132
133 float opacity = Math.Lerp(0, 1, progress);
134 w.SetOpacity(opacity);
135 w.SetVisible(true);
136 }
137}
GameSessionStorage is used to store data for whole lifetime of game executable run....
Definition Math.c:13
void Fade(Widget w, bool show, float length, float timeslice)
ref SCR_ScenarioLoadingScreenWidgets m_Widgets
void Update(float timeSlice, float progress=0, float minDurationRatio=0)
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)