Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ButtonCloseEditorUIComponent.c
Go to the documentation of this file.
2{
3 [Attribute()]
4 protected string m_sButtonCloseName;
5
6 [Attribute()]
7 protected string m_sButtonPlayerName;
8
9 [Attribute()]
10 protected string m_sButtonRespawnMenuName;
11
12 [Attribute()]
14
15 [Attribute("Toolbar_CaptureButton")]
16 protected string m_sButtonCapture;
17
18 [Attribute("Text0")]
19 protected string m_sButtonPlayerTextName;
20
21 [Attribute()]
23
24 [Attribute()]
26
32
34
35 //---- REFACTOR NOTE START: States could be enums
36
37 protected const int BUTTON_CLOSE = 0;
38 protected const int BUTTON_PLAYER = 1;
39 protected const int BUTTON_RESPAWN_MENU = 2;
40 protected const int BUTTON_RESPAWN_MENU_DISABLED = 3;
41
42 //------------------------------------------------------------------------------------------------
43 protected int GetButtonIndex()
44 {
45 //--- Player avatar exists - 'Play' button
47 if (localPlayer && !localPlayer.IsDeleted())
48 {
50 if (!damageManager)
51 return BUTTON_PLAYER;
52
53 if (damageManager.GetState() != EDamageState.DESTROYED)
54 return BUTTON_PLAYER;
55 }
56
57 //--- 'Return to respawn menu' button based on available spawn points
58 SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
59 if (factionManager)
60 {
61 int spawnPointCount;
62 Faction playerFaction = factionManager.GetPlayerFaction(SCR_PlayerController.GetLocalPlayerId());
63 if (playerFaction)
64 {
65 //--- Player has faction - return its spawn points
66 string playerFactionKey;
67 playerFactionKey = playerFaction.GetFactionKey();
68 spawnPointCount = SCR_SpawnPoint.GetSpawnPointCountForFaction(playerFactionKey)
69 }
70 else
71 {
72 //--- Player has no faction - return all spawn points
73 spawnPointCount = SCR_SpawnPoint.CountSpawnPoints();
74 }
75
76 if (spawnPointCount == 0)
78 else
80 }
81
82 //--- Default - plain 'Close' button
83 return BUTTON_CLOSE;
84 }
85
86 //------------------------------------------------------------------------------------------------
87 protected void SetPlayerButtonText(string text)
88 {
90 return;
91
92 m_wButtonPlayerText.SetText(text);
93 }
94
95 //------------------------------------------------------------------------------------------------
96 protected void Refresh()
97 {
98 int showButton = GetButtonIndex();
99
100 m_ButtonClose.SetVisible(showButton == BUTTON_CLOSE);
101 m_ButtonPlayer.SetVisible(showButton == BUTTON_PLAYER);
102 m_ButtonRespawnMenu.SetVisible(showButton == BUTTON_RESPAWN_MENU);
104
106 {
107 SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
108 if (!editorManager)
109 return;
110
111 EEditorMode mode = editorManager.GetCurrentMode();
112 m_wButtonCapture.SetVisible(mode == EEditorMode.PHOTO_SAVE);
113 }
114 }
115
116 //---- REFACTOR NOTE END ----
117
118 //------------------------------------------------------------------------------------------------
119 protected void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
120 {
121 Refresh();
122 }
123
124 //------------------------------------------------------------------------------------------------
125 protected void OnPlayerSpawnedOrDeleted(int playerId, IEntity player)
126 {
127 Refresh();
128 }
129
130 //------------------------------------------------------------------------------------------------
131 override bool OnClick(Widget w, int x, int y, int button)
132 {
133 SCR_EditorManagerEntity editorManager = SCR_EditorManagerEntity.GetInstance();
134 if (editorManager)
135 GetGame().GetCallqueue().CallLater(editorManager.Close, 1, false, false); //--- Cannot trigger operation which closes UI from that UI's handler
136
137 return false;
138 }
139
140 //------------------------------------------------------------------------------------------------
141 override void HandlerAttached(Widget w)
142 {
144 return;
145
146 m_ButtonPlayer = w.FindAnyWidget(m_sButtonPlayerName);
149 m_ButtonClose = w.FindAnyWidget(m_sButtonCloseName);
150 m_wButtonCapture = w.FindAnyWidget(m_sButtonCapture);
151
152 if (m_ButtonPlayer)
154
156 if (gameMode)
157 {
159 gameMode.GetOnPlayerKilled().Insert(OnPlayerKilled);
161 }
162
163 SCR_SpawnPoint.Event_OnSpawnPointCountChanged.Insert(Refresh);
164
166 if (mapEntity && mapEntity.IsOpen())
168 else
170
171 Refresh();
172 }
173
174 //------------------------------------------------------------------------------------------------
175 override void HandlerDeattached(Widget w)
176 {
178 if (gameMode)
179 {
181 gameMode.GetOnPlayerKilled().Remove(OnPlayerKilled);
183 }
184
185 SCR_SpawnPoint.Event_OnSpawnPointCountChanged.Remove(Refresh);
186 }
187}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_BaseGameMode GetGameMode()
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
void SCR_FactionManager(IEntitySource src, IEntity parent)
proto external Managed FindComponent(typename typeName)
proto external bool IsDeleted()
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerSpawned()
ScriptInvokerBase< SCR_BaseGameMode_PlayerIdAndEntity > GetOnPlayerDeleted()
ScriptInvokerBase< SCR_BaseGameMode_OnControllableDestroyed > GetOnPlayerKilled()
void OnPlayerKilled(notnull SCR_InstigatorContextData instigatorContextData)
void OnPlayerSpawnedOrDeleted(int playerId, IEntity player)
override bool OnClick(Widget w, int x, int y, int button)
static bool IsEditMode()
Definition Functions.c:1566
bool IsOpen()
Check if the map is opened.
static SCR_MapEntity GetMapInstance()
Get map entity instance.
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
static IEntity GetLocalMainEntity()
Spawn point entity defines positions on which players can possibly spawn.
static int CountSpawnPoints()
SCR_FieldOfViewSettings Attribute
EEditorMode
Editor mode that defines overall functionality.
Definition EEditorMode.c:6
EDamageState