Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SystemClockUIComponent.c
Go to the documentation of this file.
1 // Script File
2 
3 
7 class SCR_SystemClockUIComponent : ScriptedWidgetComponent
8 {
9  //References
10  protected TextWidget m_ClockTimeText;
11 
12 
13  //======================== CLOCK UPDATE ========================\\
14  //Sets clock as System clock, Called every seconds
15  protected void OnSystemClockUpdate()
16  {
17  //Get time
18  int hour, minute, sec;
19  System.GetHourMinuteSecond(hour, minute, sec);
20 
21  //Set text
22  m_ClockTimeText.SetText(SCR_FormatHelper.GetTimeFormattingHoursMinutes(hour, minute));
23  }
24 
25 
26  //======================== ATTACH/DEATTACH HANDLER ========================\\
27  //On Init
28  override void HandlerAttached(Widget w)
29  {
30  m_ClockTimeText = TextWidget.Cast(w);
31 
32  //Add update each second for system clock
33  if (m_ClockTimeText)
34  {
35  OnSystemClockUpdate();
36  GetGame().GetCallqueue().CallLater(OnSystemClockUpdate, 1000, true);
37  }
38  else
39  {
40  Print("System Clock not attached to Text Widget!", LogLevel.ERROR);
41  }
42  }
43 
44 
45  //On Destroy
46  override void HandlerDeattached(Widget w)
47  {
48  //Remove every second update System Clock
49  if (m_ClockTimeText)
50  {
51  GetGame().GetCallqueue().Remove(OnSystemClockUpdate);
52  }
53  }
54 
55 
56 };
SCR_FormatHelper
Definition: SCR_FormatHelper.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SystemClockUIComponent
Definition: SCR_SystemClockUIComponent.c:7