Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ContentBrowserDetails_OverviewSubMenu.c
Go to the documentation of this file.
1 /*
2 The overview tab of the details view
3 */
4 
6 {
7  protected ref SCR_WorkshopItem m_WorkshopItem;
8 
10 
11  protected ref SCR_WorkshopDownloadSequence m_DownloadRequest;
12 
13  protected SCR_LoadingOverlayDialog m_LoadingOverlayDlg;
14 
15  protected bool m_bGalleryUpdated = false; // Set true when we first time show images in gallery.
16 
17  protected SCR_ModReportDialogComponent m_ModReportDialog;
18 
19  protected SCR_InputButtonComponent m_Downloads;
20 
21  //------------------------------------------------------------------------------------------------
22  override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
23  {
24  super.OnTabCreate(menuRoot, buttonsLayout, index);
25 
26  m_WorkshopItem = ContentBrowserDetailsMenu.GetWorkshopItem();
27 
28  m_ScenarioDetailsPanel = m_Widgets.m_ScenarioDetailsPanelComponent;
29 
30  // Hide verrsion selection in release
31  #ifndef WORKSHOP_DEBUG
32  m_Widgets.m_VersionComboBoxComponent0.SetVisible(false, false);
33  #endif
34 
35  // Hide scenario and gallery section
36  m_Widgets.m_Gallery.SetVisible(false);
37  m_Widgets.m_ScenarioSection.SetVisible(false);
38 
39  // Load Item
40  LoadWorkshopDetails();
41 
42  // Init event handlers last of all.
43  // We don't want event handlers to get called while we are still initializing UI.
44  m_Widgets.m_VoteUpButtonComponent.m_OnToggled.Insert(OnVoteUpButton); // Toggleable!
45  m_Widgets.m_VoteDownButtonComponent.m_OnToggled.Insert(OnVoteDownButton); // Toggleable!
46  m_Widgets.m_EnableButtonComponent.m_OnToggled.Insert(OnEnableButtonToggled); // Toggleable!
47  m_Widgets.m_FavoriteButtonComponent.m_OnToggled.Insert(OnAddonFavouriteButtonToggled); // Toggleable!
48  m_Widgets.m_ReportButtonComponent.m_OnClicked.Insert(OnReportButton);
49 
50  m_Widgets.m_DownloadButtonComponent.m_OnClicked.Insert(OnDownloadButton);
51  m_Widgets.m_DeleteButtonComponent.m_OnClicked.Insert(OnDeleteButton);
52  m_Widgets.m_DownloadingButtonComponent.m_OnClicked.Insert(OnDownloadingButton);
53 
54  m_Widgets.m_SolveIssuesButtonComponent.m_OnClicked.Insert(OnSolveIssuesButton);
55 
56  // Init the addon details panel
57  m_Widgets.m_AddonDetailsPanelComponent.SetWorkshopItem(m_WorkshopItem);
58 
59  m_Downloads = m_DynamicFooter.FindButton("DownloadManager");
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  override void OnTabShow()
64  {
65  super.OnTabShow();
66 
67  UpdateAllWidgets();
68 
69  // Set the default focused widget to one we're sure is always present
70  Widget defaultFocus = m_Widgets.m_FavoriteButton;
71 
72  GetGame().GetCallqueue().Call(GetGame().GetWorkspace().SetFocusedWidget, defaultFocus);
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  override void OnTabRemove()
77  {
78  super.OnTabRemove();
79 
80  if (m_WorkshopItem)
81  {
82  m_WorkshopItem.m_OnGetAsset.Remove(Callback_OnGetAsset);
83  m_WorkshopItem.m_OnChanged.Remove(Callback_OnItemChanged);
84  m_WorkshopItem.m_OnScenariosLoaded.Remove(Callback_OnDownloadScenarios);
85  m_WorkshopItem.m_OnTimeout.Remove(Callback_OnTimeout);
86  }
87 
88  UpdateNavigationButtons(false);
89  }
90 
91  //------------------------------------------------------------------------------------------------
92  override void OnTabHide()
93  {
94  super.OnTabHide();
95 
96  if (m_Downloads)
97  m_Downloads.SetVisible(true);
98  }
99 
100  //------------------------------------------------------------------------------------------------
101  override void OnMenuFocusGained()
102  {
103  //Bring back focus to the last selected line after closing a pop-up dialog
104  if (!GetGame().GetMenuManager().IsAnyDialogOpen())
105  {
106  Widget target;
107 
108  if (m_LastSelectedLine)
109  target = m_LastSelectedLine.GetRootWidget();
110  else if (m_Widgets && m_Widgets.m_ScenariosList)
111  target = m_Widgets.m_ScenariosList.GetChildren();
112 
113  if (!target)
114  target = m_Widgets.m_FavoriteButton;
115 
116  GetGame().GetWorkspace().SetFocusedWidget(target);
117  }
118 
119  super.OnMenuFocusGained();
120  }
121 
122  //------------------------------------------------------------------------------------------------
123  override void OnLineFocus(SCR_ScriptedWidgetComponent entry)
124  {
125  super.OnLineFocus(entry);
126 
127  if (m_Downloads)
128  m_Downloads.SetVisible(false, false);
129  }
130 
131  //------------------------------------------------------------------------------------------------
132  override void OnLineFocusLost(SCR_ScriptedWidgetComponent entry)
133  {
134  super.OnLineFocusLost(entry);
135 
136  if (m_Downloads)
137  m_Downloads.SetVisible(true, false);
138  }
139 
140  //------------------------------------------------------------------------------------------------
141  override void UpdateNavigationButtons(bool visible = true)
142  {
143  visible =
144  visible &&
145  m_WorkshopItem &&
146  m_WorkshopItem.GetOffline() &&
147  GetSelectedLine() &&
148  GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.MOUSE;
149 
150  super.UpdateNavigationButtons(visible);
151  }
152 
153  //------------------------------------------------------------------------------------------------
154  override void OnLineClick(SCR_ContentBrowser_ScenarioLineComponent lineComp)
155  {
156  if (!lineComp)
157  return;
158 
160  if (!m_WorkshopItem || !m_WorkshopItem.GetOffline())
161  {
162  if (GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.MOUSE)
163  LineInteractionTryDownload(lineComp);
164 
165  return;
166  }
167 
169  super.OnLineClick(lineComp);
170  }
171 
172  //------------------------------------------------------------------------------------------------
173  override void OnLineDoubleClick(SCR_ContentBrowser_ScenarioLineComponent lineComp)
174  {
175  if (!lineComp)
176  return;
177 
179  if (!m_WorkshopItem || !m_WorkshopItem.GetOffline())
180  {
181  LineInteractionTryDownload(lineComp);
182  return;
183  }
184 
186  super.OnLineDoubleClick(lineComp);
187  }
188 
189  //------------------------------------------------------------------------------------------------
190  override void OnPlayInteraction(MissionWorkshopItem scenario)
191  {
192  if (!m_WorkshopItem || !m_WorkshopItem.GetOffline())
193  return;
194 
195  super.OnPlayInteraction(scenario);
196  }
197 
198  //------------------------------------------------------------------------------------------------
199  override void Play(MissionWorkshopItem scenario)
200  {
201  if (!scenario)
202  return;
203 
204  super.Play(scenario);
205  SCR_MenuLoadingComponent.SaveLastMenu(ChimeraMenuPreset.ScenarioMenu);
206  }
207 
208  //------------------------------------------------------------------------------------------------
209  override void Host(MissionWorkshopItem scenario)
210  {
211  if (!m_WorkshopItem || !m_WorkshopItem.GetOffline())
212  return;
213 
214  super.Host(scenario);
215  }
216 
217  //------------------------------------------------------------------------------------------------
218  override void Join(MissionWorkshopItem scenario)
219  {
220  if (!scenario || !m_WorkshopItem || !m_WorkshopItem.GetOffline() || scenario.GetPlayerCount() <= 1)
221  return;
222 
223  // Interrupt when server config is being edited
224  // just temporary solution to prevent endless opening of menus
225  if (ServerHostingUI.GetTemporaryConfig())
226  {
227  SCR_MenuToolsLib.GetEventOnAllMenuClosed().Insert(OnAllMenuCloseJoin);
229  return;
230  }
231 
232  super.Join(scenario);
233  }
234 
235  //------------------------------------------------------------------------------------------------
237  override void SetFavorite(MissionWorkshopItem scenario)
238  {
239  if (!m_WorkshopItem || !m_WorkshopItem.GetOffline())
240  return;
241 
242  super.SetFavorite(scenario);
243  }
244 
245  //------------------------------------------------------------------------------------------------
247  override void OnScenarioStateChanged(SCR_ContentBrowser_ScenarioLineComponent comp)
248  {
249  UpdateButtons();
250  super.OnScenarioStateChanged(comp);
251  }
252 
253  //------------------------------------------------------------------------------------------------
254  override void InitWidgets()
255  {
256  super.InitWidgets();
257  m_Widgets.Init(m_wRoot);
258  }
259 
260  //------------------------------------------------------------------------------------------------
261  override void UpdateSidePanel()
262  {
263  super.UpdateSidePanel();
264 
265  SCR_ContentBrowser_ScenarioLineComponent lineComp = GetSelectedLine();
266 
267  m_Widgets.m_AddonDetailsPanel.SetVisible(!lineComp);
268  m_Widgets.m_ScenarioDetailsPanel.SetVisible(lineComp != null);
269  }
270 
271  // ---- CALLBACKS ----
272  //------------------------------------------------------------------------------------------------
273  void Callback_OnGetAsset()
274  {
275  UpdateGallery();
276  }
277 
278  //------------------------------------------------------------------------------------------------
279  void Callback_OnItemChanged()
280  {
281  UpdateAllWidgets();
282  }
283 
284  //------------------------------------------------------------------------------------------------
286  void Callback_OnDownloadScenarios()
287  {
288  array<MissionWorkshopItem> scenarios = {};
289  m_WorkshopItem.GetScenarios(scenarios);
290 
291  #ifdef WORKSHOP_DEBUG
292  ContentBrowserUI._print(string.Format("Downloaded %1 scenarios", scenarios.Count()));
293  #endif
294 
295  m_Widgets.m_ScenarioSection.SetVisible(!scenarios.IsEmpty());
296 
297  // Delete old entries
298  while (m_Widgets.m_ScenariosList.GetChildren())
299  {
300  m_Widgets.m_ScenariosList.RemoveChild(m_Widgets.m_ScenariosList.GetChildren());
301  }
302 
303  // Sort missions by name
304  SCR_Sorting<MissionWorkshopItem, SCR_CompareMissionName>.HeapSort(scenarios, false);
305 
306  if (CreateLines(scenarios, m_Widgets.m_ScenariosList))
307  UpdateScenarioLines();
308  }
309 
310  //------------------------------------------------------------------------------------------------
311  protected void Callback_OnTimeout()
312  {
313  // Ignore if we are not connected to backend at all
314  if (!SCR_WorkshopUiCommon.GetConnectionState())
315  return;
316 
317  SCR_ConfigurableDialogUi dlg = SCR_CommonDialogs.CreateTimeoutOkDialog();
318  dlg.m_OnClose.Insert(RequestCloseMenu);
319  }
320 
321  // ---- WIDGET CALLBACKS ----
322  //------------------------------------------------------------------------------------------------
323  protected void OnDeleteButton()
324  {
325  // Unsubscribe/delete any addon data is available
326  if (m_WorkshopItem.GetOffline() || m_WorkshopItem.GetWorkshopItem().GetDownloadingRevision())
327  SCR_WorkshopUiCommon.OnUnsubscribeAddonButton(m_WorkshopItem);
328  }
329 
330  //------------------------------------------------------------------------------------------------
331  protected void OnDownloadButton()
332  {
333  // Start new download or continue in downloading
334  Revision specificVersion;
335 
336  #ifdef WORKSHOP_DEBUG
337  string strSpecificVersion = m_Widgets.m_VersionComboBoxComponent0.GetCurrentItem();
338  specificVersion = m_WorkshopItem.FindRevision(strSpecificVersion);
339  #endif
340 
341  // Setup download request
342  if (specificVersion)
344  else
346 
347  m_DownloadRequest.GetOnReady().Insert(OnClickDownloadRequestReady);
348  m_DownloadRequest.GetOnCancel().Insert(OnClickDownloadRequestCancel);
349  m_DownloadRequest.GetOnError().Insert(OnClickDownloadRequestCancel);
350 
351  // Disable button
352  m_Widgets.m_DownloadButtonComponent.SetEnabled(false);
353  }
354 
355  //------------------------------------------------------------------------------------------------
356  protected void OnClickDownloadRequestReady(SCR_DownloadSequence sequence)
357  {
359  m_Widgets.m_DownloadButtonComponent.SetEnabled(true);
360  }
361 
362  //------------------------------------------------------------------------------------------------
363  protected void OnClickDownloadRequestCancel(SCR_DownloadSequence sequence)
364  {
365  m_Widgets.m_DownloadButtonComponent.SetEnabled(true);
366  }
367 
368  //------------------------------------------------------------------------------------------------
369  protected void OnDownloadingButton()
370  {
372  }
373 
374  //------------------------------------------------------------------------------------------------
375  protected void OnSolveIssuesButton()
376  {
377  // This button does something only if there is a problem
378  EWorkshopItemProblem problem = m_WorkshopItem.GetHighestPriorityProblem();
379 
380  if (problem == EWorkshopItemProblem.NO_PROBLEM)
381  return;
382 
384  }
385 
386  //------------------------------------------------------------------------------------------------
389  protected void OnVoteUpButton()
390  {
391  bool newState = m_Widgets.m_VoteUpButtonComponent.GetToggled();
392  OnVoteButtons(newState, !newState);
393  }
394 
395  //------------------------------------------------------------------------------------------------
396  protected void OnVoteDownButton()
397  {
398  bool newState = m_Widgets.m_VoteDownButtonComponent.GetToggled();
399  OnVoteButtons(!newState, !newState);
400  }
401 
402  //------------------------------------------------------------------------------------------------
403  // resetAll - resets the rating
404  // voteUp - if not reset rating, vote up or down
405  protected void OnVoteButtons(bool voteUp, bool resetAll)
406  {
407  SCR_ModularButtonComponent bup = m_Widgets.m_VoteUpButtonComponent;
408  SCR_ModularButtonComponent bdwn = m_Widgets.m_VoteDownButtonComponent;
409 
410  bup.SetToggled(!resetAll && voteUp, false); // Don't invoke the OnToggled again!
411  bdwn.SetToggled(!resetAll && !voteUp, false);
412 
413  if (resetAll)
414  m_WorkshopItem.ResetMyRating();
415  else
416  m_WorkshopItem.SetMyRating(voteUp);
417  }
418 
419  //------------------------------------------------------------------------------------------------
420  protected void OnEnableButtonToggled(SCR_ModularButtonComponent comp)
421  {
422  SCR_WorkshopUiCommon.OnEnableAddonToggleButton(m_WorkshopItem, comp);
423  }
424 
425  //------------------------------------------------------------------------------------------------
427  protected void OnAddonFavouriteButtonToggled()
428  {
430  bool fav;
431 
432  if (item.GetRestricted())
433  return;
434 
435  fav = !item.GetFavourite();
436  item.SetFavourite(fav);
437  }
438 
439  //------------------------------------------------------------------------------------------------
441  protected void OnReportButton()
442  {
443  // Bail if not in backend
444  if (!m_WorkshopItem.GetOnline())
445  return;
446 
447  // Individually reported mod - reported by me
448  if (m_WorkshopItem.GetReportedByMe())
449  {
450  if (m_LoadingOverlayDlg)
451  m_LoadingOverlayDlg.Close();
452 
453  m_LoadingOverlayDlg = SCR_LoadingOverlayDialog.Create();
454  m_LoadingOverlayDlg.m_OnCloseStarted.Insert(Callback_OnLoadMyReportCancel); // Called when user decides to cancel and not wait
455 
456  m_WorkshopItem.m_OnMyReportLoaded.Insert(Callback_OnLoadMyReportSuccess);
457  m_WorkshopItem.m_OnMyReportLoadError.Insert(Callback_OnLoadMyReportError);
458  m_WorkshopItem.LoadReport();
459 
460  return;
461  }
462 
463  m_ModReportDialog = SCR_ModReportDialogComponent.Cast(m_wRoot.FindHandler(SCR_ModReportDialogComponent));
464  if (!m_ModReportDialog)
465  return;
466 
467  m_ModReportDialog.GetOnItemReportSuccessDialogClose().Insert(RequestCloseMenu);
468 
469  // Mod with reported author
470  if (m_WorkshopItem.GetModAuthorReportedByMe())
471  {
472  m_ModReportDialog.SetItem(m_WorkshopItem);
473  m_ModReportDialog.OnSelectReportAuthor();
474  m_WorkshopItem.m_OnReportStateChanged.Insert(OnAuthorBlockStateChanged);
475 
476  return;
477  }
478 
479  // Not reported
480  m_ModReportDialog.OpenSelectReport(m_WorkshopItem);
481  }
482 
483  //------------------------------------------------------------------------------------------------
484  protected void OnAuthorBlockStateChanged()
485  {
486  LoadWorkshopDetails();
487  m_WorkshopItem.m_OnReportStateChanged.Remove(OnAuthorBlockStateChanged);
488  }
489 
490  //------------------------------------------------------------------------------------------------
491  protected void OnAllMenuCloseJoin()
492  {
493  SCR_MenuToolsLib.GetEventOnAllMenuClosed().Remove(OnAllMenuCloseJoin);
494 
495  //GetGame().GetMenuManager().OpenMenu(ChimeraMenuPreset.ServerBrowserMenu);
497  SCR_CommonDialogs.CreateServerHostingDialog();
498  }
499 
500  //------------------------------------------------------------------------------------------------
501  // Unreporting, loading report
502  //------------------------------------------------------------------------------------------------
503  //------------------------------------------------------------------------------------------------
504  protected void Callback_OnLoadMyReportCancel()
505  {
506  m_WorkshopItem.m_OnMyReportLoaded.Remove(Callback_OnLoadMyReportSuccess); // todo improve error handling :(
507  m_WorkshopItem.m_OnMyReportLoadError.Remove(Callback_OnLoadMyReportError);
508  }
509 
510  //------------------------------------------------------------------------------------------------
511  protected void Callback_OnLoadMyReportSuccess()
512  {
513  m_WorkshopItem.m_OnMyReportLoaded.Remove(Callback_OnLoadMyReportSuccess);
514  m_WorkshopItem.m_OnMyReportLoadError.Remove(Callback_OnLoadMyReportError);
515 
516  m_LoadingOverlayDlg.CloseAnimated();
517 
519  }
520 
521  //------------------------------------------------------------------------------------------------
522  protected void Callback_OnLoadMyReportError()
523  {
524  m_WorkshopItem.m_OnMyReportLoaded.Remove(Callback_OnLoadMyReportSuccess);
525  m_WorkshopItem.m_OnMyReportLoadError.Remove(Callback_OnLoadMyReportError);
526 
527  m_LoadingOverlayDlg.CloseAnimated();
528  SCR_CommonDialogs.CreateRequestErrorDialog();
529  }
530 
531  //------------------------------------------------------------------------------------------------
532  // Methods for updating state of individual components
533  //------------------------------------------------------------------------------------------------
534  //------------------------------------------------------------------------------------------------
535  protected void LoadWorkshopDetails()
536  {
537  if (!m_WorkshopItem)
538  return;
539 
540  if (SCR_WorkshopUiCommon.GetConnectionState())
541  {
542  m_WorkshopItem.m_OnGetAsset.Insert(Callback_OnGetAsset);
543  m_WorkshopItem.m_OnChanged.Insert(Callback_OnItemChanged);
544  m_WorkshopItem.m_OnScenariosLoaded.Insert(Callback_OnDownloadScenarios);
545  m_WorkshopItem.m_OnTimeout.Insert(Callback_OnTimeout);
546  m_WorkshopItem.LoadDetails();
547  }
548  else
549  {
550  Callback_OnDownloadScenarios();
551  }
552  }
553 
554  //------------------------------------------------------------------------------------------------
555  protected void UpdateAllWidgets()
556  {
557  UpdateVersionComboBox();
558  UpdateButtons();
559  UpdateAddonStaticWidgets();
560  UpdateScenarioLines();
561  }
562 
563  //------------------------------------------------------------------------------------------------
565  protected void UpdateButtons()
566  {
567  if (!GetShown())
568  return;
569 
571  if (!item)
572  return;
573 
574  SCR_WorkshopItemActionDownload actionThisItem = item.GetDownloadAction();
575  SCR_WorkshopItemActionComposite actionDependencies = item.GetDependencyCompositeAction();
576  bool downloading = actionThisItem || actionDependencies;
577  EWorkshopItemProblem problem = item.GetHighestPriorityProblem();
578 
579  // Label of primary action
580  string primaryActionText = SCR_WorkshopUiCommon.GetPrimaryActionName(item);
581 
582  // Enable button
583  bool enableButtonEnabled = item.GetOffline() && !downloading;
584  //m_Widgets.m_EnableButtonComponent.SetVisible(enableButtonEnabled);
585  m_Widgets.m_EnableButtonComponent.SetEnabled(enableButtonEnabled);
586  m_Widgets.m_EnableButtonComponent.SetToggled(item.GetEnabled(), false);
587 
588  bool reportIndividual = item.GetReportedByMe();
589  bool reportAuthor = item.GetModAuthorReportedByMe();
590 
591  // Report button
592  m_Widgets.m_ReportButtonComponent.SetEnabled(item.GetOnline());
593  string reportButtonMode = "not_reported";
594  if (reportIndividual || reportAuthor)
595  reportButtonMode = "reported";
596  m_Widgets.m_ReportButtonComponent.SetEffectsWithAnyTagEnabled({"all", reportButtonMode});
597 
599  Revision downloadRevision = item.GetWorkshopItem().GetDownloadingRevision();
600  bool differentEnvironment = item.GetWorkshopItem().GetBackendEnv() != GetGame().GetBackendApi().GetBackendEnv();
601 
602  bool downloaded = !downloading && item.GetOnline() && (item.GetOffline() || differentEnvironment);
603 
604  m_Widgets.m_DownloadButtonComponent.SetVisible(!downloaded && !downloading);
605  m_Widgets.m_DeleteButtonComponent.SetVisible(downloaded);
606  m_Widgets.m_DownloadingButtonComponent.SetVisible(downloading);
607 
608  // Solve issues button
609  // Visible only when there are any issues
610  bool solveIssuesVisible = problem != EWorkshopItemProblem.NO_PROBLEM;
611  m_Widgets.m_SolveIssuesButton.SetVisible(solveIssuesVisible);
612  if (solveIssuesVisible)
613  {
614  SCR_ButtonEffectText textEffect = SCR_ButtonEffectText.Cast(m_Widgets.m_SolveIssuesButtonComponent.FindEffect("text"));
615  textEffect.m_sDefault = primaryActionText;
616  textEffect.m_sHovered = primaryActionText;
617  textEffect.PropertiesChanged();
618  }
619 
620  // Vote up/down
621  bool enabled = item.GetOnline();
622  m_Widgets.m_VoteUpButtonComponent.SetEnabled(enabled);
623  m_Widgets.m_VoteDownButtonComponent.SetEnabled(enabled);
624 
625  bool rating, ratingSet;
626  item.GetMyRating(ratingSet, rating);
627 
628  bool voteUpToggled = ratingSet && rating;
629  bool voteDownToggled = ratingSet && !rating;
630 
631  m_Widgets.m_VoteUpButtonComponent.SetToggled(voteUpToggled, false);
632  m_Widgets.m_VoteDownButtonComponent.SetToggled(voteDownToggled, false);
633 
635  m_Widgets.m_FavoriteButtonComponent.SetToggled(m_WorkshopItem.GetFavourite(), false);
636 
638  UpdateNavigationButtons();
639  }
640 
641  //------------------------------------------------------------------------------------------------
643  protected void UpdateAddonStaticWidgets()
644  {
645  if (!m_WorkshopItem)
646  return;
647 
648  // Name
649  m_Widgets.m_NameText.SetText(m_WorkshopItem.GetName());
650 
651  // Description
652  string description = m_WorkshopItem.GetDescription();
653  m_Widgets.m_DescriptionText.SetText(description);
654 
655  // Author
656  m_Widgets.m_AuthorNameText.SetText(m_WorkshopItem.GetAuthorName());
657 
658  // Rating
659  int ratingCount = m_WorkshopItem.GetRatingCount();
660  float avgRating = m_WorkshopItem.GetAverageRating();
661  avgRating = Math.Round(avgRating * 100.0);
662  m_Widgets.m_RatingText.SetText(string.Format("%1%% (%2x)", avgRating, ratingCount));
663  }
664 
665  //------------------------------------------------------------------------------------------------
666  protected void UpdateVersionComboBox()
667  {
668  #ifdef WORKSHOP_DEBUG
669  // Fill version combo box - only for testing!
670  if (m_Widgets.m_VersionComboBoxComponent0.GetNumItems() == 0)
671  {
672  array<string> versions = m_WorkshopItem.GetVersions();
673  if (!versions.IsEmpty())
674  {
675  m_Widgets.m_VersionComboBoxComponent0.ClearAll();
676  foreach (string version : versions)
677  {
678  m_Widgets.m_VersionComboBoxComponent0.AddItem(version);
679  }
680  }
681  }
682  #endif
683  }
684 
685  //------------------------------------------------------------------------------------------------
686  protected void UpdateGallery()
687  {
688  if (m_bGalleryUpdated)
689  return;
690 
691  array<BackendImage> galleryImages = m_WorkshopItem.GetGallery();
692 
693  m_Widgets.m_Gallery.SetVisible(!galleryImages.IsEmpty());
694 
695  if (!galleryImages.IsEmpty())
696  {
697  m_Widgets.m_GalleryComponent.SetImages(galleryImages);
698  m_bGalleryUpdated = true;
699  }
700  }
701 
702  //------------------------------------------------------------------------------------------------
703  protected void UpdateScenarioLines()
704  {
705  bool modDownloaded = m_WorkshopItem.GetOffline();
706  foreach (SCR_ContentBrowser_ScenarioLineComponent scenarioLine : m_aScenarioLines)
707  {
708  if (scenarioLine)
709  {
710  // Show favorites and mouse buttons only when downloaded
711  scenarioLine.ShowFavouriteButton(modDownloaded);
712  scenarioLine.ShowMouseInteractionButtons(modDownloaded);
713  scenarioLine.ShowLastPlayedText(modDownloaded);
714  scenarioLine.NotifyScenarioUpdate();
715  }
716  }
717  }
718 
719  //------------------------------------------------------------------------------------------------
720  protected void LineInteractionTryDownload(SCR_ContentBrowser_ScenarioLineComponent line)
721  {
722  // Check if the addon is downloaded
723  if (!line || (m_WorkshopItem && m_WorkshopItem.GetOffline()))
724  return;
725 
727  // Clicking a line without the addon installed starts the download
728  bool inProgress, paused;
729  float progress;
730  Revision revision;
731  m_WorkshopItem.GetDownloadState(inProgress, paused, progress, revision);
732 
733  if (!inProgress && !paused)
734  OnDownloadButton();
735  }
736 }
EWorkshopItemProblem
EWorkshopItemProblem
Definition: SCR_WorkshopItem.c:11
m_WorkshopItem
enum SCR_EModDetailsMenuTabs m_WorkshopItem
SCR_MenuToolsLib
Definition: SCR_MenuToolsLib.c:5
SCR_ModReportDialogComponent
Definition: SCR_ModReportDialogComponent.c:1
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_DownloadSequence
Definition: SCR_DownloadSequence.c:19
SCR_WorkshopDownloadSequence
Definition: SCR_WorkshopDownloadSequence.c:9
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_CommonDialogs
Definition: CommonDialogs.c:5
SCR_WorkshopItemActionDownload
Definition: SCR_WorkshopItemActionDownload.c:9
SCR_ButtonEffectText
Effect which changes text of a text or rich text widget.
Definition: SCR_ButtonEffectText.c:3
IsPlatformGameConsole
bool IsPlatformGameConsole()
Definition: game.c:1393
SCR_ContentBrowser_ScenarioLineComponent
Definition: SCR_ContentBrowser_ScenarioLineComponent.c:4
m_Widgets
ref SCR_VoNOverlay_ElementWidgets m_Widgets
Definition: SCR_VonDisplay.c:3
SCR_WorkshopItem
Definition: SCR_WorkshopItem.c:21
ContentBrowserDetailsMenu
Definition: ContentBrowserDetailsMenu.c:2
SCR_CancelMyReportDialog
Dialog which sends a request to delete user's report.
Definition: SCR_WorkshopUiCommon.c:973
MainMenuUI
Definition: MainMenuUI.c:1
CreateLines
protected void CreateLines(Widget w)
Definition: SCR_ServicesStatusDialogComponent.c:133
SCR_LoadingOverlayDialog
Definition: SCR_LoadingOverlayDialog.c:5
SCR_ContentBrowserDetails_OverviewSubMenuWidgets
Definition: SCR_ContentBrowserDetails_OverviewSubMenuWidgets.c:4
m_DownloadRequest
protected ref SCR_WorkshopDownloadSequence m_DownloadRequest
Definition: SCR_ContentBrowser_AddonsSubMenu.c:50
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
GetInputManager
protected InputManager GetInputManager()
Definition: SCR_BaseManualCameraComponent.c:65
SCR_DownloadManager_Dialog
void SCR_DownloadManager_Dialog()
Definition: SCR_DownloadManager_Dialog.c:491
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
SCR_ConfigurableDialogUi
Definition: SCR_ConfigurableDialogUI.c:13
SCR_ContentBrowserDetails_OverviewSubMenu
Definition: SCR_ContentBrowserDetails_OverviewSubMenu.c:5
SCR_WorkshopUiCommon
Definition: SCR_WorkshopUiCommon.c:5
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
SCR_WorkshopItemActionComposite
Composite action which includes multiple subactions.
Definition: SCR_WorkshopItemAction.c:408
ServerBrowserMenuUI
Definition: ServerBrowserMenuUI.c:10
SCR_InputButtonComponent
Definition: SCR_InputButtonComponent.c:1
SCR_ContentBrowser_ScenarioSubMenuBase
Definition: SCR_ContentBrowser_ScenarioSubMenuBase.c:5