Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_FactionsToolbarEditorUIComponent.c
Go to the documentation of this file.
1 
4 {
5  [Attribute("NoPlayerFactionsActive")]
6  protected string m_sNoPlayerFactionsActiveName;
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")]
15  protected ResourceName m_NoFactionAttributeCategory;
16 
17  protected Widget m_wNoPlayerFactionsActive;
18  protected Widget m_wButtonHint;
19  protected Widget m_wHeader;
20 
21  //------------------------------------------------------------------------------------------------
22  protected override bool CanOpenDialog()
23  {
24  //Are there any playable factions
25  SCR_DelegateFactionManagerComponent delegateFactionManager = SCR_DelegateFactionManagerComponent.GetInstance();
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  {
35  if (m_NoFactionAttributeCategory)
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 
76  map<Faction, SCR_EditableFactionComponent> delegates = new map<Faction, SCR_EditableFactionComponent>();
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)
84  scrFaction.GetOnFactionPlayableChanged().Insert(FactionPlayabilityChanged);
85  }
86 
87  Widget parent = w.GetParent();
88 
89  m_wNoPlayerFactionsActive = parent.FindAnyWidget(m_sNoPlayerFactionsActiveName);
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())
113  {
114  m_Entities.Insert(delegates.GetOrder(i), delegates[i]);
115  playerFactionsActive = true;
116  }
117 
118  }
119 
120  if (m_wNoPlayerFactionsActive && m_wButtonHint && m_wHeader)
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 
143  map<Faction, SCR_EditableFactionComponent> delegates = new map<Faction, SCR_EditableFactionComponent>();
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)
151  scrFaction.GetOnFactionPlayableChanged().Remove(FactionPlayabilityChanged);
152  }
153  }
154 
155  //------------------------------------------------------------------------------------------------
156  protected void OnEditorMenuConfirmInput()
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 }
SCR_PlayersManagerEditorComponent
Definition: SCR_PlayersManagerEditorComponent.c:9
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_Entities
protected ref SCR_SortedArray< SCR_EditableEntityComponent > m_Entities
Definition: SCR_EntitiesToolbarEditorUIComponent.c:31
m_HoverEntity
protected SCR_EditableEntityComponent m_HoverEntity
Definition: SCR_EntitiesToolbarEditorUIComponent.c:35
Faction
Definition: Faction.c:12
SCR_EntitiesToolbarEditorUIComponent
Definition: SCR_EntitiesToolbarEditorUIComponent.c:4
m_State
private EEditableEntityState m_State
Definition: SCR_BaseEntitiesEditorUIEffect.c:3
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_DelegateFactionManagerComponent
Definition: SCR_DelegateFactionManagerComponent.c:15
SCR_FactionsToolbarEditorUIComponent
Definition: SCR_FactionsToolbarEditorUIComponent.c:3
GetFaction
SCR_CampaignFaction GetFaction()
Definition: SCR_CampaignMobileAssemblyStandaloneComponent.c:351
SCR_Faction
Definition: SCR_Faction.c:6