Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DownloadManager_ProgressIndicatorComponent.c
Go to the documentation of this file.
1
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
34 if (mgr && !SCR_Global.IsEditMode())
35 {
37 }
38 }
39
40
41
42 //------------------------------------------------------------------------------------------
43 protected void UpdateAllWidgets()
44 {
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(SCR_WorkshopUiCommon.DOWNLOAD_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};
ArmaReforgerScripted GetGame()
Definition game.c:1398
ScriptCallQueue GetCallqueue()
Returns CallQueue of this AI. It gets updated from EvaluateBehavior, so that it's synchronous with ot...
Definition Math.c:13
void GetDownloadQueueState(out int nCompleted, out int nTotal)
Might get delayed by a frame! Just use it for UI.
static float GetDownloadActionsProgress(array< ref SCR_WorkshopItemActionDownload > actions)
Returns overall progress of all download actions, from 0 to 1.
static SCR_DownloadManager GetInstance()
array< ref SCR_WorkshopItemActionDownload > GetDownloadQueue()
static bool IsEditMode()
Definition Functions.c:1566