10 const int RECENT_SERVERS_SECONDS = 60 * 60 * 24 * 7;
13 const string FILTER_FAVORITES =
"favorites";
14 const string FILTER_RECENT_SERVERS =
"oldestJoinInSeconds";
15 const string FILTER_MODDED =
"modded";
16 const string FILTER_OFFICIAL =
"official";
17 const string FILTER_COMMUNITY =
"community";
18 const string FILTER_CROSS_PLAY =
"gameClientFilter";
19 const string FILTER_VERSION =
"gameVersion";
21 const string SORT_ASCENDENT =
"ascendent";
22 const string SORT_NAME =
"SessionName";
23 const string SORT_PING =
"Ping";
26 const string CATEGORY_PLAYERS =
"Players";
27 const string CATEGORY_VERSION =
"Version";
30 const string VALUE_PLAYERS_MIN =
"minPlayersPercent";
31 const string VALUE_PLAYERS_MAX =
"maxPlayersPercent";
32 const string VALUE_PLAYERS_MIN_COUNT =
"minPlayersCount";
33 const string VALUE_PLAYERS_MAX_COUNT =
"maxPlayersCount";
37 protected ref array<SCR_FilterEntryRoom> m_aFiltersUncategorized = {};
38 protected ref array<ref SCR_FilterEntryRoom> m_aDefaultFilters = {};
40 protected ref array<string> modIds =
new array<string>;
43 protected string text =
"";
45 protected string hostAddress =
"";
46 protected string directJoinCode =
"";
49 protected string scenarioId =
"";
50 protected string hostedScenarioModId =
"";
53 protected string order = SORT_NAME;
56 protected bool m_bOfficialOn =
false;
57 protected bool m_bOfficialDisplay =
false;
58 protected bool m_bFavoriteFilterOn =
false;
59 protected bool m_bRecentlyPlayedOn =
false;
62 protected bool m_bModdedFilterSelected;
63 protected bool m_bCrossPlayFilterSelected;
66 protected int m_iSelectedTab = 0;
67 protected int lockedBoth = 0;
68 protected bool m_bUsePlayerLimit =
true;
75 override void OnPack()
77 SCR_FilterEntryRoom official = FindFilterByInternalName(m_aDefaultFilters, FILTER_OFFICIAL);
78 SCR_FilterEntryRoom community = FindFilterByInternalName(m_aDefaultFilters, FILTER_COMMUNITY);
80 official.SetSelected(
false);
81 community.SetSelected(
false);
86 official.SetSelected(m_bOfficialDisplay);
87 community.SetSelected(!m_bOfficialDisplay);
90 SCR_FilterEntryRoom favorite = FindFilterByInternalName(m_aDefaultFilters, FILTER_FAVORITES);
91 favorite.SetSelected(m_bFavoriteFilterOn);
93 SCR_FilterEntryRoom recentlyPlayed = FindFilterByInternalName(m_aDefaultFilters, FILTER_RECENT_SERVERS);
94 recentlyPlayed.SetSelected(m_bRecentlyPlayedOn);
97 m_bModdedFilterSelected =
false;
98 m_bCrossPlayFilterSelected =
false;
101 StoreString(
"text", text);
110 if (m_bUsePlayerLimit)
111 FormatePlayersFilters(min, max, minCount, maxCount);
114 StoreInteger(VALUE_PLAYERS_MIN, min);
116 StoreInteger(VALUE_PLAYERS_MAX, max);
118 StoreInteger(VALUE_PLAYERS_MIN_COUNT, minCount);
120 StoreInteger(VALUE_PLAYERS_MAX_COUNT, maxCount);
126 version = m_Filter.FindFilterCategory(CATEGORY_VERSION);
128 if (version && version.GetAnySelected())
129 StoreString(FILTER_VERSION,
GetGame().GetBuildVersion());
138 if (filter.GetSelected())
141 if (m_Filter && filter.GetCategory() == m_Filter.FindFilterCategory(CATEGORY_PLAYERS))
144 ActivateFilterValues(filter);
148 if (!m_bCrossPlayFilterSelected)
149 StoreString(FILTER_CROSS_PLAY,
"AnyCompatible");
152 if (modIds.IsEmpty())
163 void AddModId(
string sId)
176 void SetHostAddress(
string address)
178 hostAddress = address;
179 directJoinCode =
string.Empty;
184 void SetJoinCode(
string joinCode)
186 directJoinCode = joinCode;
187 hostAddress =
string.Empty;
197 RegV(
"directJoinCode");
212 asc.m_sInternalName = SORT_ASCENDENT;
213 asc.AddFilterValue(SORT_ASCENDENT,
"1",
EFilterType.TYPE_BOOL);
214 asc.SetSelected(
true);
215 m_aDefaultFilters.Insert(asc);
219 filterOfficial.m_sInternalName = FILTER_OFFICIAL;
220 filterOfficial.AddFilterValue(FILTER_OFFICIAL,
"1",
EFilterType.TYPE_BOOL);
221 filterOfficial.SetSelected(
false);
222 m_aDefaultFilters.Insert(filterOfficial);
225 filterCommunity.m_sInternalName = FILTER_COMMUNITY;
226 filterCommunity.AddFilterValue(FILTER_OFFICIAL,
"0",
EFilterType.TYPE_BOOL);
227 filterCommunity.SetSelected(
false);
228 m_aDefaultFilters.Insert(filterCommunity);
232 filterFavorite.m_sInternalName = FILTER_FAVORITES;
233 filterFavorite.AddFilterValue(FILTER_FAVORITES,
"1",
EFilterType.TYPE_BOOL);
234 filterFavorite.SetSelected(
true);
235 m_aDefaultFilters.Insert(filterFavorite);
239 filterRecent.m_sInternalName = FILTER_RECENT_SERVERS;
240 filterRecent.AddFilterValue(FILTER_RECENT_SERVERS, RECENT_SERVERS_SECONDS.ToString(),
EFilterType.TYPE_INT);
241 filterRecent.SetSelected(
true);
242 m_aDefaultFilters.Insert(filterRecent);
246 m_aFiltersUncategorized.Insert(filter);
255 protected SCR_FilterEntryRoom FindFilterByInternalName(array<ref SCR_FilterEntryRoom> filters,
string internalName)
257 if (!filters || filters.IsEmpty())
264 if (roomFilter.m_sInternalName == internalName)
280 array<ref SCR_FilterEntryRoomValue> values = filter.GetValues();
282 if (!values || values.IsEmpty())
289 string name = value.GetName();
292 if (name == FILTER_MODDED && value.GetBoolValue() ==
true)
293 m_bModdedFilterSelected = filter.GetSelected();
296 if (name == FILTER_CROSS_PLAY)
297 m_bCrossPlayFilterSelected = filter.GetSelected();
306 StoreBoolean(name, value.GetBoolValue());
311 StoreInteger(name, value.GetIntNumberValue());
316 StoreFloat(name, value.GetFloatNumberValue());
321 StoreString(name, value.GetStringValue());
329 protected void FormatePlayersFilters(out
int min, out
int max, out
int minCount, out
int maxCount)
340 array<ref SCR_FilterEntry> filters = playersCat.GetFilters();
341 if(filters.IsEmpty())
350 for (
int i = 0, count = filters.Count(); i < count; i++)
364 if (minCount == -1 || valueMinCount.GetIntNumberValue() < minCount)
365 minCount = valueMinCount.GetIntNumberValue();
372 if (maxCount == -1 || valueMaxCount.GetIntNumberValue() < maxCount)
373 maxCount = valueMaxCount.GetIntNumberValue();
380 if (min == -1 || valueMin.GetIntNumberValue() < min)
381 min = valueMin.GetIntNumberValue();
388 if (max == -1 || valueMax.GetIntNumberValue() > max)
389 max = valueMax.GetIntNumberValue();
404 if (!m_aFiltersUncategorized.IsEmpty())
405 m_aFiltersUncategorized.Clear();
411 m_Filter = filterSet;
414 array<ref SCR_FilterCategory> categories = filterSet.GetFilterCategories();
415 if (!categories || categories.IsEmpty())
427 m_aFiltersUncategorized.Insert(roomFilter);
435 m_aFiltersUncategorized.Insert(filter);
440 void SetFavoriteFilter(
bool isAllowed)
442 m_bFavoriteFilterOn = isAllowed;
446 bool GetFavoriteFilter()
448 return m_bFavoriteFilterOn;
452 void SetRecentlyPlayedFilter(
bool isAllowed)
454 m_bRecentlyPlayedOn = isAllowed;
458 bool GetRecentlyPlayedFilter()
460 return m_bRecentlyPlayedOn;
464 void SetOfficialFilter(
bool activate,
bool displayOfficial)
466 m_bOfficialOn = activate;
467 m_bOfficialDisplay = displayOfficial;
471 void SetSorting(
string mOrder,
bool bAscendent)
476 SCR_FilterEntryRoom orderFilter = FindFilterByInternalName(m_aDefaultFilters, SORT_ASCENDENT);
481 orderFilter.GetValues()[0].SetValue(
"0");
484 orderFilter.GetValues()[0].SetValue(
"1");
489 string GetSortOrder() {
return order; }
492 void SetSearch(
string sInput)
498 string GetSearchText() {
return text; }
509 string GetScenarioId() {
return scenarioId; }
512 void SetScenarioId(
string id)
519 string GetHostedScenarioModId() {
return hostedScenarioModId; }
522 void SetHostedScenarioModId(
string id)
524 hostedScenarioModId = id;
527 if (!hostedScenarioModId.IsEmpty())
528 RegV(
"hostedScenarioModId");
530 UnregV(
"hostedScenarioModId");
534 bool IsModdedFilterSelected()
536 return m_bModdedFilterSelected;
540 bool IsCrossPlayFilterSelected()
546 void SetOwnedOnly(
bool showOwned)
548 ownedOnly = showOwned;
556 protected void DefaultFilter()
558 array<ref SCR_FilterEntryRoom> filters = {};
563 filters.Insert(filter);
567 filter.SetSelected(
false);
571 SetSearch(
string.Empty);
576 asc.SetSelected(
true);
583 void DefaulFilterFavorite()
585 m_bFavoriteFilterOn =
true;
589 SCR_FilterEntryRoom favorite = FindFilterByInternalName(m_aDefaultFilters, FILTER_FAVORITES);
590 favorite.SetSelected(m_bFavoriteFilterOn);
595 void DefaulFilterRecentlyPlayed()
597 m_bRecentlyPlayedOn =
true;
601 SCR_FilterEntryRoom recentlyPlayed = FindFilterByInternalName(m_aDefaultFilters, FILTER_RECENT_SERVERS);
602 recentlyPlayed.SetSelected(m_bRecentlyPlayedOn);
606 void RestoreFilters()
619 void SetUsePlayerLimit(
bool use)
621 m_bUsePlayerLimit = use;
629 bool m_bValue =
false;
630 bool m_bIsUsed =
false;
632 void BoolFilter(
string name,
bool value,
bool used =
false)
647 protected ref array<ref SCR_FilterEntryRoomValue> m_aValues;
654 m_aValues =
new array<ref SCR_FilterEntryRoomValue>;
658 filterValue.SetName(name);
659 filterValue.SetValue(value);
660 filterValue.SetType(
type);
667 array<ref SCR_FilterEntryRoomValue> GetValues() {
return m_aValues; }
672 for (
int i = 0, count =
m_aValues.Count(); i < count; i++)
686 [
Attribute(
"", UIWidgets.EditBox,
"Name of used filter")]
687 protected string m_sInternalName;
689 [
Attribute(
"", UIWidgets.EditBox,
"Filter value for any type")]
690 protected string m_sValue;
696 void SetName(
string name) { m_sInternalName = name; }
699 string GetName() {
return m_sInternalName; }
710 void SetValue(
string value) { m_sValue = value; }
713 string GetStringValue() {
return m_sValue; }
716 bool GetBoolValue() {
return m_sValue ==
"1"; }
719 float GetIntNumberValue() {
return m_sValue.ToInt(); }
722 float GetFloatNumberValue() {
return m_sValue.ToFloat(); }