Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DownloadManager.c
Go to the documentation of this file.
1/*
2This entity is required for SCR_DownloadManager_Dialog to work.
3
4It performs tracking of current downloads, while the Dialog class just visualizes them when opened.
5
6!!! This entity relies on SCR_AddonManager, which also must be placed into the world.
7*/
8
9[EntityEditorProps(category: "", description: "Entity of the download manager. Most likely only needed in the main menu world.")]
10class SCR_DownloadManagerClass: GenericEntityClass
11{
12};
13
16
19
20class SCR_DownloadManager : GenericEntity
21{
22 protected const int DOWNLOAD_STUCK_DELAY = 60; // Max time in which download needs to progress in seconds
23
24 protected const int ERROR_FULL_STORAGE = 19;
25
26 protected static SCR_DownloadManager s_Instance;
27
28 // All download actions
29 protected ref array<ref SCR_DownloadManager_Entry> m_aDownloadActions = new array<ref SCR_DownloadManager_Entry>();
30
31 // Download queue - it gets empty once all active downloads are complete, but keeps added up if new downloads are started
32 // While previous are in progress.
33 // This is mainly used by the panel.
34 protected ref array<ref SCR_WorkshopItemActionDownload> m_aDownloadQueue = new array<ref SCR_WorkshopItemActionDownload>;
35 protected int m_iQueueDownloadsCompleted; // Amount of completed downloads in the queue
36
37 protected float m_fNoDownloadProgressTimer = 0; // Track how long there was no progress on downloading until stuck delay
38 protected float m_fDownloadQueueSize;
39 protected float m_fDownloadedSize;
40
41 // Bool to pause all downloads
42 protected bool m_bDownloadsPaused;
43
44 protected const int FAIL_TIME = 500;
45 protected ref array<ref SCR_WorkshopItemActionDownload> m_aFailedDownloads = {};
46
49 ref ScriptInvoker m_OnNewDownload = new ScriptInvoker; // (SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
50
51 ref ScriptInvokerBase<ScriptInvoker_DownloadManagerAction> m_OnDownloadComplete = new ScriptInvokerBase<ScriptInvoker_DownloadManagerAction>();
52 ref ScriptInvokerBase<ScriptInvoker_DownloadManagerActionError> m_OnDownloadFailed = new ScriptInvokerBase<ScriptInvoker_DownloadManagerActionError>();
53 protected ref ScriptInvokerBase<ScriptInvoker_ActionDownloadFullStorage> m_OnFullStorageError;
54 ref ScriptInvokerBase<ScriptInvoker_DownloadManagerAction> m_OnDownloadCanceled = new ScriptInvokerBase<ScriptInvoker_DownloadManagerAction>();
55 protected ref ScriptInvokerVoid m_OnDownloadQueueCompleted
57
58 //------------------------------------------------------------------------------------------------
59 ScriptInvokerBase<ScriptInvoker_ActionDownloadFullStorage> GetOnFullStorageError()
60 {
62 m_OnFullStorageError = new ScriptInvokerBase<ScriptInvoker_ActionDownloadFullStorage>();
63
65 }
66
67 //-----------------------------------------------------------------------------------------------
69 {
70 if (!m_OnDownloadQueueCompleted)
71 m_OnDownloadQueueCompleted = new ScriptInvokerVoid();
72
73 return m_OnDownloadQueueCompleted;
74 }
75
76 //-----------------------------------------------------------------------------------------------
84
85 //-----------------------------------------------------------------------------------------------
86 // P U B L I C A P I
87 //-----------------------------------------------------------------------------------------------
88
89
90 //-----------------------------------------------------------------------------------------------
91 static SCR_DownloadManager GetInstance()
92 {
93 return s_Instance;
94 }
95
96 //-----------------------------------------------------------------------------------------------
98 void GetAllDownloads(array<ref SCR_DownloadManager_Entry> downloads)
99 {
100 downloads.Clear();
101
102 foreach (auto dl : m_aDownloadActions)
103 downloads.Insert(dl);
104 }
105
106
107 //-----------------------------------------------------------------------------------------------
109 void GetDownloadQueueState(out int nCompleted, out int nTotal)
110 {
111 nTotal = m_aDownloadQueue.Count();
112 nCompleted = m_iQueueDownloadsCompleted;
113 }
114
115 //-----------------------------------------------------------------------------------------------
117 {
118 return !m_aDownloadQueue.IsEmpty();
119 }
120
121 //-----------------------------------------------------------------------------------------------
124 {
126 {
127 if (download.m_Wrapper.GetId() != id)
128 continue;
129
130 if (runningOnly && download.IsActive() && !download.IsCompleted() && !download.IsFailed() && !download.IsCanceled())
131 return download;
132 }
133
134 return null;
135 }
136
137 //-----------------------------------------------------------------------------------------------
138 array<ref SCR_WorkshopItemActionDownload> GetDownloadQueue()
139 {
140 array<ref SCR_WorkshopItemActionDownload> downloads = {};
141
142 if (!m_aDownloadQueue)
143 return downloads;
144
146 {
147 downloads.Insert(action);
148 }
149
150 return downloads;
151 }
152
153 //-----------------------------------------------------------------------------------------------
156 {
158 {
159 if (entry.m_Item == item)
160 return entry.m_Action;
161 }
162
163 return null;
164 }
165
166 //-----------------------------------------------------------------------------------------------
170 void SetDownloadsPaused(bool pause, int count = -1)
171 {
172 if (pause == m_bDownloadsPaused)
173 return;
174
175 m_bDownloadsPaused = pause;
176
177 // Setup calls count
178 if (count == -1)
179 count = m_aDownloadQueue.Count() - 1;
180
181 // Paseu/resume
182 PauseAction(m_aDownloadQueue[count], pause);
183
184 // Late call
185 if (count > 0)
186 GetGame().GetCallqueue().CallLater(SetDownloadsPaused, 0, false, pause, count - 1);
187 }
188
189 //-----------------------------------------------------------------------------------------------
190 protected void PauseAction(SCR_WorkshopItemActionDownload action, bool pause)
191 {
192 // Pause
193 if (pause)
194 {
195 if (action.IsActive())
196 action.Pause();
197
198 return;
199 }
200
201 // Resume
202 if (action.IsPaused())
203 action.Resume();
204 else if (action.IsInactive())
205 action.Activate();
206 }
207
208 //-----------------------------------------------------------------------------------------------
210 {
211 return m_bDownloadsPaused;
212 }
213
214
215 //-----------------------------------------------------------------------------------------------
220 {
222 {
223 a.Cancel();
224 }
225 }
226
227 //-----------------------------------------------------------------------------------------------
228 // Given an array of required items, returns all those queued items that are outside of it, including mismatching versions
229 array<ref SCR_WorkshopItemActionDownload> GetUnrelatedDownloads(array<ref SCR_WorkshopItem> requiredItems)
230 {
231 array<ref SCR_WorkshopItemActionDownload> unrelatedDownloads = {};
232
234 {
235 if (!IsDownloadingActionRequired(action, requiredItems))
236 unrelatedDownloads.Insert(action);
237 }
238
239 return unrelatedDownloads;
240 }
241
242 //-----------------------------------------------------------------------------------------------
243 // Given an array of required items, returns true if the input action's item is part of it and is the correct version
244 bool IsDownloadingActionRequired(SCR_WorkshopItemActionDownload action, array<ref SCR_WorkshopItem> requiredItems)
245 {
246 SCR_WorkshopItem item = action.GetWorkshopItem();
247 if (!item)
248 return true;
249
250 bool required;
251 bool sameId;
252 bool sameVersion;
253
254 foreach (SCR_WorkshopItem requiredItem : requiredItems)
255 {
256 sameId = requiredItem.GetId() == item.GetId();
257 sameVersion = requiredItem.GetDependency().GetVersion() == action.GetTargetRevision().GetVersion();
258 required = sameId && sameVersion;
259
260 if (required)
261 return true;
262 }
263
264 return false;
265 }
266
267 // --- Helper functions for generic download functionality ---
268
269 //-----------------------------------------------------------------------------------------------
274 {
275 if (!item.GetOffline())
276 return true;
277
278 Revision latestRevision = item.GetLatestRevision();
279 Revision targetRevision;
280 bool downloading, paused;
281 float progress;
282 item.GetDownloadState(downloading, paused, progress, targetRevision);
283
284 if (!downloading)
285 {
286 return !Revision.AreEqual(item.GetCurrentLocalRevision(), latestRevision);
287 }
288 else
289 {
290 // We are already downloading this, but what versoin?
291 if (Revision.AreEqual(item.GetLatestRevision(), targetRevision))
292 return false; // Already downloading this version, no need to start a new download
293 else
294 return true; // Downloading a different version, we must download another one
295 }
296 }
297
298
299 //-----------------------------------------------------------------------------------------------
300 static void SelectAddonsForLatestDownload(array<ref SCR_WorkshopItem> arrayIn, array<ref SCR_WorkshopItem> arrayOut)
301 {
302 foreach (SCR_WorkshopItem addon : arrayIn)
303 {
304 if (IsLatestDownloadRequired(addon))
305 arrayOut.Insert(addon);
306 }
307 }
308
309 //-----------------------------------------------------------------------------------------------
313 array<ref SCR_WorkshopItemAction> DownloadLatestWithDependencies(notnull SCR_WorkshopItem mainItem, bool downloadMainItem, array<ref SCR_WorkshopItem> dependencies)
314 {
315 array<ref SCR_WorkshopItemAction> actions = {};
316
317 if (IsLatestDownloadRequired(mainItem) && downloadMainItem)
318 {
319 auto actionMain = mainItem.DownloadLatestVersion();
320 if (actionMain)
321 {
322 actions.Insert(actionMain);
324 actionMain.Activate();
325 }
326 }
327
328 if (dependencies)
329 {
330 if (dependencies.Count() > 0)
331 {
332 auto actionDependencies = mainItem.DownloadDependenciesLatest(dependencies);
333 if (actionDependencies)
334 {
336 actionDependencies.Activate();
337
338 actions.Insert(actionDependencies);
339 }
340 }
341 }
342
343 return actions;
344 }
345
346 //-----------------------------------------------------------------------------------------------
347
348 //-----------------------------------------------------------------------------------------------
351 array<ref SCR_WorkshopItemActionDownload> DownloadItems(array<ref SCR_WorkshopItem> items)
352 {
353 array<ref SCR_WorkshopItemActionDownload> actions = {};
354
355 for (int i = 0, count = items.Count(); i < count; i++)
356 {
357 Revision target = items[i].GetItemTargetRevision();
358
359 if (!target)
360 target = items[i].GetDependency().GetRevision();
361
362 if (!target)
363 {
364 return null;
365 }
366
367 // Create download action from dependency and depdency revision
368 SCR_WorkshopItemActionDownload action = items[i].Download(target);
369 actions.Insert(action);
370 action.Activate();
371 }
372
373 return actions;
374 }
375
376 //-----------------------------------------------------------------------------------------------
379 void DownloadDependecies(array<Dependency> dependencies)
380 {
381 for (int i = 0, count = dependencies.Count(); i < count; i++)
382 {
384
385 // Create download action from dependency and depdency revision
386 SCR_WorkshopItemActionDownload action = item.Download(dependencies[i].GetRevision());
387 action.Activate();
388 }
389 }
390
391 //-----------------------------------------------------------------------------------------------
392 static float GetTotalSizeBytes(array<ref SCR_WorkshopItem> arrayIn, SCR_WorkshopItem extraItem = null)
393 {
394 float sizeOut = 0;
395
396 foreach (SCR_WorkshopItem addon : arrayIn)
397 {
398 float s = addon.GetTargetRevisionPatchSize();
399 sizeOut += s;
400 }
401
402 if (extraItem)
403 {
404 float s = extraItem.GetTargetRevisionPatchSize();
405 sizeOut += s;
406 }
407
408 return sizeOut;
409 }
410
411 //-----------------------------------------------------------------------------------------------
412 protected float DownloadQueueSize()
413 {
414 array<ref SCR_WorkshopItem> downloading = {};
415 for (int i = 0, count = m_aDownloadQueue.Count(); i < count; i++)
416 {
417 downloading.Insert(m_aDownloadQueue[i].m_Wrapper);
418 }
419
420 return GetTotalSizeBytes(downloading);
421 }
422
423 //-----------------------------------------------------------------------------------------------
425 static float GetDownloadActionsProgress(array<ref SCR_WorkshopItemActionDownload> actions)
426 {
427 float totalSizeBytes = 0;
428 float totalBytesDownloaded = 0;
429
430 foreach (SCR_WorkshopItemActionDownload dl : actions)
431 {
432 float dlsize = dl.GetSizeBytes();
433 totalSizeBytes += dlsize;
434 totalBytesDownloaded += dl.GetProgress() * dlsize;
435 }
436
437 if (totalSizeBytes == 0) // Don't divide by 0
438 return 0;
439
440 float progress = totalBytesDownloaded / totalSizeBytes;
441 return progress;
442 }
443
444 //-----------------------------------------------------------------------------------------------
447 {
448 // Create an array of all download actions started from this tile
449 // Get their aggregated progress
450
451 SCR_WorkshopItemActionDownload actionThisItem = item.GetDownloadAction(); // Action for downloading this item
452 SCR_WorkshopItemActionComposite actionDependencies = item.GetDependencyCompositeAction(); // Action for downloading dependencies
453
454 array<ref SCR_WorkshopItemAction> allActions;
455 if (actionDependencies)
456 allActions = actionDependencies.GetActions();
457 else
458 allActions = new array<ref SCR_WorkshopItemAction>;
459
460 if (actionThisItem)
461 allActions.Insert(actionThisItem);
462
463 // Cast all actions to download actions...
464 auto allDownloadActions = new array<ref SCR_WorkshopItemActionDownload>;
465 foreach (auto a : allActions)
466 {
467 auto downloadAction = SCR_WorkshopItemActionDownload.Cast(a);
468 if (downloadAction)
469 allDownloadActions.Insert(downloadAction);
470 }
471
472 float progress = SCR_DownloadManager.GetDownloadActionsProgress(allDownloadActions);
473
474 return progress;
475 }
476
477 //-----------------------------------------------------------------------------------------------
478 array<ref SCR_WorkshopItemActionDownload> GetFailedDownloads()
479 {
480 array<ref SCR_WorkshopItemActionDownload> actions = {};
481 for (int i = 0, count = m_aFailedDownloads.Count(); i < count; i++)
482 {
483 actions.Insert(m_aFailedDownloads[i]);
484 }
485
486 return actions;
487 }
488
489 //-----------------------------------------------------------------------------------------------
491 {
492 m_aFailedDownloads.Clear();
493 }
494
495 //-----------------------------------------------------------------------------------------------
497 {
499
501 m_aDownloadActions.Insert(entry);
502 }
503
504 //-----------------------------------------------------------------------------------------------
508 {
509 // Release download actions
510 for (int i = 0, count = m_aDownloadActions.Count(); i < count; i++)
511 {
512 // Same addon ids?
513 if (m_aDownloadActions[i].m_Item.GetId() == item.GetId())
514 {
515 m_aDownloadActions.Remove(i);
516 break;
517 }
518 }
519
520 // Release download queue
521 for (int i = 0, count = m_aDownloadQueue.Count(); i < count; i++)
522 {
523 // Same addon ids?
524 if (m_aDownloadQueue[i].m_Wrapper.GetId() == item.GetId())
525 {
526 m_aDownloadQueue.Remove(i);
527 break;
528 }
529 }
530 }
531
532 //-----------------------------------------------------------------------------------------------
534 {
536 }
537
538 //-----------------------------------------------------------------------------------------------
540 {
541 return m_fDownloadedSize;
542 }
543
544 //-----------------------------------------------------------------------------------------------
545 //-----------------------------------------------------------------------------------------------
546 //-----------------------------------------------------------------------------------------------
547
548
549
550
551
552
553
554
555 //-----------------------------------------------------------------------------------------------
556 // P R O T E C T E D / P R I V A T E
557 //-----------------------------------------------------------------------------------------------
558
559
560
561 //-----------------------------------------------------------------------------------------------
562 override void EOnFrame(IEntity owner, float timeSlice)
563 {
564 int pausedCount = 0;
565
566 // Remove failed or canceled actions from the download queue
567 for (int i = m_aDownloadQueue.Count() - 1; i >= 0; i--)
568 {
570
571 if (action.IsCanceled() || action.IsFailed())
572 ClearUnfinishedAction(action);
573 else if (action.IsPaused())
574 pausedCount++;
575 }
576
577 // Restart no progress timer check
578 if (pausedCount == m_aDownloadQueue.Count())
579 {
581 }
582
583 // If all are completed, clear the queue entirely
584 // And reset 'all downloads paused' state.
586 {
587 m_aDownloadQueue.Clear();
590 m_bDownloadsPaused = false;
591
592 if (m_OnDownloadQueueCompleted)
593 m_OnDownloadQueueCompleted.Invoke();
594
596 }
597
598 /*
599 else
600 {
601 // Increase time from last download progress
602 m_fNoDownloadProgressTimer += timeSlice;
603
604 // Quit downloads if nothing is progressing
605 if (m_fNoDownloadProgressTimer >= DOWNLOAD_STUCK_DELAY)
606 {
607 // TODO: Display error if no progress for 1 min istead of force fail
608 }
609 }
610 */
611 }
612
613 //-----------------------------------------------------------------------------------------------
614 override void EOnInit(IEntity owner)
615 {
617
618 if (!addonManager)
619 {
620 Print("SCR_DownloadManager_Entity: SCR_AddonManager was not found. It must be placed in the world for download manager to work.", LogLevel.ERROR);
621 return;
622 }
623
624 addonManager.m_OnNewDownload.Insert(Callback_OnNewDownload);
625 }
626
627 //-----------------------------------------------------------------------------------------------
632 {
633 #ifdef WORKSHOP_DEBUG
634 Revision rev = action.GetTargetRevision();
635 if (rev)
636 _print(string.Format("Callback_OnNewDownloadStarted: %1, %2", item.GetName(), action.GetTargetRevision().GetVersion()));
637 else
638 _print(string.Format("Callback_OnNewDownloadStarted: %1", item.GetName()));
639 #endif
640
642
643 // Create a new entry
645 m_aDownloadActions.Insert(entry);
646
647 // Add the action to the queue
648 m_aDownloadQueue.Insert(action);
650
651 m_OnNewDownload.Invoke(item, action);
652
654 action.m_OnCompleted.Insert(Callback_OnDownloadCompleted);
655 action.m_OnFailed.Insert(Callback_OnFailed);
657 action.m_OnCanceled.Insert(Callback_OnCanceled);
658
660 }
661
662 //-----------------------------------------------------------------------------------------------
663 protected void OnDownloadProgress(SCR_WorkshopItemActionDownload action, float progressSize)
664 {
665 m_fDownloadedSize += progressSize;
666
667 // Restart progress timer
669 }
670
671 //-----------------------------------------------------------------------------------------------
674 {
675 // Check user's settings if we need to enable the addon automatically
676 // Ignore this if it was an update of an addon
678 if (settings.m_bAutoEnableDownloadedAddons && !action.GetUpdate())
679 {
680 SCR_WorkshopItem item = action.GetWorkshopItem();
681
682 if (!item)
683 return;
684
685 item.SetEnabled(true);
686 }
687
688 // Invoke for UI
690 m_OnDownloadComplete.Invoke(action);
691 }
692
693 //-----------------------------------------------------------------------------------------------
696 {
697 m_aFailedDownloads.Insert(action);
698
699 // TODO: hack, download manager should not open UI, but we lack a proper system to handle this better
700 SCR_FailedModsDownloadDialog.ShowFailedModsDialog(action, reason);
701
702 // Prevent error on full storage error
704 return;
705
706 // Generic error
707 m_OnDownloadFailed.Invoke(action, reason);
708 }
709
710 //-----------------------------------------------------------------------------------------------
713 {
714 // TODO: hack, download manager should not open UI, but we lack a proper system to handle this better
716
718 m_OnFullStorageError.Invoke(action, size);
719 }
720
721 //-----------------------------------------------------------------------------------------------
723 {
724 m_aFailedDownloads.Insert(action);
725 m_OnDownloadCanceled.Invoke(action);
726 }
727
728 //-----------------------------------------------------------------------------------------------
731 {
732 for (int i = 0, count = m_aDownloadQueue.Count(); i < count; i++)
733 {
734 m_aDownloadQueue[i].ForceFail();
735 }
736 }
737
738 //-----------------------------------------------------------------------------------------------
740 void DownloadAddons(array<ref SCR_WorkshopItem> items)
741 {
742 SCR_DownloadSequence sequence = SCR_DownloadSequence.Create(items, null, true);
743 sequence.GetOnReady().Insert(OnDownloadAddonsReady);
744 sequence.Init();
745
746 /*
747 array<ref SCR_WorkshopItem> offline = SCR_AddonManager.GetInstance().GetOfflineAddons();
748 array<SCR_WorkshopItem> unfinished = {};
749
750 // Filter out unfinished
751 foreach (SCR_WorkshopItem item : offline)
752 {
753 bool inProgress, paused;
754 int progress;
755 Revision targetRevision;
756
757 item.GetDownloadState(inProgress, paused, progress, targetRevision);
758 Print("item: " + item.GetName());
759 Print("in progress: " + inProgress);
760 Print("----------------------------------");
761
762 //Print("item: " + item.GetDownloadState());
763 //if (offline.ge)
764 }
765 */
766 }
767
768 //-----------------------------------------------------------------------------------------------
770 {
771 sequence.GetOnReady().Remove(OnDownloadAddonsReady);
772 //sequence.
773 }
774
775 //-----------------------------------------------------------------------------------------------
777 {
778 m_aDownloadQueue.RemoveItem(action);
779
780 // Remove canceled and failed from size count
781 m_fDownloadQueueSize = Math.Clamp(m_fDownloadQueueSize - action.GetDownloadSize(), 0, float.MAX);
782 m_fDownloadedSize = Math.Clamp(m_fDownloadedSize - action.GetDownloadSize(), 0, float.MAX);
783
786 }
787
788 //-----------------------------------------------------------------------------------------------
789 private void SCR_DownloadManager(IEntitySource src, IEntity parent)
790 {
791 SetEventMask( EntityEvent.FRAME | EntityEvent.INIT);
792 SetFlags(EntityFlags.NO_TREE | EntityFlags.NO_LINK);
793
794 s_Instance = this;
795 }
796
797 //-----------------------------------------------------------------------------------------------
798 private void ~SCR_DownloadManager()
799 {
800 s_Instance = null;
801 }
802
803
804 //-----------------------------------------------------------------------------------------------
805 //-----------------------------------------------------------------------------------------------
806 //-----------------------------------------------------------------------------------------------
807
808
809 //------------------------------------------------------------------------------------------------
810 void _print(string str, LogLevel logLevel = LogLevel.DEBUG)
811 {
812 Print(string.Format("[SCR_DownloadManager] %1 %2", this, str), logLevel);
813 }
814};
815
816
817//------------------------------------------------------------------------------------------------
819class SCR_DownloadManager_Entry
820{
821 ref SCR_WorkshopItem m_Item; // We hold strong refs to both item and action!
823
824 //------------------------------------------------------------------------------------------------
825 void SCR_DownloadManager_Entry(SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
826 {
827 m_Item = item;
828 m_Action = action;
829 }
830};
831
832//------------------------------------------------------------------------------------------------
ArmaReforgerScripted GetGame()
Definition game.c:1398
int size
@ 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
NewsFeedItem m_Item
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)
Definition Math.c:13
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)
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
static bool IsLatestDownloadRequired(SCR_WorkshopItem item)
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()
void OnDownloadProgress(SCR_WorkshopItemActionDownload action, float progressSize)
ref ScriptInvokerVoid m_OnAllDownloadsStopped
array< ref SCR_WorkshopItemActionDownload > GetDownloadQueue()
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)
override void EOnInit(IEntity owner)
ref array< ref SCR_WorkshopItemActionDownload > m_aFailedDownloads
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()
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()
@ RUNNING
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EntityFlags
Various entity flags.
Definition EntityFlags.c:14
@ INACTIVE
body is not simulated (sleeps)
Definition ActiveState.c:18
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134