resolved todo

This commit is contained in:
kremsy 2014-01-10 13:28:48 +01:00
parent 7f0c33e45f
commit fd5d2e59e9
2 changed files with 80 additions and 86 deletions

View File

@ -2,9 +2,7 @@
namespace ManiaControl\Players; namespace ManiaControl\Players;
use FML\Controls\Quads\Quad_Icons128x128_1;
use FML\Controls\Quads\Quad_Icons128x32_1; use FML\Controls\Quads\Quad_Icons128x32_1;
use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Controls\Quads\Quad_UIConstruction_Buttons; use FML\Controls\Quads\Quad_UIConstruction_Buttons;
use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
@ -22,7 +20,6 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
*/ */
const ACTION_BALANCE_TEAMS = 'PlayerCommands.BalanceTeams'; const ACTION_BALANCE_TEAMS = 'PlayerCommands.BalanceTeams';
const ACTION_OPEN_PLAYERLIST = 'PlayerCommands.OpenPlayerList'; const ACTION_OPEN_PLAYERLIST = 'PlayerCommands.OpenPlayerList';
const ACTION_CANCEL_VOTE = 'PlayerCommands.CancelVote';
/** /**
* Private Properties * Private Properties
@ -53,8 +50,6 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
$this->maniaControl->commandManager->registerCommandListener('removebots', $this, 'command_RemoveFakePlayers', true); $this->maniaControl->commandManager->registerCommandListener('removebots', $this, 'command_RemoveFakePlayers', true);
$this->maniaControl->commandManager->registerCommandListener('mute', $this, 'command_MutePlayer', true); $this->maniaControl->commandManager->registerCommandListener('mute', $this, 'command_MutePlayer', true);
$this->maniaControl->commandManager->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true); $this->maniaControl->commandManager->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true);
// TODO: Move into another class
$this->maniaControl->commandManager->registerCommandListener('cancel', $this, 'command_CancelVote', true);
// Register for player chat commands // Register for player chat commands
$this->maniaControl->commandManager->registerCommandListener('player', $this, 'command_playerList'); $this->maniaControl->commandManager->registerCommandListener('player', $this, 'command_playerList');
@ -67,13 +62,6 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
$itemQuad->setAction(self::ACTION_BALANCE_TEAMS); $itemQuad->setAction(self::ACTION_BALANCE_TEAMS);
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 9, 'Balance Teams'); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 9, 'Balance Teams');
// Action cancel Vote
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CANCEL_VOTE, $this, 'command_cancelVote');
$itemQuad = new Quad_Icons64x64_1();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowRed);
$itemQuad->setAction(self::ACTION_CANCEL_VOTE);
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 6, 'Cancel Vote');
// Action Open Playerlist // Action Open Playerlist
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
$itemQuad = new Quad_UIConstruction_Buttons(); $itemQuad = new Quad_UIConstruction_Buttons();
@ -82,24 +70,6 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 15, 'Open Playerlist'); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 15, 'Open Playerlist');
} }
/**
* Handle //cancelvote command
*
* @param array $chatCallback
* @param Player $player
*/
public function command_CancelVote(array $chatCallback, Player $player) {
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
return;
}
$success = $this->maniaControl->client->query('CancelVote');
if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return;
}
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> canceled the Vote!');
}
/** /**
* Handle //teambalance command * Handle //teambalance command
@ -181,8 +151,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
if(isset($params[2]) && is_numeric($params[2])) { if(isset($params[2]) && is_numeric($params[2])) {
$type = (int)$params[2]; $type = (int)$params[2];
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin, $type); $this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin, $type);
} } else {
else {
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin); $this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin);
} }
} }

View File

@ -3,6 +3,7 @@
namespace ManiaControl\Server; namespace ManiaControl\Server;
use FML\Controls\Quads\Quad_Icons128x32_1; use FML\Controls\Quads\Quad_Icons128x32_1;
use FML\Controls\Quads\Quad_Icons64x64_1;
use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
@ -21,7 +22,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
* Constants * Constants
*/ */
const ACTION_SET_PAUSE = 'ServerCommands.SetPause'; const ACTION_SET_PAUSE = 'ServerCommands.SetPause';
const ACTION_CANCEL_VOTE = 'ServerCommands.CancelVote';
/** /**
* Private properties * Private properties
*/ */
@ -55,16 +56,40 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
$this->maniaControl->commandManager->registerCommandListener('enablehorns', $this, 'command_EnableHorns', true); $this->maniaControl->commandManager->registerCommandListener('enablehorns', $this, 'command_EnableHorns', true);
$this->maniaControl->commandManager->registerCommandListener('disablehorns', $this, 'command_DisableHorns', true); $this->maniaControl->commandManager->registerCommandListener('disablehorns', $this, 'command_DisableHorns', true);
$this->maniaControl->commandManager->registerCommandListener('cancel', $this, 'command_CancelVote', true);
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SET_PAUSE, $this, 'setPause'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SET_PAUSE, $this, 'setPause');
//TODO correct class?
// Set Pause // Set Pause
$itemQuad = new Quad_Icons128x32_1(); //TODO check if mode supports it $itemQuad = new Quad_Icons128x32_1(); //TODO check if mode supports it
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
$itemQuad->setAction(self::ACTION_SET_PAUSE); $itemQuad->setAction(self::ACTION_SET_PAUSE);
$this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 1, 'Pauses the current game.'); $this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 1, 'Pauses the current game.');
// Action cancel Vote
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CANCEL_VOTE, $this, 'command_cancelVote');
$itemQuad = new Quad_Icons64x64_1();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowRed);
$itemQuad->setAction(self::ACTION_CANCEL_VOTE);
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 6, 'Cancel Vote');
}
/**
* Handle //cancelvote command
*
* @param array $chatCallback
* @param Player $player
*/
public function command_CancelVote(array $chatCallback, Player $player) {
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player);
return;
}
$success = $this->maniaControl->client->query('CancelVote');
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return;
}
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> canceled the Vote!');
} }
/** /**