improved map manager, actions, list

This commit is contained in:
Steffen Schröder 2014-01-06 18:50:26 +01:00
parent 012db8d8f4
commit 2e119828bc
4 changed files with 265 additions and 265 deletions

View File

@ -15,7 +15,6 @@ use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\IconManager; use ManiaControl\Manialinks\IconManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use WidgetPlugin;
/** /**
* Class offering commands to manage maps * Class offering commands to manage maps
@ -32,10 +31,9 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
const ACTION_SKIP_MAP = 'MapList.NextMap'; const ACTION_SKIP_MAP = 'MapList.NextMap';
/** /**
* Private properties * Private Properties
*/ */
private $maniaControl = null; private $maniaControl = null;
private $mapList = null;
/** /**
* Create MapCommands instance * Create MapCommands instance
@ -45,7 +43,6 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
public function __construct(ManiaControl $maniaControl) { public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
$this->initActionsMenuButtons(); $this->initActionsMenuButtons();
$this->mapList = new MapList($this->maniaControl);
// Register for admin chat commands // Register for admin chat commands
$this->maniaControl->commandManager->registerCommandListener('nextmap', $this, 'command_NextMap', true); $this->maniaControl->commandManager->registerCommandListener('nextmap', $this, 'command_NextMap', true);
@ -54,9 +51,8 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$this->maniaControl->commandManager->registerCommandListener('removemap', $this, 'command_RemoveMap', true); $this->maniaControl->commandManager->registerCommandListener('removemap', $this, 'command_RemoveMap', true);
// Register for player chat commands // Register for player chat commands
$this->maniaControl->commandManager->registerCommandListener('xlist', $this, 'command_xList'); $this->maniaControl->commandManager->registerCommandListener(array('maps', 'list'), $this, 'command_List');
$this->maniaControl->commandManager->registerCommandListener('list', $this, 'command_List'); $this->maniaControl->commandManager->registerCommandListener(array('xmaps', 'xlist'), $this, 'command_xList');
$this->maniaControl->commandManager->registerCommandListener('maps', $this, 'command_List');
// Menu Buttons // Menu Buttons
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_XLIST, $this, 'command_xList'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_XLIST, $this, 'command_xList');
@ -132,7 +128,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
// TODO: user mx fetcher // TODO: Use MX fetcher
$params = explode(' ', $chatCallback[1][2], 2); $params = explode(' ', $chatCallback[1][2], 2);
if (count($params) < 2) { if (count($params) < 2) {
$this->maniaControl->chat->sendUsageInfo('Usage example: //addmap 1234', $player->login); $this->maniaControl->chat->sendUsageInfo('Usage example: //addmap 1234', $player->login);
@ -144,7 +140,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
} }
/** /**
* Handle nextmap command * Handle /nextmap Command
* *
* @param array $chat * @param array $chat
* @param \ManiaControl\Players\Player $player * @param \ManiaControl\Players\Player $player
@ -172,13 +168,13 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
} }
/** /**
* Handle list maps command * Handle /maps command
* *
* @param array $chatCallback * @param array $chatCallback
* @param Player $player * @param Player $player
*/ */
public function command_List(array $chatCallback, Player $player) { public function command_List(array $chatCallback, Player $player) {
$this->mapList->showMapList($player); $this->maniaControl->mapManager->mapList->showMapList($player);
} }
/** /**
@ -188,6 +184,6 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
* @param Player $player * @param Player $player
*/ */
public function command_xList(array $chatCallback, Player $player) { public function command_xList(array $chatCallback, Player $player) {
$this->mapList->showManiaExchangeList($chatCallback, $player); $this->maniaControl->mapManager->mapList->showManiaExchangeList($chatCallback, $player);
} }
} }

View File

@ -62,7 +62,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswer'); 'handleManialinkPageAnswer');
$this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPLIST_UPDATED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPS_UPDATED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'updateWidget');
// TODO not working yet // TODO not working yet
@ -232,7 +232,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight(); $height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
// Get Maplist // Get Maplist
$mapList = $this->maniaControl->mapManager->getMapList(); $mapList = $this->maniaControl->mapManager->getMaps();
$this->mapListShown[$player->login] = self::SHOW_MAP_LIST; $this->mapListShown[$player->login] = self::SHOW_MAP_LIST;

View File

@ -7,7 +7,6 @@ use ManiaControl\Formatter;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use MXInfoFetcher;
require_once __DIR__ . '/Map.php'; require_once __DIR__ . '/Map.php';
require_once __DIR__ . '/MapCommands.php'; require_once __DIR__ . '/MapCommands.php';
@ -24,22 +23,23 @@ class MapManager implements CallbackListener {
* Constants * Constants
*/ */
const TABLE_MAPS = 'mc_maps'; const TABLE_MAPS = 'mc_maps';
const CB_MAPLIST_UPDATED = 'MapManager.MapListUpdated'; const CB_MAPS_UPDATED = 'MapManager.MapsUpdated';
const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated'; const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated';
/**
* Private Properties
*/
private $maniaControl = null;
private $mapCommands = null;
private $mapList = array();
private $mapListUids = array();
private $currentMap = null;
/** /**
* Public Properties * Public Properties
*/ */
public $mapQueue = null; public $mapQueue = null;
public $mapCommands = null;
public $mapList = null;
/**
* Private Properties
*/
private $maniaControl = null;
private $maps = array();
private $mapsUids = array();
private $currentMap = null;
/** /**
* Construct map manager * Construct map manager
@ -48,18 +48,17 @@ class MapManager implements CallbackListener {
*/ */
public function __construct(ManiaControl $maniaControl) { public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
// Init database tables
$this->initTables(); $this->initTables();
// Create map commands instance // Create map commands instance
$this->mapList = new MapList($this->maniaControl);
$this->mapCommands = new MapCommands($maniaControl); $this->mapCommands = new MapCommands($maniaControl);
$this->mapQueue = new MapQueue($this->maniaControl); $this->mapQueue = new MapQueue($this->maniaControl);
// Register for callbacks // Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleBeginMap'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleBeginMap');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapListModified'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapsModified');
} }
/** /**
@ -90,10 +89,10 @@ class MapManager implements CallbackListener {
} }
/** /**
* Save map to the database * Save a Map in the Database
* *
* @param \ManiaControl\Maps\Map $map * @param \ManiaControl\Maps\Map $map
* @return boolean * @return bool
*/ */
private function saveMap(Map &$map) { private function saveMap(Map &$map) {
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;
@ -126,82 +125,75 @@ class MapManager implements CallbackListener {
} }
/** /**
* Add a map to the MapList * Remove a Map
* *
* @param Map $map * @param int $id
* @return bool * @param string $uid
* @param bool $eraseFile
*/ */
private function addMap(Map $map) { // TODO needed? public function removeMap($id, $uid, $eraseFile = false) {
$this->saveMap($map); $map = $this->mapsUids[$uid];
$this->mapListUids[$map->uid] = $map;
$this->mapList[] = $map;
return true;
}
/**
* Erases a Map
*
* @param $id
* @param $uid
*/
public function eraseMap($id, $uid) {
$map = $this->mapListUids[$uid];
$this->maniaControl->client->query('RemoveMap', $map->fileName); $this->maniaControl->client->query('RemoveMap', $map->fileName);
$this->maniaControl->chat->sendSuccess('Map $<' . $map->name . '$> removed!'); $this->maniaControl->chat->sendSuccess('Map $<' . $map->name . '$> removed!');
// TODO specified message, who done it? // TODO specified message, who done it?
$this->maniaControl->log('Map $<' . $map->name . '$> removed!', true); $this->maniaControl->log('Map $<' . $map->name . '$> removed!', true);
unset($this->mapListUids[$uid]); unset($this->mapsUids[$uid]);
unset($this->mapList[$id]); unset($this->maps[$id]);
} }
/** /**
* Updates the full Map list, needed on Init, addMap and on ShuffleMaps * Updates the full Map list, needed on Init, addMap and on ShuffleMaps
*/ */
private function updateFullMapList() { private function updateFullMapList() {
if (!$this->maniaControl->client->query('GetMapList', 100, 0)) { // fetch 100 Maps if (!$this->maniaControl->client->query('GetMapList', 100, 0)) {
trigger_error("Couldn't fetch mapList. " . $this->maniaControl->getClientErrorText()); trigger_error("Couldn't fetch mapList. " . $this->maniaControl->getClientErrorText());
return null; return null;
} }
$tempList = array(); $tempList = array();
$mapList = $this->maniaControl->client->getResponse(); $maps = $this->maniaControl->client->getResponse();
foreach ($mapList as $rpcMap) { foreach ($maps as $rpcMap) {
if (array_key_exists($rpcMap["UId"], $this->mapListUids)) { // Map already exists, only update index if (array_key_exists($rpcMap["UId"], $this->mapsUids)) {
$tempList[] = $this->mapListUids[$rpcMap["UId"]]; // Map already exists, only update index
$tempList[] = $this->mapsUids[$rpcMap["UId"]];
} }
else { // Insert Map Object else { // Insert Map Object
$map = new Map($this->maniaControl, $rpcMap); $map = new Map($this->maniaControl, $rpcMap);
$this->saveMap($map); $this->saveMap($map);
$tempList[] = $map; $tempList[] = $map;
$this->mapListUids[$map->uid] = $map; $this->mapsUids[$map->uid] = $map;
} }
} }
// restore Sorted Maplist // restore Sorted Maplist
$this->mapList = $tempList; $this->maps = $tempList;
// Trigger own callback // Trigger own callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPLIST_UPDATED, array(self::CB_MAPLIST_UPDATED)); $this->maniaControl->callbackManager->triggerCallback(self::CB_MAPS_UPDATED, array(self::CB_MAPS_UPDATED));
} }
/** /**
* Fetch current map * Fetch current Map
* *
* @return \ManiaControl\Maps\Map * @return bool
*/ */
private function fetchCurrentMapInfo() { private function fetchCurrentMap() {
if (!$this->maniaControl->client->query('GetCurrentMapInfo')) { if (!$this->maniaControl->client->query('GetCurrentMapInfo')) {
trigger_error("Couldn't fetch map info. " . $this->maniaControl->getClientErrorText()); trigger_error("Couldn't fetch map info. " . $this->maniaControl->getClientErrorText());
return null; return false;
} }
$rpcMap = $this->maniaControl->client->getResponse(); $rpcMap = $this->maniaControl->client->getResponse();
if (!array_key_exists($rpcMap["UId"], $this->mapListUids)) { if (!array_key_exists($rpcMap["UId"], $this->mapsUids)) {
$map = new Map($this->maniaControl, $rpcMap); $this->currentMap = $this->mapsUids[$rpcMap["UId"]];
$this->addMap($map); return true;
return $map;
} }
return $this->mapListUids[$rpcMap["UId"]]; $map = new Map($this->maniaControl, $rpcMap);
$this->saveMap($map);
$this->mapsUids[$map->uid] = $map;
$this->maps[] = $map;
$this->currentMap = $map;
return true;
} }
/** /**
@ -211,7 +203,7 @@ class MapManager implements CallbackListener {
*/ */
public function handleOnInit(array $callback) { public function handleOnInit(array $callback) {
$this->updateFullMapList(); $this->updateFullMapList();
$this->currentMap = $this->fetchCurrentMapInfo(); $this->fetchCurrentMap();
} }
/** /**
@ -230,7 +222,10 @@ class MapManager implements CallbackListener {
* @return mixed * @return mixed
*/ */
public function getMapByUid($uid) { public function getMapByUid($uid) {
return $this->mapListUids[$uid]; if (!isset($this->mapsUids[$uid])) {
return null;
}
return $this->mapsUids[$uid];
} }
/** /**
@ -239,20 +234,22 @@ class MapManager implements CallbackListener {
* @param array $callback * @param array $callback
*/ */
public function handleBeginMap(array $callback) { public function handleBeginMap(array $callback) {
if (array_key_exists($callback[1][0]["UId"], $this->mapListUids)) { // Map already exists, only update index if (array_key_exists($callback[1][0]["UId"], $this->mapsUids)) {
$this->currentMap = $this->mapListUids[$callback[1][0]["UId"]]; // Map already exists, only update index
$this->currentMap = $this->mapsUids[$callback[1][0]["UId"]];
} }
else { // can this ever happen? else {
$this->currentMap = $this->fetchCurrentMapInfo(); // can this ever happen?
$this->fetchCurrentMap();
} }
} }
/** /**
* MapList modified by other controller or web panels * Handle Maps Modified Callback
* *
* @param array $callback * @param array $callback
*/ */
public function mapListModified(array $callback) { public function mapsModified(array $callback) {
$this->updateFullMapList(); $this->updateFullMapList();
} }
@ -260,8 +257,8 @@ class MapManager implements CallbackListener {
* *
* @return array * @return array
*/ */
public function getMapList() { public function getMaps() {
return $this->mapList; return $this->maps;
} }
/** /**
@ -343,7 +340,8 @@ class MapManager implements CallbackListener {
return; return;
} }
// Add map to map list // Add map to map list
if (!$this->maniaControl->client->query('InsertMap', $mapFileName)) { // TODO irgentein bug? if (!$this->maniaControl->client->query('InsertMap', $mapFileName)) {
// TODO irgendein bug?
$this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login); $this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login);
return; return;
} }

View File

@ -29,39 +29,35 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
* @author steeffeen & kremsy * @author steeffeen & kremsy
*/ */
class PlayerList implements ManialinkPageAnswerListener, CallbackListener { class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
/** /**
* Constants * Constants
*/ */
const ACTION_FORCE_RED = 'PlayerList.ForceRed'; const ACTION_FORCE_RED = 'PlayerList.ForceRed';
const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue'; const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue';
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec'; const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions'; const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget'; const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
const ACTION_MUTE_PLAYER = 'PlayerList.MutePlayer'; const ACTION_MUTE_PLAYER = 'PlayerList.MutePlayer';
const ACTION_UNMUTE_PLAYER = 'PlayerList.UnMutePlayer'; const ACTION_UNMUTE_PLAYER = 'PlayerList.UnMutePlayer';
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer'; const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer'; const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer'; const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster'; const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster';
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin'; const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator'; const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights'; const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed'; const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed';
const ACTION_SPECTATE_PLAYER = 'PlayerList.SpectatePlayer'; const ACTION_SPECTATE_PLAYER = 'PlayerList.SpectatePlayer';
const SHOWN_MAIN_WINDOW = -1; const SHOWN_MAIN_WINDOW = -1;
/** /**
* Private properties * Private Properties
*/ */
private $maniaControl = null; private $maniaControl = null;
private $width;
private $height;
private $quadStyle;
private $quadSubstyle;
private $playersListShown = array(); private $playersListShown = array();
/** /**
* Create a PlayerList instance * Create a PlayerList Instance
* *
* @param ManiaControl $maniaControl * @param ManiaControl $maniaControl
*/ */
@ -70,65 +66,64 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget'); $this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswer');
// Update Widget Events // Update Widget Events
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
// settings
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
$this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
} }
public function addPlayerToShownList(Player $player, $showStatus = self::SHOWN_MAIN_WINDOW) { public function addPlayerToShownList(Player $player, $showStatus = self::SHOWN_MAIN_WINDOW) {
$this->playersListShown[$player->login] = $showStatus; $this->playersListShown[$player->login] = $showStatus;
} }
/**
* Show the PlayerList Widget to the Player
*
* @param Player $player
*/
public function showPlayerList(Player $player) { public function showPlayerList(Player $player) {
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$script = $maniaLink->getScript();
// Create script and features // Main frame
$script = new Script();
$maniaLink->setScript($script);
// mainframe
$frame = new Frame(); $frame = new Frame();
$maniaLink->add($frame); $maniaLink->add($frame);
$frame->setSize($this->width, $this->height); $frame->setSize($width, $height);
$frame->setPosition(0, 0); $frame->setPosition(0, 0);
// Background Quad // Background
$backgroundQuad = new Quad(); $backgroundQuad = new Quad();
$frame->add($backgroundQuad); $frame->add($backgroundQuad);
$backgroundQuad->setSize($this->width, $this->height); $backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle); $backgroundQuad->setStyles($quadStyle, $quadSubstyle);
// Add Close Quad (X) // Close Quad (X)
$closeQuad = new Quad_Icons64x64_1(); $closeQuad = new Quad_Icons64x64_1();
$frame->add($closeQuad); $frame->add($closeQuad);
$closeQuad->setPosition($this->width * 0.483, $this->height * 0.467, 3); $closeQuad->setPosition($width * 0.483, $height * 0.467, 3);
$closeQuad->setSize(6, 6); $closeQuad->setSize(6, 6);
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace); $closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET); $closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
// Start offsets // Start offsets
$x = -$this->width / 2; $x = -$width / 2;
$y = $this->height / 2; $y = $height / 2;
// Predefine Description Label
//Predefine Description Label
$descriptionLabel = new Label(); $descriptionLabel = new Label();
$frame->add($descriptionLabel); $frame->add($descriptionLabel);
$descriptionLabel->setAlign(Control::LEFT, Control::TOP); $descriptionLabel->setAlign(Control::LEFT, Control::TOP);
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5); $descriptionLabel->setPosition($x + 10, -$height / 2 + 5);
$descriptionLabel->setSize($this->width * 0.7, 4); $descriptionLabel->setSize($width * 0.7, 4);
$descriptionLabel->setTextSize(2); $descriptionLabel->setTextSize(2);
$descriptionLabel->setVisible(false); $descriptionLabel->setVisible(false);
@ -137,9 +132,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$frame->add($headFrame); $frame->add($headFrame);
$headFrame->setY($y - 5); $headFrame->setY($y - 5);
// $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85); // $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101, "Actions" => $x + 135); $array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101, "Actions" => $x + 135);
} else { }
else {
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101); $array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101);
} }
$this->maniaControl->manialinkManager->labelLine($headFrame, $array); $this->maniaControl->manialinkManager->labelLine($headFrame, $array);
@ -149,36 +145,31 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$i = 1; $i = 1;
$y -= 10; $y -= 10;
foreach($players as $listPlayer) { foreach ($players as $listPlayer) {
/** /**
* *
* @var Player $listPlayer * @var Player $listPlayer
*/ */
$path = $listPlayer->getProvince(); $path = $listPlayer->getProvince();
$playerFrame = new Frame(); $playerFrame = new Frame();
$frame->add($playerFrame); $frame->add($playerFrame);
if($i % 2 != 0) { if ($i % 2 != 0) {
$lineQuad = new Quad_BgsPlayerCard(); $lineQuad = new Quad_BgsPlayerCard();
$playerFrame->add($lineQuad); $playerFrame->add($lineQuad);
$lineQuad->setSize($this->width, 4); $lineQuad->setSize($width, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig); $lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ(0.001); $lineQuad->setZ(0.001);
} }
$array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 70, $path => $x + 101); $array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 70, $path => $x + 101);
$frames = $this->maniaControl->manialinkManager->labelLine($playerFrame, $array); $frames = $this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
/** @var Label $nicknameLabel */
//$nicknameLabel = $frames[1];
//$nicknameLabel->setAction(self::ACTION_OPEN_PLAYER_DETAILED . '.' . $listPlayer->login);
$playerFrame->setY($y); $playerFrame->setY($y);
// Team Emblem // Team Emblem
if($listPlayer->teamId >= 0) { if ($listPlayer->teamId >= 0) {
// Player is in a Team // Player is in a Team
$teamQuad = new Quad_Emblems(); $teamQuad = new Quad_Emblems();
$playerFrame->add($teamQuad); $playerFrame->add($teamQuad);
@ -186,7 +177,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$teamQuad->setZ(0.1); $teamQuad->setZ(0.1);
$teamQuad->setSize(3.8, 3.8); $teamQuad->setSize(3.8, 3.8);
switch($listPlayer->teamId) { switch ($listPlayer->teamId) {
case 0: case 0:
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_1); $teamQuad->setSubStyle($teamQuad::SUBSTYLE_1);
break; break;
@ -194,7 +185,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$teamQuad->setSubStyle($teamQuad::SUBSTYLE_2); $teamQuad->setSubStyle($teamQuad::SUBSTYLE_2);
break; break;
} }
} else if($listPlayer->isSpectator) { }
else if ($listPlayer->isSpectator) {
// Player is in Spectator Mode // Player is in Spectator Mode
$specQuad = new Quad_BgRaceScore2(); $specQuad = new Quad_BgRaceScore2();
$playerFrame->add($specQuad); $playerFrame->add($specQuad);
@ -204,7 +196,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$specQuad->setSize(3.8, 3.8); $specQuad->setSize(3.8, 3.8);
} }
if(!$listPlayer->isFakePlayer()) { if (!$listPlayer->isFakePlayer()) {
// Nation Quad // Nation Quad
$countryQuad = new Quad(); $countryQuad = new Quad();
$playerFrame->add($countryQuad); $playerFrame->add($countryQuad);
@ -214,7 +206,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$countryQuad->setSize(4, 4); $countryQuad->setSize(4, 4);
$countryQuad->setZ(-0.1); $countryQuad->setZ(-0.1);
$script->addTooltip($countryQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $listPlayer->nickname . " from " . $listPlayer->path)); $script->addTooltip($countryQuad, $descriptionLabel,
array(Script::OPTION_TOOLTIP_TEXT => $listPlayer->nickname . " from " . $listPlayer->path));
} }
// Level Quad // Level Quad
@ -231,8 +224,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$rightLabel->setTextSize(0.8); $rightLabel->setTextSize(0.8);
$rightLabel->setZ(10); $rightLabel->setZ(10);
$script->addTooltip($rightLabel, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " . $listPlayer->nickname)); $script->addTooltip($rightLabel, $descriptionLabel,
array(
Script::OPTION_TOOLTIP_TEXT => $this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " .
$listPlayer->nickname));
// Player Statistics // Player Statistics
$playerQuad = new Quad_Icons64x64_1(); $playerQuad = new Quad_Icons64x64_1();
@ -244,7 +239,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . "." . $listPlayer->login); $playerQuad->setAction(self::ACTION_OPEN_PLAYER_DETAILED . "." . $listPlayer->login);
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View Statistics of " . $listPlayer->nickname)); $script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View Statistics of " . $listPlayer->nickname));
// Camera Quad // Camera Quad
$playerQuad = new Quad_UIConstruction_Buttons(); $playerQuad = new Quad_UIConstruction_Buttons();
$playerFrame->add($playerQuad); $playerFrame->add($playerQuad);
@ -265,10 +259,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$script->addProfileButton($playerQuad, $listPlayer->login); $script->addProfileButton($playerQuad, $listPlayer->login);
// Description Label // Description Label
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View Player profile of " . $listPlayer->nickname)); $script->addTooltip($playerQuad, $descriptionLabel,
array(Script::OPTION_TOOLTIP_TEXT => "View Player profile of " . $listPlayer->nickname));
switch ($listPlayer->authLevel) {
switch($listPlayer->authLevel) {
case authenticationManager::AUTH_LEVEL_MASTERADMIN: case authenticationManager::AUTH_LEVEL_MASTERADMIN:
$rightLabel->setText("MA"); $rightLabel->setText("MA");
break; break;
@ -284,7 +278,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$rightLabel->setTextColor("fff"); $rightLabel->setTextColor("fff");
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
// Further Player actions Quad // Further Player actions Quad
$playerQuad = new Quad_Icons64x64_1(); $playerQuad = new Quad_Icons64x64_1();
$playerFrame->add($playerQuad); $playerFrame->add($playerQuad);
@ -295,7 +289,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login); $playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login);
// Description Label // Description Label
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Advanced Player Actions on " . $listPlayer->nickname)); $script->addTooltip($playerQuad, $descriptionLabel,
array(Script::OPTION_TOOLTIP_TEXT => "Advanced Player Actions on " . $listPlayer->nickname));
// Force to Red-Team Quad // Force to Red-Team Quad
$redQuad = new Quad_Emblems(); $redQuad = new Quad_Emblems();
@ -307,7 +302,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login); $redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
// Force to Red-Team Description Label // Force to Red-Team Description Label
$script->addTooltip($redQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Red Team!')); $script->addTooltip($redQuad, $descriptionLabel,
array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Red Team!'));
// Force to Blue-Team Quad // Force to Blue-Team Quad
$blueQuad = new Quad_Emblems(); $blueQuad = new Quad_Emblems();
@ -319,7 +315,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login); $blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login);
// Force to Blue-Team Description Label // Force to Blue-Team Description Label
$script->addTooltip($blueQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Blue Team!')); $script->addTooltip($blueQuad, $descriptionLabel,
array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Blue Team!'));
// Force to Spectator Quad // Force to Spectator Quad
$spectatorQuad = new Quad_BgRaceScore2(); $spectatorQuad = new Quad_BgRaceScore2();
@ -331,19 +328,20 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . "." . $listPlayer->login); $spectatorQuad->setAction(self::ACTION_FORCE_SPEC . "." . $listPlayer->login);
// Force to Spectator Description Label // Force to Spectator Description Label
$script->addTooltip($spectatorQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Spectator!')); $script->addTooltip($spectatorQuad, $descriptionLabel,
array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Spectator!'));
} }
$i++; $i++;
$y -= 4; $y -= 4;
} }
// show advanced window // Show advanced window
if($this->playersListShown[$player->login] != false && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW) { if ($this->playersListShown[$player->login] && $this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW) {
$frame = $this->showAdvancedPlayerWidget($this->playersListShown[$player->login]); $frame = $this->showAdvancedPlayerWidget($this->playersListShown[$player->login]);
$maniaLink->add($frame); $maniaLink->add($frame);
} }
// render and display xml // Render and display xml
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player); $this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
} }
@ -351,14 +349,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
* Displays the Advanced Player Window * Displays the Advanced Player Window
* *
* @param Player $caller * @param Player $caller
* @param $login * @param $login
*/ */
public function advancedPlayerWidget(Player $caller, $login) { public function advancedPlayerWidget(Player $caller, $login) {
if(!$caller) { // Set status to target player login
return; $this->playersListShown[$caller->login] = $login;
}
$this->playersListShown[$caller->login] = $login; // Show a certain player // Reopen playerlist
$this->showPlayerList($caller); // reopen playerlist $this->showPlayerList($caller);
} }
/** /**
@ -369,14 +367,18 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
*/ */
public function showAdvancedPlayerWidget($login) { public function showAdvancedPlayerWidget($login) {
$player = $this->maniaControl->playerManager->getPlayer($login); $player = $this->maniaControl->playerManager->getPlayer($login);
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
// todo all configurable or as constants // TODO: all configurable or as constants
$x = $this->width / 2 + 2.5; $x = $width / 2 + 2.5;
$width = 35; $width = 35;
$height = $this->height * 0.75; $height = $height * 0.75;
$hAlign = Control::LEFT; $hAlign = Control::LEFT;
$style = Label_Text::STYLE_TextCardSmall; $style = Label_Text::STYLE_TextCardSmall;
$textSize = 1.5; $textSize = 1.5;
$textColor = 'FFF'; $textColor = 'FFF';
$quadWidth = $width - 7; $quadWidth = $width - 7;
@ -397,7 +399,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$backgroundQuad = new Quad(); $backgroundQuad = new Quad();
$frame->add($backgroundQuad); $frame->add($backgroundQuad);
$backgroundQuad->setSize($width, $height); $backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle); $backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$backgroundQuad->setZ(0.1); $backgroundQuad->setZ(0.1);
// Show headline // Show headline
@ -423,8 +425,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setText($player->nickname); $label->setText($player->nickname);
$label->setTextColor($textColor); $label->setTextColor($textColor);
//Mute Player // Mute Player
$y = $height / 2 - 14; $y = $height / 2 - 14;
$quad = new Quad_BgsPlayerCard(); $quad = new Quad_BgsPlayerCard();
$frame->add($quad); $frame->add($quad);
$quad->setX(0); $quad->setX(0);
@ -441,15 +443,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setTextSize($textSize); $label->setTextSize($textSize);
$label->setTextColor($textColor); $label->setTextColor($textColor);
if(!$this->maniaControl->playerManager->playerActions->isPlayerMuted($login)) { if (!$this->maniaControl->playerManager->playerActions->isPlayerMuted($login)) {
$label->setText("Mute"); $label->setText("Mute");
$quad->setAction(self::ACTION_MUTE_PLAYER . "." . $login); $quad->setAction(self::ACTION_MUTE_PLAYER . "." . $login);
} else { }
else {
$label->setText("UnMute"); $label->setText("UnMute");
$quad->setAction(self::ACTION_UNMUTE_PLAYER . "." . $login); $quad->setAction(self::ACTION_UNMUTE_PLAYER . "." . $login);
} }
//Warn Player // Warn Player
$y -= 5; $y -= 5;
$quad = clone $quad; $quad = clone $quad;
$frame->add($quad); $frame->add($quad);
@ -530,7 +533,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setText("Set Moderator"); $label->setText("Set Moderator");
$label->setTextColor($textColor); $label->setTextColor($textColor);
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$y -= 5; $y -= 5;
// Revoke Rights // Revoke Rights
$quad = clone $quad; $quad = clone $quad;
@ -561,7 +564,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
/** /**
* Closes the player advanced widget widget * Closes the player advanced widget widget
* *
* @param array $callback * @param array $callback
* @param Player $player * @param Player $player
*/ */
public function closePlayerAdvancedWidget(array $callback, Player $player) { public function closePlayerAdvancedWidget(array $callback, Player $player) {
@ -575,17 +578,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
* @param array $callback * @param array $callback
*/ */
public function handleManialinkPageAnswer(array $callback) { public function handleManialinkPageAnswer(array $callback) {
$actionId = $callback[1][2]; $actionId = $callback[1][2];
$actionArray = explode(".", $actionId); $actionArray = explode('.', $actionId);
if(count($actionArray) <= 2) { if (count($actionArray) <= 2) return;
return;
} $action = $actionArray[0] . "." . $actionArray[1];
$action = $actionArray[0] . "." . $actionArray[1]; $adminLogin = $callback[1][1];
$adminLogin = $callback[1][1];
$targetLogin = $actionArray[2]; $targetLogin = $actionArray[2];
switch($action) { switch ($action) {
case self::ACTION_SPECTATE_PLAYER: //TODO not working yet case self::ACTION_SPECTATE_PLAYER: // TODO not working yet
$this->maniaControl->client->query('ForceSpectator', $adminLogin, PlayerActions::SPECTATOR_SPECTATOR); $this->maniaControl->client->query('ForceSpectator', $adminLogin, PlayerActions::SPECTATOR_SPECTATOR);
$this->maniaControl->client->query('ForceSpectatorTarget', $adminLogin, $targetLogin, 1); $this->maniaControl->client->query('ForceSpectatorTarget', $adminLogin, $targetLogin, 1);
break; break;
@ -595,13 +597,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
unset($this->playersListShown[$player->login]); unset($this->playersListShown[$player->login]);
break; break;
case self::ACTION_FORCE_BLUE: case self::ACTION_FORCE_BLUE:
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::BLUE_TEAM); $this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_BLUE);
break; break;
case self::ACTION_FORCE_RED: case self::ACTION_FORCE_RED:
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::RED_TEAM); $this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_RED);
break; break;
case self::ACTION_FORCE_SPEC: case self::ACTION_FORCE_SPEC:
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE); $this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin,
PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
break; break;
case self::ACTION_MUTE_PLAYER: case self::ACTION_MUTE_PLAYER:
$this->maniaControl->playerManager->playerActions->mutePlayer($adminLogin, $targetLogin); $this->maniaControl->playerManager->playerActions->mutePlayer($adminLogin, $targetLogin);
@ -625,13 +628,15 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$this->advancedPlayerWidget($admin, $targetLogin); $this->advancedPlayerWidget($admin, $targetLogin);
break; break;
case self::ACTION_ADD_AS_MASTER: case self::ACTION_ADD_AS_MASTER:
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); $this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
break; break;
case self::ACTION_ADD_AS_ADMIN: case self::ACTION_ADD_AS_ADMIN:
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN); $this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
break; break;
case self::ACTION_ADD_AS_MOD: case self::ACTION_ADD_AS_MOD:
$this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR); $this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
AuthenticationManager::AUTH_LEVEL_MODERATOR);
break; break;
case self::ACTION_REVOKE_RIGHTS: case self::ACTION_REVOKE_RIGHTS:
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin); $this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
@ -645,16 +650,17 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
* @param array $callback * @param array $callback
*/ */
public function updateWidget(array $callback) { public function updateWidget(array $callback) {
foreach($this->playersListShown as $login => $shown) { foreach ($this->playersListShown as $login => $shown) {
if($shown) { if ($shown) {
// Check if Shown player still exists // Check if Shown player still exists
if($shown != self::SHOWN_MAIN_WINDOW && $this->maniaControl->playerManager->getPlayer($shown) == null) { if ($shown != self::SHOWN_MAIN_WINDOW && $this->maniaControl->playerManager->getPlayer($shown) == null) {
$this->playersListShown[$login] = false; $this->playersListShown[$login] = false;
} }
$player = $this->maniaControl->playerManager->getPlayer($login); $player = $this->maniaControl->playerManager->getPlayer($login);
if($player != null) { if ($player != null) {
$this->showPlayerList($player); $this->showPlayerList($player);
} else { }
else {
// if player with the open widget disconnected remove him from the shownlist // if player with the open widget disconnected remove him from the shownlist
unset($this->playersListShown[$login]); unset($this->playersListShown[$login]);
} }