20 protected const string STATE_ALL_PAUSE =
"#AR-DownloadManager_State_AllDownloadsPaused";
24 protected const ResourceName
DOWNLOAD_LINE_LAYOUT =
"{FB196DBC0ABA6AE4}UI/layouts/Menus/ContentBrowser/DownloadManager/DownloadManagerEntry.layout";
43 protected static bool m_bOpened =
false;
46 static bool IsOpened()
63 super.OnMenuOpen(preset);
67 GetGame().GetInputManager().AddActionListener(
"MenuDownloadManager", EActionTrigger.DOWN,
OnBackButton);
70 m_Widgets.m_DownloadSummaryText.SetVisible(
false);
71 m_Widgets.m_ProgressText.SetVisible(
false);
98 GetGame().GetInputManager().RemoveActionListener(
"MenuDownloadManager", EActionTrigger.DOWN,
OnBackButton);
112 int nCompleted, nTotal;
113 mgr.GetDownloadQueueState(nCompleted, nTotal);
116 bool pauseCancelEnabled;
119 if (!dlAction.IsFailed() && !dlAction.IsCompleted() && !dlAction.IsCanceled())
120 pauseCancelEnabled =
true;
124 bool paused = mgr.GetDownloadsPaused();
125 string pauseAllButtonLabel =
"#AR-DownloadManager_ButtonPauseAll";
127 pauseAllButtonLabel =
"#AR-DownloadManager_ButtonResumeAll";
130 string pauseButtonLabel =
"#AR-DownloadManager_ButtonPause";
133 if (dlAction.IsPaused() || dlAction.IsInactive())
134 pauseButtonLabel =
"#AR-DownloadManager_ButtonResume";
154 string downloadStateText;
155 int nCompleted, nTotal;
156 mgr.GetDownloadQueueState(nCompleted, nTotal);
158 if (nTotal > 0 && !mgr.GetDownloadsPaused())
159 downloadStateText =
string.Format(
"%1 %2 / %3", WidgetManager.Translate(
STATE_DOWNLOADING), nCompleted, nTotal);
160 else if (nTotal > 0 && mgr.GetDownloadsPaused())
161 downloadStateText =
string.Format(
"%1 %2 / %3", WidgetManager.Translate(
STATE_ALL_PAUSE), nCompleted, nTotal);
162 else if (mgr.GetDownloadsPaused())
167 m_Widgets.m_StateText.SetText(downloadStateText);
170 m_Widgets.m_DownloadSummaryText.SetVisible(mgr.HasRunningDownloads() || nCompleted > 0);
171 m_Widgets.m_ProgressText.SetVisible(nTotal > 0);
177 array<ref SCR_WorkshopItemActionDownload> downloadQueue = mgr.GetDownloadQueue();
181 m_Widgets.m_ProgressBarComponent.SetValue(progress);
184 string progressText = WidgetManager.Translate(
"#AR-ValueUnit_Percentage", Math.Floor(progress * 100.0));
185 m_Widgets.m_ProgressText.SetText(progressText);
189 m_Widgets.m_DownloadSummaryText.SetVisible(downloadTotalSize > 0);
191 if (downloadTotalSize > 0)
195 string downloadDoneSizeStr =
SCR_ByteFormat.ContentDownloadFormat(downloadDoneSize);
196 string downloadTotalSizeStr =
SCR_ByteFormat.ContentDownloadFormat(downloadTotalSize);
206 m_Widgets.m_ProgressBarComponent.SetValue(0);
213 m_Widgets.m_DownloadSpeed.SetVisible(display);
219 m_Widgets.m_DownloadSpeed.SetText(
"0 KB/s");
223 string unit =
" KB/s";
227 speed =
GetGame().GetRestApi().GetDownloadTrafficKBPerS();
237 m_Widgets.m_DownloadSpeed.SetText(Math.Round(speed).ToString() + unit);
247 array<ref SCR_DownloadManager_Entry> downloads = {};
250 array<ref SCR_WorkshopItemActionDownload> failedDownloads =
SCR_DownloadManager.GetInstance().GetFailedDownloads();
252 for (
int i = 0, count = downloads.Count(); i < count; i++)
263 if (failedDownloads.Find(action) != -1)
274 Widget w =
GetGame().GetWorkspace().GetFocusedWidget();
283 return entry.GetDownloadAction();
303 sameEntry.InitForDownloadAction(item, item.GetDownloadAction());
334 array<ref SCR_DownloadManager_Entry> downloads = {};
368 case 1: message =
"#AR-Workshop_Dialog_Error_ConnectionTimeout2";
break;
371 if (!message.IsEmpty())
451 bool paused = mgr.GetDownloadsPaused();
452 mgr.SetDownloadsPaused(!paused);
463 if (action.IsPaused())
465 else if (action.IsInactive())
523 m_PauseResumeButton = this.
FindButton(
"download_pause_resume");
524 m_CancelButton = this.
FindButton(
"download_cancel");
526 m_PauseResumeButton.m_OnActivated.Insert(OnPauseResumeButton);
527 m_CancelButton.m_OnActivated.Insert(OnCancelButton);
531 override void OnMenuUpdate(
float tDelta)
536 int nCompleted, nTotal;
537 mgr.GetDownloadQueueState(nCompleted, nTotal);
540 bool paused = mgr.GetDownloadsPaused();
541 string pauseButtonLabel =
"#AR-DownloadManager_ButtonPause";
543 pauseButtonLabel =
"#AR-DownloadManager_ButtonResume";
544 m_PauseResumeButton.SetLabel(pauseButtonLabel);
547 m_CancelButton.SetEnabled(nTotal > 0);
551 protected void OnPauseResumeButton()
558 bool paused = mgr.GetDownloadsPaused();
559 mgr.SetDownloadsPaused(!paused);
563 protected void OnCancelButton()
572 array<ref SCR_WorkshopItemActionDownload> actions = mgr.GetDownloadQueue();