Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_RejoinDialog.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
3 {
4  // Widget Names
5  const string WIDGET_TXT_TIMER = "Timer";
6  const string WIDGET_LOADING = "Loading";
7 
8  // Widgets
9  protected TextWidget m_wTimer;
10  protected Widget m_wLoading;
11 
12  protected int m_iTimer;
13 
14  // Invokers
15  protected ref ScriptInvoker<int> Event_OnTimerChanged;
16 
17  //------------------------------------------------------------------------------------------------
18  protected void InvokeEventOnTimerChanged(int arg0)
19  {
20  if (Event_OnTimerChanged)
21  Event_OnTimerChanged.Invoke(this, arg0);
22  }
23 
24  //------------------------------------------------------------------------------------------------
25  ScriptInvoker GetEventOnTimerChanged()
26  {
27  if (!Event_OnTimerChanged)
28  Event_OnTimerChanged = new ScriptInvoker();
29 
30  return Event_OnTimerChanged;
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  // Dialog override functions
35  //------------------------------------------------------------------------------------------------
36 
37  //------------------------------------------------------------------------------------------------
38  override void HandlerAttached(Widget w)
39  {
40  super.HandlerAttached(w);
41 
42  m_wTimer = TextWidget.Cast(w.FindAnyWidget(WIDGET_TXT_TIMER));
43  m_wLoading = w.FindAnyWidget(WIDGET_LOADING);
44  }
45 
46  //------------------------------------------------------------------------------------------------
47  protected void DecreaseTime()
48  {
49  m_iTimer--;
50  if (m_iTimer > 0)
51  GetGame().GetCallqueue().CallLater(DecreaseTime, 1000);
52 
53  InvokeEventOnTimerChanged(m_iTimer);
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  // Public API
58  //------------------------------------------------------------------------------------------------
59 
60  //------------------------------------------------------------------------------------------------
61  void RunTimer(bool run)
62  {
63  // Stop
64  GetGame().GetCallqueue().Remove(DecreaseTime);
65 
66  // Run next cycle
67  if (run)
68  GetGame().GetCallqueue().CallLater(DecreaseTime, 1000);
69  }
70 
71  //------------------------------------------------------------------------------------------------
72  void SetTimer(int time)
73  {
74  m_iTimer = time;
75  InvokeEventOnTimerChanged(m_iTimer);
76  }
77 
78  //------------------------------------------------------------------------------------------------
79  int GetTimer()
80  {
81  return m_iTimer;
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  void ShowLoading(bool show)
86  {
87  if (m_wLoading)
88  m_wLoading.SetVisible(show);
89  }
90 
91  //------------------------------------------------------------------------------------------------
92  static SCR_RejoinDialog FindRejoinComponent(notnull Widget w)
93  {
94  return SCR_RejoinDialog.Cast(w.FindHandler(SCR_RejoinDialog));
95  }
96 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_RejoinDialog
Definition: SCR_RejoinDialog.c:2
SCR_ErrorDialog
Definition: SCR_ErrorDialog.c:2
m_wLoading
protected Widget m_wLoading
Definition: SCR_ServerBrowserEntryComponent.c:40