Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ContentBrowserEditorComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/Editor", description: "Management of placeable entities. Works only with SCR_EditorBaseEntity!", icon: "WBData/ComponentEditorProps/componentEditor.png")]
5
6
7void ScriptInvoker_BrowserBudgetPreviewRefresh(array<ref SCR_EntityBudgetValue> previewCosts);
9typedef ScriptInvokerBase<ScriptInvoker_BrowserBudgetPreviewRefresh> ScriptInvoker_BrowserBudgetPreviewRefreshEvent;
10
17{
18 [Attribute("1", "If true will show the faction icon on the content browser cards, If false will hide them")]
20
21 protected const int ASYNC_TICK_LENGTH = 16; //--- How many ticks are allowed per async loading cycle
22
23 /*[Attribute("0", uiwidget: UIWidgets.ComboBox, "Labels that are active by default", "", ParamEnumArray.FromEnum(EEditableEntityLabel))]
24 protected ref array<EEditableEntityLabel> m_DefaultActiveLabels; */
25
26 [Attribute(desc: "Content browser menu preset.", defvalue: "-1", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(ChimeraMenuPreset))]
27 private ChimeraMenuPreset m_MenuPreset;
28
29 [Attribute("1", desc: "If true it makes sure that the content browser states are loaded from user settings. Else keeps the keeps the sates as defined in m_aContentBrowserTabStates")]
31
32 [Attribute(desc: "A list of saved states of the content browser such as labels and pagination. Index 0 is the saved hand filters.")]
33 protected ref array<ref SCR_EditorContentBrowserSaveStateDataUI> m_aContentBrowserTabStates;
34
35 [Attribute(desc: "Entities with blacklisted labels are not displayed in the content browser unless a SCR_EditorContentBrowserDisplayConfig is used when opening the content browser and the label is in the AlwaysActiveLabels", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EEditableEntityLabel))]
36 protected ref array<EEditableEntityLabel> m_eBlackListedLabels;
37
38 //~ Saved content browser state when content browser is opened with config
40
41 protected ref set<ref SCR_EditableEntityCache> m_aExtendedEntitiesCache = new set<ref SCR_EditableEntityCache>();
42
44
45 private ref array<EEditableEntityLabel> m_ActiveLabels = {};
46
47 protected ref array<ref SCR_EditableEntityCoreLabelGroupSetting> m_LabelGroups = {};
48
49 //~ An array of all the hidden state tabs
50 protected ref array<int> m_aHiddenStateTabs = {};
51
52 protected ref array<int> m_aFilteredPrefabIDs = {};
53 protected ref array<string> m_aLocalizationKeys = {};
55
61 protected ref array<ref SCR_EditableEntityUIInfo> m_aInfos;
62 protected ref array<ResourceName> m_aAsyncPrefabs;
63 protected int m_iAsyncIndex;
64
65 protected int m_iBrowserStateIndex = 0;
66 protected int m_iPageIndex;
67 protected int m_iPageEntryCount = 15;
68 protected string m_sCurrentSearchText;
69 protected string m_sLastSearchText;
71
74
76 protected ref ScriptInvoker Event_OnSearchConfirm = new ScriptInvoker; //~ Sends current search string
82 protected ref ScriptInvoker Event_OnEnableSaveStateTabs = new ScriptInvoker; //~ Sends enable bool
83 protected ref ScriptInvoker Event_OnStateTabVisibilityChanged = new ScriptInvoker; //~ Sends index and if visible or not
84
91 {
93 return m_PlacingManagerData.GetPrefab(prefabID);
94 else
95 return ResourceName.Empty;
96 }
97
104 {
105 if (index >= 0 && index < m_aFilteredPrefabIDs.Count())
106 {
107 return m_aFilteredPrefabIDs.Get(index);
108 }
109 return -1;
110 }
111
112 //------------------------------------------------------------------------------------------------
116 bool IsPrefabIDAvailable(int prefabID)
117 {
119 return false;
120
121 return m_aFilteredPrefabIDs.Contains(prefabID);
122 }
123
133
134 //------------------------------------------------------------------------------------------------
142
143 //------------------------------------------------------------------------------------------------
149 {
151 if (!extendedEntity)
152 return 0;
153
154 ResourceName extendedEntityResource = extendedEntity.GetPrefab();
155 SCR_EditableEntityCache extendedEntityCache = FindExtendedEntityCache(extendedEntityResource);
156
157 if (!extendedEntityCache)
158 return 0;
159
160 set<int> extendableEntities = new set<int>();
161 extendedEntityCache.GetExtendedEntities(extendableEntities);
162 m_aFilteredPrefabIDs.Clear();
163
164 foreach (int prefabID : extendableEntities)
165 {
166 m_aFilteredPrefabIDs.Insert(prefabID);
167 }
168
171 }
172
173 //------------------------------------------------------------------------------------------------
175 {
176 return FindExtendedEntityCache(entity.GetPrefab()) != null;
177 }
178
179 //------------------------------------------------------------------------------------------------
185 int GetValidBlackListedLabels(out notnull array<EEditableEntityLabel> validBlackListLabels)
186 {
188 {
189 validBlackListLabels.Clear();
190
192 {
193 //~ only add non "always active" labels
194 if (!m_ContentBrowserConfig.IsAlwaysActiveLabel(label))
195 validBlackListLabels.Insert(label);
196 }
197 }
198 else
199 {
200 validBlackListLabels.Copy(m_eBlackListedLabels);
201 }
202
203 return validBlackListLabels.Count();
204 }
205
206 //------------------------------------------------------------------------------------------------
208 {
210 {
211 if (entityCache.GetPrefab() == extendedEntityResource)
212 return entityCache;
213 }
214
215 set<int> extendedEntities = new set<int>();
216
217 SCR_EditableEntityUIInfo info = null;
218 for (int prefabId, count = GetInfoCount(); prefabId < count; prefabId++)
219 {
220 info = GetInfo(prefabId);
221 if (!info)
222 continue;
223
224 if (extendedEntityResource == info.GetSlotPrefab())
225 extendedEntities.Insert(prefabId);
226 }
227
228 if (extendedEntities.Count() <= 0)
229 return null;
230
231 SCR_EditableEntityCache extendedEntityCache = new SCR_EditableEntityCache();
232 m_aExtendedEntitiesCache.Insert(extendedEntityCache);
233 extendedEntityCache.SetExtendedEntities(extendedEntities);
234 extendedEntityCache.SetPrefab(extendedEntityResource);
235
236 return extendedEntityCache;
237 }
238
244 {
245 if (GetExtendedEntity())
246 return;
247
248 // Filter labels
249 m_aFilteredPrefabIDs.Clear();
250 m_aLocalizationKeys.Clear();
251 array<EEditableEntityLabel> entityLabels = {};
252
253 array<EEditableEntityLabel> validBlackListLabels = {};
254 GetValidBlackListedLabels(validBlackListLabels);
255
256 bool isBlackListed;
258 int count = GetInfoCount();
259 for (int i = 0; i < count; i++)
260 {
261 isBlackListed = false;
262 entityLabels.Clear();
263 info = GetInfo(i);
264
265 if (!info)
266 {
267 continue;
268 }
269
270 info.GetEntityLabels(entityLabels);
271 if (!IsMatchingToggledLabels(entityLabels))
272 continue;
273
274 //~ Ignore entities with blacklist labels
275 foreach (EEditableEntityLabel blackListLabel : validBlackListLabels)
276 {
277 if (entityLabels.Contains(blackListLabel))
278 {
279 isBlackListed = true;
280 break;
281 }
282 }
283
284 //~ Entity has a blacklisted label so don't show it
285 if (isBlackListed)
286 continue;
287
288 m_aFilteredPrefabIDs.Insert(i);
289
290 m_aLocalizationKeys.Insert(info.GetName());
291 }
292
293 // Search
294 string currentSearch = GetCurrentSearch();
295 if (!currentSearch.IsEmpty())
296 {
297 array<int> searchResultPrefabID = {}, searchResultIndices = {};
298 WidgetManager.SearchLocalized(currentSearch, m_aLocalizationKeys, searchResultIndices);
299
300 foreach (int searchResultIndex : searchResultIndices)
301 {
302 int prefabID = m_aFilteredPrefabIDs.Get(searchResultIndex);
303 searchResultPrefabID.Insert(prefabID);
304 }
305 m_aFilteredPrefabIDs.Copy(searchResultPrefabID);
306 }
307
309
311 }
312
313 bool isMatchingToggledLabelsOfState(int savedStateIndex)
314 {
315 if (savedStateIndex >= m_aContentBrowserTabStates.Count())
316 return false;
317
318 array<EEditableEntityLabel> activeLabels = {};
319
320 m_aContentBrowserTabStates[savedStateIndex].GetLabels(activeLabels);
321 return IsMatchingToggledLabels(activeLabels);
322 }
323
328 bool IsMatchingToggledLabels(notnull array<EEditableEntityLabel> entityLabels)
329 {
330 if (!IsAnyLabelActive())
331 {
332 return true;
333 }
334 if (entityLabels.IsEmpty())
335 {
336 return false;
337 }
338
339 array<SCR_EditableEntityCoreLabelSetting> groupLabels = {};
341 {
342 EEditableEntityLabelGroup labelGroupType = labelGroup.GetLabelGroupType();
343
344 m_EntityCore.GetLabelsOfGroup(labelGroupType, groupLabels);
345
346 int activeLabels = 0;
347 int matchesActive = 0;
348
349 bool needsAllActive = labelGroup.GetRequiresAllLabelsMatch();
350
351 foreach (SCR_EditableEntityCoreLabelSetting entityLabelSetting : groupLabels)
352 {
353 EEditableEntityLabel entityLabel = entityLabelSetting.GetLabelType();
354 if (!IsLabelActive(entityLabel))
355 {
356 continue;
357 }
358 activeLabels++;
359 if (entityLabels.Find(entityLabel) != -1)
360 {
361 matchesActive++;
362 }
363 }
364
365 if (activeLabels > 0)
366 {
367 if (needsAllActive && matchesActive != activeLabels)
368 {
369 return false;
370 }
371 else if (!needsAllActive && matchesActive == 0)
372 {
373 return false;
374 }
375 }
376 }
377
378 return true;
379 }
380
387 {
388 return m_ActiveLabels.Find(entityLabel) != -1;
389 }
390
396 {
397 return !m_ActiveLabels.IsEmpty();
398 }
399
405 void SetLabel(EEditableEntityLabel entityLabel, bool active)
406 {
407 bool labelActive = IsLabelActive(entityLabel);
408 if (active && !labelActive)
409 {
410 m_ActiveLabels.Insert(entityLabel);
411 }
412 else if (!active && labelActive)
413 {
414 m_ActiveLabels.RemoveItem(entityLabel);
415 }
416
417 Event_OnLabelChanged.Invoke(entityLabel, active);
418 }
419
424 void ResetAllLabels(bool setConfigData = true)
425 {
426 m_ActiveLabels.Clear();
427
428 if (setConfigData)
430 }
431
432 void GetActiveLabels(out notnull array<EEditableEntityLabel> activeLabels)
433 {
434 activeLabels.Copy(m_ActiveLabels);
435 }
436
438 {
439 return m_ActiveLabels.Count();
440 }
441
442 void GetLabelGroups(out notnull array<ref SCR_EditableEntityCoreLabelGroupSetting> labelGroups)
443 {
444 labelGroups = m_LabelGroups;
445 }
446
448 {
449 return m_EntityCore.GetLabelGroupType(entityLabel, groupLabel);
450 }
451
458 {
459 return m_EntityCore.GetLabelGroupOrder(groupLabel);
460 }
461
462 bool GetLabelsOfGroup(EEditableEntityLabelGroup labelGroupType, out notnull array<SCR_EditableEntityCoreLabelSetting> labels)
463 {
464 return m_EntityCore.GetLabelsOfGroup(labelGroupType, labels);
465 }
466
467 bool GetLabelUIInfo(EEditableEntityLabel entityLabel, out SCR_UIInfo uiInfo)
468 {
469 return m_EntityCore.GetLabelUIInfo(entityLabel, uiInfo);
470 }
471
472 bool GetLabelUIInfoIfValid(EEditableEntityLabel entityLabel, EEditorMode currentMode, out SCR_UIInfo uiInfo)
473 {
474 return m_EntityCore.GetLabelUIInfoIfValid(entityLabel, currentMode, uiInfo);
475 }
476
481 void OrderLabels(inout notnull array<EEditableEntityLabel> activeLabels)
482 {
483 m_EntityCore.OrderLabels(activeLabels);
484 }
485
491 {
492 EEditableEntityLabelGroup groupLabel;
493 GetLabelGroupType(entityLabel, groupLabel);
494
495 array<SCR_EditableEntityCoreLabelSetting> labelsInGroup = new array<SCR_EditableEntityCoreLabelSetting>;
496 GetLabelsOfGroup(groupLabel, labelsInGroup);
497 if (!labelsInGroup)
498 return -1;
499
500 int count = labelsInGroup.Count();
501
502 for (int i = 0; i < count; i++)
503 {
504 if (labelsInGroup[i].GetLabelType() == entityLabel)
505 return i;
506 }
507
508 return -1;
509 }
510
511
517 {
518 SCR_UIInfo uiInfo;
519 if (GetLabelUIInfo(entityLabel, uiInfo))
520 {
521 return uiInfo.GetName();
522 }
523 return string.Empty;
524 }
525
530 void SetPageIndex(int pageIndex)
531 {
532 m_iPageIndex = pageIndex;
533 }
534
540 {
541 return m_iPageIndex;
542 }
543
544 void SetPageEntryCount(int pageEntryCount)
545 {
546 m_iPageEntryCount = pageEntryCount;
547 }
548
550 {
551 return m_iPageEntryCount;
552 }
553
562
568 {
570 }
571
572
573
578 void GetHiddenStateTabs(out notnull array<int> hiddenStateTabs)
579 {
580 hiddenStateTabs.Copy(m_aHiddenStateTabs);
581 }
582
588 void SetStateTabVisible(int tabIndex, bool setVisible)
589 {
590 if (!setVisible && !m_aHiddenStateTabs.Contains(tabIndex))
591 m_aHiddenStateTabs.Insert(tabIndex);
592 else if (setVisible && m_aHiddenStateTabs.Contains(tabIndex))
593 m_aHiddenStateTabs.RemoveItem(tabIndex);
594 //~ Already hidden or shown
595 else
596 return;
597
598 Event_OnStateTabVisibilityChanged.Invoke(tabIndex, setVisible);
599 }
600
606 int GetContentBrowserTabStates(out notnull array<SCR_EditorContentBrowserSaveStateDataUI> contentBrowserStates)
607 {
609 contentBrowserStates.Insert(state);
610
611 return contentBrowserStates.Count();
612 }
613
620 {
621 if (index == -1)
622 {
625 {
626 return state;
627 }
629 }
630
632 return null;
633
635 }
636
642 {
643 return m_sLastSearchText;
644 }
645
651 {
653 }
654
659 void SetCurrentSearch(string searchText)
660 {
662 m_sCurrentSearchText = searchText;
663 }
664
669 void SetSaveStateTabsEnabled(bool enabled)
670 {
671 Event_OnEnableSaveStateTabs.Invoke(enabled);
672 }
673
681
690
699
708
717
726
735
744
753
762
769 {
770 m_ExtendedEntity = extendedEntity;
771 }
772
781
787 {
788 if (!m_aInfos)
789 return 0;
790
791 return m_aInfos.Count();
792 }
793
801 {
802 if (m_aInfos && m_aInfos.IsIndexValid(index))
803 return m_aInfos[index];
804
805 return null;
806 }
807
814 {
815 if (m_aInfos && info)
816 {
817 foreach (int i, SCR_EditableEntityUIInfo browserInfo : m_aInfos)
818 {
819 if (browserInfo && browserInfo.GetName() == info.GetName())
820 {
821 return i;
822 }
823 }
824 }
825 return -1;
826 }
827
828 bool GetFirstAvailabeBudgetCost(int prefabID, out SCR_EntityBudgetValue budgetCost)
829 {
830 SCR_EditableEntityUIInfo prefabInfo = GetInfo(prefabID);
831 if (!prefabInfo)
832 return false;
833
834 array<ref SCR_EntityBudgetValue> budgetCosts = {};
835 m_BudgetManager.GetEntityPreviewBudgetCosts(prefabInfo, budgetCosts);
836
837 if (!budgetCosts.IsEmpty())
838 budgetCost = budgetCosts.Get(0);
839 return budgetCost != null;
840 }
841
842 //------------------------------------------------------------------------------------------------
843 bool CanPlace(int prefabID, out notnull array<ref SCR_EntityBudgetValue> budgetCosts, out SCR_UIInfo blockingBudgetInfo, bool showNotification = false, out EEditableEntityBudget blockingBudget = -1)
844 {
845 if (!m_BudgetManager)
846 return true;
847
848 SCR_EditableEntityUIInfo prefabInfo = GetInfo(prefabID);
849 if (!prefabInfo)
850 return false;
851
852 if (m_BudgetManager.CanPlaceEntityInfo(prefabInfo, budgetCosts, blockingBudget, showNotification))
853 {
854 return true;
855 }
856 else
857 {
858 m_BudgetManager.GetCurrentBudgetInfo(blockingBudget, blockingBudgetInfo);
859 return false;
860 }
861 }
862
869 bool CanPlace(notnull array<ResourceName> prefabs, EEditableEntityType fallbackBudgetType = -1)
870 {
871 //~ No budget manager so get default one (Ignoring mode)
872 if (!m_BudgetManager)
874
876 return false;
877
878 int prefabId;
879 Resource resource;
880 IEntitySource source;
881 array<ref SCR_EntityBudgetValue> fullBudgetCosts = {};
882 array<ref SCR_EntityBudgetValue> budgetCosts = {};
883
884 foreach (ResourceName prefab : prefabs)
885 {
886 prefabId = m_PlacingManager.GetPrefabID(prefab);
887
888 //~ Grab budget from content browser
889 if (!m_BudgetManager.GetEntityPreviewBudgetCosts(GetInfo(prefabId), budgetCosts))
890 {
891 //~ Grab budget from entity if not registered in content browser
892 if (!m_BudgetManager.GetEntitySourcePreviewBudgetCosts(SCR_EditableEntityComponentClass.GetEditableEntitySource(Resource.Load(prefab)), budgetCosts))
893 {
894 //~ Grab default budget for type if has fall back and no budget was assigned to entity
895 if (fallbackBudgetType != -1)
896 m_BudgetManager.GetEntityTypeBudgetCost(fallbackBudgetType, budgetCosts);
897 }
898 }
899
900 //~ Add found budgets to full list
901 foreach (SCR_EntityBudgetValue budget : budgetCosts)
902 fullBudgetCosts.Insert(new SCR_EntityBudgetValue(budget.GetBudgetType(), budget.GetBudgetValue()));
903
904 budgetCosts.Clear();
905 }
906
907 //~ Merge Budgets
908 SCR_EntityBudgetValue.MergeBudgetCosts(budgetCosts, fullBudgetCosts);
909
910 EEditableEntityBudget blockingBudget;
911
912 //~ Check if can place
913 return m_BudgetManager.CanPlace(budgetCosts, blockingBudget);
914 }
915
916 bool RefreshPreviewCost(int prefabID = -1)
917 {
918 if (m_PlacingManager.HasPlacingFlag(EEditorPlacingFlags.CHARACTER_PLAYER) || prefabID == -1)
919 {
920 m_BudgetManager.ResetPreviewCost();
921 return false;
922 }
923
924 SCR_EditableEntityUIInfo editableUIInfo = GetInfo(prefabID);
925 if (!editableUIInfo)
926 {
927 return false;
928 }
929
930 array<ref SCR_EntityBudgetValue> budgetCosts = {};
931 if (m_BudgetManager.GetEntityPreviewBudgetCosts(editableUIInfo, budgetCosts))
932 {
933 m_BudgetManager.UpdatePreviewCost(budgetCosts);
934 return true;
935 }
936
937 return false;
938 }
939
945 static bool OpenBrowserInstance(int browserStateIndex = -1)
946 {
948 if (contentBrowserManager)
949 return contentBrowserManager.OpenBrowser(browserStateIndex);
950 else
951 return false;
952 }
953
960 {
962 if (contentBrowserManager)
963 return contentBrowserManager.OpenBrowserState(saveState);
964 else
965 return false;
966 }
967
975 {
977 if (contentBrowserManager)
978 return contentBrowserManager.OpenBrowserLabelConfig(contentBrowserConfig);
979 else
980 return false;
981 }
982
992 {
993 if (!m_PlacingManager || m_PlacingManager.IsPlacing())
994 return false;
995
996 SCR_CompositionSlotManagerComponent slotManager = SCR_CompositionSlotManagerComponent.GetInstance();
997 if (slotManager && slotManager.IsOccupied(extendedEntity.GetOwner()))
998 return false;
999
1000 SCR_EditableEntityComponent currentExtendedEntity = GetExtendedEntity();
1001
1002 if (contentBrowserConfig == null)
1003 SetExtendedEntity(extendedEntity);
1004 else
1005 SetExtendedEntity(null);
1006
1007 int extendedPrefabCount = 0;
1008
1009 if (extendedEntity && !contentBrowserConfig)
1010 extendedPrefabCount = FilterExtendedSlots();
1011 else
1012 extendedPrefabCount = m_iFilteredPrefabIDsCount;
1013
1014 if (extendedPrefabCount == 0)
1015 {
1016 SetExtendedEntity(null);
1017 return false;
1018 }
1019
1020 if ((!contentBrowserConfig && OpenBrowser()) || (contentBrowserConfig && OpenBrowserLabelConfig(contentBrowserConfig)))
1021 {
1024 if (previewManager)
1025 verticalMode = previewManager.GetVerticalMode();
1026
1027 vector transform[4];
1028 extendedEntity.GetTransform(transform);
1029 SCR_EditorPreviewParams params = SCR_EditorPreviewParams.CreateParams(transform, verticalMode: verticalMode);
1030
1031 //~ Extened with slot
1032 if (extendedEntity.GetEntityType() == EEditableEntityType.SLOT || extendedEntity.HasEntityFlag(EEditableEntityFlag.SLOT))
1033 {
1034 params.m_TargetInteraction = EEditableEntityInteraction.SLOT;
1035 }
1036 //~ If ever passengers picking can be chosen then this logic needs to change
1037 else if (extendedEntity.GetOwner().FindComponent(SCR_BaseCompartmentManagerComponent))
1038 {
1039 transform[3] = extendedEntity.GetOwner().GetOrigin() + BaseCompartmentSlot.SPAWN_IN_VEHICLE_OFFSET; //~ Spawn close so the entities are spawned in but still above the entity out of sight
1040 params.m_TargetInteraction = EEditableEntityInteraction.PASSENGER;
1041 params.m_Parent = extendedEntity;
1042 params.m_ParentID = Replication.FindItemId(extendedEntity);
1043 }
1044
1045 params.m_vTransform = transform;
1046 params.SetTarget(extendedEntity);
1047 m_PlacingManager.SetInstantPlacing(params);
1048 return true;
1049 }
1050
1051 return false;
1052 }
1053
1059 bool OpenBrowser(int browserStateIndex = -1)
1060 {
1062 return false;
1063
1064 //~ Clear config as browser is opened without it
1066 if (browserStateIndex > 0)
1067 {
1068 SetBrowserState(browserStateIndex);
1069 }
1070
1071 //~ Open context browser
1073 return true;
1074 }
1075
1082 {
1084 return false;
1085
1086 //~ Clear config as browser is opened without it
1087 if (displayConfig)
1088 m_ContentBrowserConfig = displayConfig;
1089 else
1091
1092 LoadBrowserState(saveState, false);
1094
1095 //~ Open context browser
1097 return true;
1098 }
1099
1107 {
1108 if (!contentBrowserConfig)
1109 return OpenBrowser();
1110
1112 return false;
1113
1114 SetExtendedEntity(null);
1115 m_ContentBrowserConfig = contentBrowserConfig;
1116 SetBrowserState(contentBrowserConfig);
1117
1118 //~ Open context browser
1120 return true;
1121 }
1122
1128 void SetBrowserState(int browserStateIndex = -1, bool saveCurrentState = false, bool clearConfigData = true)
1129 {
1130 if (saveCurrentState)
1132
1133 if (browserStateIndex < 0)
1134 LoadBrowserState(m_iBrowserStateIndex, clearConfigData);
1135 else
1136 {
1137 SetBrowserStateIndex(browserStateIndex);
1138 LoadBrowserState(browserStateIndex, clearConfigData);
1139
1140 // Reset prefab placement selection when tab changes, as when it will be placed, then it would fail local evaluation, since its not in the m_aFilteredPrefabIDs, because it was from a different tab
1141 if (m_PlacingManager)
1142 m_PlacingManager.SetSelectedPrefab(ResourceName.Empty);
1143 }
1144 }
1145
1146 void SetCustomBrowserState(SCR_EditorContentBrowserSaveStateData state, bool clearConfigData = true)
1147 {
1148 LoadBrowserState(state, false);
1149 }
1150
1156 void SetBrowserState(SCR_EditorContentBrowserDisplayConfig contentBrowserConfig, bool saveCurrentState = false)
1157 {
1158 m_ContentBrowserConfig = contentBrowserConfig;
1160 if (GetConfigState(contentBrowserConfig, state))
1161 LoadBrowserState(state, false);
1162 else
1163 ClearBrowserState(false);
1164 }
1165
1172 {
1174
1175 //~ Does not use config so use default logic
1177 {
1179
1180 //~ Invalid
1181 if (!state)
1182 return false;
1183 }
1184 //~ Uses config and allows for content browser state saving
1185 else if (!m_ContentBrowserConfig.GetSaveContentBrowserState() || !GetConfigState(m_ContentBrowserConfig, state))
1186 {
1187 //~ Do not save state
1188 return false;
1189 }
1190
1191 state.SetLabels(m_ActiveLabels);
1194
1196
1197 //~ Saved state successfully
1198 return true;
1199 }
1200
1207 void AddRemoveLabelOfPersistentBrowserState(EEditableEntityLabel label, bool addLabel, int stateIndex = -1)
1208 {
1209 if (stateIndex >= m_aContentBrowserTabStates.Count())
1210 return;
1211
1212 //~ Only change it on one state
1213 if (stateIndex > -1)
1214 {
1215 m_aContentBrowserTabStates[stateIndex].AddRemoveLabel(label, addLabel);
1216 return;
1217 }
1218
1219 //~ Add to all states
1221 state.AddRemoveLabel(label, addLabel);
1222 }
1223
1224 void ResetBrowserState(bool clearConfigData)
1225 {
1226 ClearBrowserState(clearConfigData);
1227 FilterEntries();
1228 }
1229
1231 {
1232 //m_BudgetManager.CheckMaxBudgetReached(
1233 }
1234
1236 {
1237 if (GetExtendedEntity())
1238 {
1239 //ResetBrowserState(false);
1240 SetExtendedEntity(null);
1241
1242 // Set back to previous filtering
1244 }
1245
1246 bool isBuilding = GetManager().GetCurrentMode() == EEditorMode.BUILDING;
1247 SetBrowserState(-1, true, !isBuilding);
1248
1249 //~ Save the persistent state
1252 }
1253
1254 protected bool OpenBrowserMenu()
1255 {
1257 {
1258 return m_EditorMenuManager.GetMenu().OpenDialog(m_MenuPreset);
1259 }
1260 return false;
1261 }
1262
1263 //~ Clear browser state
1264 protected void ClearBrowserState(bool clearConfigData)
1265 {
1266 ResetAllLabels(!clearConfigData);
1267 SetPageIndex(0);
1268 SetCurrentSearch(string.Empty);
1269
1270 //~ Clear config
1271 if (clearConfigData)
1273
1275 }
1276
1277 //~ Load the saved browser state using index
1278 protected void LoadBrowserState(int stateIndex, bool clearConfigData)
1279 {
1280 if (stateIndex < 0 || stateIndex >= m_aContentBrowserTabStates.Count())
1281 return;
1282
1284 if (state)
1285 {
1286 LoadBrowserState(state, clearConfigData);
1287 }
1288 }
1289
1290 //~ Load the saved browser state
1291 protected void LoadBrowserState(SCR_EditorContentBrowserSaveStateData state, bool clearConfigData)
1292 {
1293 //~ Preload before browser is cleared
1294 Event_OnBrowserStatePreload.Invoke(state);
1295
1296 ClearBrowserState(clearConfigData);
1297
1298 //~ Labels
1299 array<EEditableEntityLabel> stateActiveLabels = new array<EEditableEntityLabel>;
1300 state.GetLabels(stateActiveLabels);
1301
1302 foreach (EEditableEntityLabel activeLabel : stateActiveLabels)
1303 SetLabel(activeLabel, true);
1304
1305 //~ Page Index
1306 SetPageIndex(state.GetPageIndex());
1307
1308 //~ Search String
1310
1311 if (!clearConfigData)
1313
1314 //~ Load Event
1315 Event_OnBrowserStateLoaded.Invoke(state);
1316
1317 if (m_aInfos && m_aAsyncPrefabs == null)
1318 FilterEntries();
1319 }
1320
1322 {
1323 if (!browserConfig)
1324 return false;
1325
1326 if (!m_mContentBrowserConfigStates.Find(browserConfig, state))
1327 {
1329 m_mContentBrowserConfigStates.Insert(browserConfig, state);
1330 }
1331 return true;
1332 }
1333
1334 protected void SetConfigLabels()
1335 {
1337 return;
1338
1339 //~ Set labels active
1340 array<EEditableEntityLabel> labels = new array<EEditableEntityLabel>;
1341 m_ContentBrowserConfig.GetAlwaysActiveLabels(labels);
1342
1343 foreach (EEditableEntityLabel label : labels)
1344 SetLabel(label, true);
1345 }
1346
1355
1356 //~ Save all tab states into settings. So it can be loaded when a diffrent scenario is loaded or the game is booted up again
1358 {
1360 return;
1361
1362 BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorPersistentData");
1363 if (!editorSettings)
1364 return;
1365
1366 array<ref SCR_EditorContentBrowserSaveStateData> settingBrowserStates = {};
1367
1368 //~ Get the SCR_EditorContentBrowserStateDataUI data
1370 {
1371 settingBrowserStates.Insert(state);
1372 }
1373
1374 //~ Save the Data
1375 editorSettings.Set("m_aSavedContentBrowserStates", settingBrowserStates);
1376
1377 GetGame().UserSettingsChanged();
1378 }
1379
1380 //~ Load Persistent browser state from where the player left off last time
1382 {
1384 return;
1385
1386 BaseContainer editorSettings = GetGame().GetGameUserSettings().GetModule("SCR_EditorPersistentData");
1387 if (!editorSettings)
1388 return;
1389
1390 array<ref SCR_EditorContentBrowserSaveStateData> settingBrowserStates;
1391 editorSettings.Get("m_aSavedContentBrowserStates", settingBrowserStates);
1392
1393 if (!settingBrowserStates)
1394 return;
1395
1396 int savedCount = settingBrowserStates.Count();
1397
1398 //~ Check if saved settings are same as given tabs
1399 if (m_aContentBrowserTabStates.Count() == savedCount)
1400 {
1401 array<EEditableEntityLabel> settingSavedLabels = {};
1402
1403 //~ Get persistant data and apply the data to Browser States
1404 for (int i = 0; i < savedCount; i++)
1405 {
1406 //~ Note, does not load pageIndex as this might change if mods are added/removed. Plus it might be frustrating/confusing for user
1407 settingBrowserStates[i].GetLabels(settingSavedLabels);
1408 m_aContentBrowserTabStates[i].SetLabels(settingSavedLabels, true);
1409 m_aContentBrowserTabStates[i].SetSearchString(settingBrowserStates[i].GetSearchString());
1410 }
1411 }
1412 }
1413
1414 override void EOnEditorInit()
1415 {
1417 m_EntityCore.GetLabelGroups(m_LabelGroups);
1418
1419 //~ Load Persistent browser state from where the player left off last time
1421
1422 //~ Init the first page, else it will not load correctly
1423 SetBrowserState(0);
1424 }
1425
1437
1439 {
1440 if (m_PlacingManager)
1441 m_PlacingManager.GetOnPlaceEntityServer().Remove(OnPlaceEntityServer);
1442 }
1443
1453
1454 override bool EOnEditorActivateAsync(int attempt)
1455 {
1456 //--- Started
1457 if (attempt == 0)
1458 {
1460 if (!placingPrefabData)
1461 return true;
1462
1463 m_aInfos = {};
1464 m_aAsyncPrefabs = {};
1465 placingPrefabData.GetPrefabs(m_aAsyncPrefabs, true);
1466 m_iAsyncIndex = 0;
1467 return false;
1468 }
1469
1470 if (!m_aAsyncPrefabs)
1471 return true;
1472
1473 int tickEnd = System.GetTickCount() + ASYNC_TICK_LENGTH;
1474 int count = m_aAsyncPrefabs.Count();
1475 while (System.GetTickCount() < tickEnd)
1476 {
1477 //--- Completed
1478 if (m_iAsyncIndex >= count)
1479 {
1480 m_aAsyncPrefabs = null;
1481 FilterEntries();
1482 return true;
1483 }
1484
1485 //--- Register even when faulty, to keep indexes
1487
1488 m_iAsyncIndex++;
1489 }
1490 return false;
1491 }
1492
1493 override void EOnEditorDeactivate()
1494 {
1495 m_aInfos = null;
1496 }
1497
1498}
1499
ChimeraMenuPreset
Menu presets.
EEditableEntityBudget
EEditableEntityLabel
EEditableEntityLabelGroup
EEditorPlacingFlags
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
func ScriptInvoker_BrowserBudgetPreviewRefresh
ScriptInvokerBase< ScriptInvoker_BrowserBudgetPreviewRefresh > ScriptInvoker_BrowserBudgetPreviewRefreshEvent
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
override SCR_UIInfo GetInfo()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
static const vector SPAWN_IN_VEHICLE_OFFSET
Main replication API.
Definition Replication.c:14
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
void SCR_BaseEditorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_BaseEditorComponent FindEditorComponent(typename type, bool showError=false, bool modeFirst=false)
SCR_EditorManagerEntity GetManager()
bool OpenBrowserExtended(SCR_EditableEntityComponent extendedEntity, SCR_EditorContentBrowserDisplayConfig contentBrowserConfig=null)
ref array< EEditableEntityLabel > m_eBlackListedLabels
bool GetLabelsOfGroup(EEditableEntityLabelGroup labelGroupType, out notnull array< SCR_EditableEntityCoreLabelSetting > labels)
bool IsExtendedEntity(notnull SCR_EditableEntityComponent entity)
ref SCR_EditorContentBrowserDisplayConfig m_ContentBrowserConfig
void OrderLabels(inout notnull array< EEditableEntityLabel > activeLabels)
bool IsMatchingToggledLabels(notnull array< EEditableEntityLabel > entityLabels)
void AddRemoveLabelOfPersistentBrowserState(EEditableEntityLabel label, bool addLabel, int stateIndex=-1)
bool CanPlace(int prefabID, out notnull array< ref SCR_EntityBudgetValue > budgetCosts, out SCR_UIInfo blockingBudgetInfo, bool showNotification=false, out EEditableEntityBudget blockingBudget=-1)
bool GetLabelUIInfoIfValid(EEditableEntityLabel entityLabel, EEditorMode currentMode, out SCR_UIInfo uiInfo)
void OnPlaceEntityServer(int prefabID, SCR_EditableEntityComponent entity)
ref array< ref SCR_EditableEntityUIInfo > m_aInfos
void LoadBrowserState(SCR_EditorContentBrowserSaveStateData state, bool clearConfigData)
void SetBrowserState(int browserStateIndex=-1, bool saveCurrentState=false, bool clearConfigData=true)
void GetLabelGroups(out notnull array< ref SCR_EditableEntityCoreLabelGroupSetting > labelGroups)
void SetCustomBrowserState(SCR_EditorContentBrowserSaveStateData state, bool clearConfigData=true)
string GetLabelName(EEditableEntityLabel entityLabel)
int GetContentBrowserTabStates(out notnull array< SCR_EditorContentBrowserSaveStateDataUI > contentBrowserStates)
bool GetConfigState(SCR_EditorContentBrowserDisplayConfig browserConfig, out SCR_EditorContentBrowserSaveStateData state)
bool CanPlace(notnull array< ResourceName > prefabs, EEditableEntityType fallbackBudgetType=-1)
void SetStateTabVisible(int tabIndex, bool setVisible)
bool IsLabelActive(EEditableEntityLabel entityLabel)
void GetActiveLabels(out notnull array< EEditableEntityLabel > activeLabels)
bool GetFirstAvailabeBudgetCost(int prefabID, out SCR_EntityBudgetValue budgetCost)
bool GetLabelGroupType(EEditableEntityLabel entityLabel, out EEditableEntityLabelGroup groupLabel)
void SetBrowserState(SCR_EditorContentBrowserDisplayConfig contentBrowserConfig, bool saveCurrentState=false)
int GetLabelGroupOrder(EEditableEntityLabelGroup groupLabel)
bool OpenBrowserLabelConfig(SCR_EditorContentBrowserDisplayConfig contentBrowserConfig)
static bool OpenBrowserInstance(SCR_EditorContentBrowserSaveStateData saveState)
SCR_EditorContentBrowserDisplayConfig GetContentBrowserDisplayConfig()
void SetExtendedEntity(SCR_EditableEntityComponent extendedEntity)
ref array< ref SCR_EditableEntityCoreLabelGroupSetting > m_LabelGroups
static bool OpenBrowserLabelConfigInstance(SCR_EditorContentBrowserDisplayConfig contentBrowserConfig=null)
void SetLabel(EEditableEntityLabel entityLabel, bool active)
ref set< ref SCR_EditableEntityCache > m_aExtendedEntitiesCache
SCR_EditableEntityUIInfo GetInfo(int index)
void LoadBrowserState(int stateIndex, bool clearConfigData)
int GetLabelOrderInGroup(EEditableEntityLabel entityLabel)
SCR_EditableEntityCache FindExtendedEntityCache(ResourceName extendedEntityResource)
int FindIndexOfInfo(SCR_EditableEntityUIInfo info)
ref map< ref SCR_EditorContentBrowserDisplayConfig, ref SCR_EditorContentBrowserSaveStateData > m_mContentBrowserConfigStates
ref array< ref SCR_EditorContentBrowserSaveStateDataUI > m_aContentBrowserTabStates
bool GetLabelUIInfo(EEditableEntityLabel entityLabel, out SCR_UIInfo uiInfo)
void GetHiddenStateTabs(out notnull array< int > hiddenStateTabs)
int FilterExtendedSlots()
Filters all prefab IDs that match the extended entity.
static bool OpenBrowserInstance(int browserStateIndex=-1)
int GetValidBlackListedLabels(out notnull array< EEditableEntityLabel > validBlackListLabels)
bool OpenBrowserState(SCR_EditorContentBrowserSaveStateData saveState, SCR_EditorContentBrowserDisplayConfig displayConfig=null)
SCR_EditorContentBrowserSaveStateData GetContentBrowserTabState(int index=-1)
SCR_PlacingEditorComponentClass m_PlacingManagerData
void SetExtendedEntities(notnull set< int > prefabIDs)
void SetPrefab(ResourceName prefabResource)
int GetExtendedEntities(notnull out set< int > prefabIDs)
static IEntityComponentSource GetEditableEntitySource(Resource entityResource)
ResourceName GetPrefab(bool shorten=false)
bool HasEntityFlag(EEditableEntityFlag flag)
EEditableEntityType GetEntityType(IEntity owner=null)
bool GetTransform(out vector outTransform[4])
int GetEntityLabels(out notnull array< EEditableEntityLabel > entityLabels)
static SCR_EditableEntityUIInfo ExtractEditableUIInfoFromPrefab(ResourceName prefab)
override LocalizedString GetName()
int GetLabels(out notnull array< EEditableEntityLabel > labels)
void SetLabels(notnull array< EEditableEntityLabel > savedLabels, bool checkForInvalid=false)
Editor Content browser State data that includes UI data for tabs.
Network packet of variables for entity placing and transformation.
static SCR_EditorPreviewParams CreateParams(vector transform[4], RplId parentID=Replication.INVALID_ID, EEditorTransformVertical verticalMode=EEditorTransformVertical.SEA, bool isUnderwater=false, SCR_EditableEntityComponent target=null, EEditableEntityInteraction targetInteraction=EEditableEntityInteraction.NONE)
int GetPrefabs(out notnull array< ResourceName > outPrefabs, bool onlyExposed=false)
Definition Types.c:486
EEditableEntityType
Defines type of SCR_EditableEntityComponent. Assigned automatically based on IEntity inheritance.
EEditableEntityFlag
Unique flags of the entity.
SCR_FieldOfViewSettings Attribute
EEditorMode
Editor mode that defines overall functionality.
Definition EEditorMode.c:6
EEditorTransformVertical
Vertical transformation mode.
EEditableEntityInteraction
Type of suggested interaction when hovering edited entity on top of another entity.
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134