4 protected string m_sButtonCloseName;
7 protected string m_sButtonPlayerName;
10 protected string m_sButtonRespawnMenuName;
13 protected string m_sButtonRespawnMenuDisabledName;
15 protected Widget m_ButtonClose;
16 protected Widget m_ButtonPlayer;
17 protected Widget m_ButtonRespawnMenu;
18 protected Widget m_ButtonRespawnMenuDisabled;
20 protected const int BUTTON_CLOSE = 0;
21 protected const int BUTTON_PLAYER = 1;
22 protected const int BUTTON_RESPAWN_MENU = 2;
23 protected const int BUTTON_RESPAWN_MENU_DISABLED = 3;
26 protected int GetButtonIndex()
30 if (localPlayer && !localPlayer.IsDeleted())
49 string playerFactionKey;
50 playerFactionKey = playerFaction.GetFactionKey();
51 spawnPointCount =
SCR_SpawnPoint.GetSpawnPointCountForFaction(playerFactionKey)
59 if (spawnPointCount == 0)
60 return BUTTON_RESPAWN_MENU_DISABLED;
62 return BUTTON_RESPAWN_MENU;
70 protected void Refresh()
72 int showButton = GetButtonIndex();
74 m_ButtonClose.SetVisible(showButton == BUTTON_CLOSE);
75 m_ButtonPlayer.SetVisible(showButton == BUTTON_PLAYER);
76 m_ButtonRespawnMenu.SetVisible(showButton == BUTTON_RESPAWN_MENU);
77 m_ButtonRespawnMenuDisabled.SetVisible(showButton == BUTTON_RESPAWN_MENU_DISABLED);
81 protected void OnPlayerKilled(
int playerId, IEntity playerEntity, IEntity killerEntity, notnull
Instigator killer)
87 protected void OnPlayerSpawnedOrDeleted(
int playerId, IEntity player)
93 override bool OnClick(Widget w,
int x,
int y,
int button)
97 GetGame().GetCallqueue().CallLater(editorManager.Close, 1,
false,
false);
103 override void HandlerAttached(Widget w)
108 m_ButtonPlayer = w.FindAnyWidget(m_sButtonPlayerName);
109 m_ButtonRespawnMenu = w.FindAnyWidget(m_sButtonRespawnMenuName);
110 m_ButtonRespawnMenuDisabled = w.FindAnyWidget(m_sButtonRespawnMenuDisabledName);
111 m_ButtonClose = w.FindAnyWidget(m_sButtonCloseName);
116 gameMode.GetOnPlayerSpawned().Insert(OnPlayerSpawnedOrDeleted);
117 gameMode.GetOnPlayerKilled().Insert(OnPlayerKilled);
118 gameMode.GetOnPlayerDeleted().Insert(OnPlayerSpawnedOrDeleted);
127 override void HandlerDeattached(Widget w)
132 gameMode.GetOnPlayerSpawned().Remove(OnPlayerSpawnedOrDeleted);
133 gameMode.GetOnPlayerKilled().Remove(OnPlayerKilled);
134 gameMode.GetOnPlayerDeleted().Remove(OnPlayerSpawnedOrDeleted);