server teammode property

This commit is contained in:
kremsy
2014-02-01 19:06:21 +01:00
committed by Steffen Schröder
parent 00529d111d
commit e792c706c7
5 changed files with 83 additions and 31 deletions

View File

@ -5,16 +5,18 @@ namespace ManiaControl\Players;
use FML\Controls\Quads\Quad_Icons128x32_1;
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Server\Server;
/**
* Class offering various Admin Commands related to Players
*
* @author steeffeen & kremsy
*/
class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, CallbackListener {
/**
* Constants
*/
@ -61,12 +63,8 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_ADD_BOT, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
// Action Balance Teams
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
$itemQuad = new Quad_Icons128x32_1();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
$itemQuad->setAction(self::ACTION_BALANCE_TEAMS);
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 40, 'Balance Teams');
//CallbackManager
$this->maniaControl->callbackManager->registerCallbackListener(Server::CB_TEAM_STATUS_CHANGED, $this, 'teamStatusChanged');
// Action Open Playerlist
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
@ -76,6 +74,22 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 15, 'Open Playerlist');
}
/**
* Handle TeamStatusChanged
* @param array $callback
*/
public function teamStatusChanged(array $callback) {
$status = $callback[1];
//Add Balance Team Icon if it's a teamMode
if ($status) {
// Action Balance Teams
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
$itemQuad = new Quad_Icons128x32_1();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
$itemQuad->setAction(self::ACTION_BALANCE_TEAMS);
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 40, 'Balance Teams');
}
}
/**
* Handle //teambalance command

View File

@ -277,29 +277,31 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
// Description Label
$script->addTooltip($playerQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Advanced Player Actions on " . $listPlayer->nickname));
// Force to Red-Team Quad
$redQuad = new Quad_Emblems();
$playerFrame->add($redQuad);
$redQuad->setX($x + 145);
$redQuad->setZ(0.1);
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
$redQuad->setSize(3.8, 3.8);
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
if($this->maniaControl->server->isTeamMode()){
// Force to Red-Team Quad
$redQuad = new Quad_Emblems();
$playerFrame->add($redQuad);
$redQuad->setX($x + 145);
$redQuad->setZ(0.1);
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
$redQuad->setSize(3.8, 3.8);
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
// Force to Red-Team Description Label
$script->addTooltip($redQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Red Team!'));
// Force to Red-Team Description Label
$script->addTooltip($redQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Red Team!'));
// Force to Blue-Team Quad
$blueQuad = new Quad_Emblems();
$playerFrame->add($blueQuad);
$blueQuad->setX($x + 141);
$blueQuad->setZ(0.1);
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
$blueQuad->setSize(3.8, 3.8);
$blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login);
// Force to Blue-Team Quad
$blueQuad = new Quad_Emblems();
$playerFrame->add($blueQuad);
$blueQuad->setX($x + 141);
$blueQuad->setZ(0.1);
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
$blueQuad->setSize(3.8, 3.8);
$blueQuad->setAction(self::ACTION_FORCE_BLUE . "." . $listPlayer->login);
// Force to Blue-Team Description Label
$script->addTooltip($blueQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Blue Team!'));
// Force to Blue-Team Description Label
$script->addTooltip($blueQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Force " . $listPlayer->nickname . '$z to Blue Team!'));
}
// Force to Spectator Quad
$spectatorQuad = new Quad_BgRaceScore2();

View File

@ -128,6 +128,11 @@ class PlayerManager implements CallbackListener {
$playerItem->hoursSinceZoneInscription = $detailedPlayerInfo->hoursSinceZoneInscription;
//Check if the Player is in a Team, to notify if its a TeamMode or not
if ($playerItem->teamId != -1) {
$this->maniaControl->server->setTeamMode(true);
}
$player = new Player($playerItem);
$player->hasJoinedGame = true;
$this->addPlayer($player);
@ -186,8 +191,14 @@ class PlayerManager implements CallbackListener {
return;
}
$player->teamId = $callback[1][0]["TeamId"];
$player->ladderRank = $callback[1][0]["LadderRanking"];
$player->teamId = $callback[1][0]["TeamId"];
//Check if the Player is in a Team, to notify if its a TeamMode or not
if ($player->teamId != -1) {
$this->maniaControl->server->setTeamMode(true);
}
$prevJoinState = $player->hasJoinedGame;
@ -316,7 +327,7 @@ class PlayerManager implements CallbackListener {
if (!isset($row)) {
return null;
}
$player = new Player(false);
$player->index = $playerIndex;
$player->login = $row->login;