Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
EditorAttributesDialogUI.c
Go to the documentation of this file.
1 
4 {
5  private SCR_AttributesManagerEditorComponent m_AttributesManager;
6  private ref array<ResourceName> m_CategoryConfigs;
7  private ref array<ref SCR_EditorAttributeCategory> m_Categories;
8 
9  protected void InitCategories()
10  {
11  array<SCR_BaseEditorAttribute> attributes = new array<SCR_BaseEditorAttribute>;
12  m_AttributesManager.GetEditedAttributes(attributes);
13 
14  m_CategoryConfigs = new array<ResourceName>;
15  m_Categories = new array<ref SCR_EditorAttributeCategory>;
16  array<int> priorities = new array<int>;
17 
18  //--- Get categories from all attributes
19  foreach (SCR_BaseEditorAttribute attribute: attributes)
20  {
21  ResourceName categoryConfig = attribute.GetCategoryConfig();
22  if (m_CategoryConfigs.Find(categoryConfig) == -1)
23  {
24  //--- Get category container
25  Resource categoryContainer = BaseContainerTools.LoadContainer(categoryConfig);
26  if (!categoryContainer)
27  {
28  Print(string.Format("Error loading category '%1'!", categoryConfig), LogLevel.ERROR);
29  continue;
30  }
31 
32  SCR_EditorAttributeCategory category = SCR_EditorAttributeCategory.Cast(BaseContainerTools.CreateInstanceFromContainer(categoryContainer.GetResource().ToBaseContainer()));
33  if (!category)
34  {
35  Print(string.Format("SCR_EditorAttributeCategory not found in %1!", categoryConfig), LogLevel.ERROR);
36  continue;
37  }
38 
39  //--- Add to the array sorted by priority
40  int priority = category.GetPriority();
41  int index = 0;
42  int count = m_CategoryConfigs.Count();
43  bool breakCalled = false;
44 
45  for (int c = 0; c < count; c++)
46  {
47  if (priority > priorities[c])
48  {
49  index = c;
50  breakCalled = true;
51  break;
52  }
53  }
54 
55  if (breakCalled)
56  {
57  m_CategoryConfigs.InsertAt(categoryConfig, index);
58  m_Categories.InsertAt(category, index);
59  priorities.InsertAt(category.GetPriority(), index);
60  }
61  else {
62  m_CategoryConfigs.Insert(categoryConfig);
63  m_Categories.Insert(category);
64  priorities.Insert(category.GetPriority());
65  }
66  }
67  }
68  }
69 
70  void RemoveAutoClose()
71  {
72  if (m_AttributesManager)
73  {
74  m_AttributesManager.GetOnAttributesConfirm().Remove(CloseSelf);
75  m_AttributesManager.GetOnAttributesCancel().Remove(CloseSelf);
76  }
77  }
78 
79  override void OnMenuOpen()
80  {
81  m_AttributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent, true));
82  if (!m_AttributesManager)
83  return;
84 
85  m_AttributesManager.GetOnAttributesConfirm().Insert(CloseSelf);
86  m_AttributesManager.GetOnAttributesCancel().Insert(CloseSelf);
87 
88  InitCategories();
90  if (attributesUI)
91  {
92  attributesUI.InitWidget(m_CategoryConfigs, m_Categories);
93  }
94  }
95 
96  override void OnMenuClose()
97  {
98  RemoveAutoClose();
99  }
100 };
GetRootWidget
Widget GetRootWidget()
Definition: SCR_UITaskManagerComponent.c:160
EditorAttributesDialogUI
Definition: EditorAttributesDialogUI.c:3
SCR_EditorAttributeCategory
Definition: SCR_EditorAttributeCategory.c:8
EditorMenuBase
Definition: EditorMenuBase.c:7
SCR_BaseEditorAttribute
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
Definition: SCR_BaseEditorAttribute.c:3
SCR_AttributesEditorUIComponent
Definition: SCR_AttributesEditorUIComponent.c:3
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180