Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DownloadManager_ProgressIndicatorComponent.c
Go to the documentation of this file.
1 
4 class SCR_DownloadManager_ProgressIndicatorComponent : ScriptedWidgetComponent
5 {
7 
8  //------------------------------------------------------------------------------------------
9  override void HandlerAttached(Widget w)
10  {
11  m_Widgets.Init(w);
12 
13  Update();
14 
15  GetGame().GetCallqueue().CallLater(Update, 50, true);
16  }
17 
18 
19 
20  //------------------------------------------------------------------------------------------
21  override void HandlerDeattached(Widget w)
22  {
23  if (GetGame().GetCallqueue())
24  GetGame().GetCallqueue().Remove(Update);
25  }
26 
27 
28 
29  //------------------------------------------------------------------------------------------
30  void Update()
31  {
32  // Download state text
33  SCR_DownloadManager mgr = SCR_DownloadManager.GetInstance();
34  if (mgr && !SCR_Global.IsEditMode())
35  {
36  UpdateAllWidgets();
37  }
38  }
39 
40 
41 
42  //------------------------------------------------------------------------------------------
43  protected void UpdateAllWidgets()
44  {
45  SCR_DownloadManager mgr = SCR_DownloadManager.GetInstance();
46  string downloadStateText;
47  int nCompleted, nTotal;
48  mgr.GetDownloadQueueState(nCompleted, nTotal);
49 
50  if (nTotal > 0 && !mgr.GetDownloadsPaused())
51  downloadStateText = string.Format("%1 %2 / %3", WidgetManager.Translate("#AR-DownloadManager_State_Downloading"), nCompleted, nTotal);
52  else if (nTotal > 0 && mgr.GetDownloadsPaused())
53  downloadStateText = string.Format("%1 %2 / %3", WidgetManager.Translate("#AR-DownloadManager_State_AllDownloadsPaused"), nCompleted, nTotal);
54  else if (mgr.GetDownloadsPaused())
55  downloadStateText = "#AR-DownloadManager_State_AllDownloadsPaused";
56  else
57  downloadStateText = "#AR-DownloadManager_State_NoActiveDownloads";
58 
59  m_Widgets.m_StateText.SetText(downloadStateText);
60 
61  // Progress bar, progress text
62  if (nTotal > 0)
63  {
64  // Get total progress of all downloads
65  array<ref SCR_WorkshopItemActionDownload> downloadQueue = mgr.GetDownloadQueue();
66  float progress = SCR_DownloadManager.GetDownloadActionsProgress(downloadQueue);
67 
68  // Progress bar
69  m_Widgets.m_ProgressBar.SetCurrent(progress);
70 
71  // Progress percent text
72  string progressText = string.Format("%1 %%", Math.Floor(progress * 100.0));
73  m_Widgets.m_ProgressText.SetText(progressText);
74  }
75  else
76  {
77  m_Widgets.m_ProgressBar.SetCurrent(0);
78  }
79 
80  //m_Widgets.m_ProgressBar.SetVisible(nTotal > 0);
81  m_Widgets.m_ProgressOverlay.SetVisible(nTotal > 0);
82  }
83 
84 
85 
86 };
GetCallqueue
ScriptCallQueue GetCallqueue()
Definition: game.c:225
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_Widgets
ref SCR_VoNOverlay_ElementWidgets m_Widgets
Definition: SCR_VonDisplay.c:3
SCR_DownloadManager_ProgressIndicatorComponent
Definition: SCR_DownloadManager_ProgressIndicatorComponent.c:4
SCR_Global
Definition: Functions.c:6
SCR_DownloadManager_ProgressIndicatorWidgets
Definition: SCR_DownloadManager_ProgressIndicatorWidgets.c:4
SCR_DownloadManager
Definition: SCR_DownloadManager.c:20