20 protected const string STATE_ALL_PAUSE =
"#AR-DownloadManager_State_AllDownloadsPaused";
34 static SCR_DownloadManager_Dialog Create()
45 super.OnMenuOpen(preset);
52 m_Widgets.m_DownloadSummaryText.SetVisible(
false);
53 m_Widgets.m_ProgressText.SetVisible(
false);
89 int nCompleted, nTotal;
93 bool pauseCancelEnabled;
96 if (!dlAction.IsFailed() && !dlAction.IsCompleted() && !dlAction.IsCanceled())
97 pauseCancelEnabled =
true;
102 string pauseAllButtonLabel =
"#AR-DownloadManager_ButtonPauseAll";
104 pauseAllButtonLabel =
"#AR-DownloadManager_ButtonResumeAll";
107 string pauseButtonLabel =
"#AR-DownloadManager_ButtonPause";
110 if (dlAction.IsPaused() || dlAction.IsInactive())
111 pauseButtonLabel =
"#AR-DownloadManager_ButtonResume";
131 string downloadStateText;
132 int nCompleted, nTotal;
144 m_Widgets.m_StateText.SetText(downloadStateText);
148 m_Widgets.m_ProgressText.SetVisible(nTotal > 0);
154 array<ref SCR_WorkshopItemActionDownload> downloadQueue = mgr.
GetDownloadQueue();
158 m_Widgets.m_ProgressBarComponent.SetValue(progress);
165 m_Widgets.m_DownloadSummaryText.SetVisible(downloadTotalSize > 0);
167 if (downloadTotalSize > 0)
171 string downloadDoneSizeStr =
SCR_ByteFormat.ContentDownloadFormat(downloadDoneSize);
172 string downloadTotalSizeStr =
SCR_ByteFormat.ContentDownloadFormat(downloadTotalSize);
182 m_Widgets.m_ProgressBarComponent.SetValue(0);
189 m_Widgets.m_DownloadSpeed.SetVisible(display);
195 m_Widgets.m_DownloadSpeed.SetText(
"0 KB/s");
199 string unit =
" KB/s";
203 speed =
GetGame().GetRestApi().GetDownloadTrafficKBPerS();
213 m_Widgets.m_DownloadSpeed.SetText(
Math.Round(speed).ToString() + unit);
223 array<ref SCR_DownloadManager_Entry> downloads = {};
228 for (
int i = 0, count = downloads.Count(); i < count; i++)
239 if (failedDownloads.Find(action) != -1)
310 array<ref SCR_DownloadManager_Entry> downloads = {};
358 if (action.IsPaused())
360 else if (action.IsInactive())
ArmaReforgerScripted GetGame()
EDownloadManagerActionState
Enum describing current state of downloading action.
const string DOWNLOAD_SUMMARY_FORMAT
const string STATE_ALL_PAUSE
const ResourceName DOWNLOAD_LINE_LAYOUT
ref SCR_DownloadManagerListComponent m_HistoryDownloads
void UpdateDownloadingSpeedWidget(bool display, bool showFallback)
enum SCR_EDownloadManagerTabs STATE_DOWNLOADING
void UpdateProgressWidgets()
void OnDownloadComplete(SCR_WorkshopItemActionDownload action)
void OnDownloadCanceled(SCR_WorkshopItemActionDownload action)
void OnDownloadFailed(SCR_WorkshopItemActionDownload action, int reason)
void OnNewActionActivate(SCR_WorkshopItemActionDownload action)
const string STATE_NO_ACTIVE_DOWNLOADS
ref SCR_DownloadManagerListComponent m_ActiveDownloads
const string DOWNLOAD_SUMMARY_COLORED_FORMAT
void OnNewDownload(SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
void OnAutoenableButton()
Configuration for a dialog.
void InitForDownloadAction(SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
static EDownloadManagerActionState DownloadActionState(SCR_WorkshopItemActionDownload action)
SCR_WorkshopItemActionDownload GetDownloadAction()
void GetDownloadQueueState(out int nCompleted, out int nTotal)
Might get delayed by a frame! Just use it for UI.
float GetDownloadedSize()
array< ref SCR_WorkshopItemActionDownload > GetFailedDownloads()
ref ScriptInvokerBase< ScriptInvoker_DownloadManagerActionError > m_OnDownloadFailed
void ClearFailedDownloads()
void SetDownloadsPaused(bool pause, int count=-1)
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()
bool HasRunningDownloads()
ref ScriptInvoker m_OnNewDownload
ref ScriptInvokerBase< ScriptInvoker_DownloadManagerAction > m_OnDownloadComplete
bool GetDownloadsPaused()
float GetDownloadQueueSize()
ref ScriptInvokerBase< ScriptInvoker_DownloadManagerAction > m_OnDownloadCanceled
void GetAllDownloads(array< ref SCR_DownloadManager_Entry > downloads)
Returns an array of all downloads regardless of their state.
override void OnMenuClose()
override void OnMenuUpdate(float tDelta)
SCR_WorkshopItemActionDownload GetDownloadAction()
Returns current download action.
static void Save(SCR_WorkshopSettings settings)
static SCR_WorkshopSettings Get()
static int GetDownloadProgressPercentage(float progress)
@ ACTIVE
Tells that this entity has to be actively updated by engine.
proto external BaseUserAction GetSelectedAction()