server teammode property
This commit is contained in:
parent
00529d111d
commit
e792c706c7
@ -5,16 +5,18 @@ namespace ManiaControl\Players;
|
|||||||
use FML\Controls\Quads\Quad_Icons128x32_1;
|
use FML\Controls\Quads\Quad_Icons128x32_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\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
|
use ManiaControl\Server\Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class offering various Admin Commands related to Players
|
* Class offering various Admin Commands related to Players
|
||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, CallbackListener {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* 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_ADD_BOT, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
|
|
||||||
// Action Balance Teams
|
//CallbackManager
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
$this->maniaControl->callbackManager->registerCallbackListener(Server::CB_TEAM_STATUS_CHANGED, $this, 'teamStatusChanged');
|
||||||
$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');
|
|
||||||
|
|
||||||
// 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');
|
||||||
@ -76,6 +74,22 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 15, 'Open Playerlist');
|
$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
|
* Handle //teambalance command
|
||||||
|
@ -277,29 +277,31 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
// 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
|
if($this->maniaControl->server->isTeamMode()){
|
||||||
$redQuad = new Quad_Emblems();
|
// Force to Red-Team Quad
|
||||||
$playerFrame->add($redQuad);
|
$redQuad = new Quad_Emblems();
|
||||||
$redQuad->setX($x + 145);
|
$playerFrame->add($redQuad);
|
||||||
$redQuad->setZ(0.1);
|
$redQuad->setX($x + 145);
|
||||||
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
$redQuad->setZ(0.1);
|
||||||
$redQuad->setSize(3.8, 3.8);
|
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
|
||||||
$redQuad->setAction(self::ACTION_FORCE_RED . "." . $listPlayer->login);
|
$redQuad->setSize(3.8, 3.8);
|
||||||
|
$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();
|
||||||
$playerFrame->add($blueQuad);
|
$playerFrame->add($blueQuad);
|
||||||
$blueQuad->setX($x + 141);
|
$blueQuad->setX($x + 141);
|
||||||
$blueQuad->setZ(0.1);
|
$blueQuad->setZ(0.1);
|
||||||
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
$blueQuad->setSubStyle($blueQuad::SUBSTYLE_1);
|
||||||
$blueQuad->setSize(3.8, 3.8);
|
$blueQuad->setSize(3.8, 3.8);
|
||||||
$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();
|
||||||
|
@ -128,6 +128,11 @@ class PlayerManager implements CallbackListener {
|
|||||||
|
|
||||||
$playerItem->hoursSinceZoneInscription = $detailedPlayerInfo->hoursSinceZoneInscription;
|
$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 = new Player($playerItem);
|
||||||
$player->hasJoinedGame = true;
|
$player->hasJoinedGame = true;
|
||||||
$this->addPlayer($player);
|
$this->addPlayer($player);
|
||||||
@ -186,8 +191,14 @@ class PlayerManager implements CallbackListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$player->teamId = $callback[1][0]["TeamId"];
|
|
||||||
$player->ladderRank = $callback[1][0]["LadderRanking"];
|
$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;
|
$prevJoinState = $player->hasJoinedGame;
|
||||||
|
|
||||||
@ -316,7 +327,7 @@ class PlayerManager implements CallbackListener {
|
|||||||
if (!isset($row)) {
|
if (!isset($row)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$player = new Player(false);
|
$player = new Player(false);
|
||||||
$player->index = $playerIndex;
|
$player->index = $playerIndex;
|
||||||
$player->login = $row->login;
|
$player->login = $row->login;
|
||||||
|
@ -18,7 +18,8 @@ class Server implements CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const TABLE_SERVERS = 'mc_servers';
|
const TABLE_SERVERS = 'mc_servers';
|
||||||
|
const CB_TEAM_STATUS_CHANGED = 'ServerCallback.TeamStatusChanged';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Properties
|
* Public Properties
|
||||||
@ -33,10 +34,12 @@ class Server implements CallbackListener {
|
|||||||
public $serverCommands = null;
|
public $serverCommands = null;
|
||||||
public $usageReporter = null;
|
public $usageReporter = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
private $teamMode = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Server
|
* Construct a new Server
|
||||||
@ -126,6 +129,28 @@ class Server implements CallbackListener {
|
|||||||
$this->updateProperties();
|
$this->updateProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set if the Server Runs a Team-Mode or not
|
||||||
|
*
|
||||||
|
* @param bool $teamMode
|
||||||
|
*/
|
||||||
|
public function setTeamMode($teamMode = true) {
|
||||||
|
$this->teamMode = $teamMode;
|
||||||
|
|
||||||
|
// Trigger callback
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_TEAM_STATUS_CHANGED, array(self::CB_TEAM_STATUS_CHANGED, $teamMode));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the Server Runs a TeamMode
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isTeamMode() {
|
||||||
|
return $this->teamMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch Game Data Directory
|
* Fetch Game Data Directory
|
||||||
*
|
*
|
||||||
|
@ -83,7 +83,6 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
|
|
||||||
//Check if Pause exists in current GameMode
|
//Check if Pause exists in current GameMode
|
||||||
$scriptInfos = $this->maniaControl->client->getModeScriptInfo();
|
$scriptInfos = $this->maniaControl->client->getModeScriptInfo();
|
||||||
|
|
||||||
$pauseExists = false;
|
$pauseExists = false;
|
||||||
foreach($scriptInfos->commandDescs as $param) {
|
foreach($scriptInfos->commandDescs as $param) {
|
||||||
if ($param->name == "Command_ForceWarmUp") {
|
if ($param->name == "Command_ForceWarmUp") {
|
||||||
@ -122,6 +121,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 30, 'Cancel Vote');
|
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 30, 'Cancel Vote');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //cancelvote command
|
* Handle //cancelvote command
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user