Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DownloadManager_CircularIndicatorComponent.c
Go to the documentation of this file.
1 
6 {
7  protected const float FADE_OUT_WAIT_TIME = 2.5;
8 
10 
11  protected ref SCR_FadeInOutAnimator m_Animator;
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 
24  if (!SCR_Global.IsEditMode())
25  {
26  UpdateAllWidgets();
27 
28  if (!m_bIsDownloading)
29  m_Animator.FadeOutInstantly();
30  }
31 
32  m_Widgets.m_DownloadButtonComponent.m_OnClicked.Insert(OnButtonClick);
33 
34  // Owner menu events
35  SCR_MenuHelper.GetOnMenuFocusGained().Insert(OnMenuEnabled);
36  SCR_MenuHelper.GetOnMenuOpen().Insert(OnMenuEnabled);
37  SCR_MenuHelper.GetOnMenuFocusLost().Insert(OnMenuDisabled);
38  SCR_MenuHelper.GetOnMenuClose().Insert(OnMenuDisabled);
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
49  SCR_MenuHelper.GetOnMenuFocusGained().Remove(OnMenuEnabled);
50  SCR_MenuHelper.GetOnMenuOpen().Remove(OnMenuEnabled);
51  SCR_MenuHelper.GetOnMenuFocusLost().Remove(OnMenuDisabled);
52  SCR_MenuHelper.GetOnMenuClose().Remove(OnMenuDisabled);
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 
63  if (!SCR_Global.IsEditMode())
64  UpdateAllWidgets();
65 
66  m_Animator.Update(tDelta);
67  }
68 
69  //------------------------------------------------------------------------------------------------
70  protected void UpdateAllWidgets()
71  {
72  SCR_DownloadManager mgr = SCR_DownloadManager.GetInstance();
73  if (!mgr)
74  return;
75 
76  string downloadStateText;
77  int nCompleted, nTotal;
78  mgr.GetDownloadQueueState(nCompleted, nTotal);
79 
80  m_bIsDownloading = nTotal > 0;
81 
82  // Progress bar, progress text
83  m_Widgets.m_DownloadDoneImage.SetVisible(nTotal == 0);
84  m_Widgets.m_QueueSizeText.SetVisible(m_bIsDownloading);
85  if (m_bIsDownloading)
86  {
87  // Get total progress of all downloads
88  array<ref SCR_WorkshopItemActionDownload> downloadQueue = mgr.GetDownloadQueue();
89  float progress = SCR_DownloadManager.GetDownloadActionsProgress(downloadQueue);
90 
91  // Progress bar
92  m_Widgets.m_ProgressCircle.SetMaskProgress(progress);
93 
94  // Queue size text
95  string queueSizeText = string.Format("%1", nTotal - nCompleted);
96  m_Widgets.m_QueueSizeText.SetText(queueSizeText);
97  }
98  else
99  {
100  m_Widgets.m_QueueSizeText.SetText(string.Empty);
101  m_Widgets.m_ProgressCircle.SetMaskProgress(1.0);
102  }
103 
104  m_Animator.ForceVisible(m_bIsDownloading);
105 
106  // Disable button when invisible
107  m_Widgets.m_DownloadButtonComponent.SetEnabled(m_bIsDownloading);
108  }
109 
110  //------------------------------------------------------------------------------------------------
111  protected void OnButtonClick()
112  {
114  }
115 
116  //------------------------------------------------------------------------------------------------
117  protected void OnMenuEnabled(ChimeraMenuBase menu)
118  {
119  if (menu == ChimeraMenuBase.GetOwnerMenu(GetRootWidget()))
120  {
121  UpdateAllWidgets();
122  if (!m_bIsDownloading)
123  m_Animator.FadeOutInstantly();
124 
125  menu.m_OnUpdate.Remove(OnFrame);
126  menu.m_OnUpdate.Insert(OnFrame);
127  }
128  }
129 
130  //------------------------------------------------------------------------------------------------
131  protected void OnMenuDisabled(ChimeraMenuBase menu)
132  {
133  if (menu == ChimeraMenuBase.GetOwnerMenu(GetRootWidget()))
134  {
135  menu.m_OnUpdate.Remove(OnFrame);
136  }
137  }
138 }
ChimeraMenuBase
Constant variables used in various menus.
Definition: ChimeraMenuBase.c:70
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
UIConstants
Definition: Constants.c:130
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_DownloadManager_CircleProgressIndicatorWidgets
Definition: SCR_DownloadManager_CircleProgressIndicatorWidgets.c:1
m_Widgets
ref SCR_VoNOverlay_ElementWidgets m_Widgets
Definition: SCR_VonDisplay.c:3
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
SCR_FadeInOutAnimator
Definition: SCR_FadeInOutAnimator.c:8
SCR_MenuHelper
Definition: SCR_MenuHelper.c:15
SCR_Global
Definition: Functions.c:6
SCR_DownloadManager_Dialog
void SCR_DownloadManager_Dialog()
Definition: SCR_DownloadManager_Dialog.c:491
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
SCR_DownloadManager
Definition: SCR_DownloadManager.c:20
SCR_DownloadManager_CircularIndicatorComponent
Definition: SCR_DownloadManager_CircularIndicatorComponent.c:5