Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ContentBrowserTileComponent.c
Go to the documentation of this file.
1 //#define WORKSHOP_DEBUG
2 
6 {
7  // Event Handlers
9 
10  protected ref SCR_WorkshopTileWidgets m_Widgets = new SCR_WorkshopTileWidgets();
11 
12  protected bool m_bFocused;
13  protected bool m_bUpdatingContinuously;
14 
15  protected ref SCR_WorkshopItem m_Item;
16 
17  protected SCR_WorkshopItemBackendImageComponent m_BackendImageComponent;
18  protected ref SCR_WorkshopDownloadSequence m_DownloadRequest;
19 
20  protected SCR_ERevisionAvailability m_eRevisionAvailability;
21 
22  protected SCR_EWorkshopTileErrorState m_eErrorState;
23  protected SCR_EWorkshopTileActionState m_eMainActionState;
24 
25  protected const int CONTINUOUS_UPDATE_DELAY = 1000;
26  protected const string MAIN_ACTION_MESSAGE_DECORATION = "[%1]";
27 
28  //------------------------------------------------------------------------------------------------
29  override void HandlerAttached(Widget w)
30  {
31  super.HandlerAttached(w);
32 
33  if (!GetGame().InPlayMode())
34  return;
35 
36  m_Widgets.Init(m_wRoot);
37 
38  m_Widgets.m_EnableAddonButtonComponent.m_OnToggled.Insert(OnEnableButtonToggled);
39  m_Widgets.m_FavouriteButtonComponent0.m_OnToggled.Insert(OnFavouriteButtonToggled);
40 
41  Widget backendImage = m_wRoot.FindAnyWidget("m_BackendImage");
42  if (backendImage)
43  m_BackendImageComponent = SCR_WorkshopItemBackendImageComponent.Cast(backendImage.FindHandler(SCR_WorkshopItemBackendImageComponent));
44 
45  UpdateWarningOverlay();
46  m_Widgets.m_WarningOverlayComponent.GetOnWarningIconButtonClicked().Insert(OnWarningButtonClicked);
47 
48  UpdateHeader();
49  m_Widgets.m_MainActionButtonComponent0.m_OnClicked.Insert(OnMainActionButtonClicked);
50 
51  SCR_DownloadManager downloadManager = SCR_DownloadManager.GetInstance();
52  if (downloadManager)
53  {
54  downloadManager.m_OnNewDownload.Insert(OnAnyNewDownload);
55  downloadManager.m_OnDownloadFailed.Insert(OnAnyDownloadError);
56  downloadManager.m_OnDownloadCanceled.Insert(OnAnyDownloadCompleted);
57  downloadManager.m_OnDownloadComplete.Insert(OnAnyDownloadCompleted);
58  }
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  override void HandlerDeattached(Widget w)
63  {
64  SCR_ScriptedWidgetTooltip.GetOnTooltipShow().Remove(OnTooltipShow);
65 
66  SCR_DownloadManager downloadManager = SCR_DownloadManager.GetInstance();
67  if (downloadManager)
68  {
69  downloadManager.m_OnNewDownload.Remove(OnAnyNewDownload);
70  downloadManager.m_OnDownloadFailed.Remove(OnAnyDownloadError);
71  downloadManager.m_OnDownloadCanceled.Remove(OnAnyDownloadCompleted);
72  downloadManager.m_OnDownloadComplete.Remove(OnAnyDownloadCompleted);
73  }
74 
75  StopContinuousUpdate();
76 
77  super.HandlerDeattached(w);
78  }
79 
80  //------------------------------------------------------------------------------------------------
81  override bool OnFocus(Widget w, int x, int y)
82  {
83  m_OnFocus.Invoke(this);
84  m_bFocused = true;
85 
86  UpdateFavouriteButton();
87  UpdateNamesScrolling();
88  UpdateHeader();
89 
90  // Tooltips
91  SCR_ScriptedWidgetTooltip.GetOnTooltipShow().Insert(OnTooltipShow);
92 
93  return super.OnFocus(w, x, y);
94  }
95 
96  //------------------------------------------------------------------------------------------------
97  override bool OnFocusLost(Widget w, int x, int y)
98  {
99  m_bFocused = false;
100 
101  UpdateFavouriteButton();
102  UpdateNamesScrolling();
103  UpdateHeader();
104 
105  // Tooltips
106  SCR_ScriptedWidgetTooltip.GetOnTooltipShow().Remove(OnTooltipShow);
107 
108  return super.OnFocusLost(w, x, y);
109  }
110 
111  // ---- Protected ----
112  //------------------------------------------------------------------------------------------------
113  protected void UpdateStateFlags()
114  {
115  if (!m_Item)
116  return;
117 
118  SCR_AddonManager addonManager = SCR_AddonManager.GetInstance();
119 
120  WorkshopItem item = m_Item.GetWorkshopItem();
121  m_eRevisionAvailability = SCR_ERevisionAvailability.ERA_UNKNOWN_AVAILABILITY;
122  if (item)
123  m_eRevisionAvailability = addonManager.ItemAvailability(item);
124 
125  EWorkshopItemProblem itemProblem = m_Item.GetHighestPriorityProblem();
126 
127  // --- Download States ---
128  // Downloading is true if we are downloading anything for this addon or if we have started a download for any of its dependencies through this item
129  if (m_Item.GetDownloadAction() || m_Item.GetDependencyCompositeAction())
130  m_eMainActionState = SCR_EWorkshopTileActionState.DOWNLOADING;
131  else if (itemProblem != EWorkshopItemProblem.NO_PROBLEM)
132  {
133  switch (itemProblem)
134  {
135  case EWorkshopItemProblem.UPDATE_AVAILABLE: m_eMainActionState = SCR_EWorkshopTileActionState.UPDATE; break;
136  case EWorkshopItemProblem.DEPENDENCY_MISSING: m_eMainActionState = SCR_EWorkshopTileActionState.DEPENDENCIES_DOWNLOAD; break;
137  case EWorkshopItemProblem.DEPENDENCY_OUTDATED: m_eMainActionState = SCR_EWorkshopTileActionState.DEPENDENCIES_UPDATE; break;
138  case EWorkshopItemProblem.DEPENDENCY_DISABLED: m_eMainActionState = SCR_EWorkshopTileActionState.DEPENDENCIES_ENABLE; break;
139  }
140  }
141  else if (!m_Item.GetOffline())
142  m_eMainActionState = SCR_EWorkshopTileActionState.DOWNLOAD;
143  else
144  m_eMainActionState = SCR_EWorkshopTileActionState.DOWNLOADED;
145 
146  // --- Error States ---
147  if (m_Item.GetRestricted())
148  m_eErrorState = SCR_EWorkshopTileErrorState.RESTRICTED;
149  else if (m_eRevisionAvailability != SCR_ERevisionAvailability.ERA_AVAILABLE && m_eRevisionAvailability != SCR_ERevisionAvailability.ERA_UNKNOWN_AVAILABILITY)
150  m_eErrorState = SCR_EWorkshopTileErrorState.REVISION_AVAILABILITY_ISSUE;
151  else if (itemProblem == EWorkshopItemProblem.DEPENDENCY_MISSING || itemProblem == EWorkshopItemProblem.DEPENDENCY_DISABLED)
152  m_eErrorState = SCR_EWorkshopTileErrorState.DEPENDENCIES_ISSUE;
153  else
154  m_eErrorState = SCR_EWorkshopTileErrorState.NONE;
155  }
156 
157  //------------------------------------------------------------------------------------------------
158  protected void UpdateNames()
159  {
160  m_Widgets.m_wAddonName.SetText(m_Item.GetName());
161  m_Widgets.m_wAddonAuthor.SetText(WidgetManager.Translate("#AR-Workshop_AddonAuthorPrefix", m_Item.GetAuthorName()));
162  }
163 
164  //------------------------------------------------------------------------------------------------
165  protected void UpdateNamesScrolling()
166  {
167  if (m_bFocused)
168  {
169  if (!m_Widgets.m_FrameNameComponent.GetContentFit())
170  m_Widgets.m_FrameNameComponent.AnimationStart();
171 
172  if (!m_Widgets.m_FrameAuthorComponent.GetContentFit())
173  m_Widgets.m_FrameAuthorComponent.AnimationStart();
174  }
175  else
176  {
177  m_Widgets.m_FrameNameComponent.AnimationStop();
178  m_Widgets.m_FrameNameComponent.ResetPosition();
179 
180  m_Widgets.m_FrameAuthorComponent.AnimationStop();
181  m_Widgets.m_FrameAuthorComponent.ResetPosition();
182  }
183 
184  // TODO: additional authors
185  }
186 
187  //------------------------------------------------------------------------------------------------
188  protected void UpdateRating()
189  {
190  m_Widgets.m_wRating.SetVisible(m_eErrorState != SCR_EWorkshopTileErrorState.RESTRICTED);
191  if (!m_Widgets.m_wRating.IsVisible())
192  return;
193 
194  int rating = Math.Ceil(100 * m_Item.GetAverageRating());
195  m_Widgets.m_RatingComponent1.SetTitle(WidgetManager.Translate("#AR-ValueUnit_Percentage", rating));
196  }
197 
198  //------------------------------------------------------------------------------------------------
199  protected void UpdateImage()
200  {
201  if (!m_BackendImageComponent)
202  return;
203 
204  m_BackendImageComponent.SetWorkshopItemAndImage(m_Item, m_Item.GetThumbnail());
205  }
206 
207  //------------------------------------------------------------------------------------------------
208  protected void UpdateDependencyCountWidgets()
209  {
210  if (!m_Item)
211  return;
212 
213  bool offline = m_Item.GetOffline();
214 
215  int nDependencies = SCR_AddonManager.CountItemsBasic(m_Item.GetLatestDependencies(), EWorkshopItemQuery.OFFLINE);
216  int nDependent = SCR_AddonManager.CountItemsBasic(m_Item.GetDependentAddons(), EWorkshopItemQuery.OFFLINE);
217 
218  // Displays
219  m_Widgets.m_wDependent.SetVisible(nDependent > 0);
220  m_Widgets.m_wDependencies.SetVisible(nDependencies > 0);
221 
222  m_Widgets.m_DependentComponent1.SetTitle(Math.ClampInt(nDependent, 0, 999).ToString());
223  m_Widgets.m_DependenciesComponent1.SetTitle(Math.ClampInt(nDependencies, 0, 999).ToString());
224  }
225 
226  //------------------------------------------------------------------------------------------------
227  protected void UpdateDownloadProgressBar()
228  {
229  float progress;
230 
231  if (m_Item && m_eMainActionState == SCR_EWorkshopTileActionState.DOWNLOADING)
232  progress = GetDownloadProgress();
233 
234  m_Widgets.m_wDownloadProgressBar.SetCurrent(progress);
235  m_Widgets.m_wDownloadProgressBarOverlay.SetVisible(progress > 0);
236  }
237 
238  //------------------------------------------------------------------------------------------------
240  protected float GetDownloadProgress()
241  {
242  return SCR_DownloadManager.GetItemDownloadActionsProgress(m_Item);
243  }
244 
245  //------------------------------------------------------------------------------------------------
246  protected void UpdateEnableButton()
247  {
248  m_Widgets.m_EnableAddonButtonComponent.SetVisible(m_Item.GetOffline());
249  m_Widgets.m_EnableAddonButtonComponent.SetToggled(m_Item.GetEnabled(), false);
250 
251  if (!m_Item.GetOffline())
252  return;
253 
254  m_Widgets.m_EnableAddonButtonComponent.SetEnabled(m_eMainActionState != SCR_EWorkshopTileActionState.DOWNLOADING);
255 
256  string enableButtonMode = "no_problems";
257  if (m_eMainActionState == SCR_EWorkshopTileActionState.DEPENDENCIES_DOWNLOAD || m_eMainActionState == SCR_EWorkshopTileActionState.DEPENDENCIES_ENABLE)
258  enableButtonMode = "problems";
259 
260  m_Widgets.m_EnableAddonButtonComponent.SetEffectsWithAnyTagEnabled({"all", enableButtonMode});
261  }
262 
263  //------------------------------------------------------------------------------------------------
264  protected void UpdateFavouriteButton()
265  {
266  if (!m_Item)
267  return;
268 
269  m_Widgets.m_FavouriteButtonComponent0.SetToggled(m_Item.GetFavourite(), false);
270  m_Widgets.m_FavouriteButtonComponent0.SetVisible((m_bFocused || m_Item.GetFavourite()) && m_eErrorState != SCR_EWorkshopTileErrorState.RESTRICTED);
271  }
272 
273  //------------------------------------------------------------------------------------------------
274  protected void ShowBackendEnv()
275  {
276  string gameEnv = GetGame().GetBackendApi().GetBackendEnv();
277  string modEnv = m_Item.GetWorkshopItem().GetBackendEnv();
278 
279  bool display = (modEnv != "local") && (modEnv != "ask") && (modEnv != "invalid");
280  bool envMatch = gameEnv == modEnv;
281 
282  m_Widgets.m_wBackendSource.SetVisible(display && !envMatch);
283  if (!display)
284  return;
285 
286  m_Widgets.m_BackendSourceComponent1.SetTitle(modEnv);
287 
288  if (envMatch)
289  m_Widgets.m_BackendSourceComponent0.SetIconColor(UIColors.CONFIRM);
290  else
291  m_Widgets.m_BackendSourceComponent0.SetIconColor(UIColors.WARNING);
292  }
293 
294  //------------------------------------------------------------------------------------------------
295  protected void UpdateWarningOverlay()
296  {
297  // No error, hide
298  if (!m_Item || m_eErrorState == SCR_EWorkshopTileErrorState.NONE)
299  {
300  m_Widgets.m_WarningOverlayComponent.SetWarningVisible(false);
301 
302  if (m_BackendImageComponent)
303  m_BackendImageComponent.SetImageSaturation(UIConstants.ENABLED_WIDGET_SATURATION);
304 
305  return;
306  }
307 
308  // Errors, show and desaturate the image
309  m_Widgets.m_WarningOverlayComponent.SetWarningVisible(true);
310 
311  if (m_BackendImageComponent)
312  m_BackendImageComponent.SetImageSaturation(UIConstants.DISABLED_WIDGET_SATURATION);
313 
314  // Update Message
315  switch (m_eErrorState)
316  {
317  case SCR_EWorkshopTileErrorState.RESTRICTED:
318  {
319  m_Widgets.m_WarningOverlayComponent.SetWarning("#AR-Workshop_State_Restricted", "reportedByMe");
320  break;
321  }
322 
323  case SCR_EWorkshopTileErrorState.DEPENDENCIES_ISSUE:
324  {
325  m_Widgets.m_WarningOverlayComponent.SetWarning("#AR-Workshop_State_MissingDependencies", "dependencies");
326  break;
327  }
328 
329  case SCR_EWorkshopTileErrorState.REVISION_AVAILABILITY_ISSUE:
330  {
331  m_Widgets.m_WarningOverlayComponent.SetWarning(
332  SCR_WorkshopUiCommon.GetRevisionAvailabilityErrorMessage(m_eRevisionAvailability),
333  SCR_WorkshopUiCommon.GetRevisionAvailabilityErrorTexture(m_eRevisionAvailability)
334  );
335  break;
336  }
337  }
338  }
339 
340  //------------------------------------------------------------------------------------------------
341  protected void UpdateHeader()
342  {
343  if (!m_Item)
344  return;
345 
346  m_Widgets.m_wMainActionButton.SetVisible(
347  (m_bFocused || (m_eMainActionState != SCR_EWorkshopTileActionState.DOWNLOAD)) &&
348  m_eMainActionState != SCR_EWorkshopTileActionState.DOWNLOADED &&
349  m_eErrorState != SCR_EWorkshopTileErrorState.RESTRICTED
350  );
351 
352  if (!m_Widgets.m_wMainActionButton.IsVisible())
353  return;
354 
355  SCR_ButtonEffectColor iconColor = SCR_ButtonEffectColor.Cast(m_Widgets.m_MainActionButtonComponent0.FindEffect("IconColor"));
356  if (!iconColor)
357  return;
358 
359  SCR_ButtonEffectColor messageColor = SCR_ButtonEffectColor.Cast(m_Widgets.m_MainActionButtonComponent0.FindEffect("MessageColor"));
360  if (!iconColor)
361  return;
362 
363  string icon;
364  string message;
365 
366  switch (m_eMainActionState)
367  {
368  case SCR_EWorkshopTileActionState.DOWNLOAD:
369  {
370  iconColor.m_cDefault = UIColors.IDLE_ACTIVE;
371  icon = "download";
372 
373  message = SCR_ByteFormat.GetReadableSize(m_Item.GetSizeBytes());
374  message = string.Format(MAIN_ACTION_MESSAGE_DECORATION, message);
375 
376  messageColor.m_cDefault = UIColors.IDLE_ACTIVE;
377  break;
378  }
379 
380  case SCR_EWorkshopTileActionState.DOWNLOADING:
381  {
382  iconColor.m_cDefault = UIColors.CONTRAST_COLOR;
383  icon = "downloading";
384 
385  string percentage = WidgetManager.Translate("#AR-ValueUnit_Percentage", Math.Round(100.0 * GetDownloadProgress()));
386  string label = "#AR-DownloadManager_State_Downloading";
387  message = WidgetManager.Translate("%1 %2", label, percentage);
388 
389  messageColor.m_cDefault = UIColors.NEUTRAL_INFORMATION;
390  break;
391  }
392 
393  case SCR_EWorkshopTileActionState.UPDATE:
394  {
395  if (m_eRevisionAvailability != SCR_ERevisionAvailability.ERA_COMPATIBLE_UPDATE_AVAILABLE)
396  {
397  iconColor.m_cDefault = UIColors.SLIGHT_WARNING;
398  messageColor.m_cDefault = UIColors.IDLE_ACTIVE;
399  }
400  else
401  {
402  iconColor.m_cDefault = UIColors.WARNING;
403  messageColor.m_cDefault = UIColors.WARNING;
404  }
405 
406  icon = "update";
407  //TODO: update size
408  message = string.Format(MAIN_ACTION_MESSAGE_DECORATION, SCR_WorkshopUiCommon.GetPrimaryActionName(m_Item));
409  break;
410  }
411 
412  case SCR_EWorkshopTileActionState.DEPENDENCIES_UPDATE:
413  {
414  iconColor.m_cDefault = UIColors.SLIGHT_WARNING;
415  icon = "update";
416  message = string.Format(MAIN_ACTION_MESSAGE_DECORATION, SCR_WorkshopUiCommon.GetPrimaryActionName(m_Item));
417  messageColor.m_cDefault = UIColors.IDLE_ACTIVE;
418  break;
419  }
420 
421  case SCR_EWorkshopTileActionState.DEPENDENCIES_DOWNLOAD:
422  {
423  iconColor.m_cDefault = UIColors.SLIGHT_WARNING;
424  icon = "download";
425  message = string.Format(MAIN_ACTION_MESSAGE_DECORATION, SCR_WorkshopUiCommon.GetPrimaryActionName(m_Item));
426  messageColor.m_cDefault = UIColors.IDLE_ACTIVE;
427  break;
428  }
429 
430  case SCR_EWorkshopTileActionState.DEPENDENCIES_ENABLE:
431  {
432  iconColor.m_cDefault = UIColors.SLIGHT_WARNING;
433  icon = "repairCircle";
434  message = string.Format(MAIN_ACTION_MESSAGE_DECORATION, SCR_WorkshopUiCommon.GetPrimaryActionName(m_Item));
435  messageColor.m_cDefault = UIColors.IDLE_ACTIVE;
436  break;
437  }
438  }
439 
440  m_Widgets.m_MainActionButtonComponent0.InvokeAllEnabledEffects(false);
441  m_Widgets.m_MainActionButtonComponent1.SetImage(icon);
442  m_Widgets.m_wMainActionText.SetText(message);
443  }
444 
445  //------------------------------------------------------------------------------------------------
446  protected void UpdateAllWidgets()
447  {
448  // Tile visibility
449  if (!m_Item)
450  {
451  m_wRoot.SetVisible(false);
452  return;
453  }
454 
455  m_wRoot.SetVisible(true);
456 
457  // Check states and update dynamic elements
458  HandleDownloadChanges();
459 
460  // Update static elements
461  UpdateNames();
462  UpdateNamesScrolling();
463  UpdateRating();
464  UpdateImage();
465  ShowBackendEnv();
466  UpdateEnableButton();
467  UpdateFavouriteButton();
468  UpdateDependencyCountWidgets();
469  }
470 
471  //------------------------------------------------------------------------------------------------
472  protected void HandleDownloadChanges()
473  {
474  UpdateStateFlags();
475 
476  UpdateDownloadProgressBar();
477  UpdateWarningOverlay();
478  UpdateHeader();
479 
480  if (m_Item && m_eMainActionState == SCR_EWorkshopTileActionState.DOWNLOADING)
481  StartContinuousUpdate();
482  else
483  StopContinuousUpdate();
484  }
485 
486  //------------------------------------------------------------------------------------------------
487  protected void StartContinuousUpdate()
488  {
489  if (m_bUpdatingContinuously || !m_Item)
490  return;
491 
492  GetGame().GetCallqueue().CallLater(ContinuousUpdate, CONTINUOUS_UPDATE_DELAY, true);
493 
494  m_bUpdatingContinuously = true;
495  }
496 
497  //------------------------------------------------------------------------------------------------
498  protected void StopContinuousUpdate()
499  {
500  if (m_bUpdatingContinuously)
501  GetGame().GetCallqueue().Remove(ContinuousUpdate);
502 
503  m_bUpdatingContinuously = false;
504  }
505 
506  //------------------------------------------------------------------------------------------------
507  protected void ContinuousUpdate()
508  {
509  if (!m_Item || m_eMainActionState != SCR_EWorkshopTileActionState.DOWNLOADING)
510  StopContinuousUpdate();
511 
512  UpdateDownloadProgressBar();
513  UpdateHeader();
514  }
515 
516  //------------------------------------------------------------------------------------------------
517  protected void OnEnableButtonToggled(SCR_ModularButtonComponent comp)
518  {
519  SCR_WorkshopUiCommon.OnEnableAddonToggleButton(m_Item, comp);
520  }
521 
522  //------------------------------------------------------------------------------------------------
523  protected void OnFavouriteButtonToggled(SCR_ModularButtonComponent comp, bool toggled)
524  {
525  if (!m_Item)
526  return;
527 
528  m_Item.SetFavourite(toggled);
529  }
530 
531  //------------------------------------------------------------------------------------------------
532  protected void OnWarningButtonClicked(ScriptInvokerScriptedWidgetComponent comp)
533  {
534  SCR_WorkshopUiCommon.ExecutePrimaryAction(m_Item, m_DownloadRequest);
535  }
536 
537  //------------------------------------------------------------------------------------------------
538  protected void OnMainActionButtonClicked(SCR_ModularButtonComponent comp)
539  {
540  SCR_WorkshopUiCommon.ExecutePrimaryAction(m_Item, m_DownloadRequest);
541  }
542 
543  //------------------------------------------------------------------------------------------------
544  protected void OnWorkshopItemChange(SCR_WorkshopItem item)
545  {
546  UpdateAllWidgets();
547  }
548 
549  // --- Any downloads ---
550  // We need to update the progress bar and main action display if we start downloading this item or any of it's dependencies
551  //------------------------------------------------------------------------------------------------
552  protected void OnAnyNewDownload(SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
553  {
554  HandleDownloadChanges();
555  }
556 
557  //------------------------------------------------------------------------------------------------
558  protected void OnAnyDownloadError(SCR_WorkshopItemActionDownload action, int reason)
559  {
560  HandleDownloadChanges();
561  }
562 
563  //------------------------------------------------------------------------------------------------
564  protected void OnAnyDownloadCompleted(SCR_WorkshopItemActionDownload action)
565  {
566  HandleDownloadChanges();
567  }
568 
569  // ---- Dependency icons Tooltips ----
570  //------------------------------------------------------------------------------------------------
571  protected void OnTooltipShow(SCR_ScriptedWidgetTooltip tooltipClass, Widget tooltipWidget, Widget hoverWidget, SCR_ScriptedWidgetTooltipPreset preset, string tag)
572  {
573  if (!m_Item || !tooltipWidget)
574  return;
575 
576  array<ref SCR_WorkshopItem> addons = {};
577 
578  switch (tag)
579  {
580  case "Dependent":
581  addons = SCR_AddonManager.SelectItemsBasic(m_Item.GetDependentAddons(), EWorkshopItemQuery.OFFLINE);
582  break;
583 
584  case "Dependencies":
585  addons = SCR_AddonManager.SelectItemsBasic(m_Item.GetLatestDependencies(), EWorkshopItemQuery.OFFLINE);
586  break;
587  }
588 
590  if (comp)
591  comp.Init(addons);
592  }
593 
594  // ---- Public ----
595  //------------------------------------------------------------------------------------------------
597  void SetWorkshopItem(SCR_WorkshopItem workshopItem)
598  {
599  // Unregister from previous item
600  if (m_Item)
601  {
602  m_Item.m_OnChanged.Remove(OnWorkshopItemChange);
603  m_Item = null; // Release the old item
604  }
605 
606  if (workshopItem)
607  {
608  m_Item = workshopItem;
609  m_Item.m_OnChanged.Insert(OnWorkshopItemChange);
610  }
611 
612  UpdateAllWidgets();
613 
614  // Since we reuse these tiles, when we assign a new workshop item we should not animate the effects, but we must force them into the correct value
615  m_Widgets.m_EnableAddonButtonComponent.InvokeAllEnabledEffects(true);
616  }
617 
618  //------------------------------------------------------------------------------------------------
619  SCR_WorkshopItem GetWorkshopItem()
620  {
621  return m_Item;
622  }
623 
624  //------------------------------------------------------------------------------------------------
626  {
627  return m_OnFocus;
628  }
629 
630  //------------------------------------------------------------------------------------------------
631  static SCR_ContentBrowserTileComponent FindComponent(notnull Widget w)
632  {
634  }
635 }
636 
637 // Displayed in the warning overlay
638 enum SCR_EWorkshopTileErrorState
639 {
640  NONE,
641  RESTRICTED,
643  DEPENDENCIES_ISSUE
644 }
645 
646 // Displayed in the header
647 enum SCR_EWorkshopTileActionState
648 {
649  DOWNLOAD,
650  UPDATE,
652  DEPENDENCIES_DOWNLOAD, // Missing
653  DEPENDENCIES_ENABLE, // Disabled
654  DOWNLOADING,
655  DOWNLOADED
656 }
EWorkshopItemProblem
EWorkshopItemProblem
Definition: SCR_WorkshopItem.c:11
SCR_ERevisionAvailability
SCR_ERevisionAvailability
Definition: SCR_AddonManager.c:1090
DOWNLOAD
SCR_ContentBrowserTileComponent DOWNLOAD
SCR_ContentBrowserTileComponent
Definition: SCR_ContentBrowserTileComponent.c:5
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_WorkshopDownloadSequence
Definition: SCR_WorkshopDownloadSequence.c:9
m_Item
NewsFeedItem m_Item
Definition: SCR_NewsSubMenu.c:2
UIConstants
Definition: Constants.c:130
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_WorkshopItemActionDownload
Definition: SCR_WorkshopItemActionDownload.c:9
DOWNLOADED
class SCR_ContentBrowser_ScenarioLineWidgets DOWNLOADED
NONE
SCR_ContentBrowserTileComponent NONE
m_Widgets
ref SCR_VoNOverlay_ElementWidgets m_Widgets
Definition: SCR_VonDisplay.c:3
SCR_WorkshopItem
Definition: SCR_WorkshopItem.c:21
SCR_ButtonEffectColor
Effect which colorizes a widget with given name.
Definition: SCR_ButtonEffectColor.c:3
DEPENDENCIES_DOWNLOAD
SCR_ContentBrowserTileComponent DEPENDENCIES_DOWNLOAD
DEPENDENCIES_ENABLE
SCR_ContentBrowserTileComponent DEPENDENCIES_ENABLE
SCR_ContentBrowser_AddonsTooltipComponent
Definition: SCR_ContentBrowser_AddonsTooltipComponent.c:4
DEPENDENCIES_UPDATE
SCR_ContentBrowserTileComponent DEPENDENCIES_UPDATE
DOWNLOADING
SCR_ContentBrowserTileComponent DOWNLOADING
UIColors
Definition: Constants.c:16
UPDATE
SCR_ContentBrowserTileComponent UPDATE
SCR_WorkshopTileWidgets
Definition: SCR_WorkshopTileWidgets.c:3
SCR_ByteFormat
Definition: SCR_ByteFormat.c:5
SCR_WorkshopItemBackendImageComponent
Same as SCR_BackendImageComponent, but implements default image based on tag of Workshop Item.
Definition: SCR_WorkshopUiCommon.c:1094
m_DownloadRequest
protected ref SCR_WorkshopDownloadSequence m_DownloadRequest
Definition: SCR_ContentBrowser_AddonsSubMenu.c:50
SCR_AddonManager
Definition: SCR_AddonManager.c:72
m_OnFocus
ref ScriptInvoker m_OnFocus
Definition: SCR_ModularButtonComponent.c:63
REVISION_AVAILABILITY_ISSUE
SCR_ContentBrowserTileComponent REVISION_AVAILABILITY_ISSUE
SCR_WorkshopUiCommon
Definition: SCR_WorkshopUiCommon.c:5
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
SCR_ScriptedWidgetTooltip
Definition: SCR_ScriptedWidgetTooltip.c:15
SCR_DownloadManager
Definition: SCR_DownloadManager.c:20
ScriptInvokerScriptedWidgetComponent
ScriptInvokerBase< ScriptInvokerScriptedWidgetComponentMethod > ScriptInvokerScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:4
EWorkshopItemQuery
EWorkshopItemQuery
Definition: SCR_AddonManager.c:34
RESTRICTED
SCR_ContentBrowserTileComponent RESTRICTED