Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FactionsToolbarEditorUIComponent.c
Go to the documentation of this file.
1
2
4{
5 [Attribute("NoPlayerFactionsActive")]
7
8 [Attribute("ButtonHint")]
9 protected string m_sButtonHintName;
10
11 [Attribute("Header")]
12 protected string m_sHeaderName;
13
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")]
16
19 protected Widget m_wHeader;
20
21 //------------------------------------------------------------------------------------------------
22 protected override bool CanOpenDialog()
23 {
24 //Are there any playable factions
26 if (!delegateFactionManager || delegateFactionManager.GetPlayableFactionDelegateCount() > 0)
27 return super.CanOpenDialog();
28 //~ Open Scenario Settings with factions if it could otherwise open the dialog
29 else if (delegateFactionManager && delegateFactionManager.GetPlayableFactionDelegateCount() == 0 && super.CanOpenDialog())
30 {
31 //~ Open Global Attributes
32 SCR_AttributesManagerEditorComponent attributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
33 if (attributesManager)
34 {
36 attributesManager.SetCurrentCategory(m_NoFactionAttributeCategory);
37
38 attributesManager.StartEditing(GetGame().GetGameMode());
39 }
40
41 //~ Do not open the dialog
42 return false;
43 }
44
45 //Has attribute been changed yet
46 SCR_AttributesManagerEditorComponent attributeManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent, true));
47 if (!attributeManager || attributeManager.GetChangedAttributesOnce())
48 return super.CanOpenDialog();
49
50 //Local player has spawned yet
52 if (!editorPlayerManager || editorPlayerManager.HasLocalPlayerSpawnedOnce())
53 return super.CanOpenDialog();
54
55 return false;
56 }
57
58 //------------------------------------------------------------------------------------------------
59 protected void FactionPlayabilityChanged(Faction faction, bool playable)
60 {
61 Refresh();
62 }
63
64 //------------------------------------------------------------------------------------------------
65 override protected void HandlerAttachedScripted(Widget w)
66 {
67 m_State = -1; //--- Reset the value so no entities are added by the parent class
68
69 super.HandlerAttachedScripted(w);
70
71 //Subscribe to Playable changed
73 if (!delegatesManager)
74 return;
75
77 delegatesManager.GetFactionDelegates(delegates);
78
79 foreach (Faction faction, SCR_EditableFactionComponent delegate: delegates)
80 {
81 SCR_Faction scrFaction = SCR_Faction.Cast(faction);
82
83 if (scrFaction)
85 }
86
87 Widget parent = w.GetParent();
88
90 m_wButtonHint = parent.FindAnyWidget(m_sButtonHintName);
91 m_wHeader = parent.FindAnyWidget(m_sHeaderName);
92
93 // Add listeners
94 GetGame().GetInputManager().AddActionListener("EditorTransformToggle", EActionTrigger.DOWN, OnEditorMenuConfirmInput);
95 }
96
97 //------------------------------------------------------------------------------------------------
98 override protected void Refresh()
99 {
101 if (delegatesManager)
102 {
103 SCR_SortedArray<SCR_EditableFactionComponent> delegates = new SCR_SortedArray<SCR_EditableFactionComponent>();
104 int count = delegatesManager.GetSortedFactionDelegates(delegates);
105 bool playerFactionsActive = false;
106
107 m_Entities.Clear();
108 for (int i; i < count; i++)
109 {
110 SCR_Faction scrFaction = SCR_Faction.Cast(delegates[i].GetFaction());
111
112 if (scrFaction && scrFaction.IsPlayable() && !scrFaction.GetParent())
113 {
114 m_Entities.Insert(delegates.GetOrder(i), delegates[i]);
115 playerFactionsActive = true;
116 }
117
118 }
119
121 {
122 m_wNoPlayerFactionsActive.SetVisible(!playerFactionsActive);
123 m_wButtonHint.SetVisible(playerFactionsActive);
124 m_wHeader.SetVisible(playerFactionsActive);
125 }
126
127 if (m_Pagination)
128 m_Pagination.SetEntryCount(m_Entities.Count());
129 }
130 super.Refresh();
131 }
132
133 //------------------------------------------------------------------------------------------------
134 override protected void HandlerDeattached(Widget w)
135 {
136 super.HandlerDeattached(w);
137
138 //Remove subscription to Playable changed
140 if (!delegatesManager)
141 return;
142
144 delegatesManager.GetFactionDelegates(delegates);
145
146 foreach (Faction faction, SCR_EditableFactionComponent delegate: delegates)
147 {
148 SCR_Faction scrFaction = SCR_Faction.Cast(faction);
149
150 if (scrFaction)
152 }
153 }
154
155 //------------------------------------------------------------------------------------------------
157 {
158 if (!m_HoverEntity)
159 return;
160
161 // Open attribute manager
162 SCR_AttributesManagerEditorComponent attributesManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
163 if (attributesManager)
164 attributesManager.StartEditing(m_HoverEntity);
165 }
166}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
SCR_CampaignFaction GetFaction()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
SCR_ExternalPaginationUIComponent m_Pagination
int GetFactionDelegates(notnull out map< Faction, SCR_EditableFactionComponent > outDelegates)
static SCR_DelegateFactionManagerComponent GetInstance()
int GetSortedFactionDelegates(notnull out SCR_SortedArray< SCR_EditableFactionComponent > outDelegates)
ref SCR_SortedArray< SCR_EditableEntityComponent > m_Entities
Faction GetParent()
ScriptInvoker_FactionPlayableChanged GetOnFactionPlayableChanged()
bool IsPlayable()
void FactionPlayabilityChanged(Faction faction, bool playable)
Definition Types.c:486
SCR_FieldOfViewSettings Attribute
EActionTrigger