4 protected string m_sFullWindowName;
7 protected string m_sButtonOnlyName;
9 protected Widget m_wRoot;
11 protected bool m_bListeningToEvents;
15 protected void ShowButtonOrFullWindow(
bool showFullWindow)
17 Widget fullWindow =
m_wRoot.FindAnyWidget(m_sFullWindowName);
18 Widget buttonOnly =
m_wRoot.FindAnyWidget(m_sButtonOnlyName);
20 if (!fullWindow || !buttonOnly)
23 fullWindow.SetVisible(showFullWindow);
24 buttonOnly.SetVisible(!showFullWindow);
29 protected void OnAttributeChanges()
31 StopListeningToEvents();
32 ShowButtonOrFullWindow(
true);
39 if (!editorPlayerManager || !editorPlayerManager.HasLocalPlayerSpawnedOnce())
42 StopListeningToEvents();
43 ShowButtonOrFullWindow(
true);
48 protected void OnFactionSetPlayable(
SCR_Faction faction,
bool playable)
53 StopListeningToEvents();
54 ShowButtonOrFullWindow(
true);
59 protected void StopListeningToEvents()
61 if (!m_bListeningToEvents)
64 m_bListeningToEvents =
false;
68 if (delegateFactionManager)
70 map<Faction, SCR_EditableFactionComponent> delegates =
new map<Faction, SCR_EditableFactionComponent>();
71 delegateFactionManager.GetFactionDelegates(delegates);
74 foreach (
Faction f, SCR_EditableFactionComponent d : delegates)
81 scrFaction.GetOnFactionPlayableChanged().Remove(OnFactionSetPlayable);
86 SCR_AttributesManagerEditorComponent attributeManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent));
88 attributeManager.GetOnAttributeChangesApplied().Remove(OnAttributeChanges);
92 if (editorPlayerManager)
93 editorPlayerManager.GetOnSpawn().Remove(OnPlayerSpawned);
97 override void HandlerAttached(Widget w)
101 if (!delegateFactionManager|| delegateFactionManager.GetPlayableFactionDelegateCount() > 0)
105 SCR_AttributesManagerEditorComponent attributeManager = SCR_AttributesManagerEditorComponent.Cast(SCR_AttributesManagerEditorComponent.GetInstance(SCR_AttributesManagerEditorComponent,
true));
106 if (!attributeManager || attributeManager.GetChangedAttributesOnce())
111 if (!editorPlayerManager || editorPlayerManager.HasLocalPlayerSpawnedOnce())
117 ShowButtonOrFullWindow(
false);
120 m_bListeningToEvents =
true;
123 map<Faction, SCR_EditableFactionComponent> delegates =
new map<Faction, SCR_EditableFactionComponent>();
124 delegateFactionManager.GetFactionDelegates(delegates);
127 foreach (
Faction f, SCR_EditableFactionComponent d : delegates)
134 scrFaction.GetOnFactionPlayableChanged().Insert(OnFactionSetPlayable);
138 attributeManager.GetOnAttributeChangesApplied().Insert(OnAttributeChanges);
141 if (editorPlayerManager)
142 editorPlayerManager.GetOnSpawn().Insert(OnPlayerSpawned);
146 override void HandlerDeattached(Widget w)
148 StopListeningToEvents();