Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DownloadManager_PanelComponent.c
Go to the documentation of this file.
1/*
2Widget component of the download manager panel, which can be added into any menu where you want to have the download manager panel.
3
4It provides basic data of the current state of downloads.
5*/
6
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;
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
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
46 }
47
48
49 //------------------------------------------------------------------------------------------
50 void Update()
51 {
52 int tDeltaMs = System.GetTickCount() - m_iLastUpdateTimeMs;
53 float tDelta = 0.001 * tDeltaMs;
54
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
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 //------------------------------------------------------------------------------------------
87
88
89 //------------------------------------------------------------------------------------------
91 {
92 SCR_DownloadManager_Dialog.Create();
93 }
94
95};
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...
void Callback_OnNewDownload(SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
ref SCR_DownloadManager_PanelWidgets m_Widgets
void GetDownloadQueueState(out int nCompleted, out int nTotal)
Might get delayed by a frame! Just use it for UI.
static SCR_DownloadManager GetInstance()
ref ScriptInvoker m_OnNewDownload
static bool IsEditMode()
Definition Functions.c:1566