Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DownloadManager_CircularIndicatorComponent.c
Go to the documentation of this file.
1
4
6{
7 protected const float FADE_OUT_WAIT_TIME = 2.5;
8
10
12
13 protected bool m_bIsDownloading;
14
15 //------------------------------------------------------------------------------------------------
16 override void HandlerAttached(Widget w)
17 {
18 super.HandlerAttached(w);
19
20 m_Widgets.Init(w);
21
22 m_Animator = new SCR_FadeInOutAnimator(m_Widgets.m_DownloadButton, UIConstants.FADE_RATE_FAST, UIConstants.FADE_RATE_SLOW, FADE_OUT_WAIT_TIME, fadeOutSetVisibleFalse: true);
23
25 {
27
29 m_Animator.FadeOutInstantly();
30 }
31
32 m_Widgets.m_DownloadButtonComponent.m_OnClicked.Insert(OnButtonClick);
33
34 // Owner menu events
39 }
40
41 //------------------------------------------------------------------------------------------------
42 override void HandlerDeattached(Widget w)
43 {
44 super.HandlerDeattached(w);
45
46 GetGame().GetCallqueue().Remove(OnFrame);
47
48 // Owner menu events
53 }
54
55 //------------------------------------------------------------------------------------------------
56 protected void OnFrame(float tDelta)
57 {
58 if (!m_wRoot)
59 return;
60
61 //float tDelta = ftime / 1000.0; // delta time for callqueue
62
65
66 m_Animator.Update(tDelta);
67 }
68
69 //------------------------------------------------------------------------------------------------
70 protected void UpdateAllWidgets()
71 {
73 if (!mgr)
74 return;
75
76 int nCompleted, nTotal;
77 mgr.GetDownloadQueueState(nCompleted, nTotal);
78
79 m_bIsDownloading = nTotal > 0;
80
81 // Progress bar, progress text
82 m_Widgets.m_DownloadDoneImage.SetVisible(nTotal == 0);
83 m_Widgets.m_QueueSizeText.SetVisible(m_bIsDownloading);
85 {
86 // Get total progress of all downloads
87 array<ref SCR_WorkshopItemActionDownload> downloadQueue = mgr.GetDownloadQueue();
88 float progress = SCR_DownloadManager.GetDownloadActionsProgress(downloadQueue);
89
90 // Progress bar
91 m_Widgets.m_ProgressCircle.SetMaskProgress(progress);
92
93 // Queue size text
94 string queueSizeText = string.Format("%1", nTotal - nCompleted);
95 m_Widgets.m_QueueSizeText.SetText(queueSizeText);
96 }
97 else
98 {
99 m_Widgets.m_QueueSizeText.SetText(string.Empty);
100 m_Widgets.m_ProgressCircle.SetMaskProgress(1.0);
101 }
102
103 m_Animator.ForceVisible(m_bIsDownloading);
104
105 // Disable button when invisible
106 m_Widgets.m_DownloadButtonComponent.SetEnabled(m_bIsDownloading);
107 }
108
109 //------------------------------------------------------------------------------------------------
110 protected void OnButtonClick()
111 {
112 SCR_DownloadManager_Dialog.Create();
113 }
114
115 //------------------------------------------------------------------------------------------------
116 protected void OnMenuEnabled(ChimeraMenuBase menu)
117 {
119 {
121 if (!m_bIsDownloading)
122 m_Animator.FadeOutInstantly();
123
124 menu.m_OnUpdate.Remove(OnFrame);
125 menu.m_OnUpdate.Insert(OnFrame);
126 }
127 }
128
129 //------------------------------------------------------------------------------------------------
130 protected void OnMenuDisabled(ChimeraMenuBase menu)
131 {
133 {
134 menu.m_OnUpdate.Remove(OnFrame);
135 }
136 }
137}
ArmaReforgerScripted GetGame()
Definition game.c:1398
Constant variables used in various menus.
static ChimeraMenuBase GetOwnerMenu(Widget w)
Returns parent menu of a widget.
ref ScriptInvoker m_OnUpdate
ref SCR_DownloadManager_CircleProgressIndicatorWidgets m_Widgets
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
static ScriptInvokerMenu GetOnMenuFocusLost()
static ScriptInvokerMenu GetOnMenuClose()
static ScriptInvokerMenu GetOnMenuOpen()
static ScriptInvokerMenu GetOnMenuFocusGained()