Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AttributesManagerEditorComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor", description: "Attribute for managing attributes. Works only with SCR_EditorBaseEntity!", icon: "WBData/ComponentEditorProps/componentEditor.png")]
3 {
4  [Attribute(category: "Attributes")]
5  protected ref array<ref SCR_EditorAttributeList> m_AttributeLists;
6 
7  protected ref array<SCR_BaseEditorAttribute> m_aAttributes = {};
8 
9  //------------------------------------------------------------------------------------------------
12  SCR_BaseEditorAttribute GetAttribute(int index)
13  {
14  return m_aAttributes[index];
15  }
16 
17  //------------------------------------------------------------------------------------------------
19  int GetAttributesCount()
20  {
21  return m_aAttributes.Count();
22  }
23 
24  //------------------------------------------------------------------------------------------------
28  int FindAttribute(SCR_BaseEditorAttribute attribute)
29  {
30  return m_aAttributes.Find(attribute);
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  // constructor
36  void SCR_AttributesManagerEditorComponentClass(BaseContainer prefab)
37  {
38  foreach (SCR_EditorAttributeList list: m_AttributeLists)
39  {
40  list.InsertAllAttributes(m_aAttributes);
41  }
42  }
43 }
44 
46 
54 class SCR_AttributesManagerEditorComponent : SCR_BaseEditorComponent
55 {
56  const int SNAPSHOT_SIZE = 96;
57 
58  [Attribute(desc: "Dialog created when attributes are edited.", defvalue: "-1", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(ChimeraMenuPreset))]
60 
61  [Attribute(desc: "Displayed description and icon when hovering over an locked attribute. All attributes need access to this.", category: "Attributes")]
63 
66  private bool m_bHasServerAttributes;
67  private ref array<Managed> m_aEditedItems;
68  private ref array<SCR_BaseEditorAttribute> m_aEditedAttributes; //~~! Class, BaseEditorAttributeVar. Get this by SetInstance
69  private ref ScriptInvoker Event_OnAttributesRequest = new ScriptInvoker();
70  private ref ScriptInvoker Event_OnAttributesStart = new ScriptInvoker();
71  private ref ScriptInvoker Event_OnAttributesConfirm = new ScriptInvoker();
72  private ref ScriptInvoker Event_OnAttributesCancel = new ScriptInvoker();
73  private ref ScriptInvoker Event_OnResetAttributes = new ScriptInvoker();
74  private ref ScriptInvoker Event_OnAttributeChangesApplied = new ScriptInvoker();
75  private ref ScriptInvoker Event_OnAttributeDescriptionChanged = new ScriptInvoker();
76  private ref ScriptInvoker Event_OnAttributeCategoryChanged = new ScriptInvoker();
77 
78  protected bool m_bHasChangedAttributesOnce = false;
79  //protected bool m_CanOpenAttributes;
80 
81  //protected ref map<EEditorMode, int> m_mSavedGlobalAttributeTabs = new map<EEditorMode, int>;
82  protected ResourceName m_CurrentCategory;
83 
85  //--- StartEditing
87 
88  //------------------------------------------------------------------------------------------------
93  void StartEditing(Managed item)
94  {
95  if (!item || item.IsInherited(array) || item.IsInherited(set) || item.IsInherited(map)) //--- Lists themselves are Managed
96  {
97  if (!item)
98  {
99  array<Managed> items = {};
100  StartEditing(items);
101  Print("Opening attributes with NULL entity!", LogLevel.WARNING);
102  return;
103  }
104 
105  if (item)
106  Print(string.Format("Cannot edit attributes of %1, must be explicitly array<Managed> (even when the array element itself inherits from Managed)!", item.Type()), LogLevel.ERROR);
107  return;
108  }
109 
110  array<Managed> items = {item};
111  StartEditing(items);
112  }
113 
114  //------------------------------------------------------------------------------------------------
123  void StartEditing(notnull array<Managed> items, bool onlyServer = true)
124  {
125  //--- Not an owner, ignore
126  if (!m_PrefabData || !IsOwner())
127  return;
128 
129  //--- Already editing, ignore
130  if (m_aEditedItems)
131  return;
132 
133  if (m_StatesManager)
134  m_StatesManager.SetIsWaiting(true);
135 
136  Event_OnAttributesRequest.Invoke(items);
137 
138  if (onlyServer && m_bHasServerAttributes)
139  {
140  //--- Editing server attributes, ask for values
141  array<int> itemIds = {};
142  m_aEditedItems = {};
143  foreach (Managed item: items)
144  {
145  int id = Replication.FindId(item);
146  if (id != -1 && m_aEditedItems.Find(item) == -1)
147  {
148  m_aEditedItems.Insert(item);
149  itemIds.Insert(id);
150  }
151  }
152  //StartEditingServer(itemIds);
153  Rpc(StartEditingServer, itemIds);
154  }
155  else
156  {
157  //--- Editing only local attributes, skip server communication
158  m_aEditedItems = {};
159  foreach (Managed item: items)
160  {
161  if (m_aEditedItems.Find(item) == -1)
162  m_aEditedItems.Insert(item);
163  }
164 
165  StartEditingOwner({}, {}, {});
166  }
167  }
168 
169  //------------------------------------------------------------------------------------------------
170  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
171  protected void StartEditingServer(array<int> itemIds)
172  {
173  m_aEditedItems = {};
174  foreach (int id: itemIds)
175  {
176  Managed item = Replication.FindItem(id);
177  if (item)
178  m_aEditedItems.Insert(item);
179  }
180 
181  //--- Get attribute values from server
182  array<int> attributesIds = {};
183  array<ref SCR_BaseEditorAttributeVar> attributesVars = {};
184  array<ref EEditorAttributeMultiSelect> attributesMultiSelect = {};
185  GetVariables(true, m_aEditedItems, attributesIds, attributesVars, attributesMultiSelect);
186 
187  //--- Remember edited attributes
188  m_aEditedAttributes = {};
189  foreach (int i, int attributeId: attributesIds)
190  {
191  SCR_BaseEditorAttribute attribute = m_PrefabData.GetAttribute(attributeId);
192 
193  if (!attribute.BoolAllowDuplicate() && GetIsAttributeDuplicate(attribute.Type()))
194  {
195  Print(string.Format("Trying to add editor attribute of type '%1' but there is already an attribute of the same type", attribute.Type()), LogLevel.ERROR);
196  continue;
197  }
198 
199  m_aEditedAttributes.Insert(attribute);
200  }
201 
202  //Print("Sending attributes:");
203  //attributesVars.Debug();
204 
205  //StartEditingOwner(attributesIds, attributesVars);
206  int simulatedDelay = DiagMenu.GetValue(SCR_DebugMenuID.DEBUGUI_EDITOR_NETWORK_DELAY) * 100;
207  if (simulatedDelay > 0 && !Replication.IsRunning())
208  GetGame().GetCallqueue().CallLater(StartEditingOwner, simulatedDelay, false, attributesIds, attributesVars, attributesMultiSelect);
209  else
210  Rpc(StartEditingOwner, attributesIds, attributesVars, attributesMultiSelect);
211  }
212 
213  //------------------------------------------------------------------------------------------------
214  [RplRpc(RplChannel.Reliable, RplRcver.Owner)]
215  protected void StartEditingOwner(notnull array<int> attributesIds, notnull array<ref SCR_BaseEditorAttributeVar> attributesVars, notnull array<ref EEditorAttributeMultiSelect> attributesMultiSelect)
216  {
217  //--- Current menu changed while waiting, ignore
218  if (m_StatesManager && !m_StatesManager.SetIsWaiting(false))
219  {
220  Clean();
221  return;
222  }
223 
224  //Print("Receiving attributes:");
225  //attributesVars.Debug();
226 
227  //--- Get attribute values from client (add them to those received from the server)
228  GetVariables(false, m_aEditedItems, attributesIds, attributesVars, attributesMultiSelect);
229 
230  //--- Process all edited attributes
231  m_aEditedAttributes = {};
232  foreach (int i, int attributeId: attributesIds)
233  {
234  //-- Register to an array that is sent to the invoker
235  SCR_BaseEditorAttribute attribute = m_PrefabData.GetAttribute(attributeId);
236  SCR_BaseEditorAttributeVar var = attributesVars[i];
237  EEditorAttributeMultiSelect attributeMultiSelect = attributesMultiSelect[i];
238 
239  if (!attribute.BoolAllowDuplicate() && GetIsAttributeDuplicate(attribute.Type()))
240  {
241  Print(string.Format("Trying to add editor attribute of type '%1' but there is already an attribute of the same type", attribute.Type()), LogLevel.ERROR);
242  continue;
243  }
244 
245  attribute.SetIsMultiSelect(attributeMultiSelect & EEditorAttributeMultiSelect.MULTI_SELECT);
246  attribute.SetHasConflictingValues(attributeMultiSelect & EEditorAttributeMultiSelect.COLLIDING_ATTRIBUTE);
247 
248  m_aEditedAttributes.Insert(attribute);
249 
250  //--- Create snapshot for later comparison
251  SSnapshot snapshot = null;
252  if (var)
253  {
254  snapshot = new SSnapshot(SNAPSHOT_SIZE);
255  SSnapSerializer snapWriter = SSnapSerializer.MakeWriter(snapshot);
256  SCR_BaseEditorAttributeVar.Extract(var, null, snapWriter);
257  }
258  attribute.StartEditing(var, snapshot);
259  }
260 
261  //--- Open menu
262  GetGame().GetMenuManager().OpenDialog(m_MenuPreset);
263 
264  //--- Invoke an event for other systems
266 
267  foreach (SCR_BaseEditorAttribute attribute: m_aEditedAttributes)
268  {
269  attribute.UpdateInterlinkedVariables(attribute.GetVariable(), this, true);
270  }
271  }
272 
273  //------------------------------------------------------------------------------------------------
274  // Checks if the given attribute is a dupplicant
275  protected bool GetIsAttributeDuplicate(typename type)
276  {
277  //Ignore Attributes that can be duplicated
278  if (type.IsInherited(SCR_BaseDuplicatableEditorAttribute))
279  return false;
280 
281  foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
282  {
283  if (attributeEntry.Type() == type)
284  return true;
285  }
286 
287  return false;
288  }
289 
291  //--- ConfirmEditing
293 
294  //------------------------------------------------------------------------------------------------
298  {
299  //--- Not an owner, ignore
300  if (!IsOwner())
301  return;
302 
303  //--- Not editing, ignore
304  if (!m_aEditedItems)
305  return;
306 
308  int PlayerID = -1;
309 
310  if (playerController)
311  PlayerID = playerController.GetPlayerId();
312 
313  bool attributeChangesApplied = false;
314 
315  //--- Apply changed values
316  array<int> attributesIds = {};
317  array<ref SCR_BaseEditorAttributeVar> attributesVars = {};
318  foreach (SCR_BaseEditorAttribute attribute: m_aEditedAttributes)
319  {
320  SCR_BaseEditorAttributeVar var = attribute.GetVariable();
321  SSnapshot snapshot = attribute.GetSnapshot();
322 
323  //--- Non-shared value wasn't set, skip
324  if (!var)
325  continue;
326 
327  //~ Attribute is not enabled so skip
328  if (!attribute.IsEnabled())
329  continue;
330 
331  //~ If attribute edits multiple entities and the value on the entities differ from eachother and that value is being changed overridden (even if it might be the same as some entities) then consider the value changed
332  //~ Else check if attribute was changed using snapshot
333  if (!attribute.GetIsMultiSelect() || !attribute.GetHasConflictingValues() || !attribute.GetIsOverridingValues())
334  {
335  //--- Value didn't change compared to snapshot, skip
336  if (snapshot)
337  {
338  SSnapSerializer snapReader = SSnapSerializer.MakeReader(snapshot);
339  if (SCR_BaseEditorAttributeVar.PropCompare(var, snapReader, null))
340  continue;
341  }
342  }
343 
344  if (attribute.IsServer())
345  {
346  //--- Add to the list to be sent to server
347  attributesIds.Insert(m_PrefabData.FindAttribute(attribute));
348  attributesVars.Insert(var);
349  }
350  else
351  {
352  //--- Apply locally
353  foreach (Managed item: m_aEditedItems)
354  {
355  if (attribute.ReadVariable(item, this))
356  attribute.WriteVariable(item, var, this, PlayerID);
357  }
358  }
359 
360  attributeChangesApplied = true;
361  }
362 
363  //--- Send to server
364  if (!attributesIds.IsEmpty())
365  {
366  //ConfirmEditingServer(attributesIds, attributesVars);
367  Rpc(ConfirmEditingServer, attributesIds, attributesVars, PlayerID);
368  }
369 
371  Clean();
372 
373  if (attributeChangesApplied)
374  {
376 
379  }
380  }
381 
382  //------------------------------------------------------------------------------------------------
383  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
384  protected void ConfirmEditingServer(notnull array<int> attributesIds, notnull array<ref SCR_BaseEditorAttributeVar> attributesVars, int PlayerID)
385  {
386  if (!m_PrefabData)
387  return;
388 
389  foreach (int i, int attributeId: attributesIds)
390  {
391  SCR_BaseEditorAttribute attribute = m_PrefabData.GetAttribute(attributeId);
392  SCR_BaseEditorAttributeVar var = attributesVars[i];
393  foreach (Managed item: m_aEditedItems)
394  {
395  if (attribute.ReadVariable(item, this))
396  {
397  attribute.WriteVariable(item, var, this, PlayerID);
398 
399  //--- Mark editable entities for serialization if their attributes were modified
400  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
401  if (editableEntity)
402  editableEntity.SetHierarchyAsDirtyInParents();
403  }
404  }
405  }
407  Clean();
408  }
409 
411  //--- Cancel
413 
414  //------------------------------------------------------------------------------------------------
418  {
419  //--- Not an owner, ignore (not used, would kill the process when the world is shutting down and the owner is already null)
420  //if (!IsOwner()) return;
421 
422  //--- Not editing, ignore
423  if (!m_aEditedItems)
424  return;
425 
426  //--- Restore original values
427  Reset(false);
428 
429  if (!IsRemoved())
430  Rpc(CancelEditingServer); //--- Send Rpc only when the entity is not being deleted, e.g., when closing the game
431 
433  Clean();
434  }
435 
436  //------------------------------------------------------------------------------------------------
437  [RplRpc(RplChannel.Reliable, RplRcver.Server)]
438  protected void CancelEditingServer()
439  {
441  Clean();
442  }
443 
445  //--- Reset
447 
448  //------------------------------------------------------------------------------------------------
452  void Reset(bool telegraphChange)
453  {
454  //--- Not editing, ignore
455  if (!m_aEditedItems)
456  return;
457 
458  //--- Restore original values
459  foreach (SCR_BaseEditorAttribute attribute: m_aEditedAttributes)
460  {
461  SCR_BaseEditorAttributeVar var = attribute.GetVariable();
462  SSnapshot snapshot = attribute.GetSnapshot();
463 
464  if (var && snapshot)
465  {
466  SSnapSerializer snapReader = SSnapSerializer.MakeReader(snapshot);
467  if (!SCR_BaseEditorAttributeVar.PropCompare(var, snapReader, null))
468  {
469  //--- Create new reader with index back at 0
470  snapReader = SSnapSerializer.MakeReader(snapshot);
471  SCR_BaseEditorAttributeVar.Inject(snapReader, null, var);
472 
473  //--- Update GUI
474  if (telegraphChange)
475  attribute.TelegraphChange(true);
476 
477  foreach (Managed item: m_aEditedItems)
478  {
479  if (attribute.ReadVariable(item, this))
480  {
481  attribute.PreviewVariable(false, this);
482  attribute.UpdateInterlinkedVariables(var, this);
483  }
484 
485  }
486  }
487  //Still reset if value is conflicting or if is override var and value did not change
488  else if (attribute.GetHasConflictingValues())
489  {
490  if (telegraphChange)
491  attribute.TelegraphChange(true);
492  }
493  }
494  //If conflicting attribute then it will still set UI as default value and update copyVar
495  else if (!var)
496  {
497  if (telegraphChange)
498  attribute.TelegraphChange(true);
499  }
500  }
501 
502  Event_OnResetAttributes.Invoke();
503  }
504 
506  //--- Support Funcions
508 
509  //------------------------------------------------------------------------------------------------
510  protected void Clean()
511  {
513  {
514  foreach (SCR_BaseEditorAttribute attribute: m_aEditedAttributes)
515  {
516  attribute.StopEditing();
517  }
518  }
519 
520  m_aEditedItems = null;
521  m_aEditedAttributes = null;
522  }
523 
524  //------------------------------------------------------------------------------------------------
525  protected int GetVariables(bool onlyServer, notnull array<Managed> items, notnull out array<int> outIds, notnull out array<ref SCR_BaseEditorAttributeVar> outVars, notnull out array<ref EEditorAttributeMultiSelect> outAttributesMultiSelect)
526  {
527  SCR_BaseEditorAttribute attribute;
528  for (int i = 0, count = m_PrefabData.GetAttributesCount(); i < count; i++)
529  {
530  attribute = m_PrefabData.GetAttribute(i);
531  if (!attribute)
532  continue;
533 
534  if (attribute.IsServer() != onlyServer)
535  continue;
536 
537  SCR_BaseEditorAttributeVar var = null;
538  bool isCompatible = false;
539 
540  SSnapshot snapshot = new SSnapshot(SNAPSHOT_SIZE);
541  SSnapSerializer snapWriter;
542  SSnapSerializer snapReader;
543 
544  EEditorAttributeMultiSelect multiSelectState;
545 
546  foreach (Managed item: items)
547  {
548  if (!item)
549  continue;
550 
551  SCR_BaseEditorAttributeVar checkVar = attribute.ReadVariable(item, this);
552  if (!checkVar)
553  continue;
554 
555  var = checkVar;
556  isCompatible = true;
557 
558  if (!snapReader)
559  {
560  //--- First item, write snapshot for comparison
561  snapWriter = SSnapSerializer.MakeWriter(snapshot);
562  snapReader = SSnapSerializer.MakeReader(snapshot);
563  SCR_BaseEditorAttributeVar.Extract(var, null, snapWriter);
564  }
565  else
566  {
567  //Set is multi select
568  multiSelectState |= EEditorAttributeMultiSelect.MULTI_SELECT;
569 
570  //--- Reset the reader so the comparison starts from the beginning
571  snapReader.Seek(0);
572 
573  if (!SCR_BaseEditorAttributeVar.PropCompare(var, snapReader, null))
574  {
575  //--- When item don't share the same variable, don't check other items
576  multiSelectState |= EEditorAttributeMultiSelect.COLLIDING_ATTRIBUTE;
577  break;
578  }
579  }
580  }
581 
582  //--- Use the attribute when at least one item has it
583  if (isCompatible)
584  {
585  outIds.Insert(i);
586  outVars.Insert(var);
587  outAttributesMultiSelect.Insert(multiSelectState);
588  }
589  multiSelectState = 0;
590  }
591  return outVars.Count();
592  }
593 
594  //~Todo: Make sure server and non-server actions are correctly checked. Currently if only has attributes that can only be checked on server the attributes cannot be opened!
595  //------------------------------------------------------------------------------------------------
599  bool CanOpenAttributeDialog(notnull array<Managed> items)
600  {
601  SCR_BaseEditorAttribute attribute;
602  for (int i = 0, count = m_PrefabData.GetAttributesCount(); i < count; i++)
603  {
604  attribute = m_PrefabData.GetAttribute(i);
605  if (!attribute)
606  continue;
607  //if (attribute.IsServer() != onlyServer)
608  // continue;
609 
610  foreach (Managed item: items)
611  {
612  if (!item)
613  continue;
614 
615  SCR_BaseEditorAttributeVar var = attribute.ReadVariable(item, this);
616  if (!var)
617  continue;
618 
619  //As attribute so show context action
620  return true;
621  }
622  }
623 
624  return false;
625 
626  }
627 
628  //------------------------------------------------------------------------------------------------
635  {
636  SCR_BaseEditorAttribute attribute;
637 
638  foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
639  {
640  if (attributeEntry.Type() == type)
641  {
642  attribute = attributeEntry;
643  break;
644  }
645  }
646 
647  if (attribute)
648  {
649  return attribute.SetVariable(var);
650  }
651  else
652  {
653  Debug.Error2(type.ToString(), "Attribute type not found to set variable!");
654  return false;
655  }
656  }
657 
658  //------------------------------------------------------------------------------------------------
664  {
665  if (!m_aEditedAttributes || m_aEditedAttributes.IsEmpty())
666  return false;
667 
668  foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
669  {
670  if (attributeEntry.Type() == type)
671  {
672  var = attributeEntry.GetVariableOrCopy();
673  if (var == null)
674  Print("SCR_AttributesManagerEditorComponent could not find the attribute var which will cause certain attributes to break", LogLevel.ERROR);
675 
676  return var != null;
677  }
678  }
679 
680  return false;
681  }
682 
683  //------------------------------------------------------------------------------------------------
690  int GetActiveAttributesOfType(typename type, notnull out array<SCR_BaseEditorAttribute> attributes, bool includedInherit = true, SCR_BaseEditorAttribute ignoreAttribute = null)
691  {
692  attributes.Clear();
693 
694  if (!m_aEditedAttributes || m_aEditedAttributes.IsEmpty())
695  return 0;
696 
697  foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
698  {
699  if (((includedInherit && attributeEntry.Type().IsInherited(type)) || (!includedInherit && attributeEntry.Type() == type)) && attributeEntry != ignoreAttribute)
700  attributes.Insert(attributeEntry);
701  }
702 
703  return attributes.Count();
704  }
705 
706  //------------------------------------------------------------------------------------------------
711  bool GetActiveAttribute(typename type, out SCR_BaseEditorAttribute attribute)
712  {
713  if (!m_aEditedAttributes || m_aEditedAttributes.IsEmpty())
714  return false;
715 
716  foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
717  {
718  if (attributeEntry.Type() == type)
719  {
720  attribute = attributeEntry;
721 
722  //Attribute can only be obtained from non server attributes as changes are local
723  return !attributeEntry.IsServer();
724  }
725  }
726 
727  return false;
728  }
729 
730  //------------------------------------------------------------------------------------------------
735  bool SetAttributeEnabled(typename type, bool enabled)
736  {
737  SCR_BaseEditorAttribute attribute;
738 
739  foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
740  {
741  if (attributeEntry.Type() == type)
742  {
743  attribute = attributeEntry;
744  break;
745  }
746  }
747 
748  if (attribute)
749  {
750  attribute.Enable(enabled);
751  return true;
752  }
753  else
754  {
755  //--- Don't show error, missing link may be legit when one attribute is used in different situations
756  //Debug.Error2(type.ToString(), "Attribute type not found to set attribute enabled!");
757  return false;
758  }
759  }
760 
761  //------------------------------------------------------------------------------------------------
768  bool SetAttributeSelected(typename type, bool selected, int index = -1)
769  {
770  SCR_BaseEditorAttribute attribute;
771 
772  foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
773  {
774  if (attributeEntry.Type() == type)
775  {
776  attribute = attributeEntry;
777  break;
778  }
779  }
780 
781  if (attribute)
782  {
783  attribute.ToggleSelected(selected, index);
784  return true;
785  }
786  else
787  {
788  Debug.Error2(type.ToString(), "Attribute type not found to set attriabute selected!");
789  return false;
790  }
791  }
792 
793  //------------------------------------------------------------------------------------------------
798  {
799  SCR_BaseEditorAttribute attribute;
800 
801  foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
802  {
803  if (attributeEntry.Type() == type)
804  {
805  attribute = attributeEntry;
806  break;
807  }
808  }
809 
810  if (attribute)
811  {
812  attribute.SetAsSubAttribute();
813  return true;
814  }
815  else
816  {
817  return false;
818  }
819  }
820 
821  //------------------------------------------------------------------------------------------------
825  {
826  foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
827  {
828  if (attributeEntry.Type() == type)
829  return attributeEntry;
830  }
831 
832  return null;
833  }
834 
835  //------------------------------------------------------------------------------------------------
839  int GetEditedAttributes(out notnull array<SCR_BaseEditorAttribute> outAttributes)
840  {
841  return outAttributes.Copy(m_aEditedAttributes);
842  }
843 
844  //------------------------------------------------------------------------------------------------
848  int GetEditedItems(out notnull array<Managed> outitems)
849  {
850  return outitems.Copy(m_aEditedItems);
851  }
852 
853  //------------------------------------------------------------------------------------------------
857  ScriptInvoker GetOnAttributesRequest()
858  {
860  }
861 
862  //------------------------------------------------------------------------------------------------
866  ScriptInvoker GetOnAttributesStart()
867  {
869  }
870 
871  //------------------------------------------------------------------------------------------------
875  ScriptInvoker GetOnAttributesConfirm()
876  {
878  }
879  //------------------------------------------------------------------------------------------------
883  ScriptInvoker GetOnAttributesCancel()
884  {
886  }
887 
888  //------------------------------------------------------------------------------------------------
891  ScriptInvoker GetOnResetAttributes()
892  {
894  }
895 
896  //------------------------------------------------------------------------------------------------
900  {
902  }
903 
904  //------------------------------------------------------------------------------------------------
908  {
910  }
911 
912  //------------------------------------------------------------------------------------------------
916  {
918  }
919 
920  //------------------------------------------------------------------------------------------------
924  {
926  }
927 
928  //------------------------------------------------------------------------------------------------
931  void SetCurrentCategory(ResourceName category)
932  {
935  }
936  //------------------------------------------------------------------------------------------------
938  ResourceName GetCurrentCategory()
939  {
940  return m_CurrentCategory;
941  }
942 
943  //------------------------------------------------------------------------------------------------
947  {
949  }
950 
951  //------------------------------------------------------------------------------------------------
958  void SetAttributeDescription(SCR_EditorAttributeUIInfo uiInfo, string customDescription = string.Empty, string param1 = string.Empty, string param2 = string.Empty, string param3 = string.Empty)
959  {
960  Event_OnAttributeDescriptionChanged.Invoke(uiInfo, customDescription, param1, param2, param3);
961  }
962 
964  //--- Default Functions
966 
967  //------------------------------------------------------------------------------------------------
968  override void EOnEditorActivate()
969  {
971  }
972 
973  //------------------------------------------------------------------------------------------------
974  override void EOnEditorDeactivate()
975  {
976  CancelEditing();
977  }
978 
979  //------------------------------------------------------------------------------------------------
980  override void EOnEditorInit()
981  {
982  m_PrefabData = SCR_AttributesManagerEditorComponentClass.Cast(GetEditorComponentData());
983 
984  //--- Check if any server attributes are defined
985  m_bHasServerAttributes = false;
986  for (int i = 0, count = m_PrefabData.GetAttributesCount(); i < count; i++)
987  {
988  if (m_PrefabData.GetAttribute(i).IsServer())
989  {
990  m_bHasServerAttributes = true;
991  break;
992  }
993  }
994  }
995 
996  //------------------------------------------------------------------------------------------------
997  override void EOnEditorInitServer()
998  {
999  m_PrefabData = SCR_AttributesManagerEditorComponentClass.Cast(GetEditorComponentData());
1000  }
1001 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
SCR_BaseDuplicatableEditorAttribute
Definition: SCR_BaseDuplicatableEditorAttribute.c:5
EEditorAttributeMultiSelect
EEditorAttributeMultiSelect
Keeps track if attribute is multiselect and colliding attributes.
Definition: EEditorAttributeMultiSelect.c:3
IsOwner
protected bool IsOwner()
Definition: SCR_SpawnRequestComponent.c:86
EOnEditorInitServer
override void EOnEditorInitServer()
Definition: SCR_AttributesManagerEditorComponent.c:997
GetOnResetAttributes
ScriptInvoker GetOnResetAttributes()
Definition: SCR_AttributesManagerEditorComponent.c:891
SCR_PlayerController
Definition: SCR_PlayerController.c:31
GetAttributeRef
SCR_BaseEditorAttribute GetAttributeRef(typename type)
Definition: SCR_AttributesManagerEditorComponent.c:824
SetAttributeDescription
void SetAttributeDescription(SCR_EditorAttributeUIInfo uiInfo, string customDescription=string.Empty, string param1=string.Empty, string param2=string.Empty, string param3=string.Empty)
Definition: SCR_AttributesManagerEditorComponent.c:958
Event_OnAttributeChangesApplied
private ref ScriptInvoker Event_OnAttributeChangesApplied
Definition: SCR_AttributesManagerEditorComponent.c:74
GetOnAttributesRequest
ScriptInvoker GetOnAttributesRequest()
Definition: SCR_AttributesManagerEditorComponent.c:857
m_StatesManager
private SCR_StatesEditorComponent m_StatesManager
Definition: SCR_AttributesManagerEditorComponent.c:65
SetCurrentCategory
void SetCurrentCategory(ResourceName category)
Definition: SCR_AttributesManagerEditorComponent.c:931
m_PrefabData
private SCR_AttributesManagerEditorComponentClass m_PrefabData
Definition: SCR_AttributesManagerEditorComponent.c:64
GetEditedAttributes
int GetEditedAttributes(out notnull array< SCR_BaseEditorAttribute > outAttributes)
Definition: SCR_AttributesManagerEditorComponent.c:839
m_CurrentCategory
protected ResourceName m_CurrentCategory
Definition: SCR_AttributesManagerEditorComponent.c:82
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GetActiveAttributesOfType
int GetActiveAttributesOfType(typename type, notnull out array< SCR_BaseEditorAttribute > attributes, bool includedInherit=true, SCR_BaseEditorAttribute ignoreAttribute=null)
Definition: SCR_AttributesManagerEditorComponent.c:690
GetEditedItems
int GetEditedItems(out notnull array< Managed > outitems)
Definition: SCR_AttributesManagerEditorComponent.c:848
GetOnAttributesCancel
ScriptInvoker GetOnAttributesCancel()
Definition: SCR_AttributesManagerEditorComponent.c:883
EOnEditorDeactivate
override void EOnEditorDeactivate()
Definition: SCR_AttributesManagerEditorComponent.c:974
m_aEditedAttributes
private ref array< SCR_BaseEditorAttribute > m_aEditedAttributes
Definition: SCR_AttributesManagerEditorComponent.c:68
Clean
protected void Clean()
Definition: SCR_AttributesManagerEditorComponent.c:510
SNAPSHOT_SIZE
SCR_AttributesManagerEditorComponentClass SNAPSHOT_SIZE
GetActiveAttribute
bool GetActiveAttribute(typename type, out SCR_BaseEditorAttribute attribute)
Definition: SCR_AttributesManagerEditorComponent.c:711
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
GetOnAttributesConfirm
ScriptInvoker GetOnAttributesConfirm()
Definition: SCR_AttributesManagerEditorComponent.c:875
Event_OnResetAttributes
private ref ScriptInvoker Event_OnResetAttributes
Definition: SCR_AttributesManagerEditorComponent.c:73
m_ConflictingAttributeUIInfo
protected ref SCR_EditorAttributeUIInfo m_ConflictingAttributeUIInfo
Definition: SCR_AttributesManagerEditorComponent.c:62
SCR_EditorAttributeUIInfo
UIInfo used by editor attribute system.
Definition: SCR_EditorAttributeUIInfo.c:3
Event_OnAttributeDescriptionChanged
private ref ScriptInvoker Event_OnAttributeDescriptionChanged
Definition: SCR_AttributesManagerEditorComponent.c:75
SetAttributeSelected
bool SetAttributeSelected(typename type, bool selected, int index=-1)
Definition: SCR_AttributesManagerEditorComponent.c:768
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
m_aEditedItems
private ref array< Managed > m_aEditedItems
Definition: SCR_AttributesManagerEditorComponent.c:67
CanOpenAttributeDialog
bool CanOpenAttributeDialog(notnull array< Managed > items)
Definition: SCR_AttributesManagerEditorComponent.c:599
Event_OnAttributesRequest
private ref ScriptInvoker Event_OnAttributesRequest
Definition: SCR_AttributesManagerEditorComponent.c:69
SCR_BaseEditorComponent
Definition: SCR_BaseEditorComponent.c:119
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
GetOnAttributeCategoryChanged
ScriptInvoker GetOnAttributeCategoryChanged()
Definition: SCR_AttributesManagerEditorComponent.c:915
Attribute
typedef Attribute
Post-process effect of scripted camera.
StartEditingOwner
protected void StartEditingOwner(notnull array< int > attributesIds, notnull array< ref SCR_BaseEditorAttributeVar > attributesVars, notnull array< ref EEditorAttributeMultiSelect > attributesMultiSelect)
Definition: SCR_AttributesManagerEditorComponent.c:215
GetVariables
protected int GetVariables(bool onlyServer, notnull array< Managed > items, notnull out array< int > outIds, notnull out array< ref SCR_BaseEditorAttributeVar > outVars, notnull out array< ref EEditorAttributeMultiSelect > outAttributesMultiSelect)
Definition: SCR_AttributesManagerEditorComponent.c:525
ConfirmEditing
void ConfirmEditing()
Definition: SCR_AttributesManagerEditorComponent.c:297
GetOnAttributesStart
ScriptInvoker GetOnAttributesStart()
Definition: SCR_AttributesManagerEditorComponent.c:866
EOnEditorInit
override void EOnEditorInit()
Definition: SCR_AttributesManagerEditorComponent.c:980
GetConflictingAttributeUIInfo
SCR_EditorAttributeUIInfo GetConflictingAttributeUIInfo()
Definition: SCR_AttributesManagerEditorComponent.c:923
CancelEditingServer
protected void CancelEditingServer()
Definition: SCR_AttributesManagerEditorComponent.c:438
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_EditorAttributeList
Definition: SCR_EditorAttributeConfig.c:2
GetOnAttributeDescriptionChanged
ScriptInvoker GetOnAttributeDescriptionChanged()
Definition: SCR_AttributesManagerEditorComponent.c:907
Event_OnAttributesConfirm
private ref ScriptInvoker Event_OnAttributesConfirm
Definition: SCR_AttributesManagerEditorComponent.c:71
StartEditing
void StartEditing(Managed item)
Definition: SCR_AttributesManagerEditorComponent.c:93
Event_OnAttributesStart
private ref ScriptInvoker Event_OnAttributesStart
Definition: SCR_AttributesManagerEditorComponent.c:70
SetAttributeVariable
bool SetAttributeVariable(typename type, SCR_BaseEditorAttributeVar var)
Definition: SCR_AttributesManagerEditorComponent.c:634
GetChangedAttributesOnce
bool GetChangedAttributesOnce()
Definition: SCR_AttributesManagerEditorComponent.c:946
SCR_BaseEditorComponentClass
Definition: SCR_BaseEditorComponent.c:2
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
Reset
void Reset(bool telegraphChange)
Definition: SCR_AttributesManagerEditorComponent.c:452
SetAttributeEnabled
bool SetAttributeEnabled(typename type, bool enabled)
Definition: SCR_AttributesManagerEditorComponent.c:735
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_AttributesManagerEditorComponentClass
Definition: SCR_AttributesManagerEditorComponent.c:2
ChimeraMenuPreset
ChimeraMenuPreset
Menu presets.
Definition: ChimeraMenuBase.c:3
CancelEditing
void CancelEditing()
Definition: SCR_AttributesManagerEditorComponent.c:417
SetAttributeAsSubAttribute
bool SetAttributeAsSubAttribute(typename type)
Definition: SCR_AttributesManagerEditorComponent.c:797
Event_OnAttributesCancel
private ref ScriptInvoker Event_OnAttributesCancel
Definition: SCR_AttributesManagerEditorComponent.c:72
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
GetIsAttributeDuplicate
protected bool GetIsAttributeDuplicate(typename type)
Definition: SCR_AttributesManagerEditorComponent.c:275
GetAttributeVariable
bool GetAttributeVariable(typename type, out SCR_BaseEditorAttributeVar var)
Definition: SCR_AttributesManagerEditorComponent.c:663
m_bHasChangedAttributesOnce
protected bool m_bHasChangedAttributesOnce
Definition: SCR_AttributesManagerEditorComponent.c:78
GetOnAttributeChangesApplied
ScriptInvoker GetOnAttributeChangesApplied()
Definition: SCR_AttributesManagerEditorComponent.c:899
SCR_StatesEditorComponent
Definition: SCR_StatesEditorComponent.c:9
m_MenuPreset
private ChimeraMenuPreset m_MenuPreset
Definition: SCR_AttributesManagerEditorComponent.c:59
SCR_DebugMenuID
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition: DebugMenuID.c:3
GetCurrentCategory
ResourceName GetCurrentCategory()
Definition: SCR_AttributesManagerEditorComponent.c:938
m_bHasServerAttributes
private bool m_bHasServerAttributes
Definition: SCR_AttributesManagerEditorComponent.c:66
StartEditingServer
protected void StartEditingServer(array< int > itemIds)
Definition: SCR_AttributesManagerEditorComponent.c:171
Event_OnAttributeCategoryChanged
private ref ScriptInvoker Event_OnAttributeCategoryChanged
Definition: SCR_AttributesManagerEditorComponent.c:76
EOnEditorActivate
override void EOnEditorActivate()
Definition: SCR_AttributesManagerEditorComponent.c:968
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
ConfirmEditingServer
protected void ConfirmEditingServer(notnull array< int > attributesIds, notnull array< ref SCR_BaseEditorAttributeVar > attributesVars, int PlayerID)
Definition: SCR_AttributesManagerEditorComponent.c:384