1[
ComponentEditorProps(
category:
"GameScripted/Editor", description:
"Attribute for managing attributes. Works only with SCR_EditorBaseEntity!", icon:
"WBData/ComponentEditorProps/componentEditor.png")]
61 [
Attribute(
desc:
"Displayed description and icon when hovering over an locked attribute. All attributes need access to this.",
category:
"Attributes")]
66 private bool m_bHasServerAttributes;
67 private ref array<Managed> m_aEditedItems;
68 private ref array<SCR_BaseEditorAttribute> m_aEditedAttributes;
95 if (!item || item.IsInherited(array) || item.IsInherited(set) || item.IsInherited(
map))
99 array<Managed> items = {};
101 Print(
"Opening attributes with NULL entity!",
LogLevel.WARNING);
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);
110 array<Managed> items = {item};
123 void StartEditing(notnull array<Managed> items,
bool onlyServer =
true)
134 m_StatesManager.SetIsWaiting(
true);
136 Event_OnAttributesRequest.Invoke(items);
138 if (onlyServer && m_bHasServerAttributes)
141 array<int> itemIds = {};
143 foreach (Managed item: items)
146 if (
id != -1 && m_aEditedItems.Find(item) == -1)
148 m_aEditedItems.Insert(item);
159 foreach (Managed item: items)
161 if (m_aEditedItems.Find(item) == -1)
162 m_aEditedItems.Insert(item);
174 foreach (
int id: itemIds)
178 m_aEditedItems.Insert(item);
182 array<int> attributesIds = {};
183 array<ref SCR_BaseEditorAttributeVar> attributesVars = {};
184 array<ref EEditorAttributeMultiSelect> attributesMultiSelect = {};
185 GetVariables(
true, m_aEditedItems, attributesIds, attributesVars, attributesMultiSelect);
188 m_aEditedAttributes = {};
189 foreach (
int i,
int attributeId: attributesIds)
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);
199 m_aEditedAttributes.Insert(attribute);
207 if (simulatedDelay > 0 && !
Replication.IsRunning())
208 GetGame().GetCallqueue().CallLater(
StartEditingOwner, simulatedDelay,
false, attributesIds, attributesVars, attributesMultiSelect);
215 protected void StartEditingOwner(notnull array<int> attributesIds, notnull array<ref SCR_BaseEditorAttributeVar> attributesVars, notnull array<ref EEditorAttributeMultiSelect> attributesMultiSelect)
218 if (m_StatesManager && !m_StatesManager.SetIsWaiting(
false))
228 GetVariables(
false, m_aEditedItems, attributesIds, attributesVars, attributesMultiSelect);
231 m_aEditedAttributes = {};
232 foreach (
int i,
int attributeId: attributesIds)
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);
248 m_aEditedAttributes.Insert(attribute);
262 GetGame().GetMenuManager().OpenDialog(m_MenuPreset);
265 Event_OnAttributesStart.Invoke(m_aEditedAttributes);
269 attribute.UpdateInterlinkedVariables(attribute.GetVariable(),
this,
true);
283 if (attributeEntry.Type() ==
type)
310 if (playerController)
311 PlayerID = playerController.GetPlayerId();
313 bool attributeChangesApplied =
false;
316 array<int> attributesIds = {};
317 array<ref SCR_BaseEditorAttributeVar> attributesVars = {};
321 SSnapshot snapshot = attribute.GetSnapshot();
328 if (!attribute.IsEnabled())
333 if (!attribute.GetIsMultiSelect() || !attribute.GetHasConflictingValues() || !attribute.GetIsOverridingValues())
344 if (attribute.IsServer())
347 attributesIds.Insert(
m_PrefabData.FindAttribute(attribute));
348 attributesVars.Insert(var);
353 foreach (Managed item: m_aEditedItems)
355 if (attribute.ReadVariable(item,
this))
356 attribute.WriteVariable(item, var,
this, PlayerID);
360 attributeChangesApplied =
true;
364 if (!attributesIds.IsEmpty())
370 Event_OnAttributesConfirm.Invoke(m_aEditedAttributes);
373 if (attributeChangesApplied)
375 Event_OnAttributeChangesApplied.Invoke();
384 protected void ConfirmEditingServer(notnull array<int> attributesIds, notnull array<ref SCR_BaseEditorAttributeVar> attributesVars,
int PlayerID)
389 foreach (
int i,
int attributeId: attributesIds)
393 foreach (Managed item: m_aEditedItems)
406 Event_OnAttributesConfirm.Invoke(m_aEditedAttributes);
432 Event_OnAttributesCancel.Invoke(m_aEditedAttributes);
440 Event_OnAttributesCancel.Invoke(m_aEditedAttributes);
462 SSnapshot snapshot = attribute.GetSnapshot();
475 attribute.TelegraphChange(
true);
477 foreach (Managed item: m_aEditedItems)
479 if (attribute.ReadVariable(item,
this))
481 attribute.PreviewVariable(
false,
this);
482 attribute.UpdateInterlinkedVariables(var,
this);
488 else if (attribute.GetHasConflictingValues())
491 attribute.TelegraphChange(
true);
498 attribute.TelegraphChange(
true);
502 Event_OnResetAttributes.Invoke();
512 if (m_aEditedAttributes)
516 attribute.StopEditing();
520 m_aEditedItems = null;
521 m_aEditedAttributes = null;
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)
528 for (
int i = 0, count =
m_PrefabData.GetAttributesCount(); i < count; i++)
534 if (attribute.
IsServer() != onlyServer)
538 bool isCompatible =
false;
546 foreach (Managed item: items)
587 outAttributesMultiSelect.Insert(multiSelectState);
589 multiSelectState = 0;
591 return outVars.Count();
602 for (
int i = 0, count =
m_PrefabData.GetAttributesCount(); i < count; i++)
610 foreach (Managed item: items)
640 if (attributeEntry.Type() ==
type)
642 attribute = attributeEntry;
653 Debug.Error2(
type.ToString(),
"Attribute type not found to set variable!");
665 if (!m_aEditedAttributes || m_aEditedAttributes.IsEmpty())
670 if (attributeEntry.Type() ==
type)
672 var = attributeEntry.GetVariableOrCopy();
674 Print(
"SCR_AttributesManagerEditorComponent could not find the attribute var which will cause certain attributes to break",
LogLevel.ERROR);
694 if (!m_aEditedAttributes || m_aEditedAttributes.IsEmpty())
699 if (((includedInherit && attributeEntry.Type().IsInherited(
type)) || (!includedInherit && attributeEntry.Type() ==
type)) && attributeEntry != ignoreAttribute)
700 attributes.Insert(attributeEntry);
703 return attributes.Count();
713 if (!m_aEditedAttributes || m_aEditedAttributes.IsEmpty())
718 if (attributeEntry.Type() ==
type)
720 attribute = attributeEntry;
723 return !attributeEntry.IsServer();
737 if (!m_aEditedAttributes || m_aEditedAttributes.IsEmpty())
744 if (attributeEntry.Type() ==
type)
746 attribute = attributeEntry;
753 attribute.
Enable(enabled);
777 if (attributeEntry.Type() ==
type)
779 attribute = attributeEntry;
791 Debug.Error2(
type.ToString(),
"Attribute type not found to set attriabute selected!");
806 if (attributeEntry.Type() ==
type)
808 attribute = attributeEntry;
831 if (attributeEntry.Type() ==
type)
832 return attributeEntry;
844 return outAttributes.Copy(m_aEditedAttributes);
853 return outitems.Copy(m_aEditedItems);
862 return Event_OnAttributesRequest;
871 return Event_OnAttributesStart;
880 return Event_OnAttributesConfirm;
888 return Event_OnAttributesCancel;
896 return Event_OnResetAttributes;
904 return Event_OnAttributeChangesApplied;
912 return Event_OnAttributeDescriptionChanged;
920 return Event_OnAttributeCategoryChanged;
963 Event_OnAttributeDescriptionChanged.Invoke(uiInfo, customDescription,
param1,
param2,
param3);
988 m_bHasServerAttributes =
false;
990 for (
int i = 0, count =
m_PrefabData.GetAttributesCount(); i < count; i++)
996 m_bHasServerAttributes =
true;
1006 for (
int i = 0, count =
m_PrefabData.GetAttributesCount(); i < count; i++)
EEditorAttributeMultiSelect
Keeps track if attribute is multiselect and colliding attributes.
ArmaReforgerScripted GetGame()
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)
bool GetChangedAttributesOnce()
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)
bool m_bHasChangedAttributesOnce
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)
void CancelEditingServer()
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()
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_WristwatchComponentClass m_PrefabData
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)
SCR_BaseEditorAttribute GetAttribute(int index)
int FindAttribute(SCR_BaseEditorAttribute attribute)
ref array< SCR_BaseEditorAttribute > m_aAttributes
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...
bool BoolAllowDuplicate()
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 void SetAsSubAttribute()
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 EOnEditorDeactivate()
void EOnEditorInit()
When the entity is created.
void EOnEditorInitServer()
When the entity is created (called on server).
EntityComponentPrefabData GetEditorComponentData()
void SetHierarchyAsDirtyInParents()
UIInfo used by editor attribute system.
Snapshot serializer utility.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
SCR_AttributesManagerEditorComponentClass SNAPSHOT_SIZE
proto external PlayerController GetPlayerController()
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="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.