Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_WorkshopItem.c
Go to the documentation of this file.
1 /*
2 ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
3 ! ! If you use SCR_WorkshopItem, make sure you hold a strong reference (ref) to it:
4 ! ! Example: ref SCR_WorkshopItem m_Item;
5 ! ! The object is shared by nature and exists as long as at least something holds a strong
6 ! ! reference to it, if it is offline or as if any download is active.
7 ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
8 */
9 
10 // Enum for possible issues of addons
12 {
19 };
20 
22 {
23  // friend class SCR_WorkshopItemAction
24 
25  // ---- Public variables ----
26  ref ScriptInvoker m_OnChanged = new ScriptInvoker(); // (SCR_WorkshopItem item) - Called on any change and any event which affects state. Might be called on next frame!
27  ref ScriptInvoker m_OnGetAsset = new ScriptInvoker(); // (SCR_WorkshopItem item) - Called on failure to load details too.
28  ref ScriptInvoker m_OnDependenciesLoaded = new ScriptInvoker(); // (SCR_WorkshopItem item)
29  ref ScriptInvoker m_OnScenariosLoaded = new ScriptInvoker(); // (SCR_WorkshopItem item)
30  ref ScriptInvoker m_OnError = new ScriptInvoker(); // (SCR_WorkshopItem item) - Called on any error event
31  ref ScriptInvoker m_OnTimeout = new ScriptInvoker(); // (SCR_WorkshopItem item) - Called on any timeout event
32  ref ScriptInvoker m_OnDownloadComplete = new ScriptInvoker(); // (SCR_WorkshopItem item) - Called when any download has been completed (including an update)
33  ref ScriptInvoker m_OnOfflineStateChanged = new ScriptInvoker(); // (SCR_WorkshopItem item, bool newState) - Called when the addon was downloaded first time or deleted (OFFLINE flag changed its value)
34  ref ScriptInvoker m_OnReportStateChanged = new ScriptInvoker(); // (SCR_WorkshopItem, bool newReported) - Called when reported state has changed
35  ref ScriptInvoker m_OnMyReportLoaded = new ScriptInvoker(); // (SCR_WorkshopItem item) - called after report loading is done.
36  ref ScriptInvoker m_OnMyReportLoadError = new ScriptInvoker();
37  ref ScriptInvoker m_OnRedownload = new ScriptInvoker();
38  ref ScriptInvoker m_OnCanceled = new ScriptInvoker();
39 
40  // ---- Protected / Private ----
41 
42  protected ref WorkshopItem m_Item; // Strong reference!
43  protected ref Dependency m_Dependency;
44 
45  // Revision to download and measure patch size when item is not dependency
46  protected ref Revision m_ItemTargetRevision;
47  protected float m_fTargetRevisionPatchSize; // cached size for target revision
48 
49  protected ref array<MissionWorkshopItem> m_aMissions;
50  protected ref array<ref SCR_WorkshopItem> m_aDependencies; // Strong references!
51  protected ref array<SCR_WorkshopItem> m_aDependent = new array<SCR_WorkshopItem>; // Weak refs - array of addons which depend on this addon
52  protected ref array<Revision> m_aRevisions;
53 
54  // Name and id - just to check them in debugger
55  #ifdef WORKSHOP_DEBUG
56  protected string m_sName;
57  protected string m_sId;
58  #endif
59 
60  // Flags for state of partially loaded data
61  protected bool m_bDetailsLoaded; // Details are loaded - After LoadDetails
62 
63  // Backend callbacks
64  protected ref SCR_WorkshopItemCallback_AskDetails m_CallbackAskDetails;
65  protected ref SCR_WorkshopCallbackBase m_CallbackLoadGallery;
66  protected ref SCR_WorkshopItemCallback_LoadDependencies m_CallbackLoadDependencies;
67  protected ref SCR_WorkshopItemCallback_LoadScenarios m_CallbackLoadScenarios;
68  protected ref SCR_WorkshopItemCallback_LoadMyReport m_CallbackLoadMyReport;
69  protected ref SCR_BackendCallback m_CancelDownloadCallback = new SCR_BackendCallback();
70 
71  // Various state flags
72  protected bool m_bMyRating;
73  protected bool m_bMyRatingSet;
74  protected bool m_bFavourite;
75  protected bool m_bSubscribed;
76  protected bool m_bChanged; // Checked every frame, if something changes then this flag can be set to OnChanged script invoker is called during update.
77  protected bool m_bRequestFailed; // Set to true on HTTP request failures
78  protected bool m_bOffline;
79  protected int m_iAccessState;
80 
81  // Data loading flags
82  protected bool m_bWaitingLoadDetails; // With current API it's always true after a LoadDetails call, since we can't know when it's done for sure
83  protected float m_fPrevDownloadProgress; // Used to detect when download progress changes
84 
85  // Actions
86  protected ref SCR_WorkshopItemActionDownload m_ActionDownload;
87  protected ref SCR_WorkshopItemActionReport m_ActionReport;
88  protected ref SCR_WorkshopItemActionCancelReport m_ActionCancelReport;
89  protected ref SCR_WorkshopItemActionComposite m_ActionDependency; // Composite action we have started for dependencies
90  protected ref SCR_WorkshopItemActionAddAuthorBlock m_ActionAddAuthorBlock;
91  protected ref SCR_WorkshopItemActionRemoveAuthorBlock m_ActionRemoveAuthorBlock;
92 
93 
94  //-----------------------------------------------------------------------------------------------
95  // P U B L I C M E T H O D S
96  //-----------------------------------------------------------------------------------------------
97 
99  WorkshopItem GetWorkshopItem() { return m_Item; }
100  Dependency GetDependency() { return m_Dependency; }
101 
103  bool GetItemDataLoaded() { return m_Item != null; }
104  bool GetDetailsLoaded() { return m_bDetailsLoaded; } // GetAsset request was completed, doesn't mean that anything else related to it is loaded
105  bool GetScenariosLoaded() { return m_aMissions != null; } // Scenarios were loaded after GetAsset request
106  bool GetRevisionsLoaded() { return m_aRevisions != null; } // Revisions were loaded after GetAsset request
107  bool GetDependenciesLoaded() { return m_aDependencies != null; } // Latest dependencies were loaded after GetAsset request
108  bool GetRequestFailed() { return m_bRequestFailed; } // True when any request has failed
109 
110  //-----------------------------------------------------------------------------------------------
111  bool IsDownloadRunning()
112  {
113  if (!m_ActionDownload)
114  return false;
115 
116  return m_ActionDownload.IsActive();
117  }
118 
119  //-----------------------------------------------------------------------------------------------
121  void LogState()
122  {
123  bool myRating, myRatingSet;
124  GetMyRating(myRatingSet, myRating);
125 
126  string description = GetDescription();
127  if (description.Length() > 32)
128  {
129  description = description.Substring(0, 32);
130  description = description + " <truncated>";
131  }
132 
133  string summary = GetSummary();
134  if (summary.Length() > 32)
135  {
136  summary = summary.Substring(0, 32);
137  summary = summary + " <truncated>";
138  }
139 
140  SCR_AddonManager mgr = SCR_AddonManager.GetInstance();
141 
142  array<ref SCR_WorkshopItem> dependencies = GetLatestDependencies();
143 
144  _print("\nLogState:");
145  _print(string.Format(" Name: %1", GetName()));
146  _print(string.Format(" ID: %1", GetId()));
147  _print(string.Format(" Dependency: %1", m_Dependency));
148  _print(string.Format(" WorkshopItem: %1", m_Item));
149  _print(string.Format(" Subscribed: %1", GetSubscribed()));
150  _print(string.Format(" Enabled: %1", GetEnabled()));
151  _print(string.Format(" Online: %1", GetOnline()));
152  _print(string.Format(" Offline: %1", GetOffline()));
153  _print(string.Format(" Blocked: %1", GetBlocked()));
154  _print(string.Format(" ReportedByMe: %1", GetReportedByMe()));
155  if (GetCurrentLocalRevision())
156  _print(string.Format(" CurrentLocalVersion: %1", GetCurrentLocalRevision().GetVersion()));
157 
158  if (GetLatestVersion())
159  _print(string.Format(" LatestVersion: %1", GetLatestVersion()));
160 
161  _print(string.Format(" ItemDataLoaded: %1", GetItemDataLoaded()));
162  _print(string.Format(" DetailsLoaded: %1", GetDetailsLoaded()));
163  _print(string.Format(" ScenariosLoaded: %1", GetScenariosLoaded()));
164  _print(string.Format(" DependenciesLoaded: %1", GetDependenciesLoaded()));
165  _print(string.Format(" RequestFailed: %1", GetRequestFailed()));
166  //_print(string.Format(" OfflineAndUpToDate: %1", GetIsOfflineAndUpToDate()));
167  _print(string.Format(" AuthorName: %1", GetAuthorName()));
168  _print(string.Format(" MyRating: %1", myRating));
169  _print(string.Format(" MyRatingSet: %1", myRatingSet));
170  _print(string.Format(" Favourite: %1", GetFavourite()));
171  _print(string.Format(" Corrupted: %1", GetCorrupted()));
172  _print(string.Format(" Description: %1", description));
173  _print(string.Format(" Summary: %1", summary));
174  _print(string.Format(" RatingCount: %1", GetRatingCount()));
175  _print(string.Format(" SizeBytes: %1", GetSizeBytes()));
176  _print(string.Format(" UpdateAvailable: %1", GetUpdateAvailable()));
177  _print(string.Format(" EnabledExternally: %1", mgr.GetAddonEnabledExternally(this)));
178  _print(string.Format(" TimeSinceLastPlay: %1, %2", GetTimeSinceLastPlay(), SCR_FormatHelper.GetTimeSinceEventImprecise(GetTimeSinceLastPlay())));
179  _print(string.Format(" TimeSinceFirstDl: %1, %2", GetTimeSinceFirstDownload(), SCR_FormatHelper.GetTimeSinceEventImprecise(GetTimeSinceFirstDownload())));
180 
181  //if (m_Item)
182  //_print(string.Format(" HasBackendThumbnail: %1", m_Item.HasBackendThumbnail()));
183 
184  _print(string.Format(" AnyDepDisabled: %1", GetEnabledAndAnyDependencyDisabled()));
185  _print(string.Format(" AnyDepOutdated: %1", GetAnyDependencyUpdateAvailable()));
186  _print(string.Format(" AnyDepMissing: %1", GetAnyDependencyMissing()));
187 
188  _print(string.Format(" Dependencies: %1", dependencies.Count()));
189  foreach (SCR_WorkshopItem dep : dependencies)
190  {
191  _print(string.Format(" - %1, Offline: %2, Update Available: %3", dep.GetName(), dep.GetOffline(), dep.GetUpdateAvailable()));
192  }
193 
194  // todo scenarios, dependencies
195 
196  _print("\n\n");
197  }
198 
199  //-----------------------------------------------------------------------------------------------
201  void LoadDetails()
202  {
203  #ifdef WORKSHOP_DEBUG
204  _print("LoadDetails");
205  #endif
206 
207  if (m_Item || m_Dependency)
208  {
209  Internal_LoadDetails();
210  }
211  }
212 
213  //-----------------------------------------------------------------------------------------------
214  void ClearLoadDetails()
215  {
216  m_bDetailsLoaded = false;
217  m_bWaitingLoadDetails = false;
218  }
219 
220  //-----------------------------------------------------------------------------------------------
222  void GetScenarios(array<MissionWorkshopItem> scenarios)
223  {
224  if (!m_aMissions)
225  return;
226 
227  scenarios.Clear();
228  scenarios.Copy(m_aMissions);
229  }
230 
231 
232  //-----------------------------------------------------------------------------------------------
234  array<ref SCR_WorkshopItem> GetLatestDependencies()
235  {
236  array<ref SCR_WorkshopItem> dependencies = new array<ref SCR_WorkshopItem>;
237 
238  if (!m_aDependencies)
239  return dependencies;
240 
241  foreach (auto a : m_aDependencies)
242  dependencies.Insert(a);
243 
244  return dependencies;
245  }
246 
247  //-----------------------------------------------------------------------------------------------
249  array<ref SCR_WorkshopItem> GetDependentAddons()
250  {
251  array<ref SCR_WorkshopItem> dependent = new array<ref SCR_WorkshopItem>;
252 
253  if (!m_aDependent)
254  return dependent;
255 
256  foreach (auto a : m_aDependent)
257  {
258  if (a)
259  dependent.Insert(a);
260  }
261 
262  return dependent;
263  }
264 
265  //-----------------------------------------------------------------------------------------------
266  string GetLatestVersion()
267  {
268  Revision rev = GetLatestRevision();
269 
270  if (!rev)
271  return string.Empty;
272 
273  return rev.GetVersion();
274  }
275 
276  //-----------------------------------------------------------------------------------------------
278  array<string> GetVersions()
279  {
280  array<string> versions = new array<string>;
281 
282  if (!GetRevisionsLoaded())
283  return versions;
284 
285  foreach (auto rev : m_aRevisions)
286  {
287  versions.Insert(rev.GetVersion());
288  }
289 
290  return versions;
291  }
292 
293  //-----------------------------------------------------------------------------------------------
295  bool IsDownloadedVersionCompatible()
296  {
297  if (!GetOffline())
298  return false;
299 
300  // Hard coded check for 1.0 - should be replaced with specific version
301  string targetClientVersion = "1.0.0";
302  string addonClientVersion = m_Item.GetActiveRevision().GetGameVersion();
303 
304  array<string> targetNumbers = {};
305  targetClientVersion.Split(".", targetNumbers, false);
306 
307  array<string> addonNumbers = {};
308  addonClientVersion.Split(".", addonNumbers, false);
309 
310  for (int i = 0, count = targetNumbers.Count(); i < count; i++)
311  {
312  int targetNumber = targetNumbers[i].ToInt();
313  int addonNumber = addonNumbers[i].ToInt();
314 
315  if (targetNumber > addonNumber)
316  return false;
317  }
318 
319  return true;
320  }
321 
322  //-----------------------------------------------------------------------------------------------
323  void SetMyRating(bool newRating)
324  {
325  if (!m_Item)
326  return;
327 
328  m_bMyRatingSet = true;
329  m_bMyRating = newRating;
330 
331  #ifdef WORKSHOP_DEBUG
332  _print("WorkshopItem.Rate(%1)", newRating);
333  #endif
334 
335  m_Item.Rate(newRating, null);
336 
337  #ifdef WORKSHOP_DEBUG
338  _print("OnChanged: SetMyRating()");
339  #endif
340 
341  SetChanged();
342  }
343 
344 
345  //-----------------------------------------------------------------------------------------------
346  void ResetMyRating()
347  {
348  if (!m_Item)
349  return;
350 
351  m_bMyRatingSet = false;
352 
353  #ifdef WORKSHOP_DEBUG
354  _print("WorkshopItem.ResetRating()");
355  #endif
356 
357  m_Item.ResetRating(null);
358 
359  #ifdef WORKSHOP_DEBUG
360  _print("OnChanged: ResetMyRating()");
361  #endif
362 
363  SetChanged();
364  }
365 
366 
367  //-----------------------------------------------------------------------------------------------
368  void GetMyRating(out bool ratingSet, out bool rating)
369  {
370  ratingSet = m_bMyRatingSet;
371  rating = m_bMyRating;
372  }
373 
374 
375  //-----------------------------------------------------------------------------------------------
376  void SetFavourite(bool favourite)
377  {
378  if (!m_Item)
379  return;
380 
381  m_bFavourite = true;
382 
383  m_Item.SetFavorite(NULL,favourite);
384  m_bFavourite = favourite;
385 
386  #ifdef WORKSHOP_DEBUG
387  _print("OnChanged: SetFavourite()");
388  #endif
389 
390  SetChanged();
391  }
392 
393 
394  //-----------------------------------------------------------------------------------------------
395  bool GetFavourite()
396  {
397  return m_bFavourite;
398  }
399 
400  //-----------------------------------------------------------------------------------------------
401  void SetSubscribed(bool subscribe)
402  {
403  if (!m_Item)
404  return;
405 
406  if (subscribe)
407  m_Item.Subscribe(null);
408  else
409  m_Item.Unsubscribe(null);
410 
411  m_bSubscribed = subscribe;
412 
413  #ifdef WORKSHOP_DEBUG
414  _print("OnChanged: Subscribe()");
415  #endif
416 
417  SetChanged();
418  }
419 
420  //-----------------------------------------------------------------------------------------------
421  bool GetSubscribed()
422  {
423  return m_bSubscribed;
424  }
425 
426  //-----------------------------------------------------------------------------------------------
427  void SetEnabled(bool enable)
428  {
429  if (!GetOffline())
430  return;
431 
432  m_Item.Enable(enable);
433 
434  #ifdef WORKSHOP_DEBUG
435  _print("OnChanged: SetEnabled()");
436  #endif
437 
438  if (enable)
439  m_Item.NotifyPlay();
440 
441  SetChanged();
442  }
443 
444 
445  //-----------------------------------------------------------------------------------------------
447  void SetDependenciesEnabled(bool enable)
448  {
449  if (!m_aDependencies)
450  return;
451 
452  // Check for missing dependencies
453  array<ref SCR_WorkshopItem> missing = SCR_AddonManager.GetInstance().SelectItemsBasic(m_aDependencies, EWorkshopItemQuery.NOT_OFFLINE);
454  if (!missing.IsEmpty())
455  {
456 
457  return;
458  }
459 
460  // Enable all
461  foreach (auto dep : m_aDependencies)
462  {
463  if (dep.GetOffline() && dep.GetEnabled() != enable)
464  {
465  dep.SetEnabled(enable);
466  }
467  }
468  }
469 
470  //-----------------------------------------------------------------------------------------------
471  bool GetEnabled()
472  {
473  if (!m_Item)
474  return false;
475 
476  if (!GetOffline())
477  return false;
478 
479  return m_Item.IsEnabled();
480  }
481 
482 
483  //-----------------------------------------------------------------------------------------------
485  bool GetLoaded()
486  {
487  if (!m_Item)
488  return false;
489 
490  return m_Item.IsLoaded();
491  }
492 
493  //-----------------------------------------------------------------------------------------------
494  bool GetBlocked()
495  {
496  if (m_Item)
497  {
498  int accessState = m_Item.GetAccessState();
499  return accessState & EWorkshopItemAccessState.EWASTATE_BLOCKED;
500  }
501  else
502  return false;
503  }
504 
505  //-----------------------------------------------------------------------------------------------
506  bool GetReportedByMe()
507  {
508  if (m_Item)
509  return m_Item.GetAccessState() & EWorkshopItemAccessState.EWASTATE_REPORTED;
510  else
511  return false;
512  }
513 
514  //-----------------------------------------------------------------------------------------------
515  bool GetModAuthorReportedByMe()
516  {
517  if (m_Item)
518  {
519  WorkshopAuthor author = m_Item.Author();
520 
521  if (author)
522  return author.IsBlocked();
523 
524  return false;
525  }
526 
527  return false;
528  }
529 
530  //-----------------------------------------------------------------------------------------------
532  bool GetRestricted()
533  {
534  return GetBlocked() || GetReportedByMe() || GetModAuthorReportedByMe();
535  }
536 
537  //-----------------------------------------------------------------------------------------------
538  bool DeleteLocally()
539  {
540  if (!m_Item)
541  return false;
542 
543  // Check if addon has download progress
544  Revision downloadingRevision = m_Item.GetDownloadingRevision();
545 
546  if (!downloadingRevision && !GetOffline())
547  return true; // Already deleted
548 
549  m_Item.DeleteLocally();
550 
551  #ifdef WORKSHOP_DEBUG
552  _print("OnChanged: DeleteLocally()");
553  #endif
554 
555  SetChanged();
556 
557  return true;
558  }
559  //-----------------------------------------------------------------------------------------------
560  void DeleteDownloadProgress()
561  {
562  if (!m_Item)
563  return;
564  m_Item.DeleteDownloadProgress();
565  SetChanged();
566  }
567  //-----------------------------------------------------------------------------------------------
568  string GetName()
569  {
570  if (m_Item)
571  return m_Item.Name();
572  else if (m_Dependency)
573  return m_Dependency.GetName();
574  else
575  return string.Empty;
576  }
577 
578  //-----------------------------------------------------------------------------------------------
579  string GetId()
580  {
581  if (m_Item)
582  return m_Item.Id();
583  else if (m_Dependency)
584  return m_Dependency.GetID();
585  else
586  return string.Empty;
587  }
588 
589  //-----------------------------------------------------------------------------------------------
590  string GetAuthorName()
591  {
592  if (m_Item)
593  {
594  WorkshopAuthor author = m_Item.Author();
595 
596  if (author)
597  return author.Name();
598  }
599 
600  return string.Empty;
601  }
602 
603  //-----------------------------------------------------------------------------------------------
605  bool GetOnline()
606  {
607  if (m_Item)
608  return m_Item.GetStateFlags() & EWorkshopItemState.EWSTATE_ONLINE;
609  else if (m_Dependency)
610  return true; // TODO Apparently, if it's a dependency, then it's online
611  else
612  return false;
613  }
614 
615  //-----------------------------------------------------------------------------------------------
617  bool GetOffline()
618  {
619  if (m_Item)
620  return m_Item.GetStateFlags() & EWorkshopItemState.EWSTATE_OFFLINE;
621  else if (m_Dependency)
622  return m_Dependency.IsOffline();
623  else
624  return false;
625  }
626 
627  //-----------------------------------------------------------------------------------------------
629  Revision GetCurrentLocalRevision()
630  {
631  if (m_Item && GetOffline())
632  return m_Item.GetActiveRevision();
633  return null;
634  }
635 
636 
637  //-----------------------------------------------------------------------------------------------
639  bool GetCurrentLocalVersionMatchDependency()
640  {
641  if (!m_Item || !m_Dependency)
642  return false;
643 
644  // Does active version match required?
645  Revision ActiveV = GetCurrentLocalRevision();
646  Revision RequiredV = m_Dependency.GetRevision();
647 
648  return Revision.AreEqual(ActiveV, RequiredV);
649  }
650 
651 
652  //-----------------------------------------------------------------------------------------------
653  bool GetCorrupted()
654  {
655  if (m_Item)
656  return (m_Item.GetStateFlags() & EWorkshopItemState.EWSTATE_CORRUPTED);
657  else if (m_Dependency)
658  return false; // TODO this is not valid for dependency object
659  else
660  return false;
661  }
662 
663  //-----------------------------------------------------------------------------------------------
664  BackendImage GetThumbnail()
665  {
666  if (!m_Item)
667  return null;
668 
669  return m_Item.Thumbnail();
670  }
671 
672  //-----------------------------------------------------------------------------------------------
673  array<BackendImage> GetGallery()
674  {
675  array<BackendImage> gallery = {};
676 
677  if (!m_Item)
678  return gallery;
679 
680  m_Item.Gallery(gallery);
681  return gallery;
682  }
683 
684  //-----------------------------------------------------------------------------------------------
685  string GetDescription()
686  {
687  if (!m_Item)
688  return string.Empty;
689 
690  return m_Item.Description();
691  }
692 
693  //-----------------------------------------------------------------------------------------------
694  string GetSummary()
695  {
696  if (!m_Item)
697  return string.Empty;
698 
699  return m_Item.Summary();
700  }
701 
702  //-----------------------------------------------------------------------------------------------
703  int GetRatingCount()
704  {
705  if (!m_Item)
706  return 0;
707 
708  return m_Item.RatingCount();
709  }
710 
711  //-----------------------------------------------------------------------------------------------
712  float GetSizeBytes()
713  {
714  if (m_Item)
715  return m_Item.GetSizeBytes();
716  else if(m_Dependency)
717  return m_Dependency.TotalFileSize();
718  else
719  return 0;
720  }
721 
722  //-----------------------------------------------------------------------------------------------
723  float GetAverageRating()
724  {
725  if (!m_Item)
726  return 0;
727 
728  return m_Item.AverageRating();
729  }
730 
731  //-----------------------------------------------------------------------------------------------
733  void GetDownloadState(out bool inProgress, out bool paused, out float progress, out Revision targetRevision)
734  {
735  if (!m_ActionDownload || !m_Item)
736  {
737  inProgress = false;
738  paused = false;
739  progress = 0;
740  targetRevision = null;
741  return;
742  }
743 
744  inProgress = m_ActionDownload.IsActive() || m_ActionDownload.IsPaused();
745  paused = m_ActionDownload.IsPaused();
746  progress = m_Item.GetProgress();
747  targetRevision = m_ActionDownload.GetTargetRevision();
748  }
749 
750  //-----------------------------------------------------------------------------------------------
752  SCR_WorkshopItemActionDownload GetDownloadAction()
753  {
754  return m_ActionDownload;
755  }
756 
757  //-----------------------------------------------------------------------------------------------
759  SCR_WorkshopItemActionComposite GetDependencyCompositeAction()
760  {
761  return m_ActionDependency;
762  }
763 
764  //-----------------------------------------------------------------------------------------------
766  bool GetUpdateAvailable()
767  {
768  bool rawUpdateAvailable = false;
769  if (m_Item)
770  rawUpdateAvailable = !m_Item.HasLatestVersion();
771 
772  bool updateAvailableByVersions = Internal_GetUpdateAvailable();
773 
774  return rawUpdateAvailable || updateAvailableByVersions;
775  }
776 
777  //-----------------------------------------------------------------------------------------------
779  array<ref SCR_WorkshopItem> GetMissingDependencies()
780  {
781  array<ref SCR_WorkshopItem> dependencies = GetLatestDependencies();
782 
783  return SCR_AddonManager.SelectItemsBasic(dependencies, EWorkshopItemQuery.NOT_OFFLINE);
784  }
785 
786  //-----------------------------------------------------------------------------------------------
787  bool GetAnyDependencyMissing()
788  {
789  if (!m_aDependencies)
790  return false;
791 
792  bool count = SCR_AddonManager.CountItemsBasic(m_aDependencies, EWorkshopItemQuery.NOT_OFFLINE, true);
793  return count;
794  }
795 
796  //-----------------------------------------------------------------------------------------------
797  bool GetAnyDependencyUpdateAvailable()
798  {
799  if (!m_aDependencies)
800  return false;
801 
802  bool count = SCR_AddonManager.CountItemsBasic(m_aDependencies, EWorkshopItemQuery.UPDATE_AVAILABLE, true);
803  return count;
804  }
805 
806  //-----------------------------------------------------------------------------------------------
808  bool GetEnabledAndAnyDependencyDisabled()
809  {
810  if (!m_aDependencies)
811  return false;
812 
813  if (!GetEnabled())
814  return false;
815 
816  bool count = SCR_AddonManager.CountItemsAnd(m_aDependencies, EWorkshopItemQuery.NOT_ENABLED | EWorkshopItemQuery.OFFLINE, true);
817  return count;
818  }
819 
820  //-----------------------------------------------------------------------------------------------
824  EWorkshopItemProblem GetHighestPriorityProblem()
825  {
826  if (!GetOffline())
827  return EWorkshopItemProblem.NO_PROBLEM;
828 
829  if (GetAnyDependencyMissing())
830  return EWorkshopItemProblem.DEPENDENCY_MISSING;
831  else if (GetEnabledAndAnyDependencyDisabled())
832  return EWorkshopItemProblem.DEPENDENCY_DISABLED;
833  else if (GetUpdateAvailable())
834  return EWorkshopItemProblem.UPDATE_AVAILABLE;
835  else if (GetAnyDependencyUpdateAvailable())
836  return EWorkshopItemProblem.DEPENDENCY_OUTDATED;
837 
838  return EWorkshopItemProblem.NO_PROBLEM;
839  }
840 
841  //-----------------------------------------------------------------------------------------------
843  array<ref SCR_WorkshopItem> GetOutdatedDependencies()
844  {
845  array<ref SCR_WorkshopItem> dependencies = GetLatestDependencies();
846 
847  if (dependencies.IsEmpty())
848  return new array<ref SCR_WorkshopItem>;
849 
850  return SCR_AddonManager.SelectItemsBasic(dependencies, EWorkshopItemQuery.UPDATE_AVAILABLE);
851  }
852 
853 
854  //-----------------------------------------------------------------------------------------------
855  int GetTimeSinceLastPlay()
856  {
857  if (!m_Item)
858  return -1;
859 
860  return m_Item.GetTimeSinceLastPlay();
861  }
862 
863 
864  //-----------------------------------------------------------------------------------------------
865  int GetTimeSinceFirstDownload()
866  {
867  if (!m_Item)
868  return -1;
869 
870  return m_Item.GetTimeSinceFirstDownload();
871  }
872 
873  //-----------------------------------------------------------------------------------------------
877  protected SCR_WorkshopItemActionDownload DownloadRevision(Revision targetRevision, bool isDownloadRunning)
878  {
879  if (!m_Item && !m_Dependency)
880  return null;
881 
882  bool latestRevision = (targetRevision == null);
883 
884  // Create new download
885  if (!m_ActionDownload)
886  {
887  m_ActionDownload = new SCR_WorkshopItemActionDownload(this, latestRevision, targetRevision);
888  SCR_AddonManager.GetInstance().Internal_OnNewDownload(this, m_ActionDownload);
889 
890  return m_ActionDownload;
891  }
892 
893  // Check if same download is running
894  if (isDownloadRunning)
895  {
896  // Same kind of download is already running
897  return m_ActionDownload; // TODO if action was canceled or failed, create a new one
898  }
899 
900  // Another download is running, but downloading a different version
901  m_ActionDownload.Cancel();
902  m_ActionDownload.Internal_Detach();
903  m_ActionDownload = null;
904 
905  m_ActionDownload = new SCR_WorkshopItemActionDownload(this, latestVersion: latestRevision, targetRevision);
906  SCR_AddonManager.GetInstance().Internal_OnNewDownload(this, m_ActionDownload);
907  return m_ActionDownload;
908  }
909 
910  //-----------------------------------------------------------------------------------------------
922  SCR_WorkshopItemActionDownload Download(notnull Revision targetRevision)
923  {
924  #ifdef WORKSHOP_DEBUG
925  if (targetRevision)
926  _print(string.Format("Download: %1", targetRevision.GetVersion()));
927  else
928  _print(string.Format("Download: the latest one"));
929  #endif
930 
931  bool running = false;
932  if (m_ActionDownload && targetRevision)
933  running = Revision.AreEqual(m_ActionDownload.GetTargetRevision(), targetRevision);
934 
935  return DownloadRevision(targetRevision, running);
936  }
937 
938  //-----------------------------------------------------------------------------------------------
939  SCR_WorkshopItemActionDownload DownloadLatestVersion()
940  {
941  #ifdef WORKSHOP_DEBUG
942  _print("DownloadLatestVersion()");
943  #endif
944 
945  Revision latestRevision = GetLatestRevision(); // Might return empty string if revs not loaded!
946 
947  bool running = false;
948  if (m_ActionDownload && latestRevision)
949  running = m_ActionDownload.GetTargetedAtLatestVersion() || Revision.AreEqual(latestRevision, m_ActionDownload.GetTargetRevision());
950 
951  return DownloadRevision(null, running);
952  }
953 
954  //-----------------------------------------------------------------------------------------------
955  void RetryDownload(Revision targetRevision)
956  {
957  if (!m_ActionDownload)
958  m_ActionDownload = new SCR_WorkshopItemActionDownload(this, latestVersion: false, targetRevision);
959 
960  SCR_AddonManager.GetInstance().Internal_OnNewDownload(this, m_ActionDownload);
961 
962  m_ActionDownload.Activate();
963  }
964 
965  //-----------------------------------------------------------------------------------------------
969  SCR_WorkshopItemActionDownloadDependenciesLatest DownloadDependenciesLatest(array<ref SCR_WorkshopItem> dependencies)
970  {
971  #ifdef WORKSHOP_DEBUG
972  _print("DownloadDependenciesLatest()");
973  #endif
974 
975  if (!m_Item)
976  return null;
977 
978  if (m_ActionDependency)
979  {
980  auto action = SCR_WorkshopItemActionDownloadDependenciesLatest.Cast(m_ActionDependency);
981  if (action)
982  {
983  // Download action with dependencies is running
984  return action;
985  }
986  else
987  {
988  // Another kind of action with dependencies is running, cancel it
989  m_ActionDependency.Cancel();
990  m_ActionDependency.Internal_Detach();
991  m_ActionDependency = null;
992 
993  action = new SCR_WorkshopItemActionDownloadDependenciesLatest(this, dependencies);
994  m_ActionDependency = action;
995  return action;
996  }
997  }
998  else
999  {
1000  auto action = new SCR_WorkshopItemActionDownloadDependenciesLatest(this, dependencies);
1001  m_ActionDependency = action;
1002  return action;
1003  }
1004  }
1005 
1006  //-----------------------------------------------------------------------------------------------
1008  bool PauseDownload()
1009  {
1010  if (!m_Item)
1011  return false;
1012 
1013  if (m_ActionDownload)
1014  {
1015  return m_ActionDownload.Pause();
1016  }
1017 
1018  return false;
1019  }
1020 
1021  //-----------------------------------------------------------------------------------------------
1023  bool CancelDownload()
1024  {
1025  if (!m_Item)
1026  return false;
1027 
1028  if (m_ActionDownload)
1029  {
1030  return m_ActionDownload.Cancel();
1031  }
1032 
1033  return false;
1034  }
1035 
1036  //-----------------------------------------------------------------------------------------------
1038  bool ResumeDownload()
1039  {
1040  if (!m_Item)
1041  return false;
1042 
1043  if (m_ActionDownload)
1044  {
1045  return m_ActionDownload.Resume();
1046  }
1047 
1048  return false;
1049  }
1050 
1051 
1052  //-----------------------------------------------------------------------------------------------
1059  SCR_WorkshopItemActionReport Report(EWorkshopReportType eReport, string sMessage)
1060  {
1061  if (!m_Item)
1062  return null;
1063 
1064  if (m_ActionReport)
1065  {
1066  // We can't abort it or change while it's being sent anyway,
1067  // Return the existing action
1068  return m_ActionReport;
1069  }
1070  else
1071  {
1072  m_ActionReport = new SCR_WorkshopItemActionReport(this, eReport, sMessage);
1073  return m_ActionReport;
1074  }
1075  }
1076 
1077  //-----------------------------------------------------------------------------------------------
1079  void LoadReport()
1080  {
1081  if (!m_Item)
1082  return;
1083 
1084  if (!m_CallbackLoadMyReport)
1085  {
1086  m_CallbackLoadMyReport = new SCR_WorkshopItemCallback_LoadMyReport();
1087  m_CallbackLoadMyReport.m_OnSuccess.Insert(Callback_LoadMyReport_OnSuccess);
1088  m_CallbackLoadMyReport.m_OnTimeout.Insert(Callback_LoadMyReport_OnTimeout);
1089  m_CallbackLoadMyReport.m_OnError.Insert(Callback_LoadMyReport_OnError);
1090  }
1091 
1092  m_Item.LoadReport(m_CallbackLoadMyReport);
1093  }
1094 
1095 
1096  //-----------------------------------------------------------------------------------------------
1099  void GetReport(out EWorkshopReportType reportType, out string reportDescription)
1100  {
1101  if (!m_Item)
1102  {
1103  reportType = EWorkshopReportType.EWREPORT_OTHER;
1104  reportDescription = string.Empty;
1105  return;
1106  }
1107 
1108  reportType = m_Item.GetReportType();
1109  reportDescription = m_Item.GetReportDescription();
1110  }
1111 
1112 
1113  //-----------------------------------------------------------------------------------------------
1115  SCR_WorkshopItemActionCancelReport CancelReport()
1116  {
1117  if (!m_Item)
1118  return null;
1119 
1120  if (m_ActionReport)
1121  {
1122  // We can't abort it or change while it's being sent anyway,
1123  // Return the existing action
1124  return m_ActionCancelReport;
1125  }
1126  else
1127  {
1128  m_ActionCancelReport = new SCR_WorkshopItemActionCancelReport(this);
1129  return m_ActionCancelReport;
1130  }
1131  }
1132 
1133  //-----------------------------------------------------------------------------------------------
1135  SCR_WorkshopItemActionAddAuthorBlock AddAuthorBlock()
1136  {
1137  if (!m_Item)
1138  return null;
1139 
1140  if (!m_ActionAddAuthorBlock)
1141  m_ActionAddAuthorBlock = new SCR_WorkshopItemActionAddAuthorBlock(this);
1142 
1143  return m_ActionAddAuthorBlock;
1144  }
1145 
1146  //-----------------------------------------------------------------------------------------------
1148  SCR_WorkshopItemActionRemoveAuthorBlock RemoveAuthorBlock()
1149  {
1150  if (!m_Item)
1151  return null;
1152 
1153  if (!m_ActionRemoveAuthorBlock)
1154  m_ActionRemoveAuthorBlock = new SCR_WorkshopItemActionRemoveAuthorBlock(this);
1155 
1156  return m_ActionRemoveAuthorBlock;
1157  }
1158 
1159  //-----------------------------------------------------------------------------------------------
1161  Revision FindRevision(string version)
1162  {
1163  if (!m_aRevisions)
1164  return null;
1165 
1166  foreach (Revision r : m_aRevisions)
1167  {
1168  if (r.GetVersion() == version)
1169  return r;
1170  }
1171 
1172  return null;
1173  }
1174 
1175  //-----------------------------------------------------------------------------------------------
1176  // P R O T E C T E D / P R I V A T E
1177  //-----------------------------------------------------------------------------------------------
1178 
1179 
1180  //-----------------------------------------------------------------------------------------------
1181  Revision GetLatestRevision()
1182  {
1183  if (!m_Item)
1184  return null;
1185 
1186  return m_Item.GetLatestRevision();
1187  }
1188 
1189 
1190  //-----------------------------------------------------------------------------------------------
1191  // C A L L B A C K S
1192  //-----------------------------------------------------------------------------------------------
1193 
1194 
1195  // --- Ask Details ---
1196 
1197  //-----------------------------------------------------------------------------------------------
1198  protected void Callback_AskDetails_OnGetAsset()
1199  {
1200  #ifdef WORKSHOP_DEBUG
1201  _print("Callback_AskDetails_OnGetAsset()");
1202  #endif
1203 
1204  TryLoadItemFromDependency();
1205 
1206  TryLoadRevisions();
1207 
1208  if (!m_aRevisions || m_aRevisions.IsEmpty())
1209  {
1210  #ifdef WORKSHOP_DEBUG
1211  _print("Callback_AskDetails_OnGetAsset(): Received no revisions", LogLevel.ERROR);
1212  #endif
1213  }
1214  else
1215  {
1216  #ifdef WORKSHOP_DEBUG
1217  _print("Callback_AskDetails_OnGetAsset(): Received revisions:");
1218  array<string> versions = GetVersions();
1219  foreach (string ver : versions)
1220  {
1221  _print(string.Format("Callback_AskDetails_OnGetAsset(): %1", ver));
1222  }
1223  #endif
1224 
1225  if (!m_CallbackLoadDependencies)
1226  {
1227  m_CallbackLoadDependencies = new SCR_WorkshopItemCallback_LoadDependencies;
1228  m_CallbackLoadDependencies.m_OnSuccess.Insert(Callback_LoadDependencies_OnSuccess);
1229  m_CallbackLoadDependencies.m_OnError.Insert(Callback_LoadDependencies_OnError);
1230  m_CallbackLoadDependencies.m_OnTimeout.Insert(Callback_LoadDependencies_OnTimeout);
1231  }
1232 
1233  if (!m_CallbackLoadScenarios)
1234  {
1235  m_CallbackLoadScenarios = new SCR_WorkshopItemCallback_LoadScenarios;
1236  m_CallbackLoadScenarios.m_OnSuccess.Insert(Callback_LoadScenarios_OnSuccess);
1237  m_CallbackLoadScenarios.m_OnError.Insert(Callback_LoadScenarios_OnError);
1238  m_CallbackLoadScenarios.m_OnTimeout.Insert(Callback_LoadScenarios_OnTimeout);
1239  }
1240 
1241  if (m_Item)
1242  {
1243  Revision latestRevision = GetLatestRevision();
1244  m_Item.LoadDependencies(m_CallbackLoadDependencies, latestRevision);
1245  m_Item.LoadScenarios(m_CallbackLoadScenarios, latestRevision);
1246  }
1247  }
1248 
1249  m_bDetailsLoaded = true;
1250  m_OnGetAsset.Invoke(this);
1251 
1252  #ifdef WORKSHOP_DEBUG
1253  _print("OnChanged: Callback_AskDetails_OnGetAsset");
1254  #endif
1255 
1256  SetChanged();
1257 
1258  m_bWaitingLoadDetails = false;
1259  }
1260 
1261 
1262  //-----------------------------------------------------------------------------------------------
1263  protected void Callback_AskDetails_OnTimeout()
1264  {
1265  #ifdef WORKSHOP_DEBUG
1266  _print("Callback_AskDetails_OnTimeout()");
1267  #endif
1268 
1269  m_bWaitingLoadDetails = false;
1270 
1271  m_OnTimeout.Invoke(this);
1272  }
1273 
1274  //-----------------------------------------------------------------------------------------------
1275  protected void Callback_AskDetails_OnError(SCR_WorkshopCallbackBase callback, EBackendError code, int restCode, int apiCode )
1276  {
1277  m_bRequestFailed = true;
1278  m_bWaitingLoadDetails = false;
1279 
1280  // We still have received a response, but with an error.
1281  m_OnGetAsset.Invoke(this);
1282 
1283  SetChanged();
1284 
1285  //CustomDebugError("SCR_WorkshopItem failed to load details");
1286  }
1287 
1288 
1289  //-----------------------------------------------------------------------------------------------
1290  protected void Callback_LoadDependencies_OnSuccess()
1291  {
1292  #ifdef WORKSHOP_DEBUG
1293  _print("Callback_LoadDependencies_OnSuccess()");
1294  #endif
1295 
1296  TryLoadDependencies(); // For now we support only dependencies of latest version
1297  }
1298 
1299  //-----------------------------------------------------------------------------------------------
1300  protected void Callback_LoadDependencies_OnError()
1301  {
1302  #ifdef WORKSHOP_DEBUG
1303  _print("Callback_LoadDependencies_OnError()");
1304  #endif
1305 
1306  m_OnError.Invoke(this);
1307 
1308  CustomDebugError("SCR_WorkshopItem failed to load dependencies");
1309  }
1310 
1311  //-----------------------------------------------------------------------------------------------
1312  protected void Callback_LoadDependencies_OnTimeout()
1313  {
1314  #ifdef WORKSHOP_DEBUG
1315  _print("Callback_LoadDependencies_OnTimeout()");
1316  #endif
1317 
1318  m_OnTimeout.Invoke(this);
1319  }
1320 
1321 
1322  //-----------------------------------------------------------------------------------------------
1323  protected void Callback_LoadScenarios_OnSuccess()
1324  {
1325  #ifdef WORKSHOP_DEBUG
1326  _print("Callback_LoadScenarios_OnSuccess()");
1327  #endif
1328 
1329  TryLoadScenarios();
1330  }
1331 
1332  //-----------------------------------------------------------------------------------------------
1333  protected void Callback_LoadScenarios_OnError()
1334  {
1335  #ifdef WORKSHOP_DEBUG
1336  _print("Callback_LoadScenarios_OnError()");
1337  #endif
1338 
1339  m_OnError.Invoke(this);
1340 
1341  CustomDebugError("SCR_WorkshopItem failed to load scenarios");
1342  }
1343 
1344  //-----------------------------------------------------------------------------------------------
1345  protected void Callback_LoadScenarios_OnTimeout()
1346  {
1347  #ifdef WORKSHOP_DEBUG
1348  _print("Callback_LoadScenarios_OnTimeout()");
1349  #endif
1350 
1351  m_OnTimeout.Invoke(this);
1352  }
1353 
1354 
1355  //-----------------------------------------------------------------------------------------------
1356  protected void Callback_LoadMyReport_OnSuccess()
1357  {
1358  m_OnMyReportLoaded.Invoke(this);
1359  }
1360 
1361  //-----------------------------------------------------------------------------------------------
1362  protected void Callback_LoadMyReport_OnError()
1363  {
1364  m_OnMyReportLoadError.Invoke(this);
1365  }
1366 
1367  //-----------------------------------------------------------------------------------------------
1368  protected void Callback_LoadMyReport_OnTimeout()
1369  {
1370  m_OnMyReportLoadError.Invoke(this);
1371  }
1372 
1373  //-----------------------------------------------------------------------------------------------
1374  protected void TryLoadItemFromDependency()
1375  {
1376  // Try to get WorkshopItem from Dependency, if we have only Dependency
1377  if (!m_Item && m_Dependency)
1378  {
1379  m_Item = m_Dependency.GetCachedItem();
1380 
1381  if (m_Item)
1382  {
1383  UpdateStateFromWorkshopItem();
1384  }
1385 
1386  #ifdef WORKSHOP_DEBUG
1387  if (m_Item)
1388  _print(string.Format("WorkshopItem was missing, but was loaded: %1", m_Item.Name()));
1389  #endif
1390  }
1391  }
1392 
1393 
1394  //-----------------------------------------------------------------------------------------------
1395  protected void TryLoadRevisions(bool log = true)
1396  {
1397  if (!m_Item)
1398  return;
1399 
1400  array<Revision> revisionsTemp = new array<Revision>;
1401  m_Item.GetRevisions(revisionsTemp);
1402 
1403  if (revisionsTemp.IsEmpty() && m_Dependency)
1404  revisionsTemp.Insert(m_Dependency.GetRevision());
1405 
1406  if (revisionsTemp.IsEmpty())
1407  {
1408  #ifdef WORKSHOP_DEBUG
1409  if (log)
1410  _print(string.Format("Revisions are not loaded yet. Revision array is empty."));
1411  #endif
1412 
1413  return;
1414  }
1415 
1416  // The revision array is not empty, so we can store it
1417  // When m_aRevisions is not null, it means revisions are loaded
1418  m_aRevisions = revisionsTemp;
1419  }
1420 
1421  //-----------------------------------------------------------------------------------------------
1422  array<ref SCR_WorkshopItem> GetLoadedDependencies()
1423  {
1424  return m_aDependencies;
1425  }
1426 
1427  //-----------------------------------------------------------------------------------------------
1428  protected void TryLoadDependencies(bool log = true)
1429  {
1430  #ifdef WORKSHOP_DEBUG
1431  if (log)
1432  _print("TryLoadDependencies()");
1433  #endif
1434 
1435 
1436  // Get array of dependencies - TODO: differentiate between dependencies version to load
1437  Revision latestRevision = GetLatestRevision();
1438  array<Dependency> dependencies = new array<Dependency>;
1439  latestRevision.GetDependencies(dependencies);
1440 
1441  if (!m_aDependencies)
1442  m_aDependencies = new array<ref SCR_WorkshopItem>;
1443 
1444  m_aDependencies.Clear();
1445 
1446  foreach (Dependency dep : dependencies)
1447  {
1448  SCR_WorkshopItem registeredItem = SCR_AddonManager.GetInstance().Register(dep);
1449 
1450  RegisterDependency(registeredItem);
1451  registeredItem.RegisterDependent(this);
1452  }
1453 
1454  m_OnDependenciesLoaded.Invoke(this);
1455  }
1456 
1457 
1458 
1459  //-----------------------------------------------------------------------------------------------
1460  protected void TryLoadScenarios(bool log = true)
1461  {
1462  #ifdef WORKSHOP_DEBUG
1463  if (log)
1464  _print("TryLoadScenarios()");
1465  #endif
1466 
1467  // Load scenarios of latest revision
1468  Revision latestRevision = GetLatestRevision();
1469 
1470  m_aMissions = new array<MissionWorkshopItem>;
1471  latestRevision.GetScenarios(m_aMissions);
1472 
1473  #ifdef WORKSHOP_DEBUG
1474  _print(string.Format("TryLoadScenarios(): Received %1 scenarios", m_aMissions.Count()));
1475  _print("OnChanged: Callback_AskDetails_OnGetScenarios");
1476  #endif
1477 
1478  SetChanged();
1479 
1480  m_OnScenariosLoaded.Invoke(this);
1481  }
1482 
1483 
1484 
1485  //-----------------------------------------------------------------------------------------------
1486  protected void RegisterDependency(SCR_WorkshopItem item)
1487  {
1488  int id = m_aDependencies.Find(item);
1489  if (id == -1)
1490  m_aDependencies.Insert(item);
1491  }
1492 
1493 
1494  //-----------------------------------------------------------------------------------------------
1495  protected void UnregisterDependency(SCR_WorkshopItem item)
1496  {
1497  m_aDependencies.RemoveItem(item);
1498  }
1499 
1500 
1501  //-----------------------------------------------------------------------------------------------
1502  protected void RegisterDependent(SCR_WorkshopItem item)
1503  {
1504  int id = m_aDependent.Find(item);
1505  if (id == -1)
1506  m_aDependent.Insert(item);
1507  }
1508 
1509 
1510  //-----------------------------------------------------------------------------------------------
1511  protected void UnregisterDependent(SCR_WorkshopItem item)
1512  {
1513  m_aDependent.RemoveItem(item);
1514  }
1515 
1516  //-----------------------------------------------------------------------------------------------
1517  //-----------------------------------------------------------------------------------------------
1518  //-----------------------------------------------------------------------------------------------
1519 
1520 
1521 
1522 
1523 
1524 
1525 
1526 
1527 
1528 
1529  //-----------------------------------------------------------------------------------------------
1530  // I N T E R A C T I O N S W I T H W O R K S H O P A P I
1531  //-----------------------------------------------------------------------------------------------
1532 
1533  //-----------------------------------------------------------------------------------------------
1534  bool Internal_StartDownload(notnull Revision targetRevision, BackendCallback callback)
1535  {
1536  #ifdef WORKSHOP_DEBUG
1537  _print(string.Format("Internal_StartDownload(): %1, %2", targetRevision.GetVersion(), callback));
1538  #endif
1539 
1540  // Check privileges
1541  if (!SCR_AddonManager.GetInstance().GetUgcPrivilege())
1542  {
1543  #ifdef WORKSHOP_DEBUG
1544  _print("Internal_StartDownload(): UGC privileges were not checked or false!");
1545  #endif
1546  return false;
1547  }
1548 
1549 
1550  #ifdef WORKSHOP_DEBUG
1551  _print("Internal_StartDownload(): Calling WorkshopItem.Download ...");
1552  #endif
1553 
1554  if (!m_Item)
1555  {
1556  if (!m_Dependency)
1557  {
1558  return false;
1559  }
1560  m_Dependency.Download(callback);
1561  }
1562  else
1563  m_Item.Download(callback, targetRevision);
1564 
1565  return true;
1566  }
1567 
1568  //-----------------------------------------------------------------------------------------------
1569  bool Internal_CancelDownload()
1570  {
1571  // Check
1572  #ifdef WORKSHOP_DEBUG
1573  _print("Internal_CancelDownload()");
1574  #endif
1575 
1576  if (!m_Item)
1577  return false;
1578 
1579  // Pause
1580  m_CancelDownloadCallback.GetEventOnResponse().Insert(OnCancelDownloadResponse);
1581  m_Item.Cancel(m_CancelDownloadCallback);
1582  return true;
1583  }
1584 
1585  //-----------------------------------------------------------------------------------------------
1586  protected void OnCancelDownloadResponse(SCR_BackendCallback callback)
1587  {
1588  m_CancelDownloadCallback.GetEventOnResponse().Remove(OnCancelDownloadResponse);
1589 
1590  if (callback.GetResponseType() != EBackendCallbackResponse.SUCCESS)
1591  {
1592  m_OnError.Invoke(this);
1593  }
1594 
1595  m_OnCanceled.Invoke(this);
1596  }
1597 
1598  /*
1599  protected ref SCR_BackendCallback m_PauseDownloadCallback = new SCR_BackendCallback();
1600  protected ref bool m_bRunningRequested;
1601  protected ref bool m_bRunningProccessed;
1602 
1603  //-----------------------------------------------------------------------------------------------
1604  bool Internal_PauseDownload()
1605  {
1606  // Check
1607  #ifdef WORKSHOP_DEBUG
1608  _print("Internal_PauseDownload()");
1609  #endif
1610 
1611  if (!m_Item)
1612  return false;
1613 
1614  // Pause
1615  m_bRunningRequested = false;
1616 
1617  m_PauseDownloadCallback.GetEventOnResponse().Insert(OnPauseDownloadResponse);
1618  m_Item.PauseDownload(m_PauseDownloadCallback);
1619  return true;
1620  }
1621 
1622  //-----------------------------------------------------------------------------------------------
1623  protected void OnPauseDownloadResponse(SCR_BackendCallback callback)
1624  {
1625  m_PauseDownloadCallback.GetEventOnResponse().Remove(OnPauseDownloadResponse);
1626  m_bRunningProccessed = false;
1627  }
1628 
1629  //-----------------------------------------------------------------------------------------------
1630  bool Internal_ResumeDownload(BackendCallback callback)
1631  {
1632  #ifdef WORKSHOP_DEBUG
1633  _print("Internal_ResumeDownload()");
1634  #endif
1635 
1636  if (!m_Item)
1637  return false;
1638 
1639  // Resume
1640  m_bRunningRequested = true;
1641 
1642  m_Item.ResumeDownload(callback);
1643  return true;
1644  }
1645  */
1646 
1647  //-----------------------------------------------------------------------------------------------
1648  bool Internal_Report(EWorkshopReportType eReport, string sMessage, BackendCallback callback)
1649  {
1650  #ifdef WORKSHOP_DEBUG
1651  _print(string.Format("Internal_Report(): %1, %2, %3", eReport, sMessage, callback));
1652  #endif
1653 
1654  if (!m_Item)
1655  return false;
1656 
1657  m_Item.Report(eReport, sMessage, callback);
1658 
1659  #ifdef WORKSHOP_DEBUG
1660  _print("OnChanged: Internal_Report()");
1661  #endif
1662 
1663  SetChanged();
1664 
1665  return true;
1666  }
1667 
1668 
1669  //-----------------------------------------------------------------------------------------------
1670  bool Internal_CancelReport(BackendCallback callback)
1671  {
1672  #ifdef WORKSHOP_DEBUG
1673  _print(string.Format("Internal_CancelReport(): %1", callback));
1674  #endif
1675 
1676  if (!m_Item)
1677  return false;
1678 
1679  m_Item.CancelReport(callback);
1680 
1681  #ifdef WORKSHOP_DEBUG
1682  _print("OnChanged: Internal_CancelReport()");
1683  #endif
1684 
1685  SetChanged();
1686 
1687  return true;
1688  }
1689 
1690  //-----------------------------------------------------------------------------------------------
1691  bool Internal_AddAuthorBlock(BackendCallback callback)
1692  {
1693  #ifdef WORKSHOP_DEBUG
1694  _print(string.Format("Internal_AddAuthorBlock(): %1", callback));
1695  #endif
1696 
1697  if (!m_Item)
1698  return false;
1699 
1700  WorkshopAuthor author = m_Item.Author();
1701  if (!author)
1702  return false;
1703 
1704  author.AddBlock(callback);
1705 
1706  #ifdef WORKSHOP_DEBUG
1707  _print("OnChanged: Internal_AddAuthorBlock()");
1708  #endif
1709 
1710  SetChanged();
1711 
1712  return true;
1713  }
1714 
1715  //-----------------------------------------------------------------------------------------------
1716  bool Internal_RemoveAuthorBlock(BackendCallback callback)
1717  {
1718  #ifdef WORKSHOP_DEBUG
1719  _print(string.Format("Internal_RemoveAuthorBlock(): %1", callback));
1720  #endif
1721 
1722  if (!m_Item)
1723  return false;
1724 
1725  WorkshopAuthor author = m_Item.Author();
1726  if (!author)
1727  return false;
1728 
1729  author.RemoveBlock(callback);
1730 
1731  #ifdef WORKSHOP_DEBUG
1732  _print("OnChanged: Internal_RemoveAuthorBlock()");
1733  #endif
1734 
1735  SetChanged();
1736 
1737  return true;
1738  }
1739 
1740  //-----------------------------------------------------------------------------------------------
1742  void Internal_Update(float timeSlice)
1743  {
1744  // Check if we are waiting for dependencies or revisions
1745  /*
1746  if (!GetRevisionsLoaded())
1747  TryLoadRevisions(false);
1748  */
1749  //if (!GetDependenciesLoaded())
1750  // TryLoadDependencies(false);
1751 
1752 
1753  // Update all our current actions
1754  // If our own action are completed, we unref and detach them
1755  // We don't delete the actions so that users can still access them
1756  if (m_ActionDownload)
1757  {
1758 
1759 
1760  m_ActionDownload.Internal_Update(timeSlice);
1761 
1762  float newProgress;
1763  if (m_Item)
1764  newProgress = m_Item.GetProgress();
1765  if (newProgress != m_fPrevDownloadProgress)
1766  {
1767  /*
1768  // Too spammy
1769  #ifdef WORKSHOP_DEBUG
1770  _print(string.Format("OnChanged: Internal_Update: Download Progress Changed: %1", newProgress));
1771  #endif
1772  */
1773  m_fPrevDownloadProgress = newProgress;
1774  }
1775 
1776  if (m_ActionDownload.IsCompleted())
1777  {
1778  #ifdef WORKSHOP_DEBUG
1779  _print("OnChanged: Internal_Update: Download Is Completed");
1780  #endif
1781 
1782  m_ActionDownload.Internal_Detach();
1783  m_ActionDownload = null;
1784  m_OnDownloadComplete.Invoke(this);
1785  SetChanged();
1786  }
1787  else if (m_ActionDownload.IsCanceled())
1788  {
1789  #ifdef WORKSHOP_DEBUG
1790  _print("OnChanged: Internal_Update: Download was canceled, unregistering");
1791  #endif
1792 
1793  m_ActionDownload.Internal_Detach();
1794  m_ActionDownload = null;
1795  SetChanged();
1796  }
1797  else if (m_ActionDownload.IsFailed())
1798  {
1799  #ifdef WORKSHOP_DEBUG
1800  _print("OnChanged: Internal_Update: Download has failed, unregistering");
1801  #endif
1802 
1803  m_ActionDownload.Internal_Detach();
1804  m_ActionDownload = null;
1805  SetChanged();
1806  }
1807  }
1808 
1809  if (m_ActionReport)
1810  {
1811  m_ActionReport.Internal_Update(timeSlice);
1812 
1813  if (m_ActionReport.IsCompleted())
1814  {
1815  m_ActionReport.Internal_Detach();
1816  m_ActionReport = null;
1817 
1818  #ifdef WORKSHOP_DEBUG
1819  _print("OnChanged: Internal_Update: Report Action Was Completed");
1820  #endif
1821 
1822  SetChanged();
1823  m_OnReportStateChanged.Invoke(this, true);
1824  }
1825  }
1826 
1827  if (m_ActionCancelReport)
1828  {
1829  m_ActionCancelReport.Internal_Update(timeSlice);
1830 
1831  if (m_ActionCancelReport.IsCompleted())
1832  {
1833  m_ActionCancelReport.Internal_Detach();
1834  m_ActionCancelReport = null;
1835 
1836  #ifdef WORKSHOP_DEBUG
1837  _print("OnChanged: Internal_Update: Cancel report Action Was Completed");
1838  #endif
1839 
1840  SetChanged();
1841  m_OnReportStateChanged.Invoke(this, false);
1842  }
1843  }
1844 
1845  if (m_ActionDependency)
1846  {
1847  m_ActionDependency.Internal_Update(timeSlice);
1848 
1849  if (m_ActionDependency.IsCompleted())
1850  {
1851  #ifdef WORKSHOP_DEBUG
1852  _print("OnChanged: Internal_Update: Dependency action is completed, unregistering");
1853  #endif
1854 
1855  m_ActionDependency.Internal_Detach();
1856  m_ActionDependency = null;
1857  SetChanged();
1858  return;
1859  }
1860  else if (m_ActionDependency.IsCanceled())
1861  {
1862  #ifdef WORKSHOP_DEBUG
1863  _print("OnChanged: Internal_Update: Dependency action is canceled, unregistering");
1864  #endif
1865 
1866  m_ActionDependency.Internal_Detach();
1867  m_ActionDependency = null;
1868  SetChanged();
1869  }
1870  else if (m_ActionDependency.IsFailed())
1871  {
1872  #ifdef WORKSHOP_DEBUG
1873  _print("OnChanged: Internal_Update: Dependency action has failed, unregistering");
1874  #endif
1875 
1876  m_ActionDependency.Internal_Detach();
1877  m_ActionDependency = null;
1878  SetChanged();
1879  }
1880  }
1881 
1882  // Update mod author block state
1883  UpdateAuthorBlock();
1884 
1885  // Update the offline state
1886  bool offlineNew = GetOffline();
1887  if (offlineNew != m_bOffline)
1888  {
1889  m_OnOfflineStateChanged.Invoke(this, offlineNew);
1890  }
1891  m_bOffline = offlineNew;
1892 
1893  // Update the access state
1894  if (m_Item)
1895  {
1896  int accessState = m_Item.GetAccessState();
1897  if (accessState != m_iAccessState)
1898  {
1899  #ifdef WORKSHOP_DEBUG
1900  _print("OnChanged: Internal_Update: Access state has changed");
1901  #endif
1902  SetChanged();
1903  m_iAccessState = accessState;
1904  }
1905  }
1906 
1907  // Invoke changed script invoker
1908  if (m_bChanged)
1909  {
1910 
1911  #ifdef WORKSHOP_DEBUG
1912  _print(string.Format("Invoking OnChanged: ID: %1, Name: %2", GetId(), GetName()));
1913  #endif
1914 
1915  m_OnChanged.Invoke(this);
1916  m_bChanged = false;
1917 
1918  // Invoke it for dependent addons too
1919  foreach (auto i : m_aDependent)
1920  {
1921  if (i)
1922  {
1923  #ifdef WORKSHOP_DEBUG
1924  _print(string.Format("Invoking OnChanged: ID: %1, Name: %2, for dependent: %3, %4", GetId(), GetName(), i.GetId(), i.GetName()));
1925  #endif
1926  i.m_OnChanged.Invoke(i);
1927  }
1928  }
1929  }
1930  }
1931 
1932  //-----------------------------------------------------------------------------------------------
1934  protected void UpdateAuthorBlock()
1935  {
1936  // Add block
1937  if (m_ActionAddAuthorBlock)
1938  {
1939  m_ActionAddAuthorBlock.Internal_Update(0);
1940 
1941  if (m_ActionAddAuthorBlock.IsCompleted())
1942  {
1943  m_ActionAddAuthorBlock.Internal_Detach();
1944  m_ActionAddAuthorBlock = null;
1945 
1946  #ifdef WORKSHOP_DEBUG
1947  _print("OnChanged: Internal_Update: Add author block action Was Completed");
1948  #endif
1949 
1950  SetChanged();
1951  m_OnReportStateChanged.Invoke(this, true);
1952  }
1953  }
1954 
1955  // Remove block
1956  if (m_ActionRemoveAuthorBlock)
1957  {
1958  m_ActionRemoveAuthorBlock.Internal_Update(0);
1959 
1960  if (m_ActionRemoveAuthorBlock.IsCompleted())
1961  {
1962  m_ActionRemoveAuthorBlock.Internal_Detach();
1963  m_ActionRemoveAuthorBlock = null;
1964 
1965  #ifdef WORKSHOP_DEBUG
1966  _print("OnChanged: Internal_Update: Add author block action Was Completed");
1967  #endif
1968 
1969  SetChanged();
1970  m_OnReportStateChanged.Invoke(this, false);
1971  }
1972  }
1973  }
1974 
1975  //-----------------------------------------------------------------------------------------------
1977  void Internal_OnChanged()
1978  {
1979  SetChanged();
1980  }
1981 
1982 
1983  //-----------------------------------------------------------------------------------------------
1986  bool Internal_GetCanBeUnregistered()
1987  {
1988  if (m_ActionDownload || m_ActionReport || m_ActionDependency || m_ActionCancelReport || GetOffline()
1989  || m_ActionAddAuthorBlock || m_ActionRemoveAuthorBlock)
1990  return false;
1991  else
1992  return true;
1993  }
1994 
1995 
1996  //-----------------------------------------------------------------------------------------------
1998  WorkshopItem Internal_GetWorkshopItem()
1999  {
2000  if (!m_Item)
2001  m_Item = m_Dependency.GetCachedItem();
2002  return m_Item;
2003  }
2004 
2005  //-----------------------------------------------------------------------------------------------
2006  float Internal_GetDownloadProgress()
2007  {
2008  if (!m_Item)
2009  return 0;
2010 
2011  return m_Item.GetProgress();
2012  }
2013 
2014  //-----------------------------------------------------------------------------------------------
2015  bool Internal_GetIsProcessing()
2016  {
2017  if (!m_Item)
2018  return false;
2019 
2020  return m_Item.IsProcessing();
2021  }
2022 
2023  //-----------------------------------------------------------------------------------------------
2024  float Internal_GetProcessingProgress()
2025  {
2026  if (!m_Item)
2027  return 0;
2028 
2029  return m_Item.GetProcessingProgress();
2030  }
2031 
2032  //-----------------------------------------------------------------------------------------------
2034  void Internal_LoadDetails()
2035  {
2036  if (!m_CallbackAskDetails)
2037  {
2038  m_CallbackAskDetails = new SCR_WorkshopItemCallback_AskDetails(m_Item);
2039  m_CallbackAskDetails.m_OnGetAsset.Insert(Callback_AskDetails_OnGetAsset);
2040  //m_CallbackAskDetails.m_OnGetDependencyTree.Insert(Callback_AskDetails_OnGetDependencyTree); // Not needed any more - we load dependencies in another request.
2041  // m_CallbackAskDetails.m_OnGetAssetScenarios.Insert(Callback_AskDetails_OnGetScenarios); // Not needed any more
2042  m_CallbackAskDetails.m_OnTimeout.Insert(Callback_AskDetails_OnTimeout);
2043  m_CallbackAskDetails.m_OnError.Insert(Callback_AskDetails_OnError);
2044  }
2045 
2046  //Restarts waiting for details? - TODO review logic
2047  if (!m_bWaitingLoadDetails)
2048  {
2049  if (m_Item)
2050  {
2051  if (m_Item.GetStateFlags() & EWorkshopItemState.EWSTATE_ONLINE)
2052  {
2053  m_Item.AskDetail(m_CallbackAskDetails); // Internally both methods perform the same request
2054  m_bWaitingLoadDetails = true;
2055  }
2056  }
2057  else if (m_Dependency)
2058  {
2059  m_Dependency.LoadItem(m_CallbackAskDetails);
2060  m_bWaitingLoadDetails = true;
2061  }
2062  }
2063  }
2064 
2065  //-----------------------------------------------------------------------------------------------
2066  void SetItemTargetRevision(Revision revision)
2067  {
2068  m_ItemTargetRevision = revision;
2069  }
2070 
2071  //-----------------------------------------------------------------------------------------------
2072  Revision GetItemTargetRevision()
2073  {
2074  return m_ItemTargetRevision;
2075  }
2076 
2077  //-----------------------------------------------------------------------------------------------
2078  void SetTargetRevisionPatchSize(float size)
2079  {
2080  m_fTargetRevisionPatchSize = size;
2081  }
2082 
2083  //-----------------------------------------------------------------------------------------------
2086  float GetTargetRevisionPatchSize()
2087  {
2088  return m_fTargetRevisionPatchSize;
2089  }
2090 
2091  //-----------------------------------------------------------------------------------------------
2092  protected void SetChanged()
2093  {
2094  m_bChanged = true;
2095  }
2096 
2097  //-----------------------------------------------------------------------------------------------
2098  //-----------------------------------------------------------------------------------------------
2099  //-----------------------------------------------------------------------------------------------
2100 
2101 
2102 
2103 
2104 
2105 
2106 
2107 
2108 
2109 
2110  //-----------------------------------------------------------------------------------------------
2111  // C O N S T R U C T I O N
2112  //-----------------------------------------------------------------------------------------------
2113 
2114  //-----------------------------------------------------------------------------------------------
2116  private void SCR_WorkshopItem(WorkshopItem item, Dependency dependency)
2117  {
2118  m_Item = item;
2119  m_Dependency = dependency;
2120 
2121  if (m_Item)
2122  {
2123  #ifdef WORKSHOP_DEBUG
2124  _print(string.Format("NEW for WorkshopItem: ID: %1, Name: %2", m_Item.Id(), m_Item.Name()));
2125  #endif
2126 
2127  UpdateStateFromWorkshopItem();
2128  }
2129 
2130  if(m_Dependency)
2131  {
2132  #ifdef WORKSHOP_DEBUG
2133  _print(string.Format("NEW for Dependency: ID: %1, Name: %2", m_Dependency.GetID(), m_Dependency.GetName()));
2134  #endif
2135  }
2136 
2137  if (!m_Item && !m_Dependency)
2138  Print("Can't be set!");
2139 
2140  m_bOffline = GetOffline();
2141 
2142  #ifdef WORKSHOP_DEBUG
2143  m_sName = GetName();
2144  m_sId = GetId();
2145  #endif
2146  }
2147 
2148  //-----------------------------------------------------------------------------------------------
2149  void ~SCR_WorkshopItem()
2150  {
2151  #ifdef WORKSHOP_DEBUG
2152  _print(string.Format("DELETE for: ID: %1, Name: %2", this.GetId(), this.GetName()));
2153  #endif
2154 
2155  if (m_aDependencies)
2156  {
2157  foreach (SCR_WorkshopItem dependency : m_aDependencies)
2158  {
2159  if (dependency)
2160  {
2161  // Unregister this from dependency, so that it doesn't point back at a null
2162  dependency.UnregisterDependent(this);
2163  }
2164  }
2165  }
2166  }
2167 
2168 
2169  //-----------------------------------------------------------------------------------------------
2170  void Internal_UpdateObjects(WorkshopItem item, Dependency dependency)
2171  {
2172  #ifdef WORKSHOP_DEBUG
2173  _print(string.Format("Internal_UpdateObjects: %1, %2", item, dependency));
2174  #endif
2175 
2176  if (!m_Item && item)
2177  {
2178  m_Item = item;
2179  UpdateStateFromWorkshopItem();
2180  }
2181 
2182  // Alwasys update dependency - because it might be required to join a different server and thus dependency object
2183  // will be different!
2184  if (dependency)
2185  m_Dependency = dependency;
2186  }
2187 
2188  //-----------------------------------------------------------------------------------------------
2190  void Internal_OnAddonsChecked()
2191  {
2192  UpdateStateFromWorkshopItem();
2193  }
2194 
2195  //-----------------------------------------------------------------------------------------------
2196  protected bool Internal_GetUpdateAvailable()
2197  {
2198  if (GetCurrentLocalRevision())
2199  return GetCurrentLocalRevision().CompareTo(GetLatestRevision()) < 0;
2200  else
2201  return false;
2202  }
2203 
2204  //-----------------------------------------------------------------------------------------------
2205  static SCR_WorkshopItem Internal_CreateFromWorkshopItem(WorkshopItem item)
2206  {
2207  SCR_WorkshopItem wrapper = new SCR_WorkshopItem(item, null);
2208  return wrapper;
2209  }
2210 
2211 
2212  //-----------------------------------------------------------------------------------------------
2213  static SCR_WorkshopItem Internal_CreateFromDependency(Dependency dependency)
2214  {
2215  WorkshopItem cachedItem = dependency.GetCachedItem();
2216  #ifdef WORKSHOP_DEBUG
2217  _sprint(string.Format("Internal_CreateFromDependency(): cached Workshop Item was found"));
2218  #endif
2219  SCR_WorkshopItem wrapper = new SCR_WorkshopItem(cachedItem, dependency);
2220  return wrapper;
2221  }
2222 
2223  //-----------------------------------------------------------------------------------------------
2224  void UpdateStateFromWorkshopItem()
2225  {
2226  if (m_Item)
2227  {
2228  m_bSubscribed = m_Item.IsSubscribed();
2229  m_bMyRating = m_Item.MyRating();
2230  m_bMyRatingSet = m_Item.IsRatingSet();
2231  m_bFavourite = m_Item.IsFavorite();
2232 
2233  if (m_Item.IsEnabled())
2234  m_Item.NotifyPlay();
2235  }
2236 
2237  TryLoadDependencies();
2238  TryLoadScenarios();
2239  }
2240 
2241  //-----------------------------------------------------------------------------------------------
2242  //-----------------------------------------------------------------------------------------------
2243  //-----------------------------------------------------------------------------------------------
2244 
2245  //------------------------------------------------------------------------------------------------
2246  static void _sprint(string str, LogLevel logLevel = LogLevel.DEBUG)
2247  {
2248  Print(string.Format("[SCR_AddonManager] %1", str), logLevel);
2249  }
2250 
2251  //------------------------------------------------------------------------------------------------
2252  void _print(string str, LogLevel logLevel = LogLevel.DEBUG)
2253  {
2254  Print(string.Format("[SCR_AddonManager] %1 %2", this, str), logLevel);
2255  }
2256 
2257  //-----------------------------------------------------------------------------------------------
2258  protected void CustomDebugError(string message)
2259  {
2260  string addonEnv = "unknown due to missing item";
2261  if (m_Item)
2262  addonEnv = m_Item.GetBackendEnv();
2263 
2264  string CurrentEnv = GetGame().GetBackendApi().GetBackendEnv();
2265  //Debug.Error(string.Format("Addon: %1 [id: %2, from: %3] - %4 [current env: %5]", GetName(), GetId(), addonEnv, message, CurrentEnv));
2266  }
2267 };
EWorkshopItemProblem
EWorkshopItemProblem
Definition: SCR_WorkshopItem.c:11
NO_PROBLEM
@ NO_PROBLEM
Definition: SCR_WorkshopItem.c:13
SCR_FormatHelper
Definition: SCR_FormatHelper.c:1
m_Item
NewsFeedItem m_Item
Definition: SCR_NewsSubMenu.c:2
SCR_WorkshopItemActionAddAuthorBlock
Action for blocking author.
Definition: WorkshopItemActions.c:210
SCR_WorkshopItemCallback_LoadScenarios
Definition: SCR_OnlineServiceWorkshop.c:156
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_WorkshopItemActionDownload
Definition: SCR_WorkshopItemActionDownload.c:9
SCR_WorkshopItemCallback_LoadDependencies
Definition: SCR_OnlineServiceWorkshop.c:150
SCR_WorkshopItem
Definition: SCR_WorkshopItem.c:21
SCR_WorkshopItemActionDownloadDependenciesLatest
Action for downloading latest dependencies. Doesn't download this addon, but only downloads dependenc...
Definition: WorkshopItemActions.c:7
SCR_BackendCallback
Scripted backend callback class unifying backend response.
Definition: SCR_BackendCallback.c:21
UPDATE_AVAILABLE
@ UPDATE_AVAILABLE
Definition: SCR_WorkshopItem.c:17
SCR_WorkshopItemCallback_LoadMyReport
Definition: SCR_OnlineServiceWorkshop.c:261
DEPENDENCY_MISSING
@ DEPENDENCY_MISSING
Definition: SCR_WorkshopItem.c:15
m_OnChanged
protected ref ScriptInvokerTabViewIndex m_OnChanged
Definition: SCR_TabViewComponent.c:64
DEPENDENCY_DISABLED
@ DEPENDENCY_DISABLED
Definition: SCR_WorkshopItem.c:16
BROKEN
@ BROKEN
Definition: SCR_WorkshopItem.c:14
SCR_WorkshopItemActionCancelReport
Action for canceling report of an item.
Definition: WorkshopItemActions.c:199
m_aDependencies
protected ref array< ref SCR_WorkshopItem > m_aDependencies
Definition: SCR_ModDetailsSuperMenuComponent.c:10
NULL
PauseMenuUI NULL
SCR_WorkshopItemActionRemoveAuthorBlock
Action for removing author mod content blocking.
Definition: WorkshopItemActions.c:220
SCR_WorkshopCallbackBase
Definition: SCR_OnlineServiceWorkshop.c:101
DEPENDENCY_OUTDATED
@ DEPENDENCY_OUTDATED
Definition: SCR_WorkshopItem.c:18
BackendCallback
Base server browser callback.
Definition: SCR_ServerListComponent.c:4
SCR_WorkshopItemCallback_AskDetails
Definition: SCR_OnlineServiceWorkshop.c:210
SCR_AddonManager
Definition: SCR_AddonManager.c:72
SCR_WorkshopItemActionReport
Action for reporting an item.
Definition: WorkshopItemActions.c:175
EBackendCallbackResponse
EBackendCallbackResponse
Basic callback responses.
Definition: SCR_BackendCallback.c:12
callback
DownloadConfigCallback callback
m_sName
protected LocalizedString m_sName
Definition: SCR_GroupIdentityComponent.c:19
SCR_WorkshopItemActionComposite
Composite action which includes multiple subactions.
Definition: SCR_WorkshopItemAction.c:408
EWorkshopItemQuery
EWorkshopItemQuery
Definition: SCR_AddonManager.c:34