37 super.OnTabCreate(menuRoot, buttonsLayout,
index);
41 m_ScenarioDetailsPanel =
m_Widgets.m_ScenarioDetailsPanelComponent;
44 m_Widgets.m_FilterPanelComponent.TryLoad();
75 if (m_LastSelectedLine)
76 target = m_LastSelectedLine.GetRootWidget();
78 target =
m_Widgets.m_ScenarioList.GetChildren();
81 GetGame().GetWorkspace().SetFocusedWidget(target);
83 super.OnMenuFocusGained();
101 visible = GetSelectedLine() &&
GetGame().GetInputManager().GetLastUsedInputDevice() != EInputDeviceType.MOUSE;
102 super.UpdateNavigationButtons(visible);
106 override void Play(MissionWorkshopItem scenario)
111 super.Play(scenario);
116 override void Continue(MissionWorkshopItem scenario)
121 super.Continue(scenario);
128 super.OnRestartConfirmed();
137 super.OnScenarioStateChanged(comp);
146 array<MissionWorkshopItem> missionItemsAll = {};
150 for (
int i = missionItemsAll.Count() - 1; i >= 0; i--)
152 MissionWorkshopItem m = missionItemsAll[i];
153 WorkshopItem addon = m.GetOwner();
160 if (scriptedItem && scriptedItem.GetAnyDependencyMissing())
161 missionItemsAll.Remove(i);
168 array<MissionWorkshopItem> missionItemsTabFiltered = {};
174 foreach (MissionWorkshopItem m : missionItemsAll)
177 missionItemsTabFiltered.Insert(m);
181 if (missionItemsTabFiltered.IsEmpty())
197 SCR_Sorting<MissionWorkshopItem, SCR_CompareMissionTimeSinceLastPlay>.HeapSort(missionItemsAll,
false);
202 int dt = missionItemsAll[i].GetTimeSinceLastPlay();
204 missionItemsTabFiltered.Insert(missionItemsAll[i]);
209 if (missionItemsTabFiltered.IsEmpty())
224 if (missionItemsAll.IsEmpty())
233 missionItemsTabFiltered = missionItemsAll;
239 string searchStr =
m_Widgets.m_FilterPanelComponent.GetEditBoxSearch().GetValue();
240 array<MissionWorkshopItem> missionItemsSearched =
SearchScenarios(missionItemsTabFiltered, searchStr);
243 if (missionItemsSearched.IsEmpty())
271 array<MissionWorkshopItem> missionItems = missionItemsSearched;
273 string currentSortingItem =
m_Widgets.m_SortingHeaderComponent.GetSortElementName();
275 bool sortOrder =
false;
280 if (currentSortingItem.IsEmpty())
282 currentSortingItem =
"name";
285 switch (currentSortingItem)
288 SCR_Sorting<MissionWorkshopItem, SCR_CompareMissionName>.HeapSort(missionItems, sortOrder);
291 SCR_Sorting<MissionWorkshopItem, SCR_CompareMissionPlayerCount>.HeapSort(missionItems, sortOrder);
294 SCR_Sorting<MissionWorkshopItem, SCR_CompareMissionFavourite>.HeapSort(missionItems, sortOrder);
297 SCR_Sorting<MissionWorkshopItem, SCR_CompareMissionTimeSinceLastPlay>.HeapSort(missionItems, sortOrder);
300 SCR_Sorting<MissionWorkshopItem, SCR_CompareMissionAddonName>.HeapSort(missionItems, sortOrder);
310 protected static bool SearchStringLocalized(
string str,
string searchStrLower)
312 if (str.StartsWith(
"#"))
315 string strTranslated = WidgetManager.Translate(str);
316 if (!strTranslated.IsEmpty())
318 string strTranslatedLower = strTranslated;
319 strTranslatedLower.ToLower();
321 if (strTranslatedLower.Contains(searchStrLower))
328 string strLower = str;
331 if (strLower.Contains(searchStrLower))
342 Widget child =
m_Widgets.m_ScenarioList.GetChildren();
345 Widget nextChild = child.GetSibling();
346 m_Widgets.m_ScenarioList.RemoveChild(child);
361 Widget firstLine =
m_Widgets.m_ScenarioList.GetChildren();
362 if (firstLine && setNewFocus)
366 GetGame().GetCallqueue().CallLater(
GetGame().GetWorkspace().SetFocusedWidget, 0,
false, firstLine,
false);
370 m_Widgets.m_ScenarioScroll.SetSliderPos(0, 0,
true);
464 void SetPanelsMode(
bool showEmptyPanel,
string messagePresetTag =
string.Empty)
467 m_Widgets.m_EmptyPanel.SetVisible(showEmptyPanel);
468 m_Widgets.m_FilterPanel.SetVisible(!showEmptyPanel);
469 m_Widgets.m_LeftPanel.SetVisible(!showEmptyPanel);
472 m_Widgets.m_EmptyPanelMessage.SetVisible(!messagePresetTag.IsEmpty());
473 m_Widgets.m_MainPanelMessage.SetVisible(!messagePresetTag.IsEmpty());
476 if (!messagePresetTag.IsEmpty())
479 m_Widgets.m_EmptyPanelMessageComponent.SetContentFromPreset(messagePresetTag);
481 m_Widgets.m_MainPanelMessageComponent.SetContentFromPreset(messagePresetTag);
489 array<MissionWorkshopItem>
SearchScenarios(array<MissionWorkshopItem> scenarios,
string searchStr)
491 array<MissionWorkshopItem> scenariosOut = {};
493 if (!searchStr.IsEmpty())
495 string searchStrLower = searchStr;
496 searchStrLower.ToLower();
497 foreach (MissionWorkshopItem scenario : scenarios)
500 if (SearchStringLocalized(scenario.Name(), searchStrLower))
502 scenariosOut.Insert(scenario);
507 if (SearchStringLocalized(scenario.Description(), searchStrLower))
509 scenariosOut.Insert(scenario);
516 scenariosOut.Copy(scenarios);
523 static bool GetHostingAllowed()
525 #ifdef HOST_SCENARIO_ENABLED
538 override static int Compare(MissionWorkshopItem left, MissionWorkshopItem right)
540 string name1 = ResolveName(left.Name());
541 string name2 = ResolveName(right.Name());
543 if (name1.Compare(name2) == -1)
549 static string ResolveName(
string name)
551 if (name.StartsWith(
"#"))
552 return WidgetManager.Translate(name);
559 class SCR_CompareMissionAddonName : SCR_SortCompare<MissionWorkshopItem>
561 override static int Compare(MissionWorkshopItem left, MissionWorkshopItem right)
563 WorkshopItem ownerItem = left.GetOwner();
566 string name1 = ResolveAddonName(left);
567 string name2 = ResolveAddonName(right);
569 if (name1.Compare(name2) == -1)
575 static string ResolveAddonName(MissionWorkshopItem scenario)
578 WorkshopItem sourceAddon = scenario.GetOwner();
580 return WidgetManager.Translate(
"#AR-Editor_Attribute_OverlayLogo_Reforger");
582 return sourceAddon.Name();
589 override static int Compare(MissionWorkshopItem left, MissionWorkshopItem right)
591 return left.GetPlayerCount() < right.GetPlayerCount();
596 class SCR_CompareMissionFavourite : SCR_SortCompare<MissionWorkshopItem>
598 override static int Compare(MissionWorkshopItem left, MissionWorkshopItem right)
600 return right.IsFavorite();
607 override static int Compare(MissionWorkshopItem left, MissionWorkshopItem right)
609 int timeLeft = left.GetTimeSinceLastPlay();
611 timeLeft = 0x7FFFFFFF;
612 int timeRight = right.GetTimeSinceLastPlay();
614 timeRight = 0x7FFFFFFF;
616 return timeLeft < timeRight;