7 protected ref array<SCR_ContentBrowser_ScenarioLineComponent> m_aScenarioLines = {};
12 protected MissionWorkshopItem m_SelectedScenario;
18 protected EInputDeviceType m_eLastInputType;
19 protected bool m_bWasLineSelected;
31 protected ref array<SCR_InputButtonComponent> m_aRightFooterButtons = {};
36 protected bool m_bIsListeningForCommStatus;
37 protected WorkshopApi m_WorkshopApi;
40 override void HandlerAttached(Widget w)
42 super.HandlerAttached(w);
47 override void OnTabCreate(Widget menuRoot, ResourceName buttonsLayout,
int index)
49 super.OnTabCreate(menuRoot, buttonsLayout,
index);
53 if (m_ActionsComponent)
54 m_ActionsComponent.GetOnAction().Insert(OnActionTriggered);
58 m_DynamicFooter.GetOnButtonActivated().Insert(OnInteractionButtonPressed);
60 m_NavPlay = m_DynamicFooter.FindButton(SCR_ScenarioEntryHelper.BUTTON_PLAY);
61 m_NavContinue = m_DynamicFooter.FindButton(SCR_ScenarioEntryHelper.BUTTON_CONTINUE);
62 m_NavRestart = m_DynamicFooter.FindButton(SCR_ScenarioEntryHelper.BUTTON_RESTART);
63 m_NavHost = m_DynamicFooter.FindButton(SCR_ScenarioEntryHelper.BUTTON_HOST);
64 m_NavFindServers = m_DynamicFooter.FindButton(SCR_ScenarioEntryHelper.BUTTON_FIND_SERVERS);
65 m_NavFavorite = m_DynamicFooter.FindButton(SCR_ScenarioEntryHelper.BUTTON_FAVORITE);
69 UpdateNavigationButtons();
78 override void OnMenuUpdate(
float tDelta)
80 super.OnMenuUpdate(tDelta);
83 MissionWorkshopItem selectedMission = GetSelectedScenario();
84 if (selectedMission && m_SelectedScenario != selectedMission)
86 m_SelectedScenario = selectedMission;
91 EInputDeviceType inputDeviceType =
GetGame().GetInputManager().GetLastUsedInputDevice();
92 bool isLineSelected = GetSelectedLine();
93 bool shouldUpdateButtons = inputDeviceType != m_eLastInputType || isLineSelected != m_bWasLineSelected;
95 if (shouldUpdateButtons)
96 UpdateNavigationButtons();
98 m_eLastInputType = inputDeviceType;
99 m_bWasLineSelected = isLineSelected;
103 override void OnTabShow()
109 if (!m_bIsListeningForCommStatus)
112 m_bIsListeningForCommStatus =
true;
114 if (m_ActionsComponent)
115 m_ActionsComponent.ActivateActions();
119 override void OnTabHide()
123 UpdateNavigationButtons(
false);
126 m_bIsListeningForCommStatus =
false;
130 override void OnMenuFocusGained()
132 super.OnMenuFocusGained();
136 UpdateNavigationButtons();
139 m_ActionsComponent.ActivateActions();
143 override void OnMenuShow()
148 m_ActionsComponent.ActivateActions();
153 protected void OnCommStatusCheckFinished(
SCR_ECommStatus status,
float responseTime,
float lastSuccessTime,
float lastFailTime)
155 UpdateNavigationButtons();
163 m_SelectedLine = lineComp;
164 m_SelectedLine.m_OnClick.Insert(OnLineMouseClick);
166 UpdateNavigationButtons();
173 m_LastSelectedLine = m_SelectedLine;
174 m_SelectedLine.m_OnClick.Remove(OnLineMouseClick);
201 protected void OnActionTriggered(
string action,
float multiplier)
207 MissionWorkshopItem scenario = GetSelectedScenario();
208 if (!SCR_ScenarioEntryHelper.IsReady(scenario) && action != SCR_ScenarioEntryHelper.ACTION_DOUBLE_CLICK)
213 case SCR_ScenarioEntryHelper.ACTION_DOUBLE_CLICK: OnLineClickInteraction(multiplier);
break;
214 case SCR_ScenarioEntryHelper.ACTION_RESTART: Restart(scenario);
break;
215 case SCR_ScenarioEntryHelper.ACTION_FIND_SERVERS: Join(scenario);
break;
216 case SCR_ScenarioEntryHelper.ACTION_FAVORITE: OnFavouriteButton();
break;
217 case SCR_ScenarioEntryHelper.ACTION_HOST:
227 protected void OnInteractionButtonPressed(
string action)
229 SwitchOnButton(action, GetSelectedScenario());
238 SwitchOnButton(tag, dialog.GetScenario());
242 protected void SwitchOnButton(
string tag, MissionWorkshopItem scenario)
244 if (!SCR_ScenarioEntryHelper.IsReady(scenario))
250 case SCR_ScenarioEntryHelper.BUTTON_PLAY: Play(scenario);
break;
251 case SCR_ScenarioEntryHelper.BUTTON_CONTINUE: Continue(scenario);
break;
252 case SCR_ScenarioEntryHelper.BUTTON_RESTART: Restart(scenario);
break;
253 case SCR_ScenarioEntryHelper.BUTTON_FIND_SERVERS: Join(scenario);
break;
254 case SCR_ScenarioEntryHelper.BUTTON_HOST: Host(scenario);
break;
255 case SCR_ScenarioEntryHelper.BUTTON_FAVORITE: OnFavouriteButton();
break;
261 protected void OnLineClickInteraction(
float multiplier)
266 if (!lineComp || !GetLineUnderCursor())
269 switch (Math.Floor(multiplier))
271 case 1: OnLineClick(lineComp);
break;
272 case 2: OnLineDoubleClick(lineComp);
break;
275 m_ClickedLine =
null;
285 MissionWorkshopItem scenario = lineComp.GetScenario();
293 if (!scenarioConfirmationDialog)
295 OnPlayInteraction(scenario);
300 scenarioConfirmationDialog.m_OnButtonPressed.Insert(OnConfirmationDialogButtonPressed);
301 scenarioConfirmationDialog.GetOnFavorite().Insert(SetFavorite);
306 OnPlayInteraction(scenario);
316 OnPlayInteraction(lineComp.GetScenario());
321 protected void OnFavouriteButton()
323 SetFavorite(GetSelectedScenario());
324 if (m_NavFavorite && GetSelectedLine())
325 m_NavFavorite.SetLabel(GetFavoriteLabel(GetSelectedScenario().IsFavorite()));
330 protected void OnPlayInteraction(MissionWorkshopItem scenario)
332 if (!SCR_ScenarioEntryHelper.IsReady(scenario))
335 if (SCR_ScenarioEntryHelper.HasSave(scenario))
342 protected void Play(MissionWorkshopItem scenario)
351 protected void Continue(MissionWorkshopItem scenario)
356 if (m_Header && !m_Header.GetSaveFileName().IsEmpty())
357 GetGame().GetSaveManager().SetFileNameToLoad(m_Header);
359 GetGame().GetSaveManager().ResetFileNameToLoad();
365 protected void Restart(MissionWorkshopItem scenario)
370 m_SelectedScenario = scenario;
373 if (!SCR_ScenarioEntryHelper.HasSave(scenario))
377 dialog.m_OnConfirm.Insert(OnRestartConfirmed);
381 protected void OnRestartConfirmed()
383 GetGame().GetSaveManager().ResetFileNameToLoad();
388 protected void Join(MissionWorkshopItem scenario)
391 if (!scenario || !SCR_ScenarioEntryHelper.IsMultiplayer(scenario) || SCR_ScenarioEntryHelper.IsInErrorState(state))
398 protected void Host(MissionWorkshopItem scenario)
401 if (!scenario || !SCR_ScenarioEntryHelper.IsMultiplayer(scenario) || SCR_ScenarioEntryHelper.IsInErrorState(state))
408 dialog.SelectScenario(scenario);
412 protected void SetFavorite(MissionWorkshopItem scenario)
414 if (!scenario || !m_SelectedLine || m_SelectedLine.GetScenario() != scenario)
417 bool isFavorite = !scenario.IsFavorite();
420 scenario.SetFavorite(isFavorite);
423 m_SelectedLine.NotifyScenarioUpdate();
426 if (m_OnLineFavorite)
427 m_OnLineFavorite.Invoke(isFavorite);
433 protected bool CreateLines(array<MissionWorkshopItem> scenarios, Widget parent)
435 foreach (MissionWorkshopItem scenario : scenarios)
445 comp.SetScenario(scenario);
446 m_aScenarioLines.Insert(comp);
448 comp.GetOnFavorite().Insert(OnLineFavorite);
449 comp.GetOnMouseInteractionButtonClicked().Insert(OnInteractionButtonPressed);
450 comp.GetOnFocus().Insert(OnLineFocus);
451 comp.GetOnFocusLost().Insert(OnLineFocusLost);
458 protected void InitWidgets();
462 protected void InitWorkshopApi()
470 protected void UpdateSidePanel()
476 MissionWorkshopItem scenario = lineComp.GetScenario();
477 if (scenario && m_ScenarioDetailsPanel)
478 m_ScenarioDetailsPanel.SetScenario(scenario);
482 protected void UpdateNavigationButtons(
bool visible =
true)
484 MissionWorkshopItem scenario = GetSelectedScenario();
489 m_NavFavorite.SetVisible(visible,
false);
491 m_NavFavorite.SetLabel(GetFavoriteLabel(GetSelectedScenario().IsFavorite()));
496 protected string GetFavoriteLabel(
bool isFavorite)
508 Widget wfocused =
GetGame().GetWorkspace().GetFocusedWidget();
513 EInputDeviceType inputDevice =
GetGame().GetInputManager().GetLastUsedInputDevice();
514 bool isCursorOnInnerButton = m_SelectedLine && m_SelectedLine.IsInnerButtonInteraction();
516 if (inputDevice == EInputDeviceType.MOUSE && (GetLineUnderCursor() || isCursorOnInnerButton))
517 return m_SelectedLine;
527 Widget w = WidgetManager.GetWidgetUnderCursor();
536 protected MissionWorkshopItem GetSelectedScenario()
543 return comp.GetScenario();
550 if (!m_OnLineFavorite)
553 return m_OnLineFavorite;