8 [
Attribute(defvalue:
"1",
desc:
"True to get the value from server.")]
9 private bool m_bIsServer;
12 protected ResourceName m_CategoryConfig;
15 protected ResourceName m_Layout;
17 [
Attribute(
desc:
"Holds a list of dynamic descriptions from attributes. When hovered and when changing the attribute the system will loop through all entries and display the dynamic description for the first valid. If none are valid than the default description is shown")]
18 protected ref array<ref SCR_BaseAttributeDynamicDescription> m_aAttributeDynamicDescriptions;
21 protected bool m_bAttributeEnabled =
true;
22 protected bool m_bIsSubAttribute;
23 protected bool m_bInitCalled;
24 protected bool m_bConflictingAttributeWasReset;
27 protected bool m_bIsMultiSelect =
false;
28 protected bool m_bHasConflictingValues =
false;
29 protected bool m_bOverridingValues =
false;
35 protected ref SSnapshot m_Snapshot;
36 protected ref ScriptInvoker Event_OnExternalChange;
37 protected ref ScriptInvoker Event_OnVarChanged =
new ScriptInvoker;
38 protected ref ScriptInvoker Event_OnToggleEnable =
new ScriptInvoker;
39 protected ref ScriptInvoker Event_OnToggleButtonSelected =
new ScriptInvoker;
40 protected ref ScriptInvoker Event_OnSetAsSubAttribute =
new ScriptInvoker;
49 SetIsOverridingValues(
false);
50 SetConflictingAttributeWasReset(
false);
65 int GetDynamicDescriptionArray(notnull out array<SCR_BaseAttributeDynamicDescription> dynamicDescriptionArray)
69 dynamicDescriptionArray.Insert(description);
72 return dynamicDescriptionArray.Count();
86 ResourceName GetCategoryConfig()
88 return m_CategoryConfig;
94 ResourceName GetLayout()
103 bool BoolAllowDuplicate()
110 bool IsSerializable()
126 if (var.Type() == m_Var.Type())
129 Event_OnVarChanged.Invoke(var);
134 PrintFormat(
"Trying to set attribute var to type '%1' but is type '%2'", var.Type().ToString(), m_Var.Type().ToString(), LogLevel.WARNING);
141 Event_OnVarChanged.Invoke(var);
148 sealed
void ClearVar()
155 sealed
void ClearCopyVar()
163 sealed ScriptInvoker GetOnVarChanged()
165 return Event_OnVarChanged;
171 sealed
void Enable(
bool enabled)
173 m_bAttributeEnabled = enabled;
174 Event_OnToggleEnable.Invoke(enabled);
180 sealed
void ToggleSelected(
bool selected,
int index)
182 Event_OnToggleButtonSelected.Invoke(selected,
index,
true);
188 sealed
void SetAsSubAttribute()
190 m_bIsSubAttribute =
true;
191 Event_OnSetAsSubAttribute.Invoke();
199 return m_bInitCalled;
205 void SetInitCalled(
bool initCalled)
207 m_bInitCalled = initCalled;
214 bool GetIsMultiSelect()
216 return m_bIsMultiSelect;
223 void SetIsMultiSelect(
bool isMultiSelect)
225 m_bIsMultiSelect = isMultiSelect;
232 bool GetHasConflictingValues()
234 return m_bHasConflictingValues;
241 void SetHasConflictingValues(
bool hasConflictingValues)
243 m_bHasConflictingValues = hasConflictingValues;
249 void SetIsOverridingValues(
bool isOverridingValues)
251 m_bOverridingValues = isOverridingValues;
257 bool GetIsOverridingValues()
259 return m_bOverridingValues;
267 return m_bAttributeEnabled;
273 bool GetIsSubAttribute()
275 return m_bIsSubAttribute;
281 sealed ScriptInvoker GetOnToggleEnable()
283 return Event_OnToggleEnable;
289 sealed ScriptInvoker GetOnToggleButtonSelected()
291 return Event_OnToggleButtonSelected;
297 sealed ScriptInvoker GetOnSetAsSubAttribute()
299 return Event_OnSetAsSubAttribute;
308 if (!m_Var && createWhenNull)
309 m_Var = CreateDefaultVariable();
336 sealed
void CreateCopyVariable()
347 sealed
bool GetConflictingAttributeWasReset()
349 return m_bConflictingAttributeWasReset;
355 sealed
void SetConflictingAttributeWasReset(
bool wasReset)
357 m_bConflictingAttributeWasReset = wasReset;
363 sealed SSnapshot GetSnapshot()
371 sealed ScriptInvoker GetOnExternalnChange()
373 return Event_OnExternalChange;
381 m_Snapshot = snapshot;
382 Event_OnExternalChange =
new ScriptInvoker;
387 sealed
void StopEditing()
391 Event_OnExternalChange =
null;
394 PreviewVariable(
false,
null);
399 sealed
void TelegraphChange(
bool isReset)
404 if (GetHasConflictingValues())
406 SetConflictingAttributeWasReset(
true);
407 SetIsOverridingValues(
false);
411 Event_OnExternalChange.Invoke(m_Var, isReset);
443 void PreviewVariable(
bool setPreview, SCR_AttributesManagerEditorComponent manager);
450 void UpdateInterlinkedVariables(
SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager,
bool isInit =
false);
457 int GetEntries(notnull array<ref SCR_BaseEditorAttributeEntry> outEntries)
465 protected bool IsGameMode(Managed item)
467 return item ==
GetGame().GetGameMode();
471 class SCR_BaseEditorAttributeEntry
495 private int m_iValue;
556 value = Math.Round(value * coef);
557 string valueText = value.ToString();
560 for (
int i = 0, count =
m_sDecimals - valueText.Length() + 1; i < count; i++)
562 valueText =
"0" + valueText;
564 int length = valueText.Length();
583 string sliderValueSymbol;
584 string sliderValueFormating;
585 float min, max, step, decimals;
587 sliderValues.GetSliderValues(sliderValueFormating, min, max, step, decimals);
600 protected bool m_bAlwaysHideSeconds;
606 void GetTimeSliderValues(out
ETimeFormatParam hideIfZero, out
bool alwaysHideSeconds)
608 hideIfZero = m_eHideIfZero;
609 alwaysHideSeconds = m_bAlwaysHideSeconds;
616 m_eHideIfZero = hideIfZero;
617 m_bAlwaysHideSeconds = alwaysHideSeconds;
623 protected array<ref SCR_EditorAttributeFloatStringValueHolder>
m_aValues;
663 protected bool m_bBool;
673 void SetBool(
bool newBool)
687 protected array<ref LocalizedString>
m_aValues;
713 protected array<ref int> m_aValues;
729 int GetEntry(
int index)
731 if (index < 0 || index >=
m_aValues.Count())
759 protected int m_iButtonsOnRow;
760 protected bool m_bHasRandomizeButton;
761 protected ResourceName m_sIconOfRandomizeButton;
762 protected bool m_bHasIcon;
763 protected bool m_bHasButtonDescription;
764 protected string m_sButtonDescription;
765 protected float m_iButtonHeight;
776 void SCR_EditorAttributePresetEntry(
int buttonsOnRow,
bool hasRandomizeButton, ResourceName iconOfRandomizeButton =
string.Empty,
bool hasIcon =
false,
bool hasButtonDescription =
false,
string buttonDescription =
string.Empty,
int buttonHeight = -1)
778 m_iButtonsOnRow = buttonsOnRow;
779 m_bHasRandomizeButton = hasRandomizeButton;
780 m_sIconOfRandomizeButton = iconOfRandomizeButton;
781 m_bHasIcon = hasIcon;
782 m_bHasButtonDescription = hasButtonDescription;
783 m_sButtonDescription = buttonDescription;
784 m_iButtonHeight = buttonHeight;
789 void GetPresetValues(out
int buttonsOnRow, out
bool hasRandomizeButton, out ResourceName iconOfRandomizeButton, out
bool hasIcon, out
bool hasButtonDescription, out
string buttonDescription, out
int buttonHeight)
791 buttonsOnRow = m_iButtonsOnRow;
792 hasRandomizeButton = m_bHasRandomizeButton;
793 iconOfRandomizeButton = m_sIconOfRandomizeButton;
794 hasIcon = m_bHasIcon;
795 buttonHeight = m_iButtonHeight;
796 buttonDescription = m_sButtonDescription;
797 hasButtonDescription = m_bHasButtonDescription;
815 void SCR_EditorAttributePresetMultiSelectEntry(
int buttonsOnRow,
bool hasRandomizeButton, ResourceName iconOfRandomizeButton =
string.Empty,
bool hasIcon =
false,
bool hasButtonDescription =
false,
string buttonDescription =
string.Empty,
int buttonHeight = -1,
int customFlags =
false)
817 SCR_EditorAttributePresetEntry(buttonsOnRow, hasRandomizeButton, iconOfRandomizeButton, hasIcon, hasButtonDescription, buttonDescription, buttonHeight);
831 protected bool m_bOverrideToggled;
832 protected typename m_LinkedOverrideAttributeType;
838 m_bOverrideToggled = overrideToggled;
839 m_LinkedOverrideAttributeType = linkedOverrideAttributeType;
843 void GetToggleStateAndTypename(out
bool overrideToggleState, out
typename linkedOverrideAttributeType)
845 overrideToggleState = m_bOverrideToggled;
846 linkedOverrideAttributeType = m_LinkedOverrideAttributeType;
871 override bool _WB_GetCustomTitle(BaseContainer source, out
string title)
873 title = source.GetClassName();
874 title.Replace(
"SCR_",
"");
875 title.Replace(
"EditorAttribute",
"");
878 source.Get(
"m_bIsServer", isServer);