Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ContentBrowserDetails_OverviewSubMenu.c
Go to the documentation of this file.
1/*
2The overview tab of the details view
3*/
4
5class SCR_ContentBrowserDetails_OverviewSubMenu : SCR_ContentBrowser_ScenarioSubMenuBase
6{
7 protected ref SCR_WorkshopItem m_Item;
8
10
15
16 protected SCR_ERevisionAvailability m_eRevisionAvailability;
17 protected SCR_EAddonPrimaryActionState m_ePrimaryActionState;
18
20
23
24 //------------------------------------------------------------------------------------------------
26 {
27 if (!item)
28 return;
29
31
32 m_Item = item;
33
34 m_Item.m_OnGetAsset.Insert(Callback_OnGetAsset);
35 m_Item.m_OnChanged.Insert(Callback_OnItemChanged);
36 m_Item.m_OnScenariosLoaded.Insert(Callback_OnDownloadScenarios);
37 m_Item.m_OnTimeout.Insert(Callback_OnTimeout);
38
39 // Init the addon details panel
40 m_Widgets.m_AddonDetailsPanelComponent.SetWorkshopItem(m_Item);
41
42 // Load Item
44 }
45
46 //------------------------------------------------------------------------------------------------
47 override void HandlerAttached(Widget w)
48 {
49 super.HandlerAttached(w);
50
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 m_Widgets.m_DescriptionHoverDetectorComponent.GetOnMouseEnter().Insert(OnDescriptionMouseEnter);
61 }
62
63 //------------------------------------------------------------------------------------------------
64 override void HandlerDeattached(Widget w)
65 {
66 super.HandlerDeattached(w);
67
69
72
74 if (downloadManager)
75 {
76 downloadManager.m_OnNewDownload.Remove(OnAnyNewDownload);
77 downloadManager.m_OnDownloadFailed.Remove(OnAnyDownloadError);
78 downloadManager.m_OnDownloadCanceled.Remove(OnAnyDownloadCompleted);
79 downloadManager.m_OnDownloadComplete.Remove(OnAnyDownloadCompleted);
80 }
81 }
82
83 //------------------------------------------------------------------------------------------------
84 override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
85 {
86 super.OnTabCreate(menuRoot, buttonsLayout, index);
87
88 m_ScenarioDetailsPanel = m_Widgets.m_ScenarioDetailsPanelComponent;
89
90 // Hide verrsion selection in release
91 #ifndef WORKSHOP_DEBUG
92 m_Widgets.m_VersionComboBoxComponent0.SetVisible(false, false);
93 #endif
94
95 // Hide scenario and gallery section
96 m_Widgets.m_wGallery.SetVisible(false);
97 m_Widgets.m_wScenarioSection.SetVisible(false);
98
99 // Init event handlers last of all.
100 // We don't want event handlers to get called while we are still initializing UI.
101 m_Widgets.m_VoteUpButtonComponent0.m_OnToggled.Insert(OnVoteUpButton);
102 m_Widgets.m_VoteDownButtonComponent0.m_OnToggled.Insert(OnVoteDownButton);
103
104 m_Widgets.m_EnableButtonComponent.m_OnToggled.Insert(OnEnableButtonToggled);
105 m_Widgets.m_FavoriteButtonComponent0.m_OnToggled.Insert(OnAddonFavouriteButtonToggled);
106 m_Widgets.m_RepairButtonComponent0.m_OnClicked.Insert(OnRepairActionButton);
107 m_Widgets.m_ReportButtonComponent0.m_OnClicked.Insert(OnReportButton);
108 m_Widgets.m_PrimaryActionButtonComponent0.m_OnClicked.Insert(OnPrimaryActionButton);
109 m_Widgets.m_DeleteButtonComponent0.m_OnClicked.Insert(OnDeleteButton);
110 m_Widgets.m_LicensesComponent0.m_OnClicked.Insert(OnLicensesButton);
111 m_Widgets.m_DependenciesComponent0.m_OnClicked.Insert(OnDependenciesButton);
112 m_Widgets.m_DependentComponent0.m_OnClicked.Insert(OnDependentButton);
113
114 m_Downloads = m_DynamicFooter.FindButton("DownloadManager");
115
116 m_LicenseAndContributors = m_DynamicFooter.FindButton("LicenseAndContributors");
118 m_LicenseAndContributors.m_OnActivated.Insert(OnLicensesButton);
119 }
120
121 //------------------------------------------------------------------------------------------------
122 override void OnTabShow()
123 {
124 super.OnTabShow();
125
127 m_LicenseAndContributors.SetVisible(true, false);
128
130
131 // Set the default focused widget to one we're sure is always present
132 Widget defaultFocus = m_Widgets.m_wFavoriteButton;
133 GetGame().GetCallqueue().Call(UpdateFocus, defaultFocus);
134
136 }
137
138 //------------------------------------------------------------------------------------------------
139 override void OnTabRemove()
140 {
141 super.OnTabRemove();
142
145
147 }
148
149 //------------------------------------------------------------------------------------------------
150 override void OnTabHide()
151 {
152 super.OnTabHide();
153
154 // This button must be visible in other tabs as well
155 if (m_Downloads)
156 m_Downloads.SetVisible(true);
157
159 m_LicenseAndContributors.SetVisible(false, false);
160
162 }
163
164 //------------------------------------------------------------------------------------------------
165 override void OnMenuFocusGained()
166 {
167 //Bring back focus to the last selected line after closing a pop-up dialog
168 if (!GetGame().GetMenuManager().IsAnyDialogOpen())
169 {
170 Widget target;
171
173 target = m_LastSelectedLine.GetRootWidget();
174 else if (m_Widgets && m_Widgets.m_wScenariosList)
175 target = m_Widgets.m_wScenariosList.GetChildren();
176
177 if (!target)
178 target = m_Widgets.m_wFavoriteButton;
179
180 UpdateFocus(target);
181 }
182
183 super.OnMenuFocusGained();
184 }
185
186 //------------------------------------------------------------------------------------------------
188 {
189 super.OnLineFocus(entry);
190
191 if (m_Downloads)
192 m_Downloads.SetVisible(false, false);
193 }
194
195 //------------------------------------------------------------------------------------------------
197 {
198 super.OnLineFocusLost(entry);
199
200 if (m_Downloads)
201 m_Downloads.SetVisible(true, false);
202 }
203
204 //------------------------------------------------------------------------------------------------
205 // Restore the scenario details display if we move the mouse back on an already focused line
207 {
208 super.OnLineMouseEnter(entry);
209
211 if (!lineComp)
212 return;
213
214 if (m_MouseTriggeredPanelUpdate && lineComp.IsFocused())
215 {
216 GetGame().GetCallqueue().Call(UpdateSidePanel);
218 }
219 }
220
221 //------------------------------------------------------------------------------------------------
222 override void UpdateNavigationButtons(bool visible = true)
223 {
224 visible =
225 visible &&
226 m_Item &&
227 m_Item.GetOffline() &&
228 GetSelectedLine() &&
229 GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.MOUSE;
230
231 super.UpdateNavigationButtons(visible);
232 }
233
234 //------------------------------------------------------------------------------------------------
236 {
237 if (!lineComp)
238 return;
239
241 if (!m_Item || !m_Item.GetOffline())
242 {
243 if (GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.MOUSE)
245
246 return;
247 }
248
250 super.OnLineClick(lineComp);
251 }
252
253 //------------------------------------------------------------------------------------------------
255 {
256 if (!lineComp)
257 return;
258
260 if (!m_Item || !m_Item.GetOffline())
261 {
263 return;
264 }
265
267 super.OnLineDoubleClick(lineComp);
268 }
269
270 //------------------------------------------------------------------------------------------------
272 {
273 if (!m_Item || !m_Item.GetOffline())
274 return;
275
276 super.OnPlayInteraction(scenario);
277 }
278
279 //------------------------------------------------------------------------------------------------
280 override bool Play(MissionWorkshopItem scenario)
281 {
282 if (!super.Play(scenario))
283 return false;
284
285 SCR_MenuLoadingComponent.SaveLastMenu(ChimeraMenuPreset.ScenarioMenu);
286 return true;
287 }
288
289 //------------------------------------------------------------------------------------------------
290 override void Join(MissionWorkshopItem scenario)
291 {
292 if (!scenario || !SCR_ScenarioUICommon.CanJoin(scenario))
293 return;
294
295 // Interrupt when server config is being edited
296 // just temporary solution to prevent endless opening of menus
297 if (ServerHostingUI.GetTemporaryConfig() && SCR_ScenarioUICommon.CanHost(scenario))
298 {
301 return;
302 }
303
304 super.Join(scenario);
305 }
306
307 //------------------------------------------------------------------------------------------------
309 override void SetFavorite(MissionWorkshopItem scenario)
310 {
311 if (!m_Item || !m_Item.GetOffline())
312 return;
313
314 super.SetFavorite(scenario);
315 }
316
317 //------------------------------------------------------------------------------------------------
320 {
322
323 super.OnScenarioStateChanged(comp);
324 }
325
326 //------------------------------------------------------------------------------------------------
327 override void InitWidgets()
328 {
329 super.InitWidgets();
330 m_Widgets.Init(m_wRoot);
331 }
332
333 //------------------------------------------------------------------------------------------------
334 override void UpdateSidePanel()
335 {
336 super.UpdateSidePanel();
337
338 GetGame().GetCallqueue().Remove(UpdateSidePanel);
339
341
342 m_Widgets.m_wAddonDetailsPanel.SetVisible(!lineComp);
343 m_Widgets.m_wScenarioDetailsPanel.SetVisible(lineComp != null);
344 }
345
346 //------------------------------------------------------------------------------------------------
347 protected void HandleDownloadChanges()
348 {
349 if (!m_Item)
350 return;
351
353
357
358 WorkshopItem item = m_Item.GetWorkshopItem();
359 Revision itemRevision = item.GetActiveRevision();
360
361 m_Widgets.m_wRepairButton.SetVisible(itemRevision && itemRevision.IsCorrupted());
362
363 // Continuous update
366 else
368 }
369
370 //------------------------------------------------------------------------------------------------
371 protected void StartContinuousUpdate()
372 {
374 return;
375
376 // Update download progress widgets
377 GetGame().GetCallqueue().CallLater(ContinuousUpdate, SCR_WorkshopUiCommon.CONTINUOUS_UPDATE_DELAY, true);
378
380 }
381
382 //------------------------------------------------------------------------------------------------
383 protected void StopContinuousUpdate()
384 {
386 GetGame().GetCallqueue().Remove(ContinuousUpdate);
387
389 }
390
391 //------------------------------------------------------------------------------------------------
400
401 //------------------------------------------------------------------------------------------------
403 {
404 if (!m_Item)
405 return;
406
407 m_Item.m_OnGetAsset.Remove(Callback_OnGetAsset);
408 m_Item.m_OnChanged.Remove(Callback_OnItemChanged);
409 m_Item.m_OnScenariosLoaded.Remove(Callback_OnDownloadScenarios);
410 m_Item.m_OnTimeout.Remove(Callback_OnTimeout);
411 }
412
413 // ---- CALLBACKS ----
414 //------------------------------------------------------------------------------------------------
416 {
419 }
420
421 //------------------------------------------------------------------------------------------------
423 {
425 }
426
427 //------------------------------------------------------------------------------------------------
430 {
431 array<MissionWorkshopItem> scenarios = {};
432 m_Item.GetScenarios(scenarios);
433
434 #ifdef WORKSHOP_DEBUG
435 ContentBrowserUI._print(string.Format("Downloaded %1 scenarios", scenarios.Count()));
436 #endif
437
438 m_Widgets.m_wScenarioSection.SetVisible(!scenarios.IsEmpty());
439
440 // Delete old entries
441 while (m_Widgets.m_wScenariosList.GetChildren())
442 {
443 m_Widgets.m_wScenariosList.RemoveChild(m_Widgets.m_wScenariosList.GetChildren());
444 }
445
446 // Sort missions by name
447 SCR_Sorting<MissionWorkshopItem, SCR_CompareMissionName>.HeapSort(scenarios, false);
448
449 CreateLines(scenarios, m_Widgets.m_wScenariosList);
451 }
452
453 //------------------------------------------------------------------------------------------------
454 protected void Callback_OnTimeout()
455 {
456 // Ignore if we are not connected to backend at all
458 return;
459
460 SCR_ConfigurableDialogUi dlg = SCR_CommonDialogs.CreateTimeoutOkDialog();
461 dlg.m_OnClose.Insert(RequestCloseMenu);
462 }
463
464 // --- Any downloads ---
465 // We need to update the progress bar and main action display if we start downloading this item or any of its dependencies
466 //------------------------------------------------------------------------------------------------
468 {
469 GetGame().GetCallqueue().Call(HandleDownloadChanges);
470 }
471
472 //------------------------------------------------------------------------------------------------
477
478 //------------------------------------------------------------------------------------------------
483
484 // ---- WIDGET CALLBACKS ----
485 //------------------------------------------------------------------------------------------------
486 protected void OnDeleteButton()
487 {
488 if (!m_Item)
489 return;
490
491 // Unsubscribe/delete any addon data is available
492 if (m_Item.GetOffline() || m_Item.GetWorkshopItem().GetDownloadingRevision())
494 }
495
496 //------------------------------------------------------------------------------------------------
497 protected void OnLicensesButton()
498 {
499 if (!m_Item)
500 return;
501
503 }
504
505 //------------------------------------------------------------------------------------------------
506 protected void OnPrimaryActionButton()
507 {
508 Revision revisionToDownload;
509
510 #ifdef WORKSHOP_DEBUG
511 string strSpecificVersion = m_Widgets.m_VersionComboBoxComponent0.GetCurrentItem();
512 revisionToDownload = m_Item.FindRevision(strSpecificVersion);
513 #endif
514
516 }
517
518 //------------------------------------------------------------------------------------------------
519 protected void OnDependenciesButton()
520 {
521 RequestTabChange(SCR_EModDetailsMenuTabs.DEPENDENCY);
522 }
523
524 //------------------------------------------------------------------------------------------------
525 protected void OnDependentButton()
526 {
527 RequestTabChange(SCR_EModDetailsMenuTabs.DEPENDENT);
528 }
529
530 // --- Rating ---
531 // We have two buttons: vote up and vote down. They have a toggled visual
532 // When we interact with one of the buttons, we also need to update the other's toggled visual
533 // They are mutually esclusive, so rating has three states: neutral, positive, negative
534 //------------------------------------------------------------------------------------------------
535 // By the time when this is called, the button has already been toggled by the widget library code
536 protected void OnVoteUpButton()
537 {
538 bool toggled = m_Widgets.m_VoteUpButtonComponent0.GetToggled();
539 OnVoteButtons(toggled, !toggled);
540 }
541
542 //------------------------------------------------------------------------------------------------
543 protected void OnVoteDownButton()
544 {
545 bool toggled = m_Widgets.m_VoteDownButtonComponent0.GetToggled();
546 OnVoteButtons(!toggled, !toggled);
547 }
548
549 //------------------------------------------------------------------------------------------------
550 // resetAll - resets the rating
551 // voteUp - if not reset rating, vote up or down
552 protected void OnVoteButtons(bool voteUp, bool resetAll)
553 {
554 if (resetAll)
555 m_Item.ResetMyRating();
556 else
557 m_Item.SetMyRating(voteUp);
558
559 //TODO: delayed update based on callback
561 }
562
563 //------------------------------------------------------------------------------------------------
564 protected void OnEnableButtonToggled(SCR_ModularButtonComponent comp)
565 {
567 }
568
569 //------------------------------------------------------------------------------------------------
571 protected void OnRepairActionButton()
572 {
573 if (!m_Item || m_Item.GetRestricted())
574 return;
575
576 SCR_ValidateRepair_Dialog dialogValidator = SCR_CommonDialogs.CreateValidateRepairDialog();
577 dialogValidator.LoadAddon(m_Item);
578 }
579
580 //------------------------------------------------------------------------------------------------
583 {
584 if (!m_Item || m_Item.GetRestricted())
585 return;
586
587 m_Item.SetFavourite(!m_Item.GetFavourite());
589 }
590
591 //------------------------------------------------------------------------------------------------
593 protected void OnReportButton()
594 {
595 // Bail if not in backend
596 if (!m_Item.GetOnline())
597 return;
598
599 // Individually reported mod - reported by me
600 if (m_Item.GetReportedByMe())
601 {
603 m_LoadingOverlay.Close();
604
606 m_LoadingOverlay.m_OnCloseStarted.Insert(Callback_OnLoadMyReportCancel); // Called when user decides to cancel and not wait
607
608 m_Item.m_OnMyReportLoaded.Insert(Callback_OnLoadMyReportSuccess);
609 m_Item.m_OnMyReportLoadError.Insert(Callback_OnLoadMyReportError);
610 m_Item.LoadReport();
611
612 return;
613 }
614
615 // TODO: move to configurable dialog
617 if (!comp)
618 return;
619
620 comp.GetOnItemReportSuccessDialogClose().Insert(RequestCloseMenu);
621
622 // Mod with reported author
623 if (m_Item.GetModAuthorReportedByMe())
624 {
626 m_Item.m_OnReportStateChanged.Insert(OnReportStateChanged);
627
628 return;
629 }
630
631 // Not reported
633 }
634
635 //------------------------------------------------------------------------------------------------
636 protected void OnReportStateChanged()
637 {
639 m_Item.m_OnReportStateChanged.Remove(OnReportStateChanged);
640 }
641
642 //------------------------------------------------------------------------------------------------
643 protected void OnAllMenuCloseJoin()
644 {
646 SCR_CommonDialogs.CreateServerHostingDialog();
647 }
648
649 //------------------------------------------------------------------------------------------------
650 // Restore the addon details display if we move the mouse in the description area
651 protected void OnDescriptionMouseEnter()
652 {
653 m_Widgets.m_wAddonDetailsPanel.SetVisible(true);
654 m_Widgets.m_wScenarioDetailsPanel.SetVisible(false);
655
657 }
658
659 //------------------------------------------------------------------------------------------------
660 // Unreporting, loading report
661 //------------------------------------------------------------------------------------------------
662 //------------------------------------------------------------------------------------------------
664 {
665 m_Item.m_OnMyReportLoaded.Remove(Callback_OnLoadMyReportSuccess); // todo improve error handling :(
666 m_Item.m_OnMyReportLoadError.Remove(Callback_OnLoadMyReportError);
667 }
668
669 //------------------------------------------------------------------------------------------------
671 {
672 m_Item.m_OnMyReportLoaded.Remove(Callback_OnLoadMyReportSuccess);
673 m_Item.m_OnMyReportLoadError.Remove(Callback_OnLoadMyReportError);
674
675 m_LoadingOverlay.CloseAnimated();
676
678 }
679
680 //------------------------------------------------------------------------------------------------
682 {
683 m_Item.m_OnMyReportLoaded.Remove(Callback_OnLoadMyReportSuccess);
684 m_Item.m_OnMyReportLoadError.Remove(Callback_OnLoadMyReportError);
685
686 m_LoadingOverlay.CloseAnimated();
687 SCR_CommonDialogs.CreateRequestErrorDialog();
688 }
689
690 //------------------------------------------------------------------------------------------------
691 // Methods for updating state of individual components
692 //------------------------------------------------------------------------------------------------
693 //------------------------------------------------------------------------------------------------
694 protected void LoadWorkshopDetails()
695 {
696 if (!m_Item)
697 return;
698
699 if (!m_Item.GetDetailsLoaded())
700 m_Item.LoadDetails();
701
705 }
706
707 //------------------------------------------------------------------------------------------------
708 protected void UpdateAllWidgets()
709 {
710 if (!m_Item)
711 return;
712
714
717 //UpdateTimeInfoWidgets();
720
723
724 m_Widgets.m_wDescriptionText.SetText(m_Item.GetDescription());
725 m_Widgets.m_wSummaryText.SetText(m_Item.GetSummary());
726 }
727
728 //------------------------------------------------------------------------------------------------
729 protected void UpdateStateFlags()
730 {
731 if (!m_Item)
732 return;
733
735 WorkshopItem item = m_Item.GetWorkshopItem();
736 EWorkshopItemProblem itemProblem = m_Item.GetHighestPriorityProblem();
737
738 // --- Revision Availability ---
739 m_eRevisionAvailability = SCR_ERevisionAvailability.ERA_UNKNOWN_AVAILABILITY;
740 if (item)
741 m_eRevisionAvailability = addonManager.ItemAvailability(item);
742
743 // --- Primary Action State ---
745 }
746
747 //------------------------------------------------------------------------------------------------
749 protected void UpdateButtons()
750 {
751 if (!m_bShown || !m_Item)
752 return;
753
754 // --- Enable button ---
757
758 // --- Report button ---
759 m_Widgets.m_ReportButtonComponent0.SetEnabled(m_Item.GetOnline());
760 m_Widgets.m_ReportButtonComponent0.SetToggled(m_Item.GetReportedByMe() || m_Item.GetModAuthorReportedByMe(), false);
762
763 // --- Vote up/down ---
765
766 // --- Favourite button ---
767 m_Widgets.m_FavoriteButtonComponent0.SetToggled(m_Item.GetFavourite(), false);
769
770 // --- Dependencies ---
772
773 // --- Navigation buttons ---
775 }
776
777 //------------------------------------------------------------------------------------------------
779 {
780 if (!m_Item)
781 return;
782
783 m_Widgets.m_wPrimaryActionButton.SetVisible(m_ePrimaryActionState != SCR_EAddonPrimaryActionState.DOWNLOADED && !m_Item.GetRestricted());
784 if (!m_Widgets.m_wPrimaryActionButton.IsVisible())
785 return;
786
788
789 SCR_ButtonEffectColor iconColorEffect = SCR_ButtonEffectColor.Cast(m_Widgets.m_PrimaryActionButtonComponent0.FindEffect(SCR_ListEntryHelper.EFFECT_ICON_COLOR));
790 if (!iconColorEffect)
791 return;
792
793 SCR_ButtonEffectColor messageColorEffect = SCR_ButtonEffectColor.Cast(m_Widgets.m_PrimaryActionButtonComponent0.FindEffect(SCR_ListEntryHelper.EFFECT_MESSAGE_COLOR));
794 if (!messageColorEffect)
795 return;
796
797 string icon;
798 string message;
799 Color iconColor;
800 Color messageColor;
802
803 if (iconColor)
804 {
805 iconColorEffect.m_cDefault = iconColor;
806 iconColorEffect.m_cFocusLost = iconColor;
807 }
808
809 if (messageColor)
810 {
811 messageColorEffect.m_cDefault = messageColor;
812 messageColorEffect.m_cFocusLost = messageColor;
813 }
814
815 m_Widgets.m_PrimaryActionButtonComponent0.InvokeAllEnabledEffects(true);
816
817 m_Widgets.m_PrimaryActionButtonComponent1.SetImage(icon);
818 m_Widgets.m_PrimaryActionButtonComponent2.SetTitle(message);
819 }
820
821 //------------------------------------------------------------------------------------------------
822 protected void UpdateDeleteButton()
823 {
824 if (!m_Item)
825 return;
826
828 bool differentEnvironment = m_Item.GetWorkshopItem().GetBackendEnv() != GetGame().GetBackendApi().GetBackendEnv();
829 SCR_ERevisionAvailability availability = SCR_AddonManager.ItemAvailability(m_Item.Internal_GetWorkshopItem());
830
831 m_Widgets.m_DeleteButtonComponent0.SetVisible(
832 !downloading &&
833 m_Item.GetOnline() &&
834 (differentEnvironment || m_Item.GetOffline()) &&
835 availability != SCR_ERevisionAvailability.ERA_DOWNLOAD_NOT_FINISHED
836 )
837 }
838
839 //------------------------------------------------------------------------------------------------
841 {
842 if (!m_Item)
843 return;
844
845 float progress;
846
847 if (m_Item && m_ePrimaryActionState == SCR_EAddonPrimaryActionState.DOWNLOADING)
849
850 m_Widgets.m_wDownloadProgressBar.SetCurrent(progress);
851 m_Widgets.m_wDownloadProgressBarOverlay.SetVisible(progress > 0);
852 }
853
854 //------------------------------------------------------------------------------------------------
855 protected void UpdateRatingButtons()
856 {
857 if (!m_Item)
858 return;
859
860 m_Widgets.m_VoteUpButtonComponent0.SetEnabled(m_Item.GetOnline());
861 m_Widgets.m_VoteDownButtonComponent0.SetEnabled(m_Item.GetOnline());
862
863 bool upvote, ratingSet;
864 m_Item.GetMyRating(ratingSet, upvote);
865
866 m_Widgets.m_VoteUpButtonComponent0.SetToggled(ratingSet && upvote, false);
867 m_Widgets.m_VoteDownButtonComponent0.SetToggled(ratingSet && !upvote, false);
868
869 bool restricted = m_Item.GetRestricted();
872
873 WorkshopItem item = m_Item.GetWorkshopItem();
874 bool showVotes;
875 if (item)
876 showVotes = item.IsAuthor() || item.IsContributor();
877
878 m_Widgets.m_VoteUpButtonComponent2.SetTitleVisible(showVotes);
879 m_Widgets.m_VoteDownButtonComponent2.SetTitleVisible(showVotes);
880
881 if (showVotes)
882 {
883 m_Widgets.m_VoteUpButtonComponent2.SetTitle(upVotes.ToString());
884 m_Widgets.m_VoteDownButtonComponent2.SetTitle(downVotes.ToString());
885 }
886 }
887
888 //------------------------------------------------------------------------------------------------
890 {
891 if (!m_Item)
892 return;
893
894 int nDependent = Math.ClampInt(SCR_WorkshopUiCommon.GetDownloadedDependentAddons(m_Item).Count(), 0, SCR_WorkshopUiCommon.MAX_DEPENDENCIES_SHOWN);
895 int nDependencies = Math.ClampInt(m_Item.GetLatestDependencies().Count(), 0, SCR_WorkshopUiCommon.MAX_DEPENDENCIES_SHOWN);
896
897 // Displays
898 m_Widgets.m_wDependent.SetVisible(nDependent > 0);
899 m_Widgets.m_wDependencies.SetVisible(nDependencies > 0);
900
901 if (nDependent > 0)
902 {
903 if (nDependent == 1)
904 m_Widgets.m_DependentComponent2.SetTitle(SCR_WorkshopUiCommon.LABEL_DEPENDENT_NUMBER_ONE);
905 else
906 m_Widgets.m_DependentComponent2.m_wTitle.SetTextFormat(SCR_WorkshopUiCommon.LABEL_DEPENDENT_NUMBER, nDependent);
907 }
908
909 if (nDependencies > 0)
910 {
911 if (nDependencies == 1)
912 m_Widgets.m_DependenciesComponent2.SetTitle(SCR_WorkshopUiCommon.LABEL_DEPENDENCIES_NUMBER_ONE);
913 else
914 m_Widgets.m_DependenciesComponent2.m_wTitle.SetTextFormat(SCR_WorkshopUiCommon.LABEL_DEPENDENCIES_NUMBER, nDependencies);
915 }
916
918 }
919 /* TODO: disabled for now, we might return to this display in the future
920 //------------------------------------------------------------------------------------------------
921 protected void UpdateTimeInfoWidgets()
922 {
923 if (!m_Item)
924 return;
925
926 // Time since first downloaded
927 int time = m_Item.GetTimeSinceFirstDownload();
928 m_Widgets.m_wLastDownloadedHorizontalLayout.SetVisible(time >= 0);
929
930 if (time >= 0)
931 m_Widgets.m_wLastDownloaded.SetText(SCR_FormatHelper.GetTimeSinceEventImprecise(time));
932
933 // Time since last played
934 time = m_Item.GetTimeSinceLastPlay();
935 m_Widgets.m_wLastPlayedHorizontalLayout.SetVisible(time >= 0);
936
937 if (time >= 0)
938 m_Widgets.m_wLastPlayed.SetText(SCR_FormatHelper.GetTimeSinceEventImprecise(time));
939 }*/
940
941 //------------------------------------------------------------------------------------------------
942 protected void UpdateSizeInfoWidgets()
943 {
944 if (!m_Item)
945 return;
946
947 float sizef = m_Item.GetSizeBytes();
948 string sizeStr = SCR_ByteFormat.GetReadableSize(sizef);
949 m_Widgets.m_AddonSizeComponent1.SetTitle(sizeStr);
950 }
951
952 //------------------------------------------------------------------------------------------------
954 {
955 bool showUpdateText;
956 string currentVersionIcon;
957 Color currentVersionIconColor;
958 string currentVersionText;
959 Color currentVersionTextColor;
960 string updateVersionText;
961
963 m_Item,
964 showUpdateText,
965 currentVersionIcon,
966 currentVersionIconColor,
967 currentVersionText,
968 currentVersionTextColor,
969 updateVersionText);
970
971 m_Widgets.m_wVersionUpdateHorizontalLayout.SetVisible(showUpdateText);
972 m_Widgets.m_wCurrentVersion.SetColor(currentVersionTextColor);
973 m_Widgets.m_wCurrentVersion.SetText(currentVersionText);
974 m_Widgets.m_wUpdateVersion.SetText(updateVersionText);
975 m_Widgets.m_wCurrentVersionIcon.SetColor(currentVersionIconColor);
976 m_Widgets.m_wCurrentVersionIcon.LoadImageFromSet(0, UIConstants.ICONS_IMAGE_SET, currentVersionIcon);
977 }
978
979 //------------------------------------------------------------------------------------------------
980 protected void UpdateGallery()
981 {
982 if (!m_Item)
983 {
984 m_Widgets.m_wGallery.SetVisible(false);
985 return;
986 }
987
988 array<BackendImage> galleryImages = m_Item.GetGallery();
989
990 m_Widgets.m_wGallery.SetVisible(!galleryImages.IsEmpty() && !m_Item.GetRestricted());
991
992 if (!galleryImages.IsEmpty())
993 m_Widgets.m_GalleryComponent.SetImages(galleryImages);
994 }
995
996 //------------------------------------------------------------------------------------------------
997 protected void ShowBackendEnv()
998 {
999 WorkshopItem item = m_Item.GetWorkshopItem();
1000 if (!item)
1001 {
1002 m_Widgets.m_wBackendSource.SetVisible(false);
1003 return;
1004 }
1005
1006 string gameEnv = GetGame().GetBackendApi().GetBackendEnv();
1007 string modEnv = m_Item.GetWorkshopItem().GetBackendEnv();
1008
1009 bool display = (modEnv != "local") && (modEnv != "ask") && (modEnv != "invalid");
1010 bool envMatch = gameEnv == modEnv;
1011
1012 m_Widgets.m_wBackendSource.SetVisible(display && !envMatch);
1013 if (!display)
1014 return;
1015
1016 m_Widgets.m_BackendSourceComponent1.SetTitle(modEnv);
1017
1018 if (envMatch)
1019 m_Widgets.m_BackendSourceComponent0.SetIconColor(UIColors.CONFIRM);
1020 else
1021 m_Widgets.m_BackendSourceComponent0.SetIconColor(UIColors.WARNING);
1022 }
1023
1024 //------------------------------------------------------------------------------------------------
1025 protected void UpdateVersionComboBox()
1026 {
1027 #ifdef WORKSHOP_DEBUG
1028 // Fill version combo box - only for testing!
1029 if (m_Widgets.m_VersionComboBoxComponent0.GetNumItems() == 0)
1030 {
1031 array<string> versions = m_Item.GetVersions();
1032 if (!versions.IsEmpty())
1033 {
1034 m_Widgets.m_VersionComboBoxComponent0.ClearAll();
1035 foreach (string version : versions)
1036 {
1037 m_Widgets.m_VersionComboBoxComponent0.AddItem(version);
1038 }
1039 }
1040 }
1041 #endif
1042 }
1043
1044 //------------------------------------------------------------------------------------------------
1045 protected void UpdateScenarioLines()
1046 {
1047 if (!m_Item)
1048 return;
1049
1051 {
1052 if (!scenarioLine)
1053 continue;
1054
1055 // Show favorites and mouse buttons only when downloaded
1056 scenarioLine.NotifyScenarioUpdate(m_Item.GetOffline());
1057 }
1058 }
1059
1060 //------------------------------------------------------------------------------------------------
1062 {
1063 // Check if the addon is downloaded
1064 if (!line || (m_Item && m_Item.GetOffline()))
1065 return;
1066
1068 // Clicking a line without the addon installed starts the download
1069 bool inProgress, paused;
1070 float progress;
1071 Revision revision;
1072 m_Item.GetDownloadState(inProgress, paused, progress, revision);
1073
1074 if (!inProgress && !paused)
1076 }
1077
1078 //------------------------------------------------------------------------------------------------
1079 protected void UpdateFocus(Widget target)
1080 {
1081 GetGame().GetWorkspace().SetFocusedWidget(target);
1082 }
1083
1084
1085 // ---- Tooltips ----
1086 //------------------------------------------------------------------------------------------------
1097
1098 //------------------------------------------------------------------------------------------------
1100 {
1101 if (!m_Tooltip || !m_Tooltip.GetContent() || !m_Tooltip.IsValid("MainAction_Simple", m_Widgets.m_wPrimaryActionButton))
1102 return;
1103
1105 }
1106
1107 //------------------------------------------------------------------------------------------------
1109 {
1110 if (!m_Item || !m_Tooltip || !m_Tooltip.GetContent() || !m_Tooltip.IsValid("Enable_Simple", m_Widgets.m_wEnableButton))
1111 return;
1112
1113 if (m_Item.GetEnabled())
1114 m_Tooltip.GetContent().SetMessage(SCR_WorkshopUiCommon.LABEL_DISABLE);
1115 else
1116 m_Tooltip.GetContent().SetMessage(SCR_WorkshopUiCommon.LABEL_ENABLE);
1117 }
1118
1119 //------------------------------------------------------------------------------------------------
1121 {
1122 if (!m_Item || !m_Tooltip || !m_Tooltip.GetContent() || !m_Tooltip.IsValid("Report", m_Widgets.m_wReportButton))
1123 return;
1124
1125 if (m_Item.GetReportedByMe())
1126 m_Tooltip.GetContent().SetMessage(SCR_WorkshopUiCommon.LABEL_CANCEL_REPORT);
1127 else
1128 m_Tooltip.GetContent().SetMessage(SCR_WorkshopUiCommon.LABEL_REPORT);
1129 }
1130
1131 //------------------------------------------------------------------------------------------------
1133 {
1134 if (!m_Item || !m_Tooltip || !m_Tooltip.GetContent() || !m_Tooltip.IsValid("Favorite_Simple", m_Widgets.m_wFavoriteButton))
1135 return;
1136
1137 m_Tooltip.GetContent().SetMessage(UIConstants.GetFavoriteLabel(m_Item.GetFavourite()));
1138 }
1139
1140 //------------------------------------------------------------------------------------------------
1142 {
1143 if (!m_Item || !m_Tooltip || !m_Tooltip.GetContentRoot())
1144 return;
1145
1147 if (!comp)
1148 return;
1149
1150 if (m_Tooltip.IsValid("Dependent", m_Widgets.m_wDependent))
1152 else if (m_Tooltip.IsValid("Dependencies", m_Widgets.m_wDependencies))
1153 comp.Init(m_Item.GetLatestDependencies());
1154 }
1155}
ChimeraMenuPreset
Menu presets.
ArmaReforgerScripted GetGame()
Definition game.c:1398
InputManager GetInputManager()
void UpdateNavigationButtons()
ref array< SCR_ContentBrowser_ScenarioLineComponent > m_aScenarioLines
SCR_ContentBrowser_ScenarioLineComponent GetSelectedLine()
SCR_ContentBrowser_ScenarioLineComponent m_LastSelectedLine
SCR_ScenarioDetailsPanelComponent m_ScenarioDetailsPanel
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Widget m_wRoot
bool m_bShown
void CreateLines(Widget w)
EWorkshopItemProblem
Definition Color.c:13
Definition Math.c:13
static SCR_ERevisionAvailability ItemAvailability(notnull WorkshopItem item)
static SCR_AddonManager GetInstance()
Effect which colorizes a widget with given name.
Dialog which sends a request to delete user's report.
static SCR_ContentBrowser_AddonsTooltipComponent FindComponent(notnull Widget w)
void OnAnyDownloadCompleted(SCR_WorkshopItemActionDownload action)
override void OnLineFocus(SCR_ScriptedWidgetComponent entry)
void OnReportButton()
This button used in reported and not reported state. It either sends a report or cancels it.
override void OnScenarioStateChanged(SCR_ContentBrowser_ScenarioLineComponent comp)
Called from scenario line component when scenario state changes.
void OnAddonFavouriteButtonToggled()
Sets favorite state of the Addon.
void OnAnyDownloadError(SCR_WorkshopItemActionDownload action, int reason)
override void OnLineDoubleClick(SCR_ContentBrowser_ScenarioLineComponent lineComp)
override void OnLineMouseEnter(SCR_ScriptedWidgetComponent entry)
void Callback_OnDownloadScenarios(SCR_WorkshopItem item)
Called when we receive scenarios from backend.
override void OnPlayInteraction(MissionWorkshopItem scenario)
void OnRepairActionButton()
Start the repairing process of the addon.
override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout, int index)
override void OnLineFocusLost(SCR_ScriptedWidgetComponent entry)
void LineInteractionTryDownload(SCR_ContentBrowser_ScenarioLineComponent line)
ref SCR_ContentBrowserDetails_OverviewSubMenuWidgets m_Widgets
override void SetFavorite(MissionWorkshopItem scenario)
Sets favorite state of the Scenario line.
override void OnLineClick(SCR_ContentBrowser_ScenarioLineComponent lineComp)
void UpdateButtons()
updated m_Widgets which depend on state of the mod (so everything except for description,...
void OnAnyNewDownload(SCR_WorkshopItem item, SCR_WorkshopItemActionDownload action)
ref ScriptInvokerBase< ScriptInvoker_DownloadManagerActionError > m_OnDownloadFailed
static SCR_DownloadManager GetInstance()
ref ScriptInvoker m_OnNewDownload
ref ScriptInvokerBase< ScriptInvoker_DownloadManagerAction > m_OnDownloadComplete
static float GetItemDownloadActionsProgress(SCR_WorkshopItem item)
Returns overall download progress for all actions of a workshop item.
ref ScriptInvokerBase< ScriptInvoker_DownloadManagerAction > m_OnDownloadCanceled
static SCR_LoadingOverlayDialog Create(string text=string.Empty)
static ScriptInvoker GetEventOnAllMenuClosed()
static void CloseAllMenus(array< typename > menus)
Close all menus that are not of selected class.
static SCR_ModDetailsAdditionalInfoDialog CreateDialog(SCR_WorkshopItem scriptedItem)
void OpenSelectReportAuthor(notnull SCR_WorkshopItem item)
void OpenSelectReport(notnull SCR_WorkshopItem item)
static bool CanJoin(MissionWorkshopItem mission)
static bool CanHost(MissionWorkshopItem mission)
static ScriptInvokerTooltip GetOnTooltipShow()
void LoadAddon(notnull SCR_WorkshopItem item)
static void UpdateEnableAddonToggleButton(SCR_ModularButtonComponent button, SCR_WorkshopItem item, SCR_EAddonPrimaryActionState state, bool alwaysShowWhenDownloaded=true)
static int GetDownvotes(notnull SCR_WorkshopItem item)
static void OnEnableAddonToggleButton(SCR_WorkshopItem item, SCR_ModularButtonComponent buttonComp)
static void ExecutePrimaryAction(notnull SCR_WorkshopItem item, out SCR_WorkshopDownloadSequence dlRequest, Revision revision=null)
static array< ref SCR_WorkshopItem > GetDownloadedDependentAddons(notnull SCR_WorkshopItem item)
static SCR_EAddonPrimaryActionState GetPrimaryActionState(notnull SCR_WorkshopItem item)
static bool IsDownloadingAddon(SCR_WorkshopItem item)
static void GetPrimaryActionLook(SCR_EAddonPrimaryActionState state, SCR_ERevisionAvailability availability, SCR_WorkshopItem item, out string icon, out Color iconColor, out string message, out Color messageColor)
static void OnDeleteAddonButton(SCR_WorkshopItem item)
Shows a confirmation dialog when unsubscribing an addon.
static int GetUpvotes(notnull SCR_WorkshopItem item)
static bool IsDownloadingAddonOrDependencies(SCR_WorkshopItem item)
static void GetVersionDisplayLook(SCR_WorkshopItem item, out bool showUpdateText, out string currentVersionIcon, out Color currentVersionIconColor, out string currentVersionText, out Color currentVersionTextColor, out string updateVersionText)
static string GetPrimaryActionTooltipMessage(SCR_EAddonPrimaryActionState state, SCR_WorkshopItem item)
Workshop Item instance.