Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SessionDurationUIComponent.c
Go to the documentation of this file.
1
5{
6 [Attribute("#AR-ValueUnit_Short_Plus", uiwidget: UIWidgets.LocaleEditBox)]
8
10
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 //------------------------------------------------------------------------------------------------
29 {
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
40 {
41 Print("'SCR_SessionDurationUIComponent' needs to be attached to a 'TextWidget'!", LogLevel.ERROR);
42 return;
43 }
44
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 {
56 return;
57
58 GetGame().GetCallqueue().Remove(SetSessionDurationTime);
59 }
60};
ETimeFormatParam
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
Main replication API.
Definition Replication.c:14
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute