Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DownloadManager_PanelComponent.c
Go to the documentation of this file.
1 /*
2 Widget component of the download manager panel, which can be added into any menu where you want to have the download manager panel.
3 
4 It provides basic data of the current state of downloads.
5 */
6 
7 class SCR_DownloadManager_PanelComponent : ScriptedWidgetComponent
8 {
9  // The panel will be visible for this time, then it will fade out
10  protected const float FADE_OUT_WAIT_TIME = 5;
11 
13  protected Widget m_wRoot;
14  protected ref SCR_FadeInOutAnimator m_Animator;
15 
16  protected int m_iLastUpdateTimeMs;
17 
18  //------------------------------------------------------------------------------------------
19  override void HandlerAttached(Widget w)
20  {
21  m_wRoot = w;
22  m_Widgets.Init(w);
23 
24  m_iLastUpdateTimeMs = System.GetTickCount();
25 
26  if (SCR_DownloadManager.GetInstance())
27  SCR_DownloadManager.GetInstance().m_OnNewDownload.Insert(Callback_OnNewDownload);
28 
29  m_Widgets.m_OpenButtonComponent.m_OnActivated.Insert(OnOpenButton);
30 
31  m_Animator = new SCR_FadeInOutAnimator(m_wRoot, UIConstants.FADE_RATE_FAST, UIConstants.FADE_RATE_SLOW, FADE_OUT_WAIT_TIME, fadeOutSetVisibleFalse: true);
32  m_Animator.FadeOutInstantly();
33 
34  Update();
35  }
36 
37 
38  //------------------------------------------------------------------------------------------
39  override void HandlerDeattached(Widget w)
40  {
41  if (GetGame().GetCallqueue())
42  GetGame().GetCallqueue().Remove(Update);
43 
44  if (SCR_DownloadManager.GetInstance())
45  SCR_DownloadManager.GetInstance().m_OnNewDownload.Remove(Callback_OnNewDownload);
46  }
47 
48 
49  //------------------------------------------------------------------------------------------
50  void Update()
51  {
52  int tDeltaMs = System.GetTickCount() - m_iLastUpdateTimeMs;
53  float tDelta = 0.001 * tDeltaMs;
54 
55  SCR_DownloadManager mgr = SCR_DownloadManager.GetInstance();
56  if (mgr && !SCR_Global.IsEditMode())
57  {
58  UpdateAllWidgets(tDelta);
59 
60  GetGame().GetCallqueue().CallLater(Update, 10);
61  }
62 
63  m_iLastUpdateTimeMs = System.GetTickCount();
64  }
65 
66 
67  //------------------------------------------------------------------------------------------
68  protected void UpdateAllWidgets(float tDelta)
69  {
70  // Update whole overlay visibility
71  // It's visible when there are some downloads
72 
73  SCR_DownloadManager mgr = SCR_DownloadManager.GetInstance();
74  int nTotal, nCompleted;
75  mgr.GetDownloadQueueState(nCompleted, nTotal);
76 
77  m_Animator.ForceVisible(nTotal > 0);
78 
79  m_Animator.Update(tDelta);
80  }
81 
82 
83  //------------------------------------------------------------------------------------------
84  void Callback_OnNewDownload(SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
85  {
86  }
87 
88 
89  //------------------------------------------------------------------------------------------
90  void OnOpenButton()
91  {
93  }
94 
95 };
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
GetCallqueue
ScriptCallQueue GetCallqueue()
Definition: game.c:225
UIConstants
Definition: Constants.c:130
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_WorkshopItemActionDownload
Definition: SCR_WorkshopItemActionDownload.c:9
m_Widgets
ref SCR_VoNOverlay_ElementWidgets m_Widgets
Definition: SCR_VonDisplay.c:3
SCR_WorkshopItem
Definition: SCR_WorkshopItem.c:21
SCR_FadeInOutAnimator
Definition: SCR_FadeInOutAnimator.c:8
SCR_Global
Definition: Functions.c:6
SCR_DownloadManager_Dialog
void SCR_DownloadManager_Dialog()
Definition: SCR_DownloadManager_Dialog.c:491
SCR_DownloadManager_PanelWidgets
Definition: SCR_DownloadManager_PanelWidgets.c:4
SCR_DownloadManager
Definition: SCR_DownloadManager.c:20
SCR_DownloadManager_PanelComponent
Definition: SCR_DownloadManager_PanelComponent.c:7