22 protected bool m_bSubscribeToAddons;
24 protected ref array<ref SCR_WorkshopItem> m_aDependencies = {};
25 protected bool m_bWaitingResponse;
26 protected bool m_bCanceled;
27 protected bool m_bFailed;
28 protected bool m_bRestrictedAddons;
29 protected bool m_bBlockedAddons;
30 protected bool m_bPatchSizeLoaded;
33 protected bool m_bSkipDetails;
35 protected int m_iDependencyDetailsLoadedCount = 0;
36 protected bool m_bAllDependencyDetailsLoaded;
38 protected int m_iPatchesLoaded = 0;
40 protected ref array<ref SCR_BackendCallbackWorkshopItem> m_aPatchSizeCallbacks = {};
42 protected ref array<ref SCR_WorkshopItem> m_aDependenciesIssues = {};
48 protected ref ScriptInvokerBase<ScriptInvoker_DownloadSequence> m_OnInit;
49 protected ref ScriptInvokerBase<ScriptInvoker_DownloadSequence> m_OnDetailsLoaded;
50 protected ref ScriptInvokerBase<ScriptInvoker_DownloadSequence> m_OnDependenciesLoaded;
51 protected ref ScriptInvokerBase<ScriptInvoker_DownloadSequenceDependencies> m_OnRestrictedDependencies;
52 protected ref ScriptInvokerBase<ScriptInvoker_DownloadSequenceDependencies> m_OnDependenciesLoadingPrevented;
53 protected ref ScriptInvokerBase<ScriptInvoker_DownloadSequence> m_OnError;
54 protected ref ScriptInvokerBase<ScriptInvoker_DownloadSequence> m_OnReady;
56 protected ref ScriptInvokerBase<ScriptInvoker_DownloadSequence> m_OnCancel;
57 protected ref ScriptInvokerBase<ScriptInvoker_DownloadSequence> m_OnDestroyed;
60 ScriptInvokerBase<ScriptInvoker_DownloadSequenceDependencies> GetOnRestrictedDependency()
62 if (!m_OnRestrictedDependencies)
63 m_OnRestrictedDependencies =
new ScriptInvokerBase<ScriptInvoker_DownloadSequenceDependencies>();
65 return m_OnRestrictedDependencies;
69 ScriptInvokerBase<ScriptInvoker_DownloadSequenceDependencies> GetOnDependenciesLoadingPrevented()
71 if (!m_OnDependenciesLoadingPrevented)
72 m_OnDependenciesLoadingPrevented =
new ScriptInvokerBase<ScriptInvoker_DownloadSequenceDependencies>();
74 return m_OnDependenciesLoadingPrevented;
78 ScriptInvokerBase<ScriptInvoker_DownloadSequence> GetOnError()
81 m_OnError =
new ScriptInvokerBase<ScriptInvoker_DownloadSequence>();
87 ScriptInvokerBase<ScriptInvoker_DownloadSequence> GetOnReady()
90 m_OnReady =
new ScriptInvokerBase<ScriptInvoker_DownloadSequence>();
96 ScriptInvokerBase<ScriptInvoker_DownloadSequence> GetOnCancel()
99 m_OnCancel =
new ScriptInvokerBase<ScriptInvoker_DownloadSequence>();
111 if (previous && previous.m_bWaitingResponse)
115 sequence.Setup(dependencies, skipDetails);
125 m_bWaitingResponse =
true;
126 m_bRestrictedAddons =
false;
127 m_bBlockedAddons =
false;
132 OnAllDependenciesDetailsLoaded();
137 LoadDependenciesDetails();
151 reportedDialog.GetOnAllReportsCanceled().Insert(OnAllReportsCanceled);
153 return reportedDialog;
161 m_bWaitingResponse =
false;
164 m_OnCancel.Invoke(
this);
173 protected void Setup(notnull array<ref SCR_WorkshopItem> dependencies,
bool skipDetails)
175 m_bSubscribeToAddons =
true;
176 m_bSkipDetails = skipDetails;
186 protected bool HasAllDetails()
188 if (m_bFailed || m_bCanceled || m_bWaitingResponse)
191 if (m_bSkipDetails && !m_bAllDependencyDetailsLoaded)
199 protected void LoadDependenciesDetails()
201 m_iDependencyDetailsLoadedCount = 0;
206 OnAllDependenciesDetailsLoaded();
214 if (dep.GetDetailsLoaded() || dep.GetOffline())
216 OnDependencyDetailsLoaded(dep);
221 dep.m_OnGetAsset.Insert(OnDependencyDetailsLoaded);
222 dep.m_OnError.Insert(OnItemError);
223 dep.m_OnTimeout.Insert(OnItemError);
231 protected void OnAllDependenciesDetailsLoaded()
233 m_bAllDependencyDetailsLoaded =
true;
236 if (m_bFailed || m_bCanceled)
241 if (!restricted.IsEmpty())
243 m_bRestrictedAddons =
true;
246 m_bBlockedAddons = !blocked.IsEmpty();
248 if (m_OnRestrictedDependencies)
249 m_OnRestrictedDependencies.Invoke(
this, restricted);
255 AllPatchSizeLoaded();
260 m_iPatchesLoaded = 0;
265 if (dependency.GetBlocked())
267 OnDependencyPatchSizeLoadResponse(
null);
274 Revision revision =
null;
276 if (dependency.GetDependency())
277 revision = dependency.GetDependency().GetRevision();
281 revision = dependency.GetWorkshopItem().GetPendingDownload();
292 OnDependencyPatchSizeLoadResponse(
null);
298 if (!dependency.GetOffline())
300 SetDependencySize(dependency, dependency.GetSizeBytes());
306 callback.GetEventOnResponse().Insert(OnDependencyPatchSizeLoadResponse);
307 m_aPatchSizeCallbacks.Insert(
callback);
309 revision.ComputePatchSize(
callback);
314 protected array<ref SCR_WorkshopItem> MissingWorkshopItems()
316 array<ref SCR_WorkshopItem> missingItems = {};
320 if (!dependency.GetWorkshopItem())
321 missingItems.Insert(dependency);
328 protected void AllPatchSizeLoaded()
330 m_bWaitingResponse =
false;
332 if (m_OnReady && HasAllDetails())
333 m_OnReady.Invoke(
this);
340 dialog.GetOnAllReportsCanceled().Remove(OnAllReportsCanceled);
342 m_bRestrictedAddons =
false;
343 OnAllDependenciesDetailsLoaded();
354 item.m_OnGetAsset.Remove(OnDependencyDetailsLoaded);
356 m_iDependencyDetailsLoadedCount++;
360 OnAllDependenciesDetailsLoaded();
371 callback.GetEventOnResponse().Remove(OnDependencyPatchSizeLoadResponse);
380 callback.GetItem().GetDependency().GetRevision().GetPatchSize(size);
381 callback.GetItem().SetTargetRevisionPatchSize(size);
385 CheckAllPatchSizeLoaded();
391 item.SetTargetRevisionPatchSize(size);
394 CheckAllPatchSizeLoaded();
398 protected void CheckAllPatchSizeLoaded()
403 m_aPatchSizeCallbacks.Clear();
404 AllPatchSizeLoaded();
408 if (m_OnDependenciesLoadingPrevented && !m_aDependenciesIssues.IsEmpty() &&
m_aDependencies.Count() == m_iPatchesLoaded + m_aDependenciesIssues.Count())
409 m_OnDependenciesLoadingPrevented.Invoke(
this, m_aDependenciesIssues);
416 m_OnError.Invoke(
this);
423 m_OnError.Invoke(
this);
431 bool GetRestrictedAddons()
433 return m_bRestrictedAddons;
437 bool GetBlockedAddons()
439 return m_bBlockedAddons;