Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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 //------------------------------------------------------------------------------------------------
16
17 //------------------------------------------------------------------------------------------------
20 {
21 return m_aAttributes.Count();
22 }
23
24 //------------------------------------------------------------------------------------------------
29 {
30 return m_aAttributes.Find(attribute);
31 }
32
33 //------------------------------------------------------------------------------------------------
34 // constructor
37 {
39 {
40 list.InsertAllAttributes(m_aAttributes);
41 }
42 }
43}
44
46
54class 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))]
59 private ChimeraMenuPreset m_MenuPreset;
60
61 [Attribute(desc: "Displayed description and icon when hovering over an locked attribute. All attributes need access to this.", category: "Attributes")]
63
65 private SCR_StatesEditorComponent m_StatesManager;
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>;
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.FindItemId(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
265 Event_OnAttributesStart.Invoke(m_aEditedAttributes);
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
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
370 Event_OnAttributesConfirm.Invoke(m_aEditedAttributes);
371 Clean();
372
373 if (attributeChangesApplied)
374 {
375 Event_OnAttributeChangesApplied.Invoke();
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
401 if (editableEntity)
402 editableEntity.SetHierarchyAsDirtyInParents();
403 }
404 }
405 }
406 Event_OnAttributesConfirm.Invoke(m_aEditedAttributes);
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
432 Event_OnAttributesCancel.Invoke(m_aEditedAttributes);
433 Clean();
434 }
435
436 //------------------------------------------------------------------------------------------------
437 [RplRpc(RplChannel.Reliable, RplRcver.Server)]
438 protected void CancelEditingServer()
439 {
440 Event_OnAttributesCancel.Invoke(m_aEditedAttributes);
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 {
512 if (m_aEditedAttributes)
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
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 if (!m_aEditedAttributes || m_aEditedAttributes.IsEmpty())
738 return false;
739
740 SCR_BaseEditorAttribute attribute;
741
742 foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
743 {
744 if (attributeEntry.Type() == type)
745 {
746 attribute = attributeEntry;
747 break;
748 }
749 }
750
751 if (attribute)
752 {
753 attribute.Enable(enabled);
754 return true;
755 }
756 else
757 {
758 //--- Don't show error, missing link may be legit when one attribute is used in different situations
759 //Debug.Error2(type.ToString(), "Attribute type not found to set attribute enabled!");
760 return false;
761 }
762 }
763
764 //------------------------------------------------------------------------------------------------
771 bool SetAttributeSelected(typename type, bool selected, int index = -1)
772 {
773 SCR_BaseEditorAttribute attribute;
774
775 foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
776 {
777 if (attributeEntry.Type() == type)
778 {
779 attribute = attributeEntry;
780 break;
781 }
782 }
783
784 if (attribute)
785 {
786 attribute.ToggleSelected(selected, index);
787 return true;
788 }
789 else
790 {
791 Debug.Error2(type.ToString(), "Attribute type not found to set attriabute selected!");
792 return false;
793 }
794 }
795
796 //------------------------------------------------------------------------------------------------
801 {
802 SCR_BaseEditorAttribute attribute;
803
804 foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
805 {
806 if (attributeEntry.Type() == type)
807 {
808 attribute = attributeEntry;
809 break;
810 }
811 }
812
813 if (attribute)
814 {
815 attribute.SetAsSubAttribute();
816 return true;
817 }
818 else
819 {
820 return false;
821 }
822 }
823
824 //------------------------------------------------------------------------------------------------
828 {
829 foreach (SCR_BaseEditorAttribute attributeEntry: m_aEditedAttributes)
830 {
831 if (attributeEntry.Type() == type)
832 return attributeEntry;
833 }
834
835 return null;
836 }
837
838 //------------------------------------------------------------------------------------------------
842 int GetEditedAttributes(out notnull array<SCR_BaseEditorAttribute> outAttributes)
843 {
844 return outAttributes.Copy(m_aEditedAttributes);
845 }
846
847 //------------------------------------------------------------------------------------------------
851 int GetEditedItems(out notnull array<Managed> outitems)
852 {
853 return outitems.Copy(m_aEditedItems);
854 }
855
856 //------------------------------------------------------------------------------------------------
861 {
862 return Event_OnAttributesRequest;
863 }
864
865 //------------------------------------------------------------------------------------------------
870 {
871 return Event_OnAttributesStart;
872 }
873
874 //------------------------------------------------------------------------------------------------
879 {
880 return Event_OnAttributesConfirm;
881 }
882 //------------------------------------------------------------------------------------------------
887 {
888 return Event_OnAttributesCancel;
889 }
890
891 //------------------------------------------------------------------------------------------------
895 {
896 return Event_OnResetAttributes;
897 }
898
899 //------------------------------------------------------------------------------------------------
903 {
904 return Event_OnAttributeChangesApplied;
905 }
906
907 //------------------------------------------------------------------------------------------------
911 {
912 return Event_OnAttributeDescriptionChanged;
913 }
914
915 //------------------------------------------------------------------------------------------------
919 {
920 return Event_OnAttributeCategoryChanged;
921 }
922
923 //------------------------------------------------------------------------------------------------
930
931 //------------------------------------------------------------------------------------------------
935 {
937 Event_OnAttributeCategoryChanged.Invoke(m_CurrentCategory);
938 }
939 //------------------------------------------------------------------------------------------------
945
946 //------------------------------------------------------------------------------------------------
953
954 //------------------------------------------------------------------------------------------------
961 void SetAttributeDescription(SCR_EditorAttributeUIInfo uiInfo, string customDescription = string.Empty, string param1 = string.Empty, string param2 = string.Empty, string param3 = string.Empty)
962 {
963 Event_OnAttributeDescriptionChanged.Invoke(uiInfo, customDescription, param1, param2, param3);
964 }
965
967 //--- Default Functions
969
970 //------------------------------------------------------------------------------------------------
971 override void EOnEditorActivate()
972 {
974 }
975
976 //------------------------------------------------------------------------------------------------
977 override void EOnEditorDeactivate()
978 {
980 }
981
982 //------------------------------------------------------------------------------------------------
983 override void EOnEditorInit()
984 {
986
987 //--- Check if any server attributes are defined
988 m_bHasServerAttributes = false;
989 SCR_BaseEditorAttribute attribute;
990 for (int i = 0, count = m_PrefabData.GetAttributesCount(); i < count; i++)
991 {
992 attribute = m_PrefabData.GetAttribute(i);
993 attribute.Initialize();
994 if (attribute.IsServer())
995 {
996 m_bHasServerAttributes = true;
997 continue;
998 }
999 }
1000 }
1001
1002 //------------------------------------------------------------------------------------------------
1003 override void EOnEditorInitServer()
1004 {
1006 for (int i = 0, count = m_PrefabData.GetAttributesCount(); i < count; i++)
1007 {
1008 m_PrefabData.GetAttribute(i).Initialize();
1009 }
1010 }
1011
1012}
ChimeraMenuPreset
Menu presets.
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
EEditorAttributeMultiSelect
Keeps track if attribute is multiselect and colliding attributes.
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
int GetEditedItems(out notnull array< Managed > outitems)
ScriptInvoker GetOnAttributesCancel()
ScriptInvoker GetOnAttributesRequest()
bool SetAttributeSelected(typename type, bool selected, int index=-1)
void StartEditingOwner(notnull array< int > attributesIds, notnull array< ref SCR_BaseEditorAttributeVar > attributesVars, notnull array< ref EEditorAttributeMultiSelect > attributesMultiSelect)
ResourceName m_CurrentCategory
bool GetAttributeVariable(typename type, out SCR_BaseEditorAttributeVar var)
bool SetAttributeVariable(typename type, SCR_BaseEditorAttributeVar var)
SCR_EditorAttributeUIInfo GetConflictingAttributeUIInfo()
int GetEditedAttributes(out notnull array< SCR_BaseEditorAttribute > outAttributes)
void SetCurrentCategory(ResourceName category)
void ConfirmEditingServer(notnull array< int > attributesIds, notnull array< ref SCR_BaseEditorAttributeVar > attributesVars, int PlayerID)
bool GetActiveAttribute(typename type, out SCR_BaseEditorAttribute attribute)
void StartEditingServer(array< int > itemIds)
ScriptInvoker GetOnAttributeDescriptionChanged()
bool SetAttributeAsSubAttribute(typename type)
ScriptInvoker GetOnAttributeChangesApplied()
int GetActiveAttributesOfType(typename type, notnull out array< SCR_BaseEditorAttribute > attributes, bool includedInherit=true, SCR_BaseEditorAttribute ignoreAttribute=null)
ScriptInvoker GetOnAttributesConfirm()
SCR_BaseEditorAttribute GetAttributeRef(typename type)
bool SetAttributeEnabled(typename type, bool enabled)
ResourceName GetCurrentCategory()
ScriptInvoker GetOnResetAttributes()
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)
void StartEditing(Managed item)
bool GetIsAttributeDuplicate(typename type)
ref SCR_EditorAttributeUIInfo m_ConflictingAttributeUIInfo
void SetAttributeDescription(SCR_EditorAttributeUIInfo uiInfo, string customDescription=string.Empty, string param1=string.Empty, string param2=string.Empty, string param3=string.Empty)
bool CanOpenAttributeDialog(notnull array< Managed > items)
ScriptInvoker GetOnAttributeCategoryChanged()
ScriptInvoker GetOnAttributesStart()
EDamageType type
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_WristwatchComponentClass m_PrefabData
Definition Debug.c:13
Diagnostic and developer menu system.
Definition DiagMenu.c:18
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
Main replication API.
Definition Replication.c:14
void SCR_AttributesManagerEditorComponentClass(IEntityComponentSource componentSource, IEntitySource parentSource, IEntitySource prefabSource)
ref array< ref SCR_EditorAttributeList > m_AttributeLists
Base Attribute Script for other attributes to inherent from to get and set varriables in Editor Attri...
sealed void StartEditing(SCR_BaseEditorAttributeVar var, SSnapshot snapshot)
Initialise editing variables.
void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
void SetHasConflictingValues(bool hasConflictingValues)
sealed bool SetVariable(SCR_BaseEditorAttributeVar var)
SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
void Initialize()
Method for initialization of base editor attribute.
sealed void ToggleSelected(bool selected, int index)
sealed void Enable(bool enabled)
void SetIsMultiSelect(bool isMultiSelect)
static bool PropCompare(SCR_BaseEditorAttributeVar prop, SSnapSerializerBase snapshot, ScriptCtx hint)
static bool Inject(SSnapSerializerBase snapshot, ScriptCtx hint, SCR_BaseEditorAttributeVar prop)
static bool Extract(SCR_BaseEditorAttributeVar prop, ScriptCtx hint, SSnapSerializerBase snapshot)
void EOnEditorInit()
When the entity is created.
void EOnEditorInitServer()
When the entity is created (called on server).
EntityComponentPrefabData GetEditorComponentData()
UIInfo used by editor attribute system.
Snapshot serializer utility.
Definition EnNetwork.c:381
Definition Types.c:486
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
SCR_AttributesManagerEditorComponentClass SNAPSHOT_SIZE
proto external PlayerController GetPlayerController()
void Reset()
SSnapSerializerBase Managed SSnapshot(int sizeInBytes)
Binary data container used in conjuction with a serializer.
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
Definition EnNetwork.c:95
RplRcver
Definition RplRcver.c:59
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
Definition RplChannel.c:14
T3 param3
Definition tuple.c:93
T2 param2
Definition tuple.c:92
Tuple param1
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134