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_ServerRestartTimerUIComponent.c
Go to the documentation of this file.
1
class
SCR_ServerRestartTimerUIComponent
:
SCR_ScriptedWidgetComponent
2
{
3
[
Attribute
(
"#AR-Endscreen_RestartTimer_Format-UC"
,
desc
:
"Restart timer format %1 is the time"
)]
4
protected
LocalizedString
m_sRestartTimerFormat
;
5
6
[
Attribute
(
desc
:
"Widget name of restart timer text. Leave empty to take root as the TextWidget"
)]
7
protected
string
m_sRestartTimerName
;
8
9
[
Attribute
(
"1"
,
desc
:
"Countdown sfx will play if true"
)]
10
protected
bool
m_bEnableCountDownSfx
;
11
12
[
Attribute
(
"1"
,
desc
:
"Start timer on init, note that it will be hidden if the game has not ended or it is not set up correctly"
)]
13
protected
bool
m_bStartOnInit
;
14
15
//~ Timer values
16
protected
float
m_fAutoReloadDelay
= -1;
17
protected
WorldTimestamp
m_GameEndTimeStamp
= null;
18
protected
int
m_iPreviousRestartTime
;
19
20
//~ References
21
protected
ChimeraWorld
m_World
;
22
protected
TextWidget
m_wRestartTimer
;
23
25
protected
const
int
UPDATE_TIME
= 100;
26
27
//------------------------------------------------------------------------------------------------
29
bool
IsValid
()
30
{
31
if
(!
m_wRestartTimer
)
32
Init
();
33
34
return
m_fAutoReloadDelay
> 0;
35
}
36
37
//------------------------------------------------------------------------------------------------
38
protected
void
Init
()
39
{
40
if
(!
m_sRestartTimerName
.IsEmpty())
41
m_wRestartTimer
=
TextWidget
.Cast(
m_wRoot
.FindAnyWidget(
m_sRestartTimerName
));
42
else
43
m_wRestartTimer
=
TextWidget
.Cast(
m_wRoot
);
44
45
if
(!
m_wRestartTimer
)
46
return
;
47
48
SCR_BaseGameMode
gameMode =
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
49
if
(!gameMode)
50
return
;
51
52
m_World
=
GetGame
().GetWorld();
53
if
(!
m_World
)
54
return
;
55
56
m_fAutoReloadDelay
= gameMode.
GetAutoReloadDelay
();
57
m_GameEndTimeStamp
= gameMode.
GetGameEndTimeStamp
();
58
}
59
60
//------------------------------------------------------------------------------------------------
63
void
StartTimer
(
bool
checkIfValid =
true
)
64
{
65
if
(checkIfValid && !
IsValid
())
66
return
;
67
68
UpdateTimer
();
69
GetGame
().GetCallqueue().CallLater(
UpdateTimer
,
UPDATE_TIME
,
true
);
70
}
71
72
//------------------------------------------------------------------------------------------------
74
void
StopTimer
()
75
{
76
if
(
m_fAutoReloadDelay
<= 0)
77
return
;
78
79
GetGame
().GetCallqueue().Remove(
UpdateTimer
);
80
}
81
82
//------------------------------------------------------------------------------------------------
83
protected
void
UpdateTimer
()
84
{
85
if
(!
m_World
|| !
m_wRestartTimer
|| !
m_wRoot
.IsVisible())
86
return
;
87
88
//~ Call function which knows everythime the time changes a second with current restart time left
89
OnTimeUpdate
(
Math
.Clamp(
m_fAutoReloadDelay
- ((
m_World
.GetLocalTimestamp().DiffMilliseconds(
m_GameEndTimeStamp
)) * 0.001), 0,
float
.MAX));
90
}
91
92
//------------------------------------------------------------------------------------------------
93
protected
void
OnTimeUpdate
(
float
currentRestartTimer)
94
{
95
//~ Value did not change
96
if
((
int
)currentRestartTimer ==
m_iPreviousRestartTime
)
97
return
;
98
99
//~ Set current timer as previous timer
100
m_iPreviousRestartTime
= currentRestartTimer;
101
102
//~ Update the timer widget
103
string
timerText =
string
.Format(
"<color rgba='%1'>%2</color>"
,
UIColors
.FormatColor(GUIColors.ENABLED),
SCR_FormatHelper
.GetTimeFormatting(currentRestartTimer,
ETimeFormatParam
.DAYS |
ETimeFormatParam
.HOURS));
104
m_wRestartTimer
.SetTextFormat(
m_sRestartTimerFormat
, timerText);
105
106
//~ Countdown SFX
107
if
(
m_bEnableCountDownSfx
)
108
{
109
if
((
int
)currentRestartTimer > 0)
110
{
111
SCR_UISoundEntity
.SetSignalValueStr(
"countdownValue"
, currentRestartTimer);
112
SCR_UISoundEntity
.SetSignalValueStr(
"maxCountdownValue"
,
m_fAutoReloadDelay
);
113
SCR_UISoundEntity
.SoundEvent(
SCR_SoundEvent
.SOUND_RESPAWN_COUNTDOWN);
114
}
115
else
116
{
117
SCR_UISoundEntity
.SoundEvent(
SCR_SoundEvent
.SOUND_RESPAWN_COUNTDOWN_END);
118
}
119
}
120
}
121
122
//------------------------------------------------------------------------------------------------
123
override
void
HandlerAttached
(
Widget
w)
124
{
125
super.HandlerAttached(w);
126
127
if
(
SCR_Global
.
IsEditMode
())
128
return
;
129
130
Init
();
131
132
if
(!
IsValid
())
133
w.SetVisible(
false
);
134
else
if
(
m_bStartOnInit
)
135
StartTimer
(
false
);
136
}
137
138
//------------------------------------------------------------------------------------------------
139
override
void
HandlerDeattached
(
Widget
w)
140
{
141
super.HandlerDeattached(w);
142
143
if
(
m_fAutoReloadDelay
<= 0)
144
return
;
145
146
GetGame
().GetCallqueue().Remove(
UpdateTimer
);
147
}
148
}
ETimeFormatParam
ETimeFormatParam
Definition
ETimeFormatParam.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition
SCR_BaseGameModeComponent.c:15
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
ChimeraWorld
Definition
ChimeraWorld.c:13
LocalizedString
Definition
LocalizedString.c:22
Math
Definition
Math.c:13
SCR_BaseGameMode
Definition
SCR_BaseGameMode.c:139
SCR_BaseGameMode::GetGameEndTimeStamp
WorldTimestamp GetGameEndTimeStamp()
Definition
SCR_BaseGameMode.c:753
SCR_BaseGameMode::GetAutoReloadDelay
float GetAutoReloadDelay()
Definition
SCR_BaseGameMode.c:762
SCR_FormatHelper
Definition
SCR_FormatHelper.c:2
SCR_Global
Definition
Functions.c:7
SCR_Global::IsEditMode
static bool IsEditMode()
Definition
Functions.c:1566
SCR_ScriptedWidgetComponent
Definition
SCR_ScriptedWidgetComponent.c:8
SCR_ScriptedWidgetComponent::m_wRoot
Widget m_wRoot
Definition
SCR_ScriptedWidgetComponent.c:9
SCR_ServerRestartTimerUIComponent
Definition
SCR_ServerRestartTimerUIComponent.c:2
SCR_ServerRestartTimerUIComponent::m_iPreviousRestartTime
int m_iPreviousRestartTime
Definition
SCR_ServerRestartTimerUIComponent.c:18
SCR_ServerRestartTimerUIComponent::StopTimer
void StopTimer()
Stop the timer.
Definition
SCR_ServerRestartTimerUIComponent.c:74
SCR_ServerRestartTimerUIComponent::m_sRestartTimerName
string m_sRestartTimerName
Definition
SCR_ServerRestartTimerUIComponent.c:7
SCR_ServerRestartTimerUIComponent::m_wRestartTimer
TextWidget m_wRestartTimer
Definition
SCR_ServerRestartTimerUIComponent.c:22
SCR_ServerRestartTimerUIComponent::m_bEnableCountDownSfx
bool m_bEnableCountDownSfx
Definition
SCR_ServerRestartTimerUIComponent.c:10
SCR_ServerRestartTimerUIComponent::m_World
ChimeraWorld m_World
Definition
SCR_ServerRestartTimerUIComponent.c:21
SCR_ServerRestartTimerUIComponent::IsValid
bool IsValid()
return If the restart timer is set up correctly
Definition
SCR_ServerRestartTimerUIComponent.c:29
SCR_ServerRestartTimerUIComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_ServerRestartTimerUIComponent.c:139
SCR_ServerRestartTimerUIComponent::Init
void Init()
Definition
SCR_ServerRestartTimerUIComponent.c:38
SCR_ServerRestartTimerUIComponent::UpdateTimer
void UpdateTimer()
Definition
SCR_ServerRestartTimerUIComponent.c:83
SCR_ServerRestartTimerUIComponent::HandlerAttached
override void HandlerAttached(Widget w)
Definition
SCR_ServerRestartTimerUIComponent.c:123
SCR_ServerRestartTimerUIComponent::StartTimer
void StartTimer(bool checkIfValid=true)
Definition
SCR_ServerRestartTimerUIComponent.c:63
SCR_ServerRestartTimerUIComponent::UPDATE_TIME
const int UPDATE_TIME
Refresh time of timer (in milliseconds).
Definition
SCR_ServerRestartTimerUIComponent.c:25
SCR_ServerRestartTimerUIComponent::m_sRestartTimerFormat
LocalizedString m_sRestartTimerFormat
Definition
SCR_ServerRestartTimerUIComponent.c:4
SCR_ServerRestartTimerUIComponent::m_bStartOnInit
bool m_bStartOnInit
Definition
SCR_ServerRestartTimerUIComponent.c:13
SCR_ServerRestartTimerUIComponent::OnTimeUpdate
void OnTimeUpdate(float currentRestartTimer)
Definition
SCR_ServerRestartTimerUIComponent.c:93
SCR_ServerRestartTimerUIComponent::m_GameEndTimeStamp
WorldTimestamp m_GameEndTimeStamp
Definition
SCR_ServerRestartTimerUIComponent.c:17
SCR_ServerRestartTimerUIComponent::m_fAutoReloadDelay
float m_fAutoReloadDelay
Definition
SCR_ServerRestartTimerUIComponent.c:16
SCR_SoundEvent
Definition
SCR_SoundEvent.c:2
SCR_UISoundEntity
Definition
SCR_UISoundEntity.c:8
TextWidget
Definition
TextWidget.c:16
UIColors
Definition
Constants.c:17
Widget
Definition
Widget.c:13
WorldTimestamp
Definition
WorldTimestamp.c:26
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
GameOverScreen
SCR_ServerRestartTimerUIComponent.c
Generated by
1.17.0