Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_LoadoutSaveBlackListHolder.c
Go to the documentation of this file.
1 [BaseContainerProps(configRoot: true)]
3 {
4  [Attribute(desc: "List of blacklist entries. Each blacklist becomes a button in attributes which the GM can enable and/or disable and is a set of items/item types which cannot be saved in loadout if the blacklist is activate")]
5  protected ref array<ref SCR_LoadoutSaveBlackList> m_LoadoutSaveBlackLists;
6 
7  //------------------------------------------------------------------------------------------------
9  void Init()
10  {
11  for (int i = m_LoadoutSaveBlackLists.Count() - 1; i >= 0; i--)
12  {
13  //~ Removed disabled lists
14  if (!m_LoadoutSaveBlackLists[i].IsEnabled() || !m_LoadoutSaveBlackLists[i].Init())
15  {
16  m_LoadoutSaveBlackLists.RemoveOrdered(i);
17  continue;
18  }
19  }
20  }
21 
22  //------------------------------------------------------------------------------------------------
26  int GetLoadoutSaveBlackLists(out notnull array<SCR_LoadoutSaveBlackList> loadoutSaveBlackLists)
27  {
28  loadoutSaveBlackLists.Clear();
29 
30  foreach (SCR_LoadoutSaveBlackList blackList : m_LoadoutSaveBlackLists)
31  {
32  loadoutSaveBlackLists.Insert(blackList);
33  }
34 
35  return loadoutSaveBlackLists.Count();
36  }
37 
38  //------------------------------------------------------------------------------------------------
40  int GetBlackListsCount()
41  {
42  return m_LoadoutSaveBlackLists.Count();
43  }
44 
45  //------------------------------------------------------------------------------------------------
49  bool IsPrefabBlacklisted(ResourceName prefab)
50  {
51  if (SCR_StringHelper.IsEmptyOrWhiteSpace(prefab))
52  return true;
53 
54  foreach (SCR_LoadoutSaveBlackList blackList : m_LoadoutSaveBlackLists)
55  {
56  if (!blackList || !blackList.IsActive())
57  continue;
58 
59  //~ Prefab in blacklist so not allowed to save
60  if (blackList.DoesBlackListContaintPrefab(prefab))
61  return true;
62  }
63 
64  //~ Prefab not in an enabled blacklist
65  return false;
66  }
67 
68  //------------------------------------------------------------------------------------------------
72  bool IsBlackListActive(int index)
73  {
74  if (!m_LoadoutSaveBlackLists.IsIndexValid(index))
75  {
76  Print("'SCR_LoadoutSaveBlackListHolder' function 'IsBlackListEnabled' given index is invalid", LogLevel.ERROR);
77  return false;
78  }
79 
80  return m_LoadoutSaveBlackLists[index].IsActive();
81  }
82 
83  //------------------------------------------------------------------------------------------------
87  void SetBlackListActive(int index, bool active)
88  {
89  if (!m_LoadoutSaveBlackLists.IsIndexValid(index))
90  {
91  Print("'SCR_LoadoutSaveBlackListHolder' function 'SetBlackListEnabled' given index is invalid", LogLevel.ERROR);
92  return;
93  }
94 
95  m_LoadoutSaveBlackLists[index].SetActive(active);
96  }
97 
98  //------------------------------------------------------------------------------------------------
102  int GetOrderedBlackListsActive(out notnull array<bool> orderedBlackListActive)
103  {
104  orderedBlackListActive.Clear();
105 
106  array<SCR_LoadoutSaveBlackList> loadoutSaveBlackLists = {};
107  GetLoadoutSaveBlackLists(loadoutSaveBlackLists);
108 
109  foreach (SCR_LoadoutSaveBlackList blackList : loadoutSaveBlackLists)
110  {
111  orderedBlackListActive.Insert(blackList.IsActive());
112  }
113 
114  return orderedBlackListActive.Count();
115  }
116 
117  //------------------------------------------------------------------------------------------------
120  void SetOrderedBlackListsActive(notnull array<bool> orderedBlackListActive)
121  {
122  for (int i = 0, count = orderedBlackListActive.Count(); i < count; i++)
123  {
124  SetBlackListActive(i, orderedBlackListActive[i]);
125  }
126  }
127 };
128 
129 //------------------------------------------------------------------------------------------------
132 {
133  [Attribute("1", "If blacklist is enabled or not. Disabled blacklists are removed on init and is used for mods")]
134  protected bool m_bEnabled;
135 
136  [Attribute("0", "If blacklist is active or not. If active than the items within the prefab list can never be saved in loadouts")]
137  protected bool m_bBlackListActive;
138 
139  [Attribute(desc: "Ui info to display in editor to set blacklist saving or not")]
140  protected ref SCR_UIInfo m_UIInfo;
141 
142  [Attribute(desc: "List of entities that are blacklisted and can never be saved when player saves their loadout. Is cleared on init and any prefabs are added to a faster set.", uiwidget: UIWidgets.ResourcePickerThumbnail, params: "et")]
143  protected ref array<ResourceName> m_aBlackListedPrefabs;
144 
145  [Attribute(desc: "List of item type and mode that cannot be saved in loadout. This list is cleared on init and any prefabs that fit the set up are added to a faster set.")]
146  protected ref array<ref SCR_LoadoutSaveBlackListItemType> m_BlackListedItemTypes;
147 
148  //~ List of resource names that are black listed
149  protected ref set<ResourceName> m_BlackListedPrefabs = new set<ResourceName>();
150 
151  //------------------------------------------------------------------------------------------------
154  bool Init()
155  {
156  foreach (ResourceName prefab : m_aBlackListedPrefabs)
157  {
158  m_BlackListedPrefabs.Insert(prefab);
159  }
160 
161  //~ Delete the array list as it is no longer needed
162  m_aBlackListedPrefabs = null;
163 
164  SCR_EntityCatalogManagerComponent catalogManager = SCR_EntityCatalogManagerComponent.GetInstance();
165 
166  if (!catalogManager && !m_BlackListedItemTypes.IsEmpty())
167  {
168  Debug.Error2("SCR_LoadoutSaveBlackList", "Black lists need the 'SCR_EntityCatalogManagerComponent' to set the the prefabs who are blacklisted. The blacklist will be disabled if the custom prefab blacklist is empty");
169  m_BlackListedItemTypes = null;
170 
171  //~ No items in the black list so set disabled
172  if (m_BlackListedPrefabs.IsEmpty())
173  {
174  m_bEnabled = false;
175  return false;
176  }
177 
178  return true;
179  }
180 
181  array<SCR_ArsenalItem> filteredArsenalItems = {};
182 
183  //~ Find arsenal items for each filter (Intensive search)
184  foreach (SCR_LoadoutSaveBlackListItemType blackList : m_BlackListedItemTypes)
185  {
186  //~ Get list of arsenal items either with or without mode
187  if (blackList.m_bIgnoreItemMode)
188  catalogManager.GetAllArsenalItems(filteredArsenalItems, blackList.m_eItemType);
189  else
190  catalogManager.GetAllArsenalItems(filteredArsenalItems, blackList.m_eItemType, blackList.m_eItemMode);
191 
192  //~ Get the Prefab resourcename form arsenal item
193  foreach (SCR_ArsenalItem arsenalItem : filteredArsenalItems)
194  {
195  m_BlackListedPrefabs.Insert(arsenalItem.GetItemResourceName());
196  }
197  }
198 
199  //~ Delete the array list as no longer needed
200  m_BlackListedItemTypes = null;
201  return true;
202  }
203 
204  //------------------------------------------------------------------------------------------------
206  bool IsEnabled()
207  {
208  return m_bEnabled;
209  }
210 
211  //------------------------------------------------------------------------------------------------
213  bool IsActive()
214  {
215  return m_bBlackListActive;
216  }
217 
218  //------------------------------------------------------------------------------------------------
221  void SetActive(bool active)
222  {
223  m_bBlackListActive = active
224  }
225 
226  //------------------------------------------------------------------------------------------------
230  bool DoesBlackListContaintPrefab(ResourceName prefab)
231  {
232  return m_BlackListedPrefabs.Contains(prefab);
233  }
234 
235  //------------------------------------------------------------------------------------------------
237  SCR_UIInfo GetUIInfo()
238  {
239  if (!m_UIInfo)
240  return new SCR_UIInfo();
241 
242  return m_UIInfo;
243  }
244 }
245 
247 class SCR_LoadoutSaveBlackListItemType
248 {
249  [Attribute("2", UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(SCR_EArsenalItemType))]
251 
252  [Attribute("-1", UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(SCR_EArsenalItemMode))]
254 
255  [Attribute("1", desc: "If true than the ItemMode will be ignored and any items that have the type regardless of the mode will be blacklisted", UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(SCR_EArsenalItemMode))]
256  bool m_bIgnoreItemMode;
257 }
m_BlackListedPrefabs
protected ref set< ResourceName > m_BlackListedPrefabs
Definition: SCR_LoadoutSaveBlackListHolder.c:18
m_UIInfo
protected SCR_UIInfo m_UIInfo
Definition: SCR_EditableEntityCampaignBuildingModeLabelSetting.c:17
m_aBlackListedPrefabs
protected ref array< ResourceName > m_aBlackListedPrefabs
Definition: SCR_LoadoutSaveBlackListHolder.c:12
SCR_EArsenalItemMode
SCR_EArsenalItemMode
Definition: SCR_EArsenalItemMode.c:1
m_eItemMode
protected SCR_EArsenalItemMode m_eItemMode
Definition: SCR_ArsenalItem.c:6
SCR_LoadoutSaveBlackList
Definition: SCR_LoadoutSaveBlackListHolder.c:131
SCR_StringHelper
Definition: SCR_StringHelper.c:1
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
SCR_LoadoutSaveBlackListHolder
Definition: SCR_LoadoutSaveBlackListHolder.c:2
SCR_EArsenalItemType
SCR_EArsenalItemType
Definition: SCR_EArsenalItemType.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
IsEnabled
bool IsEnabled()
Definition: SCR_LoadoutSaveBlackListHolder.c:75
SCR_UIInfo
Definition: SCR_UIInfo.c:7
SCR_BaseContainerCustomTitleEnum
class SCR_LoadoutSaveBlackList SCR_BaseContainerCustomTitleEnum(SCR_EArsenalItemType, "m_eItemType")
Definition: SCR_LoadoutSaveBlackListHolder.c:246
m_bBlackListActive
protected bool m_bBlackListActive
Definition: SCR_LoadoutSaveBlackListHolder.c:6
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
m_BlackListedItemTypes
protected ref array< ref SCR_LoadoutSaveBlackListItemType > m_BlackListedItemTypes
Definition: SCR_LoadoutSaveBlackListHolder.c:15
BaseContainerProps
class SCR_LoadoutSaveBlackList BaseContainerProps()
m_bEnabled
private bool m_bEnabled
Definition: SCR_BaseManualCameraComponent.c:3
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
m_eItemType
protected SCR_EArsenalItemType m_eItemType
Definition: SCR_ArsenalItem.c:3
SCR_BaseContainerCustomTitleUIInfo
void SCR_BaseContainerCustomTitleUIInfo(string propertyName, string format="%1")
Definition: Attributes.c:788
SCR_ArsenalItem
Definition: SCR_ArsenalItem.c:2