2013-12-18 15:48:33 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Players;
|
|
|
|
|
2013-12-19 21:59:10 +01:00
|
|
|
use FML\Controls\Control;
|
2013-12-18 15:48:33 +01:00
|
|
|
use FML\Controls\Frame;
|
2013-12-19 21:59:10 +01:00
|
|
|
use FML\Controls\Label;
|
2013-12-23 19:13:59 +01:00
|
|
|
use FML\Controls\Labels\Label_Button;
|
2013-12-18 23:35:33 +01:00
|
|
|
use FML\Controls\Labels\Label_Text;
|
2013-12-18 15:48:33 +01:00
|
|
|
use FML\Controls\Quad;
|
|
|
|
use FML\Controls\Quads\Quad_BgRaceScore2;
|
2013-12-23 19:13:59 +01:00
|
|
|
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
2013-12-19 21:59:10 +01:00
|
|
|
use FML\Controls\Quads\Quad_Emblems;
|
2013-12-18 15:48:33 +01:00
|
|
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
|
|
|
use FML\ManiaLink;
|
2013-12-19 21:59:10 +01:00
|
|
|
use FML\Script\Script;
|
|
|
|
use FML\Script\Tooltips;
|
2013-12-18 23:35:33 +01:00
|
|
|
use ManiaControl\Admin\AuthenticationManager;
|
2013-12-18 15:48:33 +01:00
|
|
|
use ManiaControl\Callbacks\CallbackListener;
|
2013-12-19 21:59:10 +01:00
|
|
|
use ManiaControl\Callbacks\CallbackManager;
|
2013-12-24 13:27:59 +01:00
|
|
|
use ManiaControl\Formatter;
|
2013-12-18 15:48:33 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use ManiaControl\Manialinks\ManialinkManager;
|
|
|
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
|
|
|
|
2013-12-24 13:09:39 +01:00
|
|
|
/**
|
|
|
|
* PlayerList Widget Class
|
|
|
|
*
|
|
|
|
* @author steeffeen & kremsy
|
|
|
|
*/
|
2013-12-18 15:48:33 +01:00
|
|
|
class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constants
|
|
|
|
*/
|
2013-12-19 21:59:10 +01:00
|
|
|
const ACTION_FORCE_RED = 'PlayerList.ForceRed';
|
|
|
|
const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue';
|
|
|
|
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
|
2013-12-23 19:13:59 +01:00
|
|
|
|
|
|
|
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
|
|
|
|
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
|
2013-12-23 21:47:39 +01:00
|
|
|
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
|
|
|
|
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
|
|
|
|
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
|
|
|
|
const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster';
|
|
|
|
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
|
|
|
|
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
|
2013-12-26 11:25:10 +01:00
|
|
|
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
|
2013-12-23 19:13:59 +01:00
|
|
|
|
2013-12-26 17:27:21 +01:00
|
|
|
const SHOWN_MAIN_WINDOW = -1;
|
2013-12-18 15:48:33 +01:00
|
|
|
/**
|
|
|
|
* Private properties
|
|
|
|
*/
|
|
|
|
private $maniaControl = null;
|
|
|
|
private $width;
|
|
|
|
private $height;
|
|
|
|
private $quadStyle;
|
|
|
|
private $quadSubstyle;
|
2013-12-19 21:59:10 +01:00
|
|
|
private $playersListShown = array();
|
2013-12-18 15:48:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new server commands instance
|
|
|
|
*
|
|
|
|
* @param ManiaControl $maniaControl
|
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
|
|
|
|
2013-12-24 13:05:10 +01:00
|
|
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this,
|
2013-12-18 15:48:33 +01:00
|
|
|
'closeWidget');
|
2013-12-23 19:13:59 +01:00
|
|
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV , $this,
|
|
|
|
'closePlayerAdvancedWidget');
|
2013-12-19 21:59:10 +01:00
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
|
|
|
'handleManialinkPageAnswer');
|
2013-12-23 21:52:30 +01:00
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'updateWidget');
|
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'updateWidget');
|
2013-12-26 11:35:59 +01:00
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
2013-12-18 15:48:33 +01:00
|
|
|
//settings
|
|
|
|
$this->width = 150;
|
|
|
|
$this->height = 80;
|
|
|
|
$this->quadStyle = Quad_BgRaceScore2::STYLE; //TODO add default menu style to style manager
|
|
|
|
$this->quadSubstyle = Quad_BgRaceScore2::SUBSTYLE_HandleSelectable;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-12-26 17:27:21 +01:00
|
|
|
public function addPlayerToShownList(Player $player, $showStatus = self::SHOWN_MAIN_WINDOW){
|
|
|
|
$this->playersListShown[$player->login] = $showStatus;
|
|
|
|
}
|
2013-12-19 21:59:10 +01:00
|
|
|
|
2013-12-26 17:27:21 +01:00
|
|
|
public function showPlayerList(Player $player){
|
2013-12-18 15:48:33 +01:00
|
|
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
|
|
|
|
2013-12-19 21:59:10 +01:00
|
|
|
// Create script and features
|
|
|
|
$script = new Script();
|
|
|
|
$maniaLink->setScript($script);
|
|
|
|
|
|
|
|
$tooltips = new Tooltips();
|
|
|
|
$script->addFeature($tooltips);
|
|
|
|
|
2013-12-18 15:48:33 +01:00
|
|
|
//mainframe
|
|
|
|
$frame = new Frame();
|
|
|
|
$maniaLink->add($frame);
|
|
|
|
$frame->setSize($this->width,$this->height);
|
|
|
|
$frame->setPosition(0, 0);
|
|
|
|
|
|
|
|
//Background Quad
|
|
|
|
$backgroundQuad = new Quad();
|
|
|
|
$frame->add($backgroundQuad);
|
|
|
|
$backgroundQuad->setSize($this->width,$this->height);
|
|
|
|
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle);
|
|
|
|
|
|
|
|
// Add Close Quad (X)
|
|
|
|
$closeQuad = new Quad_Icons64x64_1();
|
|
|
|
$frame->add($closeQuad);
|
|
|
|
$closeQuad->setPosition($this->width * 0.483, $this->height * 0.467, 3);
|
|
|
|
$closeQuad->setSize(6, 6);
|
|
|
|
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
2013-12-24 13:05:10 +01:00
|
|
|
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
2013-12-18 15:48:33 +01:00
|
|
|
|
|
|
|
//Start offsets
|
|
|
|
$x = -$this->width / 2;
|
|
|
|
$y = $this->height / 2;
|
|
|
|
|
|
|
|
//Headline
|
|
|
|
$headFrame = new Frame();
|
|
|
|
$frame->add($headFrame);
|
2013-12-19 21:59:10 +01:00
|
|
|
$headFrame->setY($y - 5);
|
2013-12-18 15:48:33 +01:00
|
|
|
//$array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
|
2013-12-19 21:59:10 +01:00
|
|
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)){
|
|
|
|
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91, "Actions" => $x + 135);
|
|
|
|
}else{
|
|
|
|
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91);
|
|
|
|
}
|
2013-12-18 15:48:33 +01:00
|
|
|
$this->maniaControl->manialinkManager->labelLine($headFrame,$array);
|
|
|
|
|
|
|
|
//get PlayerList
|
|
|
|
$players = $this->maniaControl->playerManager->getPlayers();
|
|
|
|
|
|
|
|
$i = 1;
|
|
|
|
$y -= 10;
|
|
|
|
foreach($players as $listPlayer){
|
2013-12-24 13:27:59 +01:00
|
|
|
|
2013-12-18 15:48:33 +01:00
|
|
|
//$path = substr($listPlayer->path, 6);
|
2013-12-19 21:59:10 +01:00
|
|
|
//$path = $listPlayer->getCountry() . " - " . $listPlayer->getProvince();
|
|
|
|
$path = $listPlayer->getProvince();
|
2013-12-18 15:48:33 +01:00
|
|
|
$playerFrame = new Frame();
|
|
|
|
$frame->add($playerFrame);
|
|
|
|
//$array = array($i => $x + 5, $listPlayer->nickname => $x + 10, $listPlayer->login => $x + 50, $listPlayer->ladderRank => $x + 60, $listPlayer->ladderScore => $x + 70, $path => $x + 85);
|
2013-12-19 21:59:10 +01:00
|
|
|
$array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 60, $path => $x + 91);
|
2013-12-18 15:48:33 +01:00
|
|
|
$this->maniaControl->manialinkManager->labelLine($playerFrame,$array);
|
|
|
|
$playerFrame->setY($y);
|
|
|
|
|
2013-12-19 21:59:10 +01:00
|
|
|
//Team Emblem
|
2013-12-19 22:29:21 +01:00
|
|
|
if($listPlayer->teamId >= 0){ //Player is in a Team
|
2013-12-19 21:59:10 +01:00
|
|
|
$redQuad = new Quad_Emblems(); //TODO rename quads
|
|
|
|
$playerFrame->add($redQuad);
|
|
|
|
$redQuad->setX($x + 10);
|
|
|
|
$redQuad->setZ(0.1);
|
|
|
|
$redQuad->setSize(3.8,3.8);
|
|
|
|
|
|
|
|
switch($listPlayer->teamId){
|
|
|
|
case 0: $redQuad->setSubStyle($redQuad::SUBSTYLE_1); break;
|
|
|
|
case 1: $redQuad->setSubStyle($redQuad::SUBSTYLE_2); break;
|
2013-12-18 23:35:33 +01:00
|
|
|
}
|
2013-12-19 22:29:21 +01:00
|
|
|
}else if($listPlayer->isSpectator){ //Player is in Spectator Mode
|
2013-12-19 21:59:10 +01:00
|
|
|
$neutralQuad = new Quad_BgRaceScore2();
|
|
|
|
$playerFrame->add($neutralQuad);
|
|
|
|
$neutralQuad->setX($x + 10);
|
|
|
|
$neutralQuad->setZ(0.1);
|
|
|
|
$neutralQuad->setSubStyle($neutralQuad::SUBSTYLE_Spectator);
|
|
|
|
$neutralQuad->setSize(3.8,3.8);
|
|
|
|
}
|
|
|
|
|
2013-12-26 11:28:58 +01:00
|
|
|
|
2013-12-19 21:59:10 +01:00
|
|
|
//Nation Quad
|
|
|
|
$countryQuad = new Quad();
|
|
|
|
$playerFrame->add($countryQuad);
|
2013-12-26 11:28:58 +01:00
|
|
|
$countryCode = Formatter::mapCountry($listPlayer->getCountry());
|
|
|
|
$countryQuad->setImage("file://Skins/Avatars/Flags/{$countryCode}.dds");
|
2013-12-19 21:59:10 +01:00
|
|
|
$countryQuad->setX($x + 88);
|
|
|
|
$countryQuad->setSize(4,4);
|
|
|
|
$countryQuad->setZ(-0.1);
|
2013-12-23 16:14:03 +01:00
|
|
|
//TODO mousover show locations in descript bar
|
|
|
|
|
2013-12-19 21:59:10 +01:00
|
|
|
|
|
|
|
//Level Quad
|
|
|
|
$rightQuad = new Quad_BgRaceScore2();
|
|
|
|
$playerFrame->add($rightQuad);
|
|
|
|
$rightQuad->setX($x + 13);
|
|
|
|
$rightQuad->setZ(-0.1);
|
|
|
|
$rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher);
|
|
|
|
$rightQuad->setSize(7,3.5);
|
|
|
|
|
|
|
|
$rightLabel = new Label_Text();
|
|
|
|
$playerFrame->add($rightLabel);
|
|
|
|
$rightLabel->setX($x + 13.9);
|
|
|
|
$rightLabel->setTextSize(0.8);
|
|
|
|
|
2013-12-18 23:35:33 +01:00
|
|
|
|
2013-12-19 21:59:10 +01:00
|
|
|
//Description Label
|
|
|
|
$descriptionLabel = new Label();
|
|
|
|
$frame->add($descriptionLabel);
|
|
|
|
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
|
|
|
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
|
|
|
|
$descriptionLabel->setSize($this->width * 0.7, 4);
|
|
|
|
$descriptionLabel->setTextSize(2);
|
|
|
|
$descriptionLabel->setVisible(false);
|
2013-12-23 19:13:59 +01:00
|
|
|
$descriptionLabel->setText($this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " . $listPlayer->nickname);
|
2013-12-19 21:59:10 +01:00
|
|
|
$tooltips->add($rightQuad, $descriptionLabel);
|
|
|
|
|
|
|
|
switch($listPlayer->authLevel){
|
|
|
|
case authenticationManager::AUTH_LEVEL_MASTERADMIN:
|
|
|
|
case authenticationManager::AUTH_LEVEL_SUPERADMIN: $rightLabel->setText("MA"); break;
|
|
|
|
case authenticationManager::AUTH_LEVEL_ADMIN: $rightLabel->setText("AD"); break;
|
2013-12-27 21:10:53 +01:00
|
|
|
case authenticationManager::AUTH_LEVEL_OPERATOR: $rightLabel->setText("MOD");
|
2013-12-19 21:59:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$rightLabel->setTextColor("fff");
|
|
|
|
|
|
|
|
|
|
|
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)){
|
|
|
|
|
2013-12-26 17:45:15 +01:00
|
|
|
//Further Player actions Quad
|
2013-12-19 21:59:10 +01:00
|
|
|
$playerQuad = new Quad_Icons64x64_1();
|
|
|
|
$playerFrame->add($playerQuad);
|
|
|
|
$playerQuad->setX($x + 132);
|
|
|
|
$playerQuad->setZ(0.1);
|
|
|
|
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
|
|
|
$playerQuad->setSize(3.8,3.8);
|
2013-12-23 19:13:59 +01:00
|
|
|
$playerQuad->setAction(self::ACTION_PLAYER_ADV . "." .$listPlayer->login);
|
2013-12-23 16:14:03 +01:00
|
|
|
|
2013-12-26 17:45:15 +01:00
|
|
|
//Further Player actions Mousover Description
|
|
|
|
$descriptionLabel = new Label();
|
|
|
|
$frame->add($descriptionLabel);
|
|
|
|
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
|
|
|
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
|
|
|
|
$descriptionLabel->setSize($this->width * 0.7, 4);
|
|
|
|
$descriptionLabel->setTextSize(2);
|
|
|
|
$descriptionLabel->setVisible(false);
|
|
|
|
$descriptionLabel->setText("Advanced Player Actions on " . $listPlayer->nickname);
|
|
|
|
$tooltips->add($playerQuad, $descriptionLabel);
|
2013-12-19 21:59:10 +01:00
|
|
|
|
2013-12-26 17:45:15 +01:00
|
|
|
//Force to Red-Team Quad
|
2013-12-19 21:59:10 +01:00
|
|
|
$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);
|
|
|
|
|
2013-12-26 17:45:15 +01:00
|
|
|
//Force to Red-Team Description Label
|
2013-12-19 21:59:10 +01:00
|
|
|
$descriptionLabel = new Label();
|
|
|
|
$frame->add($descriptionLabel);
|
|
|
|
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
|
|
|
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
|
|
|
|
$descriptionLabel->setSize($this->width * 0.7, 4);
|
|
|
|
$descriptionLabel->setTextSize(2);
|
|
|
|
$descriptionLabel->setVisible(false);
|
|
|
|
$descriptionLabel->setText("Force " . $listPlayer->nickname . '$z to Red Team!');
|
|
|
|
$tooltips->add($redQuad, $descriptionLabel);
|
|
|
|
|
2013-12-26 17:45:15 +01:00
|
|
|
//Force to Blue-Team Quad
|
2013-12-19 21:59:10 +01:00
|
|
|
$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);
|
|
|
|
|
2013-12-26 17:45:15 +01:00
|
|
|
//Force to Blue-Team Description Label
|
2013-12-19 21:59:10 +01:00
|
|
|
$descriptionLabel = new Label();
|
|
|
|
$frame->add($descriptionLabel);
|
|
|
|
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
|
|
|
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
|
|
|
|
$descriptionLabel->setSize($this->width * 0.7, 4);
|
|
|
|
$descriptionLabel->setTextSize(2);
|
|
|
|
$descriptionLabel->setVisible(false);
|
|
|
|
$descriptionLabel->setText("Force " . $listPlayer->nickname . '$z to Blue Team!');
|
|
|
|
$tooltips->add($blueQuad, $descriptionLabel);
|
|
|
|
|
2013-12-26 17:45:15 +01:00
|
|
|
//Force to Spectator Quad
|
2013-12-19 21:59:10 +01:00
|
|
|
$spectatorQuad = new Quad_BgRaceScore2();
|
|
|
|
$playerFrame->add($spectatorQuad);
|
|
|
|
$spectatorQuad->setX($x + 137);
|
|
|
|
$spectatorQuad->setZ(0.1);
|
|
|
|
$spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator);
|
|
|
|
$spectatorQuad->setSize(3.8,3.8);
|
|
|
|
$spectatorQuad->setAction(self::ACTION_FORCE_SPEC . "." .$listPlayer->login);
|
|
|
|
|
2013-12-26 17:45:15 +01:00
|
|
|
//Force to Spectator Description Label
|
2013-12-19 21:59:10 +01:00
|
|
|
$descriptionLabel = new Label();
|
|
|
|
$frame->add($descriptionLabel);
|
|
|
|
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
|
|
|
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
|
|
|
|
$descriptionLabel->setSize($this->width * 0.7, 4);
|
|
|
|
$descriptionLabel->setTextSize(2);
|
|
|
|
$descriptionLabel->setVisible(false);
|
|
|
|
$descriptionLabel->setText("Force " . $listPlayer->nickname . '$z to Spectator!');
|
|
|
|
$tooltips->add($spectatorQuad, $descriptionLabel);
|
2013-12-18 23:35:33 +01:00
|
|
|
}
|
2013-12-18 15:48:33 +01:00
|
|
|
$i++;
|
|
|
|
$y -= 4;
|
|
|
|
}
|
|
|
|
|
2013-12-26 17:27:21 +01:00
|
|
|
//show advanced window
|
|
|
|
if($this->playersListShown[$player->login] != self::SHOWN_MAIN_WINDOW){
|
2013-12-26 17:45:15 +01:00
|
|
|
$frame = $this->showAdvancedPlayerWidget($this->playersListShown[$player->login]);
|
2013-12-26 17:27:21 +01:00
|
|
|
$maniaLink->add($frame);
|
|
|
|
}
|
|
|
|
|
2013-12-18 15:48:33 +01:00
|
|
|
//render and display xml
|
|
|
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
2013-12-23 19:13:59 +01:00
|
|
|
|
|
|
|
return $maniaLink;
|
2013-12-18 15:48:33 +01:00
|
|
|
}
|
|
|
|
|
2013-12-26 17:27:21 +01:00
|
|
|
/**
|
|
|
|
* Displays the Advanced Player Window
|
|
|
|
* @param Player $caller
|
|
|
|
* @param $login
|
|
|
|
*/
|
|
|
|
public function advancedPlayerWidget(Player $caller, $login){
|
|
|
|
$this->playersListShown[$caller->login] = $login; //Show a certain player
|
|
|
|
$this->showPlayerList($caller); //reoppen playerlist
|
|
|
|
}
|
|
|
|
|
2013-12-23 19:13:59 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Extra window with special actions on players like warn,kick, ban, authorization levels...
|
|
|
|
* @param $login
|
2013-12-26 17:27:21 +01:00
|
|
|
* @return Frame
|
2013-12-23 19:13:59 +01:00
|
|
|
*/
|
2013-12-26 17:45:15 +01:00
|
|
|
public function showAdvancedPlayerWidget($login){
|
2013-12-23 19:13:59 +01:00
|
|
|
//todo all configurable or as constants
|
|
|
|
$x = $this->width / 2 + 2.5;
|
|
|
|
$width = 35;
|
2013-12-26 11:25:10 +01:00
|
|
|
$height = $this->height * 0.7;
|
2013-12-23 19:13:59 +01:00
|
|
|
$hAlign = Control::LEFT;
|
|
|
|
$style = Label_Text::STYLE_TextCardSmall;
|
|
|
|
$textSize = 1.5;
|
|
|
|
$textColor = 'FFF';
|
2013-12-26 11:25:10 +01:00
|
|
|
$quadWidth = $width - 7;
|
2013-12-23 19:13:59 +01:00
|
|
|
|
|
|
|
//mainframe
|
|
|
|
$frame = new Frame();
|
|
|
|
$frame->setSize($width,$height);
|
|
|
|
$frame->setPosition($x + $width / 2, 0);
|
|
|
|
|
|
|
|
// Add Close Quad (X)
|
|
|
|
$closeQuad = new Quad_Icons64x64_1();
|
|
|
|
$frame->add($closeQuad);
|
|
|
|
$closeQuad->setPosition($width * 0.4, $height * 0.43, 3);
|
|
|
|
$closeQuad->setSize(6, 6);
|
|
|
|
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
|
|
|
$closeQuad->setAction(self::ACTION_CLOSE_PLAYER_ADV );
|
|
|
|
|
|
|
|
//Background Quad
|
|
|
|
$backgroundQuad = new Quad();
|
|
|
|
$frame->add($backgroundQuad);
|
|
|
|
$backgroundQuad->setSize($width,$height);
|
|
|
|
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle);
|
|
|
|
$backgroundQuad->setZ(0.1);
|
|
|
|
|
|
|
|
//Show headline
|
|
|
|
$label = new Label_Text();
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setHAlign($hAlign);
|
|
|
|
$label->setX(-$width / 2 + 5);
|
|
|
|
$label->setY($height / 2 - 5);
|
|
|
|
$label->setStyle($style);
|
|
|
|
$label->setTextSize($textSize);
|
|
|
|
$label->setText("Advanced Actions");
|
|
|
|
$label->setTextColor($textColor);
|
|
|
|
|
|
|
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
|
|
|
|
|
|
//Show Nickname
|
|
|
|
$label = new Label_Text();
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setHAlign($hAlign);
|
|
|
|
$label->setX(0);
|
|
|
|
$label->setAlign(Control::CENTER,Control::CENTER);
|
|
|
|
$label->setY($height / 2 - 8);
|
|
|
|
$label->setStyle($style);
|
|
|
|
$label->setTextSize($textSize);
|
|
|
|
$label->setText($player->nickname);
|
|
|
|
$label->setTextColor($textColor);
|
|
|
|
|
|
|
|
$y = $height / 2 - 14;
|
|
|
|
//Show Warn
|
|
|
|
$quad = new Quad_BgsPlayerCard();
|
|
|
|
$frame->add($quad);
|
|
|
|
$quad->setX(0);
|
|
|
|
$quad->setY($y);
|
2013-12-26 17:27:21 +01:00
|
|
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
2013-12-26 11:25:10 +01:00
|
|
|
$quad->setSize($quadWidth, 5);
|
2013-12-23 19:13:59 +01:00
|
|
|
$quad->setAction(self::ACTION_WARN_PLAYER . "." .$login);
|
|
|
|
|
|
|
|
$label = new Label_Button();
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setX(0);
|
|
|
|
$label->setAlign(Control::CENTER,Control::CENTER);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setStyle($style);
|
|
|
|
$label->setTextSize($textSize);
|
|
|
|
$label->setText("Warn");
|
|
|
|
$label->setTextColor($textColor);
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
//Show Kick
|
|
|
|
$quad = new Quad_BgsPlayerCard();
|
|
|
|
$frame->add($quad);
|
|
|
|
$quad->setX(0);
|
|
|
|
$quad->setY($y);
|
2013-12-26 17:27:21 +01:00
|
|
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
2013-12-26 11:25:10 +01:00
|
|
|
$quad->setSize($quadWidth, 5);
|
2013-12-23 19:13:59 +01:00
|
|
|
$quad->setAction(self::ACTION_KICK_PLAYER . "." .$login);
|
|
|
|
|
|
|
|
$label = new Label_Button();
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setAlign(Control::CENTER,Control::CENTER);
|
|
|
|
$label->setX(0);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setStyle($style);
|
|
|
|
$label->setTextSize($textSize);
|
|
|
|
$label->setText("Kick");
|
|
|
|
$label->setTextColor($textColor);
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
//Show Ban
|
|
|
|
$quad = new Quad_BgsPlayerCard();
|
|
|
|
$frame->add($quad);
|
|
|
|
$quad->setX(0);
|
|
|
|
$quad->setY($y);
|
2013-12-26 17:27:21 +01:00
|
|
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
2013-12-26 11:25:10 +01:00
|
|
|
$quad->setSize($quadWidth, 5);
|
2013-12-23 19:13:59 +01:00
|
|
|
$quad->setAction(self::ACTION_BAN_PLAYER . "." .$login);
|
|
|
|
|
|
|
|
$label = new Label_Button();
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setAlign(Control::CENTER,Control::CENTER);
|
|
|
|
$label->setX(0);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setStyle($style);
|
|
|
|
$label->setTextSize($textSize);
|
|
|
|
$label->setText("Ban");
|
|
|
|
$label->setTextColor($textColor);
|
|
|
|
|
|
|
|
$y -= 10;
|
|
|
|
//Show Add as Master-Admin
|
|
|
|
$quad = new Quad_BgsPlayerCard();
|
|
|
|
$frame->add($quad);
|
|
|
|
$quad->setX(0);
|
|
|
|
$quad->setY($y);
|
2013-12-26 17:27:21 +01:00
|
|
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
2013-12-26 11:25:10 +01:00
|
|
|
$quad->setSize($quadWidth, 5);
|
2013-12-23 19:13:59 +01:00
|
|
|
$quad->setAction(self::ACTION_ADD_AS_MASTER . "." .$login);
|
|
|
|
|
|
|
|
$label = new Label_Button();
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setAlign(Control::CENTER,Control::CENTER);
|
|
|
|
$label->setX(0);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setStyle($style);
|
|
|
|
$label->setTextSize($textSize);
|
2013-12-26 11:25:10 +01:00
|
|
|
|
2013-12-23 19:13:59 +01:00
|
|
|
$label->setText("Add MasterAdmin");
|
2013-12-26 11:25:10 +01:00
|
|
|
|
2013-12-23 19:13:59 +01:00
|
|
|
$label->setTextColor($textColor);
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
//Show Add as Admin
|
|
|
|
$quad = new Quad_BgsPlayerCard();
|
|
|
|
$frame->add($quad);
|
|
|
|
$quad->setX(0);
|
|
|
|
$quad->setY($y);
|
2013-12-26 17:27:21 +01:00
|
|
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
2013-12-26 11:25:10 +01:00
|
|
|
$quad->setSize($quadWidth, 5);
|
2013-12-23 19:13:59 +01:00
|
|
|
$quad->setAction(self::ACTION_ADD_AS_ADMIN . "." .$login);
|
|
|
|
|
|
|
|
$label = new Label_Button();
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setAlign(Control::CENTER,Control::CENTER);
|
|
|
|
$label->setX(0);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setStyle($style);
|
|
|
|
$label->setTextSize($textSize);
|
|
|
|
$label->setText("Add Admin");
|
|
|
|
$label->setTextColor($textColor);
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
//Show Add as Moderator
|
|
|
|
$quad = new Quad_BgsPlayerCard();
|
|
|
|
$frame->add($quad);
|
|
|
|
$quad->setX(0);
|
|
|
|
$quad->setY($y);
|
2013-12-26 17:27:21 +01:00
|
|
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
2013-12-26 11:25:10 +01:00
|
|
|
$quad->setSize($quadWidth, 5);
|
2013-12-23 19:13:59 +01:00
|
|
|
$quad->setAction(self::ACTION_ADD_AS_MOD . "." .$login);
|
|
|
|
|
|
|
|
$label = new Label_Button();
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setAlign(Control::CENTER,Control::CENTER);
|
|
|
|
$label->setX(0);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setStyle($style);
|
|
|
|
$label->setTextSize($textSize);
|
2013-12-23 20:57:50 +01:00
|
|
|
$label->setText("Add Moderator");
|
2013-12-23 19:13:59 +01:00
|
|
|
$label->setTextColor($textColor);
|
|
|
|
|
2013-12-26 11:25:10 +01:00
|
|
|
|
|
|
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)){
|
|
|
|
$y -= 5;
|
|
|
|
//Revoke Rights
|
|
|
|
$quad = new Quad_BgsPlayerCard();
|
|
|
|
$frame->add($quad);
|
|
|
|
$quad->setX(0);
|
|
|
|
$quad->setY($y);
|
2013-12-26 17:27:21 +01:00
|
|
|
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
|
2013-12-26 11:25:10 +01:00
|
|
|
$quad->setSize($quadWidth, 5);
|
|
|
|
$quad->setAction(self::ACTION_REVOKE_RIGHTS . "." .$login);
|
|
|
|
|
|
|
|
$label = new Label_Button();
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setAlign(Control::CENTER,Control::CENTER);
|
|
|
|
$label->setX(0);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setStyle($style);
|
|
|
|
$label->setTextSize($textSize);
|
|
|
|
$label->setText("Revoke Rights");
|
|
|
|
$label->setTextColor($textColor);
|
|
|
|
}
|
|
|
|
|
2013-12-23 19:13:59 +01:00
|
|
|
//render and display xml
|
2013-12-26 17:27:21 +01:00
|
|
|
//$this->maniaControl->manialinkManager->displayWidget($maniaLink, $caller);
|
|
|
|
return $frame;
|
2013-12-23 19:13:59 +01:00
|
|
|
}
|
2013-12-18 15:48:33 +01:00
|
|
|
/**
|
|
|
|
* Closes the widget
|
|
|
|
* @param array $callback
|
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function closeWidget(array $callback, Player $player) {
|
2013-12-26 17:45:15 +01:00
|
|
|
$this->playersListShown[$player->login] = false;
|
2013-12-18 15:48:33 +01:00
|
|
|
}
|
2013-12-19 21:59:10 +01:00
|
|
|
|
|
|
|
|
2013-12-23 19:13:59 +01:00
|
|
|
/**
|
|
|
|
* Closes the player advanced widget widget
|
|
|
|
* @param array $callback
|
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function closePlayerAdvancedWidget(array $callback, Player $player) {
|
2013-12-26 17:38:23 +01:00
|
|
|
$this->playersListShown[$player->login] = self::SHOWN_MAIN_WINDOW;
|
2013-12-23 19:13:59 +01:00
|
|
|
$this->showPlayerList($player); //overwrite the manialink
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-19 21:59:10 +01:00
|
|
|
/**
|
|
|
|
* @param array $callback
|
|
|
|
*/
|
|
|
|
public function handleManialinkPageAnswer(array $callback){
|
|
|
|
$actionId = $callback[1][2];
|
2013-12-23 20:57:50 +01:00
|
|
|
$actionArray = explode(".", $actionId);
|
2013-12-19 21:59:10 +01:00
|
|
|
|
2013-12-23 20:57:50 +01:00
|
|
|
//TODO maybe with ids instead of logins, lower network traffic
|
|
|
|
switch($actionArray[0].".".$actionArray[1]){
|
|
|
|
case self::ACTION_FORCE_BLUE:
|
|
|
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($callback[1][1],$actionArray[2],playerActions::BLUE_TEAM);
|
|
|
|
break;
|
|
|
|
case self::ACTION_FORCE_RED:
|
|
|
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($callback[1][1],$actionArray[2],playerActions::RED_TEAM);
|
|
|
|
break;
|
|
|
|
case self::ACTION_FORCE_SPEC:
|
|
|
|
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($callback[1][1],$actionArray[2],playerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
|
|
|
break;
|
|
|
|
case self::ACTION_WARN_PLAYER:
|
|
|
|
$this->maniaControl->playerManager->playerActions->warnPlayer($callback[1][1],$actionArray[2]);
|
|
|
|
break;
|
|
|
|
case self::ACTION_KICK_PLAYER:
|
|
|
|
$this->maniaControl->playerManager->playerActions->kickPlayer($callback[1][1],$actionArray[2]);
|
|
|
|
break;
|
|
|
|
case self::ACTION_BAN_PLAYER:
|
|
|
|
$this->maniaControl->playerManager->playerActions->banPlayer($callback[1][1],$actionArray[2]);
|
|
|
|
break;
|
|
|
|
case self::ACTION_PLAYER_ADV:
|
|
|
|
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]);
|
2013-12-26 17:27:21 +01:00
|
|
|
$this->advancedPlayerWidget($player, $actionArray[2]);
|
2013-12-23 20:57:50 +01:00
|
|
|
break;
|
2013-12-26 11:25:10 +01:00
|
|
|
case self::ACTION_ADD_AS_MASTER:
|
|
|
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2], AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
|
|
|
break;
|
|
|
|
case self::ACTION_ADD_AS_ADMIN:
|
|
|
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2], AuthenticationManager::AUTH_LEVEL_ADMIN);
|
|
|
|
break;
|
|
|
|
case self::ACTION_ADD_AS_MOD:
|
|
|
|
$this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2], AuthenticationManager::AUTH_LEVEL_OPERATOR);
|
|
|
|
break;
|
|
|
|
case self::ACTION_REVOKE_RIGHTS:
|
|
|
|
$this->maniaControl->playerManager->playerActions->revokeAuthLevel($callback[1][1], $actionArray[2]);
|
|
|
|
break;
|
2013-12-23 20:57:50 +01:00
|
|
|
}
|
2013-12-19 21:59:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-23 21:52:30 +01:00
|
|
|
* Reopen the widget on PlayerInfoChanged / Player Connect and Disconnect
|
2013-12-19 21:59:10 +01:00
|
|
|
* @param array $callback
|
|
|
|
*/
|
2013-12-23 21:52:30 +01:00
|
|
|
public function updateWidget(array $callback){
|
2013-12-19 21:59:10 +01:00
|
|
|
foreach($this->playersListShown as $login => $shown){
|
2013-12-26 17:28:47 +01:00
|
|
|
if($shown){
|
2013-12-19 21:59:10 +01:00
|
|
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
2013-12-24 16:35:42 +01:00
|
|
|
if($player != null)
|
|
|
|
$this->showPlayerList($player);
|
2013-12-26 11:25:10 +01:00
|
|
|
else
|
|
|
|
unset($this->playersListShown[$login]);
|
2013-12-19 21:59:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-18 15:48:33 +01:00
|
|
|
}
|