Improved Player Actions

This commit is contained in:
Steffen Schröder 2013-12-31 16:01:22 +01:00
parent eeb2a89c4f
commit 96eda851df
2 changed files with 160 additions and 141 deletions

View File

@ -2,7 +2,6 @@
namespace ManiaControl\Players; namespace ManiaControl\Players;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Controls\Frame; use FML\Controls\Frame;
use FML\Controls\Labels\Label_Text; use FML\Controls\Labels\Label_Text;
@ -26,114 +25,126 @@ class PlayerActions {
*/ */
const BLUE_TEAM = 0; const BLUE_TEAM = 0;
const RED_TEAM = 1; const RED_TEAM = 1;
const SPECTATOR_USER_SELECTABLE = 0; const SPECTATOR_USER_SELECTABLE = 0;
const SPECTATOR_SPECTATOR = 1; const SPECTATOR_SPECTATOR = 1;
const SPECTATOR_PLAYER = 2; const SPECTATOR_PLAYER = 2;
const SPECTATOR_BUT_KEEP_SELECTABLE = 3; const SPECTATOR_BUT_KEEP_SELECTABLE = 3;
/** /**
* Private properties * Private Properties
*/ */
private $maniaControl = null; private $maniaControl = null;
/**
* Create a PlayerActions Instance
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) { public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
} }
/** /**
* Forces a Player to a certain team * Force a Player to a certain Team
* @param $adminLogin *
* @param $targetLogin * @param string $adminLogin
* @param $teamId * @param string $targetLogin
* @param int $teamId
*/ */
public function forcePlayerToTeam($adminLogin, $targetLogin, $teamId){ //TODO get used by playercommands public function forcePlayerToTeam($adminLogin, $targetLogin, $teamId) {
// TODO: get used by playercommands
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
if (!$admin || !$target) return;
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if($target->isSpectator){ if ($target->isSpectator) {
$success = $this->maniaControl->client->query('ForceSpectator', $targetLogin, self::SPECTATOR_PLAYER); $success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_PLAYER);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
} }
$success = $this->maniaControl->client->query('ForcePlayerTeam', $targetLogin, $teamId); //TODO bestätigung $success = $this->maniaControl->client->query('ForcePlayerTeam', $target->login, $teamId);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
if($teamId == self::BLUE_TEAM){ $chatMessage = false;
$this->maniaControl->chat->sendInformation($title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!'); if ($teamId == self::BLUE_TEAM) {
$this->maniaControl->log($title .' ' . Formatter::stripCodes($admin->nickname) . ' forced player '. Formatter::stripCodes($target->nickname) . ' into the Blue-Team'); $chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!';
}else if($teamId == self::RED_TEAM){
$this->maniaControl->chat->sendInformation($title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!');
$this->maniaControl->log($title .' ' . Formatter::stripCodes($admin->nickname) . ' forced player '. Formatter::stripCodes($target->nickname) . ' into the Red-Team');
} }
else if ($teamId == self::RED_TEAM) {
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!';
}
if (!$chatMessage) return;
$this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage));
} }
/** /**
* Forces a Player to spectator * Force a Player to Spectator
* @param $adminLogin *
* @param $targetLogin * @param string $adminLogin
* @param string $targetLogin
* @param int $spectatorState * @param int $spectatorState
*/ */
public function forcePlayerToSpectator($adminLogin, $targetLogin, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE){ //TODO get used by playercommands public function forcePlayerToSpectator($adminLogin, $targetLogin, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE) {
// TODO: get used by playercommands
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
$success = $this->maniaControl->client->query('ForceSpectator', $targetLogin, $spectatorState); //TODO bestätigung $success = $this->maniaControl->client->query('ForceSpectator', $targetLogin, $spectatorState);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$this->maniaControl->chat->sendInformation($title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> to spectator!'); $chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> to Spectator!';
$this->maniaControl->chat->sendInformation($chatMessage);
// log console message $this->maniaControl->log(Formatter::stripCodes($chatMessage));
$this->maniaControl->log($title .' ' . Formatter::stripCodes($admin->nickname) . ' forced player '. Formatter::stripCodes($target->nickname) . ' to Spectator');
} }
/** /**
* Warn a Player * Warn a Player
* @param $adminLogin *
* @param $targetLogin * @param string $adminLogin
* @param string $targetLogin
*/ */
public function warnPlayer($adminLogin, $targetLogin){ //TODO chatcommand public function warnPlayer($adminLogin, $targetLogin) {
// TODO: chatcommand
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
// display warning message // display warning message
$message = '$s$f00This is an administrative warning.{br}{br}$gWhatever you wrote or you have done is against {br} our server\'s policy. $message = '$s$f00This is an administrative warning.{br}{br}$gWhatever you wrote or you have done is against {br} our server\'s policy.
{br}Not respecting other players, or{br}using offensive language might result in a{br}$f00kick, or ban $ff0the next time. {br}Not respecting other players, or{br}using offensive language might result in a{br}$f00kick, or ban $ff0the next time.
{br}{br}$gThe server administrators.'; {br}{br}$gThe server administrators.';
$message = preg_split('/{br}/', $message); $message = preg_split('/{br}/', $message);
$width = 80; $width = 80;
$height = 50; $height = 50;
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
//mainframe // mainframe
$frame = new Frame(); $frame = new Frame();
$maniaLink->add($frame); $maniaLink->add($frame);
$frame->setSize($width,$height); $frame->setSize($width, $height);
$frame->setPosition(0, 10); $frame->setPosition(0, 10);
//Background Quad // Background Quad
$backgroundQuad = new Quad(); $backgroundQuad = new Quad();
$frame->add($backgroundQuad); $frame->add($backgroundQuad);
$backgroundQuad->setSize($width,$height); $backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle); $backgroundQuad->setStyles($quadStyle, $quadSubstyle);
// Add Close Quad (X) // Add Close Quad (X)
$closeQuad = new Quad_Icons64x64_1(); $closeQuad = new Quad_Icons64x64_1();
$frame->add($closeQuad); $frame->add($closeQuad);
@ -141,8 +152,8 @@ class PlayerActions {
$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);
//Headline Label // Headline Label
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
$label->setHAlign(Control::CENTER); $label->setHAlign(Control::CENTER);
@ -152,14 +163,14 @@ class PlayerActions {
$label->setTextSize(4); $label->setTextSize(4);
$label->setText('Administrative Warning'); $label->setText('Administrative Warning');
$label->setTextColor('F00'); $label->setTextColor('F00');
$y = $height / 2 - 15; $y = $height / 2 - 15;
foreach ($message as &$line){ foreach ($message as &$line) {
//Warn Labels // Warn Labels
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
$label->setHAlign(Control::CENTER); $label->setHAlign(Control::CENTER);
//$label->setX(-$width / 2 + 5); // $label->setX(-$width / 2 + 5);
$label->setX(0); $label->setX(0);
$label->setY($y); $label->setY($y);
$label->setStyle(Label_Text::STYLE_TextCardMedium); $label->setStyle(Label_Text::STYLE_TextCardMedium);
@ -168,128 +179,132 @@ class PlayerActions {
$label->setTextColor('FF0'); $label->setTextColor('FF0');
$y -= 4; $y -= 4;
} }
// Display manialink
//render and display xml
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $target); $this->maniaControl->manialinkManager->displayWidget($maniaLink, $target);
// log console message $chatMessage = $title . ' $<' . $admin->nickname . '$> warned $<' . $target->nickname . '$>!';
$this->maniaControl->log($title .' ' . Formatter::stripCodes($admin->nickname) . ' warned player '. Formatter::stripCodes($target->nickname)); $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage));
// show chat message
$this->maniaControl->chat->sendInformation($title . ' $<' . $admin->nickname . '$> warned $<' . $target->nickname . '$>!');
} }
/** /**
* Kicks a Player * Kicks a Player
* @param $adminLogin *
* @param $targetLogin * @param string $adminLogin
* @param string $targetLogin
* @param string $message * @param string $message
*/ */
public function kickPlayer($adminLogin, $targetLogin, $message = ''){ public function kickPlayer($adminLogin, $targetLogin, $message = '') {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if($target->isFakePlayer()) if ($target->isFakePlayer()) {
$success = $this->maniaControl->client->query('DisconnectFakePlayer', $target->login); $success = $this->maniaControl->client->query('DisconnectFakePlayer', $target->login);
else }
$success = $this->maniaControl->client->query('Kick', $target->login, $message); //TODO bestätigung else {
$success = $this->maniaControl->client->query('Kick', $target->login, $message);
}
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$this->maniaControl->chat->sendInformation($title . ' $<' . $admin->nickname . '$> kicked $<' . $target->nickname . '$>!');
$chatMessage = $title . ' $<' . $admin->nickname . '$> kicked $<' . $target->nickname . '$>!';
// log console message $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log($title .' ' . Formatter::stripCodes($admin->nickname) . ' kicked player '. Formatter::stripCodes($target->nickname)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
} }
/** /**
* Bans a Player * Bans a Player
* @param $adminLogin *
* @param $targetLogin * @param string $adminLogin
* @param string $targetLogin
* @param string $message * @param string $message
*/ */
public function banPlayer($adminLogin, $targetLogin, $message = ''){ public function banPlayer($adminLogin, $targetLogin, $message = '') {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
$success = $this->maniaControl->client->query('Ban', $target->login, $message); //TODO bestätigung $success = $this->maniaControl->client->query('Ban', $target->login, $message); // TODO bestätigung
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$this->maniaControl->chat->sendInformation($title . ' $<' . $admin->nickname . '$> banned $<' . $target->nickname . '$>!');
$chatMessage = $title . ' $<' . $admin->nickname . '$> banned $<' . $target->nickname . '$>!';
// log console message $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log($title .' ' . Formatter::stripCodes($admin->nickname) . ' banned player '. Formatter::stripCodes($target->nickname)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
} }
/** /**
* Grands Player an authorization level * Grands the Player an Authorization Level
* @param $adminLogin *
* @param $targetLogin * @param string $adminLogin
* @param $authLevel * @param string $targetLogin
* @param int $authLevel
*/ */
public function grandAuthLevel($adminLogin, $targetLogin, $authLevel){ public function grandAuthLevel($adminLogin, $targetLogin, $authLevel) {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if($this->maniaControl->authenticationManager->checkRight($target,$authLevel)){ if ($this->maniaControl->authenticationManager->checkRight($target, $authLevel)) {
$this->maniaControl->chat->sendError('This admin is already ' . $this->maniaControl->authenticationManager->getAuthLevelName($target->authLevel), $admin->login); $this->maniaControl->chat->sendError(
'This Player is already ' . $this->maniaControl->authenticationManager->getAuthLevelName($target->authLevel),
$admin->login);
return; return;
} }
$authLevelName = $this->maniaControl->authenticationManager->getAuthLevelName($authLevel); $authLevelName = $this->maniaControl->authenticationManager->getAuthLevelName($authLevel);
if($this->maniaControl->authenticationManager->checkRight($admin,$authLevel) <= $this->maniaControl->authenticationManager->checkRight($target,$authLevel)){ if ($this->maniaControl->authenticationManager->checkRight($admin, $authLevel) <=
$this->maniaControl->authenticationManager->checkRight($target, $authLevel)) {
$this->maniaControl->chat->sendError('You don\'t have the permission to add a ' . $authLevelName . '!', $admin->login); $this->maniaControl->chat->sendError('You don\'t have the permission to add a ' . $authLevelName . '!', $admin->login);
return; return;
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($target, $authLevel); $success = $this->maniaControl->authenticationManager->grantAuthLevel($target, $authLevel);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$this->maniaControl->chat->sendInformation($title . ' $<' . $admin->nickname . '$> added $<' . $target->nickname . '$> as $< ' . $authLevelName. '$>!'); $chatMessage = $title . ' $<' . $admin->nickname . '$> added $<' . $target->nickname . '$> as $< ' . $authLevelName . '$>!';
$this->maniaControl->chat->sendInformation($chatMessage);
// log console message $this->maniaControl->log(Formatter::stripCodes($chatMessage));
$this->maniaControl->log($title .' ' . Formatter::stripCodes($admin->nickname) . ' added player '. Formatter::stripCodes($target->nickname) . ' as ' . $authLevelName);
} }
/** /**
* Revokes all rights from a Admin * Revokes all Rights from the Player
* @param $adminLogin *
* @param $targetLogin * @param string $adminLogin
* @param string $targetLogin
*/ */
public function revokeAuthLevel($adminLogin, $targetLogin){ public function revokeAuthLevel($adminLogin, $targetLogin) {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if($this->maniaControl->authenticationManager->checkRight($target,AuthenticationManager::AUTH_LEVEL_MASTERADMIN)){ if ($this->maniaControl->authenticationManager->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
$this->maniaControl->chat->sendError('MasterAdmins can\'t be removed ', $admin->login); $this->maniaControl->chat->sendError('MasterAdmins can\'t be removed ', $admin->login);
return; return;
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER); $success = $this->maniaControl->authenticationManager->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$this->maniaControl->chat->sendInformation($title . ' $<' . $admin->nickname . '$> revokes $<' . $target->nickname . '$> rights!'); $chatMessage = $title . ' $<' . $admin->nickname . '$> revokes the Rights of $<' . $target->nickname . '$>!';
$this->maniaControl->chat->sendInformation($chatMessage);
// log console message $this->maniaControl->log(Formatter::stripCodes($chatMessage));
$this->maniaControl->log($title .' ' . Formatter::stripCodes($admin->nickname) . ' revokes '. Formatter::stripCodes($target->nickname) . ' rights');
} }
} }

View File

@ -160,7 +160,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
// $array = array($i => $x + 5, $listPlayer->nickname => $x + 10, $listPlayer->login => $x + 50, $listPlayer->ladderRank => // $array = array($i => $x + 5, $listPlayer->nickname => $x + 10, $listPlayer->login => $x + 50, $listPlayer->ladderRank =>
// $x + 60, $listPlayer->ladderScore => $x + 70, $path => $x + 85); // $x + 60, $listPlayer->ladderScore => $x + 70, $path => $x + 85);
$array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 60, $path => $x + 91); $array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 60, $path => $x + 91);
//$properties = array('profile' => $listPlayer->login, 'script' => $script); // $properties = array('profile' => $listPlayer->login, 'script' => $script);
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array); $this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
$playerFrame->setY($y); $playerFrame->setY($y);
@ -238,8 +238,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$descriptionLabel->setText( $descriptionLabel->setText(
$this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " . $listPlayer->nickname); $this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " . $listPlayer->nickname);
$script->addTooltip($rightQuad, $descriptionLabel); $script->addTooltip($rightQuad, $descriptionLabel);
// Player Profile Quad // Player Profile Quad
$playerQuad = new Quad_UIConstruction_Buttons(); $playerQuad = new Quad_UIConstruction_Buttons();
$playerFrame->add($playerQuad); $playerFrame->add($playerQuad);
@ -247,8 +246,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$playerQuad->setZ(20); $playerQuad->setZ(20);
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author); $playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author);
$playerQuad->setSize(3.8, 3.8); $playerQuad->setSize(3.8, 3.8);
$script->addProfileButton($playerQuad,$listPlayer->login); $script->addProfileButton($playerQuad, $listPlayer->login);
// Description Label // Description Label
$descriptionLabel = new Label(); $descriptionLabel = new Label();
$frame->add($descriptionLabel); $frame->add($descriptionLabel);
@ -259,7 +258,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$descriptionLabel->setVisible(false); $descriptionLabel->setVisible(false);
$descriptionLabel->setText("View Player profile of " . $listPlayer->nickname); $descriptionLabel->setText("View Player profile of " . $listPlayer->nickname);
$script->addTooltip($playerQuad, $descriptionLabel); $script->addTooltip($playerQuad, $descriptionLabel);
switch ($listPlayer->authLevel) { switch ($listPlayer->authLevel) {
case authenticationManager::AUTH_LEVEL_MASTERADMIN: case authenticationManager::AUTH_LEVEL_MASTERADMIN:
$rightLabel->setText("MA"); $rightLabel->setText("MA");
@ -277,8 +276,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$rightLabel->setTextColor("fff"); $rightLabel->setTextColor("fff");
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) {
// Further Player actions Quad // Further Player actions Quad
$playerQuad = new Quad_Icons64x64_1(); $playerQuad = new Quad_Icons64x64_1();
$playerFrame->add($playerQuad); $playerFrame->add($playerQuad);
@ -287,7 +285,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy); $playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
$playerQuad->setSize(3.8, 3.8); $playerQuad->setSize(3.8, 3.8);
$playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login); $playerQuad->setAction(self::ACTION_PLAYER_ADV . "." . $listPlayer->login);
// Further Player actions Mousover Description // Further Player actions Mousover Description
$descriptionLabel = new Label(); $descriptionLabel = new Label();
$frame->add($descriptionLabel); $frame->add($descriptionLabel);
@ -380,6 +378,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
* @param $login * @param $login
*/ */
public function advancedPlayerWidget(Player $caller, $login) { public function advancedPlayerWidget(Player $caller, $login) {
if (!$caller) return;
$this->playersListShown[$caller->login] = $login; // Show a certain player $this->playersListShown[$caller->login] = $login; // Show a certain player
$this->showPlayerList($caller); // reopen playerlist $this->showPlayerList($caller); // reopen playerlist
} }
@ -622,48 +621,53 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
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) {
return;
}
$action = $actionArray[0] . "." . $actionArray[1];
$adminLogin = $callback[1][1];
$targetLogin = $actionArray[2];
// TODO maybe with ids instead of logins, lower network traffic switch ($action) {
switch ($actionArray[0] . "." . $actionArray[1]) {
case self::ACTION_FORCE_BLUE: case self::ACTION_FORCE_BLUE:
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($callback[1][1], $actionArray[2], $this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin,
playerActions::BLUE_TEAM); PlayerActions::BLUE_TEAM);
break; break;
case self::ACTION_FORCE_RED: case self::ACTION_FORCE_RED:
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($callback[1][1], $actionArray[2], $this->maniaControl->playerManager->playerActions->forcePlayerToTeam($adminLogin, $targetLogin,
playerActions::RED_TEAM); PlayerActions::RED_TEAM);
break; break;
case self::ACTION_FORCE_SPEC: case self::ACTION_FORCE_SPEC:
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($callback[1][1], $actionArray[2], $this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin,
playerActions::SPECTATOR_BUT_KEEP_SELECTABLE); PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
break; break;
case self::ACTION_WARN_PLAYER: case self::ACTION_WARN_PLAYER:
$this->maniaControl->playerManager->playerActions->warnPlayer($callback[1][1], $actionArray[2]); $this->maniaControl->playerManager->playerActions->warnPlayer($adminLogin, $targetLogin);
break; break;
case self::ACTION_KICK_PLAYER: case self::ACTION_KICK_PLAYER:
$this->maniaControl->playerManager->playerActions->kickPlayer($callback[1][1], $actionArray[2]); $this->maniaControl->playerManager->playerActions->kickPlayer($adminLogin, $targetLogin);
break; break;
case self::ACTION_BAN_PLAYER: case self::ACTION_BAN_PLAYER:
$this->maniaControl->playerManager->playerActions->banPlayer($callback[1][1], $actionArray[2]); $this->maniaControl->playerManager->playerActions->banPlayer($adminLogin, $targetLogin);
break; break;
case self::ACTION_PLAYER_ADV: case self::ACTION_PLAYER_ADV:
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$this->advancedPlayerWidget($player, $actionArray[2]); $this->advancedPlayerWidget($admin, $targetLogin);
break; break;
case self::ACTION_ADD_AS_MASTER: case self::ACTION_ADD_AS_MASTER:
$this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2], $this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
AuthenticationManager::AUTH_LEVEL_SUPERADMIN); AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
break; break;
case self::ACTION_ADD_AS_ADMIN: case self::ACTION_ADD_AS_ADMIN:
$this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2], $this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
AuthenticationManager::AUTH_LEVEL_ADMIN); AuthenticationManager::AUTH_LEVEL_ADMIN);
break; break;
case self::ACTION_ADD_AS_MOD: case self::ACTION_ADD_AS_MOD:
$this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2], $this->maniaControl->playerManager->playerActions->grandAuthLevel($adminLogin, $targetLogin,
AuthenticationManager::AUTH_LEVEL_OPERATOR); AuthenticationManager::AUTH_LEVEL_OPERATOR);
break; break;
case self::ACTION_REVOKE_RIGHTS: case self::ACTION_REVOKE_RIGHTS:
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($callback[1][1], $actionArray[2]); $this->maniaControl->playerManager->playerActions->revokeAuthLevel($adminLogin, $targetLogin);
break; break;
} }
} }