9[
EntityEditorProps(
category:
"", description:
"Entity of the download manager. Most likely only needed in the main menu world.")]
29 protected ref array<ref SCR_DownloadManager_Entry>
m_aDownloadActions =
new array<ref SCR_DownloadManager_Entry>();
34 protected ref array<ref SCR_WorkshopItemActionDownload>
m_aDownloadQueue =
new array<ref SCR_WorkshopItemActionDownload>;
51 ref ScriptInvokerBase<ScriptInvoker_DownloadManagerAction>
m_OnDownloadComplete =
new ScriptInvokerBase<ScriptInvoker_DownloadManagerAction>();
52 ref ScriptInvokerBase<ScriptInvoker_DownloadManagerActionError>
m_OnDownloadFailed =
new ScriptInvokerBase<ScriptInvoker_DownloadManagerActionError>();
54 ref ScriptInvokerBase<ScriptInvoker_DownloadManagerAction>
m_OnDownloadCanceled =
new ScriptInvokerBase<ScriptInvoker_DownloadManagerAction>();
70 if (!m_OnDownloadQueueCompleted)
73 return m_OnDownloadQueueCompleted;
103 downloads.Insert(dl);
127 if (download.m_Wrapper.GetId() !=
id)
130 if (runningOnly && download.IsActive() && !download.IsCompleted() && !download.IsFailed() && !download.IsCanceled())
140 array<ref SCR_WorkshopItemActionDownload> downloads = {};
147 downloads.Insert(action);
159 if (entry.m_Item == item)
160 return entry.m_Action;
195 if (action.IsActive())
202 if (action.IsPaused())
204 else if (action.IsInactive())
231 array<ref SCR_WorkshopItemActionDownload> unrelatedDownloads = {};
236 unrelatedDownloads.Insert(action);
239 return unrelatedDownloads;
256 sameId = requiredItem.GetId() == item.
GetId();
257 sameVersion = requiredItem.GetDependency().GetVersion() == action.
GetTargetRevision().GetVersion();
258 required = sameId && sameVersion;
280 bool downloading, paused;
305 arrayOut.Insert(addon);
315 array<ref SCR_WorkshopItemAction> actions = {};
319 auto actionMain = mainItem.DownloadLatestVersion();
322 actions.Insert(actionMain);
324 actionMain.Activate();
330 if (dependencies.Count() > 0)
332 auto actionDependencies = mainItem.DownloadDependenciesLatest(dependencies);
333 if (actionDependencies)
336 actionDependencies.Activate();
338 actions.Insert(actionDependencies);
351 array<ref SCR_WorkshopItemActionDownload>
DownloadItems(array<ref SCR_WorkshopItem> items)
353 array<ref SCR_WorkshopItemActionDownload> actions = {};
355 for (
int i = 0, count = items.Count(); i < count; i++)
357 Revision target = items[i].GetItemTargetRevision();
360 target = items[i].GetDependency().GetRevision();
369 actions.Insert(action);
381 for (
int i = 0, count = dependencies.Count(); i < count; i++)
398 float s = addon.GetTargetRevisionPatchSize();
404 float s = extraItem.GetTargetRevisionPatchSize();
414 array<ref SCR_WorkshopItem> downloading = {};
427 float totalSizeBytes = 0;
428 float totalBytesDownloaded = 0;
432 float dlsize = dl.GetSizeBytes();
433 totalSizeBytes += dlsize;
434 totalBytesDownloaded += dl.GetProgress() * dlsize;
437 if (totalSizeBytes == 0)
440 float progress = totalBytesDownloaded / totalSizeBytes;
454 array<ref SCR_WorkshopItemAction> allActions;
455 if (actionDependencies)
456 allActions = actionDependencies.GetActions();
458 allActions =
new array<ref SCR_WorkshopItemAction>;
461 allActions.Insert(actionThisItem);
464 auto allDownloadActions =
new array<ref SCR_WorkshopItemActionDownload>;
465 foreach (
auto a : allActions)
469 allDownloadActions.Insert(downloadAction);
472 float progress = SCR_DownloadManager.GetDownloadActionsProgress(allDownloadActions);
480 array<ref SCR_WorkshopItemActionDownload> actions = {};
571 if (action.IsCanceled() || action.IsFailed())
573 else if (action.IsPaused())
592 if (m_OnDownloadQueueCompleted)
593 m_OnDownloadQueueCompleted.Invoke();
620 Print(
"SCR_DownloadManager_Entity: SCR_AddonManager was not found. It must be placed in the world for download manager to work.",
LogLevel.ERROR);
633 #ifdef WORKSHOP_DEBUG
636 _print(
string.Format(
"Callback_OnNewDownloadStarted: %1, %2", item.
GetName(), action.
GetTargetRevision().GetVersion()));
638 _print(
string.Format(
"Callback_OnNewDownloadStarted: %1", item.
GetName()));
678 if (settings.m_bAutoEnableDownloadedAddons && !action.
GetUpdate())
700 SCR_FailedModsDownloadDialog.ShowFailedModsDialog(action,
reason);
798 private void ~SCR_DownloadManager()
812 Print(
string.Format(
"[SCR_DownloadManager] %1 %2",
this, str), logLevel);
819class SCR_DownloadManager_Entry
ArmaReforgerScripted GetGame()
@ FAILED
Job failed during its processing and can be retried.
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
EDownloadManagerActionState
Enum describing current state of downloading action.
func ScriptInvoker_DownloadManagerAction
func ScriptInvoker_DownloadManagerActionError
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
void IEntity(IEntitySource src, IEntity parent)
protected script Constructor
proto external EntityEvent SetEventMask(EntityEvent e)
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
ref ScriptInvoker m_OnNewDownload
static SCR_AddonManager GetInstance()
Helper class to store current downloads and their attributes.
static void SelectAddonsForLatestDownload(array< ref SCR_WorkshopItem > arrayIn, array< ref SCR_WorkshopItem > arrayOut)
ScriptInvokerBase< ScriptInvoker_ActionDownloadFullStorage > GetOnFullStorageError()
void Callback_OnDownloadCompleted(SCR_WorkshopItemActionDownload action)
Called from aciton when a download is completed.
SCR_WorkshopItemActionDownload DownloadingActionAddonById(string id, bool runningOnly=true)
Return true if there is addon with given id in download queue.
bool IsDownloadingActionRequired(SCR_WorkshopItemActionDownload action, array< ref SCR_WorkshopItem > requiredItems)
void GetDownloadQueueState(out int nCompleted, out int nTotal)
Might get delayed by a frame! Just use it for UI.
void Callback_OnNewDownload(SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
static SCR_DownloadManager s_Instance
void ForceFailRunningDownloads()
End all running downloads as fail.
static float GetTotalSizeBytes(array< ref SCR_WorkshopItem > arrayIn, SCR_WorkshopItem extraItem=null)
const int ERROR_FULL_STORAGE
float GetDownloadedSize()
const int DOWNLOAD_STUCK_DELAY
array< ref SCR_WorkshopItemActionDownload > GetFailedDownloads()
void Callback_OnFailed(SCR_WorkshopItemActionDownload action, int reason)
Call on downloading fail to show download manager dialog with problematic.
ref array< ref SCR_WorkshopItemActionDownload > m_aDownloadQueue
ref ScriptInvokerBase< ScriptInvoker_DownloadManagerActionError > m_OnDownloadFailed
float DownloadQueueSize()
static bool IsLatestDownloadRequired(SCR_WorkshopItem item)
void ClearFailedDownloads()
float m_fDownloadQueueSize
void ClearUnfinishedAction(SCR_WorkshopItemActionDownload action)
void SetDownloadsPaused(bool pause, int count=-1)
void PauseAction(SCR_WorkshopItemActionDownload action, bool pause)
static float GetDownloadActionsProgress(array< ref SCR_WorkshopItemActionDownload > actions)
Returns overall progress of all download actions, from 0 to 1.
SCR_WorkshopItemActionDownload GetActionOfItem(SCR_WorkshopItem item)
Return item action for given workshop item.
static SCR_DownloadManager GetInstance()
ScriptInvokerVoid GetOnAllDownloadsStopped()
float m_fNoDownloadProgressTimer
void OnDownloadProgress(SCR_WorkshopItemActionDownload action, float progressSize)
ref ScriptInvokerVoid m_OnAllDownloadsStopped
array< ref SCR_WorkshopItemActionDownload > GetDownloadQueue()
int m_iQueueDownloadsCompleted
bool HasRunningDownloads()
ref ScriptInvoker m_OnNewDownload
ref ScriptInvokerBase< ScriptInvoker_DownloadManagerAction > m_OnDownloadComplete
static float GetItemDownloadActionsProgress(SCR_WorkshopItem item)
Returns overall download progress for all actions of a workshop item.
void AddDownloadManagerEntry(notnull SCR_WorkshopItem item, notnull SCR_WorkshopItemActionDownload action)
array< ref SCR_WorkshopItemAction > DownloadLatestWithDependencies(notnull SCR_WorkshopItem mainItem, bool downloadMainItem, array< ref SCR_WorkshopItem > dependencies)
ScriptInvokerVoid GetOnDownloadQueueCompleted()
void Callback_OnCanceled(SCR_WorkshopItemActionDownload action)
ref ScriptInvokerBase< ScriptInvoker_ActionDownloadFullStorage > m_OnFullStorageError
void DownloadDependecies(array< Dependency > dependencies)
bool GetDownloadsPaused()
override void EOnInit(IEntity owner)
ref array< ref SCR_WorkshopItemActionDownload > m_aFailedDownloads
float GetDownloadQueueSize()
ref ScriptInvokerBase< ScriptInvoker_DownloadManagerAction > m_OnDownloadCanceled
array< ref SCR_WorkshopItemActionDownload > DownloadItems(array< ref SCR_WorkshopItem > items)
array< ref SCR_WorkshopItemActionDownload > GetUnrelatedDownloads(array< ref SCR_WorkshopItem > requiredItems)
void RemoveSameAddonFromDownloads(notnull SCR_WorkshopItem item)
void DownloadAddons(array< ref SCR_WorkshopItem > items)
Start downloading list of given addons.
override void EOnFrame(IEntity owner, float timeSlice)
void Callback_OnFullStorageError(SCR_WorkshopItemActionDownload action, float size)
Call on full addons storage reached to display storage limit reached error.
void GetAllDownloads(array< ref SCR_DownloadManager_Entry > downloads)
Returns an array of all downloads regardless of their state.
void OnDownloadAddonsReady(SCR_DownloadSequence sequence)
ref array< ref SCR_DownloadManager_Entry > m_aDownloadActions
ScriptInvokerBase< ScriptInvoker_DownloadSequence > GetOnReady()
static SCR_DownloadSequence Create(array< ref SCR_WorkshopItem > dependencies, SCR_DownloadSequence previous, bool skipDetails=false)
There is not enough storage on your hard drive. The space required is at least %1.
static void ShowNotEnoughStorageDialog(float sizeBytes, SCR_WorkshopItemActionDownload action)
Composite action which includes multiple subactions.
bool GetUpdate()
Returns true when this is an update, false when regular download.
ScriptInvokerBase< ScriptInvoker_ActionDownloadProgress > GetOnDownloadProgress()
Revision GetTargetRevision()
ScriptInvokerBase< ScriptInvoker_ActionDownloadFullStorage > GetOnFullStorageError()
Revision GetCurrentLocalRevision()
Returns the revision which we currently have on the local storage.
Revision GetLatestRevision()
bool GetOffline()
True when we have the item on our local storage.
void GetDownloadState(out bool inProgress, out bool paused, out float progress, out Revision targetRevision)
Returns state of the download process.
SCR_WorkshopItemActionComposite GetDependencyCompositeAction()
Returns the current composite action performed for dependencies of this addon.
void SetEnabled(bool enable)
SCR_WorkshopItemActionDownload Download(notnull Revision targetRevision)
SCR_WorkshopItemActionDownload GetDownloadAction()
Returns current download action.
static SCR_WorkshopItem Internal_CreateFromDependency(Dependency dependency)
static SCR_WorkshopSettings Get()
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
EntityEvent
Various entity events.
EntityFlags
Various entity flags.
@ INACTIVE
body is not simulated (sleeps)