6 protected string m_sNoPlayerFactionsActiveName;
9 protected string m_sButtonHintName;
12 protected string m_sHeaderName;
14 [
Attribute(
desc:
"Config of the global attribute menu category that should be selected upon opening attribute window when there are no playable factions and player tries to select the playable factions with Gamepad.",
params:
"conf class=SCR_EditorAttributeCategory")]
15 protected ResourceName m_NoFactionAttributeCategory;
17 protected Widget m_wNoPlayerFactionsActive;
18 protected Widget m_wButtonHint;
19 protected Widget m_wHeader;
22 protected override bool CanOpenDialog()
26 if (!delegateFactionManager || delegateFactionManager.GetPlayableFactionDelegateCount() > 0)
27 return super.CanOpenDialog();
29 else if (delegateFactionManager && delegateFactionManager.GetPlayableFactionDelegateCount() == 0 && super.CanOpenDialog())
32 SCR_AttributesManagerEditorComponent attributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
33 if (attributesManager)
35 if (m_NoFactionAttributeCategory)
36 attributesManager.SetCurrentCategory(m_NoFactionAttributeCategory);
46 SCR_AttributesManagerEditorComponent attributeManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent,
true));
47 if (!attributeManager || attributeManager.GetChangedAttributesOnce())
48 return super.CanOpenDialog();
52 if (!editorPlayerManager || editorPlayerManager.HasLocalPlayerSpawnedOnce())
53 return super.CanOpenDialog();
59 protected void FactionPlayabilityChanged(
Faction faction,
bool playable)
65 override protected void HandlerAttachedScripted(Widget w)
69 super.HandlerAttachedScripted(w);
73 if (!delegatesManager)
76 map<Faction, SCR_EditableFactionComponent> delegates =
new map<Faction, SCR_EditableFactionComponent>();
77 delegatesManager.GetFactionDelegates(delegates);
79 foreach (
Faction faction, SCR_EditableFactionComponent delegate: delegates)
84 scrFaction.GetOnFactionPlayableChanged().Insert(FactionPlayabilityChanged);
87 Widget parent = w.GetParent();
89 m_wNoPlayerFactionsActive = parent.FindAnyWidget(m_sNoPlayerFactionsActiveName);
90 m_wButtonHint = parent.FindAnyWidget(m_sButtonHintName);
91 m_wHeader = parent.FindAnyWidget(m_sHeaderName);
94 GetGame().GetInputManager().AddActionListener(
"EditorTransformToggle", EActionTrigger.DOWN, OnEditorMenuConfirmInput);
98 override protected void Refresh()
101 if (delegatesManager)
103 SCR_SortedArray<SCR_EditableFactionComponent> delegates =
new SCR_SortedArray<SCR_EditableFactionComponent>();
104 int count = delegatesManager.GetSortedFactionDelegates(delegates);
105 bool playerFactionsActive =
false;
108 for (
int i; i < count; i++)
112 if (scrFaction && scrFaction.IsPlayable())
114 m_Entities.Insert(delegates.GetOrder(i), delegates[i]);
115 playerFactionsActive =
true;
120 if (m_wNoPlayerFactionsActive && m_wButtonHint && m_wHeader)
122 m_wNoPlayerFactionsActive.SetVisible(!playerFactionsActive);
123 m_wButtonHint.SetVisible(playerFactionsActive);
124 m_wHeader.SetVisible(playerFactionsActive);
128 m_Pagination.SetEntryCount(
m_Entities.Count());
134 override protected void HandlerDeattached(Widget w)
136 super.HandlerDeattached(w);
140 if (!delegatesManager)
143 map<Faction, SCR_EditableFactionComponent> delegates =
new map<Faction, SCR_EditableFactionComponent>();
144 delegatesManager.GetFactionDelegates(delegates);
146 foreach (
Faction faction, SCR_EditableFactionComponent delegate: delegates)
151 scrFaction.GetOnFactionPlayableChanged().Remove(FactionPlayabilityChanged);
156 protected void OnEditorMenuConfirmInput()
162 SCR_AttributesManagerEditorComponent attributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
163 if (attributesManager)