15 protected bool m_bGalleryUpdated =
false;
22 override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout,
int index)
24 super.OnTabCreate(menuRoot, buttonsLayout,
index);
28 m_ScenarioDetailsPanel =
m_Widgets.m_ScenarioDetailsPanelComponent;
31 #ifndef WORKSHOP_DEBUG
32 m_Widgets.m_VersionComboBoxComponent0.SetVisible(
false,
false);
37 m_Widgets.m_ScenarioSection.SetVisible(
false);
40 LoadWorkshopDetails();
44 m_Widgets.m_VoteUpButtonComponent.m_OnToggled.Insert(OnVoteUpButton);
45 m_Widgets.m_VoteDownButtonComponent.m_OnToggled.Insert(OnVoteDownButton);
46 m_Widgets.m_EnableButtonComponent.m_OnToggled.Insert(OnEnableButtonToggled);
47 m_Widgets.m_FavoriteButtonComponent.m_OnToggled.Insert(OnAddonFavouriteButtonToggled);
48 m_Widgets.m_ReportButtonComponent.m_OnClicked.Insert(OnReportButton);
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);
54 m_Widgets.m_SolveIssuesButtonComponent.m_OnClicked.Insert(OnSolveIssuesButton);
59 m_Downloads = m_DynamicFooter.FindButton(
"DownloadManager");
63 override void OnTabShow()
70 Widget defaultFocus =
m_Widgets.m_FavoriteButton;
72 GetGame().GetCallqueue().Call(
GetGame().GetWorkspace().SetFocusedWidget, defaultFocus);
76 override void OnTabRemove()
84 m_WorkshopItem.m_OnScenariosLoaded.Remove(Callback_OnDownloadScenarios);
88 UpdateNavigationButtons(
false);
92 override void OnTabHide()
97 m_Downloads.SetVisible(
true);
101 override void OnMenuFocusGained()
104 if (!
GetGame().GetMenuManager().IsAnyDialogOpen())
108 if (m_LastSelectedLine)
109 target = m_LastSelectedLine.GetRootWidget();
111 target =
m_Widgets.m_ScenariosList.GetChildren();
116 GetGame().GetWorkspace().SetFocusedWidget(target);
119 super.OnMenuFocusGained();
125 super.OnLineFocus(entry);
128 m_Downloads.SetVisible(
false,
false);
134 super.OnLineFocusLost(entry);
137 m_Downloads.SetVisible(
true,
false);
141 override void UpdateNavigationButtons(
bool visible =
true)
148 GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.MOUSE;
150 super.UpdateNavigationButtons(visible);
163 LineInteractionTryDownload(lineComp);
169 super.OnLineClick(lineComp);
181 LineInteractionTryDownload(lineComp);
186 super.OnLineDoubleClick(lineComp);
190 override void OnPlayInteraction(MissionWorkshopItem scenario)
195 super.OnPlayInteraction(scenario);
199 override void Play(MissionWorkshopItem scenario)
204 super.Play(scenario);
209 override void Host(MissionWorkshopItem scenario)
214 super.Host(scenario);
218 override void Join(MissionWorkshopItem scenario)
225 if (ServerHostingUI.GetTemporaryConfig())
232 super.Join(scenario);
237 override void SetFavorite(MissionWorkshopItem scenario)
242 super.SetFavorite(scenario);
250 super.OnScenarioStateChanged(comp);
254 override void InitWidgets()
261 override void UpdateSidePanel()
263 super.UpdateSidePanel();
267 m_Widgets.m_AddonDetailsPanel.SetVisible(!lineComp);
268 m_Widgets.m_ScenarioDetailsPanel.SetVisible(lineComp !=
null);
273 void Callback_OnGetAsset()
279 void Callback_OnItemChanged()
286 void Callback_OnDownloadScenarios()
288 array<MissionWorkshopItem> scenarios = {};
291 #ifdef WORKSHOP_DEBUG
292 ContentBrowserUI._print(
string.Format(
"Downloaded %1 scenarios", scenarios.Count()));
295 m_Widgets.m_ScenarioSection.SetVisible(!scenarios.IsEmpty());
298 while (
m_Widgets.m_ScenariosList.GetChildren())
304 SCR_Sorting<MissionWorkshopItem, SCR_CompareMissionName>.HeapSort(scenarios,
false);
307 UpdateScenarioLines();
311 protected void Callback_OnTimeout()
318 dlg.m_OnClose.Insert(RequestCloseMenu);
323 protected void OnDeleteButton()
331 protected void OnDownloadButton()
334 Revision specificVersion;
336 #ifdef WORKSHOP_DEBUG
337 string strSpecificVersion =
m_Widgets.m_VersionComboBoxComponent0.GetCurrentItem();
338 specificVersion =
m_WorkshopItem.FindRevision(strSpecificVersion);
352 m_Widgets.m_DownloadButtonComponent.SetEnabled(
false);
359 m_Widgets.m_DownloadButtonComponent.SetEnabled(
true);
365 m_Widgets.m_DownloadButtonComponent.SetEnabled(
true);
369 protected void OnDownloadingButton()
375 protected void OnSolveIssuesButton()
389 protected void OnVoteUpButton()
391 bool newState =
m_Widgets.m_VoteUpButtonComponent.GetToggled();
392 OnVoteButtons(newState, !newState);
396 protected void OnVoteDownButton()
398 bool newState =
m_Widgets.m_VoteDownButtonComponent.GetToggled();
399 OnVoteButtons(!newState, !newState);
405 protected void OnVoteButtons(
bool voteUp,
bool resetAll)
407 SCR_ModularButtonComponent bup =
m_Widgets.m_VoteUpButtonComponent;
408 SCR_ModularButtonComponent bdwn =
m_Widgets.m_VoteDownButtonComponent;
410 bup.SetToggled(!resetAll && voteUp,
false);
411 bdwn.SetToggled(!resetAll && !voteUp,
false);
420 protected void OnEnableButtonToggled(SCR_ModularButtonComponent comp)
427 protected void OnAddonFavouriteButtonToggled()
432 if (item.GetRestricted())
435 fav = !item.GetFavourite();
436 item.SetFavourite(fav);
441 protected void OnReportButton()
450 if (m_LoadingOverlayDlg)
451 m_LoadingOverlayDlg.Close();
454 m_LoadingOverlayDlg.m_OnCloseStarted.Insert(Callback_OnLoadMyReportCancel);
456 m_WorkshopItem.m_OnMyReportLoaded.Insert(Callback_OnLoadMyReportSuccess);
457 m_WorkshopItem.m_OnMyReportLoadError.Insert(Callback_OnLoadMyReportError);
464 if (!m_ModReportDialog)
467 m_ModReportDialog.GetOnItemReportSuccessDialogClose().Insert(RequestCloseMenu);
473 m_ModReportDialog.OnSelectReportAuthor();
474 m_WorkshopItem.m_OnReportStateChanged.Insert(OnAuthorBlockStateChanged);
484 protected void OnAuthorBlockStateChanged()
486 LoadWorkshopDetails();
487 m_WorkshopItem.m_OnReportStateChanged.Remove(OnAuthorBlockStateChanged);
491 protected void OnAllMenuCloseJoin()
504 protected void Callback_OnLoadMyReportCancel()
506 m_WorkshopItem.m_OnMyReportLoaded.Remove(Callback_OnLoadMyReportSuccess);
507 m_WorkshopItem.m_OnMyReportLoadError.Remove(Callback_OnLoadMyReportError);
511 protected void Callback_OnLoadMyReportSuccess()
513 m_WorkshopItem.m_OnMyReportLoaded.Remove(Callback_OnLoadMyReportSuccess);
514 m_WorkshopItem.m_OnMyReportLoadError.Remove(Callback_OnLoadMyReportError);
516 m_LoadingOverlayDlg.CloseAnimated();
522 protected void Callback_OnLoadMyReportError()
524 m_WorkshopItem.m_OnMyReportLoaded.Remove(Callback_OnLoadMyReportSuccess);
525 m_WorkshopItem.m_OnMyReportLoadError.Remove(Callback_OnLoadMyReportError);
527 m_LoadingOverlayDlg.CloseAnimated();
535 protected void LoadWorkshopDetails()
544 m_WorkshopItem.m_OnScenariosLoaded.Insert(Callback_OnDownloadScenarios);
550 Callback_OnDownloadScenarios();
555 protected void UpdateAllWidgets()
557 UpdateVersionComboBox();
559 UpdateAddonStaticWidgets();
560 UpdateScenarioLines();
565 protected void UpdateButtons()
576 bool downloading = actionThisItem || actionDependencies;
583 bool enableButtonEnabled = item.GetOffline() && !downloading;
585 m_Widgets.m_EnableButtonComponent.SetEnabled(enableButtonEnabled);
586 m_Widgets.m_EnableButtonComponent.SetToggled(item.GetEnabled(),
false);
588 bool reportIndividual = item.GetReportedByMe();
589 bool reportAuthor = item.GetModAuthorReportedByMe();
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});
599 Revision downloadRevision = item.GetWorkshopItem().GetDownloadingRevision();
600 bool differentEnvironment = item.GetWorkshopItem().GetBackendEnv() !=
GetGame().GetBackendApi().GetBackendEnv();
602 bool downloaded = !downloading && item.GetOnline() && (item.GetOffline() || differentEnvironment);
604 m_Widgets.m_DownloadButtonComponent.SetVisible(!downloaded && !downloading);
605 m_Widgets.m_DeleteButtonComponent.SetVisible(downloaded);
606 m_Widgets.m_DownloadingButtonComponent.SetVisible(downloading);
611 m_Widgets.m_SolveIssuesButton.SetVisible(solveIssuesVisible);
612 if (solveIssuesVisible)
615 textEffect.m_sDefault = primaryActionText;
616 textEffect.m_sHovered = primaryActionText;
617 textEffect.PropertiesChanged();
621 bool enabled = item.GetOnline();
622 m_Widgets.m_VoteUpButtonComponent.SetEnabled(enabled);
623 m_Widgets.m_VoteDownButtonComponent.SetEnabled(enabled);
625 bool rating, ratingSet;
626 item.GetMyRating(ratingSet, rating);
628 bool voteUpToggled = ratingSet && rating;
629 bool voteDownToggled = ratingSet && !rating;
631 m_Widgets.m_VoteUpButtonComponent.SetToggled(voteUpToggled,
false);
632 m_Widgets.m_VoteDownButtonComponent.SetToggled(voteDownToggled,
false);
638 UpdateNavigationButtons();
643 protected void UpdateAddonStaticWidgets()
653 m_Widgets.m_DescriptionText.SetText(description);
661 avgRating = Math.Round(avgRating * 100.0);
662 m_Widgets.m_RatingText.SetText(
string.Format(
"%1%% (%2x)", avgRating, ratingCount));
666 protected void UpdateVersionComboBox()
668 #ifdef WORKSHOP_DEBUG
670 if (
m_Widgets.m_VersionComboBoxComponent0.GetNumItems() == 0)
673 if (!versions.IsEmpty())
675 m_Widgets.m_VersionComboBoxComponent0.ClearAll();
676 foreach (
string version : versions)
678 m_Widgets.m_VersionComboBoxComponent0.AddItem(version);
686 protected void UpdateGallery()
688 if (m_bGalleryUpdated)
693 m_Widgets.m_Gallery.SetVisible(!galleryImages.IsEmpty());
695 if (!galleryImages.IsEmpty())
697 m_Widgets.m_GalleryComponent.SetImages(galleryImages);
698 m_bGalleryUpdated =
true;
703 protected void UpdateScenarioLines()
711 scenarioLine.ShowFavouriteButton(modDownloaded);
712 scenarioLine.ShowMouseInteractionButtons(modDownloaded);
713 scenarioLine.ShowLastPlayedText(modDownloaded);
714 scenarioLine.NotifyScenarioUpdate();
728 bool inProgress, paused;
731 m_WorkshopItem.GetDownloadState(inProgress, paused, progress, revision);
733 if (!inProgress && !paused)