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_SessionDurationUIComponent.c
Go to the documentation of this file.
1
4
class
SCR_SessionDurationUIComponent
:
MenuRootSubComponent
5
{
6
[
Attribute
(
"#AR-ValueUnit_Short_Plus"
, uiwidget:
UIWidgets
.LocaleEditBox)]
7
protected
LocalizedString
m_sSessionDurationFormatting
;
8
9
protected
TextWidget
m_wSessionDurationText
;
10
11
protected
SCR_BaseGameMode
m_GameMode
;
12
13
//------------------------------------------------------------------------------------------------
14
protected
void
SetSessionDurationTime
()
15
{
16
if
(
m_GameMode
)
17
m_wSessionDurationText
.SetTextFormat(
m_sSessionDurationFormatting
,
SCR_FormatHelper
.GetTimeFormatting(
m_GameMode
.GetElapsedTime(),
ETimeFormatParam
.DAYS));
18
else
//~ Fallback if no gamemode
19
{
20
ChimeraWorld
world =
GetGame
().GetWorld();
21
float
elapsedMs = world.GetServerTimestamp().DiffMilliseconds(null);
22
m_wSessionDurationText
.SetTextFormat(
m_sSessionDurationFormatting
,
SCR_FormatHelper
.GetTimeFormatting(elapsedMs * 0.001,
ETimeFormatParam
.DAYS));
23
}
24
}
25
26
//======================== ATTACH/DEATTACH HANDLER ========================\\
27
//------------------------------------------------------------------------------------------------
28
override
void
HandlerAttachedScripted
(
Widget
w)
29
{
30
m_GameMode
=
SCR_BaseGameMode
.Cast(
GetGame
().
GetGameMode
());
31
if
(!
m_GameMode
)
32
{
33
//~ Only show error if replication is running else using replication time is fine
34
if
(
Replication
.IsRunning())
35
Print
(
"'SCR_SessionDurationUIComponent' could not find 'SCR_BaseGameMode' so will show replication time instead which is not synced with players"
,
LogLevel
.WARNING);
36
}
37
38
m_wSessionDurationText
=
TextWidget
.Cast(w);
39
if
(!
m_wSessionDurationText
)
40
{
41
Print
(
"'SCR_SessionDurationUIComponent' needs to be attached to a 'TextWidget'!"
,
LogLevel
.ERROR);
42
return
;
43
}
44
45
SetSessionDurationTime
();
46
47
//~ Called every frame to update session duration
48
GetGame
().GetCallqueue().CallLater(
SetSessionDurationTime
, 1000,
true
);
49
}
50
51
//------------------------------------------------------------------------------------------------
52
//On Destroy
53
override
void
HandlerDeattached
(
Widget
w)
54
{
55
if
(!
m_wSessionDurationText
)
56
return
;
57
58
GetGame
().GetCallqueue().Remove(
SetSessionDurationTime
);
59
}
60
};
ETimeFormatParam
ETimeFormatParam
Definition
ETimeFormatParam.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition
SCR_BaseGameModeComponent.c:15
ChimeraWorld
Definition
ChimeraWorld.c:13
LocalizedString
Definition
LocalizedString.c:22
MenuRootSubComponent
Definition
MenuRootSubComponent.c:6
Replication
Main replication API.
Definition
Replication.c:14
SCR_BaseGameMode
Definition
SCR_BaseGameMode.c:139
SCR_FormatHelper
Definition
SCR_FormatHelper.c:2
SCR_SessionDurationUIComponent
Definition
SCR_SessionDurationUIComponent.c:5
SCR_SessionDurationUIComponent::SetSessionDurationTime
void SetSessionDurationTime()
Definition
SCR_SessionDurationUIComponent.c:14
SCR_SessionDurationUIComponent::m_GameMode
SCR_BaseGameMode m_GameMode
Definition
SCR_SessionDurationUIComponent.c:11
SCR_SessionDurationUIComponent::m_sSessionDurationFormatting
LocalizedString m_sSessionDurationFormatting
Definition
SCR_SessionDurationUIComponent.c:7
SCR_SessionDurationUIComponent::HandlerDeattached
override void HandlerDeattached(Widget w)
Definition
SCR_SessionDurationUIComponent.c:53
SCR_SessionDurationUIComponent::m_wSessionDurationText
TextWidget m_wSessionDurationText
Definition
SCR_SessionDurationUIComponent.c:9
SCR_SessionDurationUIComponent::HandlerAttachedScripted
override void HandlerAttachedScripted(Widget w)
Definition
SCR_SessionDurationUIComponent.c:28
TextWidget
Definition
TextWidget.c:16
UIWidgets
Definition
attributes.c:40
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_SessionDurationUIComponent.c
Generated by
1.17.0