12 string m_sDisplayName;
15 string m_sInternalName;
18 bool m_bSelectedAtStart;
21 [
Attribute(
"", UIWidgets.ResourcePickerThumbnail,
"Image - texture or imageset",
"edds imageset")]
22 ResourceName m_sImageTexture;
24 [
Attribute(
"{00FE3DBDFD15227B}UI/Textures/Icons/icons_wrapperUI-glow.imageset", UIWidgets.ResourcePickerThumbnail,
"edds imageset")]
25 ResourceName m_sGlowTexture;
27 [
Attribute(
"", UIWidgets.EditBox,
"Image name if image set is used")]
30 protected bool m_bSelected;
41 void SetSelected(
bool newValue) {
m_bSelected = newValue; }
45 bool GetSelected(
bool defaultValue =
false)
48 return m_bSelectedAtStart;
68 string m_sDisplayName;
71 string m_sInternalName;
73 [
Attribute(
"false", UIWidgets.Auto,
"Only one filter can be enabled at a time.")]
74 bool m_bMutuallyExclusive;
76 [
Attribute(
"true", UIWidgets.Auto,
"When false, the filter panel will prohibit deselection of last selected entry.")];
77 bool m_bAllowNothingSelected;
85 [
Attribute(
"", UIWidgets.ResourcePickerThumbnail,
"Common image set for individual filters. Each filter can override it though.",
"imageset")]
86 ResourceName m_sFilterImageSet;
88 [
Attribute(
"{00FE3DBDFD15227B}UI/Textures/Icons/icons_wrapperUI-glow.imageset", UIWidgets.ResourcePickerThumbnail,
"imageset")]
89 ResourceName m_sFilterGlowImageSet;
92 protected ref array<ref SCR_FilterEntry> m_aFilters;
103 foreach (
auto f : m_aFilters)
111 array<ref SCR_FilterEntry> GetFilters()
122 if (e.m_sInternalName == internalName)
130 bool GetAllSelected()
132 foreach (
auto f : m_aFilters)
134 if (!f.GetSelected())
141 bool GetAnySelected()
143 foreach (
auto f : m_aFilters)
152 bool GetAllDeselected()
154 foreach (
auto f : m_aFilters)
164 int GetSelectedCount()
167 foreach (
auto f : m_aFilters)
186 protected ref array<ref SCR_FilterCategory> m_aFilterCategories;
189 array<ref SCR_FilterCategory> GetFilterCategories()
191 return m_aFilterCategories;
200 if (cat.m_sInternalName == internalName)
220 bool AnyFilterSelected()
225 selected =
category.GetAnySelected();
235 void ResetToDefaultValues()
241 filter.SetSelected(filter.m_bSelectedAtStart);
251 override bool _WB_GetCustomTitle(BaseContainer source, out
string title)
253 source.Get(
"m_sInternalName", title);
266 const int CURRENT_VERSION = 1;
272 ref array<string> m_aSelectedFilters;
275 ref array<string> m_aSelectedCategories;
285 ref array<ref SCR_FilterSetStorage> m_aFilterSets;
289 static void SaveFilterSet(
string tag,
SCR_FilterSet filterSet)
292 BaseContainer allFilterSetsContainer =
GetGame().GetGameUserSettings().GetModule(
"SCR_AllFilterSetsStorage");
293 BaseContainerTools.WriteToInstance(allFilterSets, allFilterSetsContainer);
296 for (
int i = allFilterSets.m_aFilterSets.Count()-1; i >= 0; i--)
299 if (storedFilterSet.m_sTag == tag)
301 allFilterSets.m_aFilterSets.Remove(i);
308 filterSetStorage.m_sTag = tag;
309 if (!filterSetStorage.m_aSelectedFilters)
310 filterSetStorage.m_aSelectedFilters =
new array<string>;
311 if (!filterSetStorage.m_aSelectedCategories)
312 filterSetStorage.m_aSelectedCategories =
new array<string>;
319 if (filter.GetSelected() && !filter.m_sInternalName.IsEmpty() && !
category.m_sInternalName.IsEmpty() )
321 filterSetStorage.m_aSelectedCategories.Insert(
category.m_sInternalName);
322 filterSetStorage.m_aSelectedFilters.Insert(filter.m_sInternalName);
327 allFilterSets.m_aFilterSets.Insert(filterSetStorage);
329 BaseContainerTools.ReadFromInstance(allFilterSets, allFilterSetsContainer);
330 GetGame().UserSettingsChanged();
337 bool IsFilterSetSaved(
string tag)
340 BaseContainer allFilterSetsContainer =
GetGame().GetGameUserSettings().GetModule(
"SCR_AllFilterSetsStorage");
341 BaseContainerTools.WriteToInstance(allFilterSets, allFilterSetsContainer);
345 for (
int i = 0; i < allFilterSets.m_aFilterSets.Count(); i++)
348 if (iFilterSet.m_sTag == tag)
358 static bool TryLoadFilterSet(
string tag,
SCR_FilterSet filterSet)
361 BaseContainer allFilterSetsContainer =
GetGame().GetGameUserSettings().GetModule(
"SCR_AllFilterSetsStorage");
362 BaseContainerTools.WriteToInstance(allFilterSets, allFilterSetsContainer);
366 for (
int i = 0; i < allFilterSets.m_aFilterSets.Count(); i++)
369 if (iFilterSet.m_sTag == tag)
371 storedFilterSet = iFilterSet;
377 if (!storedFilterSet)
393 filter.SetSelected(
false);
398 for (
int i = 0; i < storedFilterSet.m_aSelectedFilters.Count(); i++)
400 string filterName = storedFilterSet.m_aSelectedFilters[i];
401 string categoryName = storedFilterSet.m_aSelectedCategories[i];
409 filter.SetSelected(
true);
418 static void ResetAllToDefault()
422 allFilterSets.m_aFilterSets = {};
423 BaseContainer allFilterSetsContainer =
GetGame().GetGameUserSettings().GetModule(
"SCR_AllFilterSetsStorage");
426 BaseContainerTools.ReadFromInstance(allFilterSets, allFilterSetsContainer);
427 GetGame().UserSettingsChanged();