PlayerList Profile Opening

This commit is contained in:
Steffen Schröder 2013-12-31 12:17:25 +01:00
parent 8db3b2daf4
commit fd7a229e2c
2 changed files with 252 additions and 223 deletions

View File

@ -233,6 +233,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
$style = Label_Text::STYLE_TextCardSmall; $style = Label_Text::STYLE_TextCardSmall;
$textSize = 1.5; $textSize = 1.5;
$textColor = 'FFF'; $textColor = 'FFF';
$profile = (isset($properties['profile']) ? $properties['profile'] : false);
$script = (isset($properties['script']) ? $properties['script'] : null);
$frames = array(); $frames = array();
foreach ($labelStrings as $text => $x) { foreach ($labelStrings as $text => $x) {
@ -245,6 +247,10 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
$label->setText($text); $label->setText($text);
$label->setTextColor($textColor); $label->setTextColor($textColor);
if ($profile) {
$script->addProfileButton($label, $profile);
}
$frames[] = $frame; // add Frame to the frames array $frames[] = $frame; // add Frame to the frames array
} }
return $frames; return $frames;

View File

@ -36,7 +36,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
const ACTION_FORCE_RED = 'PlayerList.ForceRed'; const ACTION_FORCE_RED = 'PlayerList.ForceRed';
const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue'; const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue';
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec'; const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions'; const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget'; const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer'; const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
@ -46,7 +45,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin'; const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin';
const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator'; const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator';
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights'; const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
const SHOWN_MAIN_WINDOW = -1; const SHOWN_MAIN_WINDOW = -1;
/** /**
* Private properties * Private properties
@ -66,22 +64,24 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
public function __construct(ManiaControl $maniaControl) { public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV , $this, 'closePlayerAdvancedWidget'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this,
'closePlayerAdvancedWidget');
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget'); $this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswer');
// Update Widget Events // Update Widget Events
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this,
'updateWidget');
// settings // settings
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth(); $this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight(); $this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
$this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle(); $this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle(); $this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
} }
public function addPlayerToShownList(Player $player, $showStatus = self::SHOWN_MAIN_WINDOW) { public function addPlayerToShownList(Player $player, $showStatus = self::SHOWN_MAIN_WINDOW) {
@ -126,7 +126,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
// $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85); // $array = array("Id" => $x + 5, "Nickname" => $x + 10, "Login" => $x + 40, "Ladder" => $x + 60,"Zone" => $x + 85);
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { 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); $array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91, "Actions" => $x + 135);
}else{ }
else {
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91); $array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91);
} }
$this->maniaControl->manialinkManager->labelLine($headFrame, $array); $this->maniaControl->manialinkManager->labelLine($headFrame, $array);
@ -137,7 +138,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$i = 1; $i = 1;
$y -= 10; $y -= 10;
foreach ($players as $listPlayer) { foreach ($players as $listPlayer) {
/** @var Player $listPlayer */ /**
*
* @var Player $listPlayer
*/
$path = $listPlayer->getProvince(); $path = $listPlayer->getProvince();
$playerFrame = new Frame(); $playerFrame = new Frame();
@ -151,10 +155,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$lineQuad->setZ(0.001); $lineQuad->setZ(0.001);
} }
// $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);
$this->maniaControl->manialinkManager->labelLine($playerFrame,$array); $properties = array('profile' => $listPlayer->login, 'script' => $script);
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array, $properties);
$playerFrame->setY($y); $playerFrame->setY($y);
// Team Emblem // Team Emblem
@ -166,10 +171,15 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$redQuad->setSize(3.8, 3.8); $redQuad->setSize(3.8, 3.8);
switch ($listPlayer->teamId) { switch ($listPlayer->teamId) {
case 0: $redQuad->setSubStyle($redQuad::SUBSTYLE_1); break; case 0:
case 1: $redQuad->setSubStyle($redQuad::SUBSTYLE_2); break; $redQuad->setSubStyle($redQuad::SUBSTYLE_1);
break;
case 1:
$redQuad->setSubStyle($redQuad::SUBSTYLE_2);
break;
} }
}else if($listPlayer->isSpectator){ //Player is in Spectator Mode }
else if ($listPlayer->isSpectator) { // Player is in Spectator Mode
$neutralQuad = new Quad_BgRaceScore2(); $neutralQuad = new Quad_BgRaceScore2();
$playerFrame->add($neutralQuad); $playerFrame->add($neutralQuad);
$neutralQuad->setX($x + 10); $neutralQuad->setX($x + 10);
@ -178,7 +188,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$neutralQuad->setSize(3.8, 3.8); $neutralQuad->setSize(3.8, 3.8);
} }
// Display country quad only on normal players // Display country quad only on normal players
if (!$listPlayer->isFakePlayer()) { if (!$listPlayer->isFakePlayer()) {
// Nation Quad // Nation Quad
@ -224,19 +233,26 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$descriptionLabel->setSize($this->width * 0.7, 4); $descriptionLabel->setSize($this->width * 0.7, 4);
$descriptionLabel->setTextSize(2); $descriptionLabel->setTextSize(2);
$descriptionLabel->setVisible(false); $descriptionLabel->setVisible(false);
$descriptionLabel->setText($this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " . $listPlayer->nickname); $descriptionLabel->setText(
$this->maniaControl->authenticationManager->getAuthLevelName($listPlayer->authLevel) . " " . $listPlayer->nickname);
$script->addTooltip($rightQuad, $descriptionLabel); $script->addTooltip($rightQuad, $descriptionLabel);
switch ($listPlayer->authLevel) { switch ($listPlayer->authLevel) {
case authenticationManager::AUTH_LEVEL_MASTERADMIN: $rightLabel->setText("MA"); break; case authenticationManager::AUTH_LEVEL_MASTERADMIN:
case authenticationManager::AUTH_LEVEL_SUPERADMIN: $rightLabel->setText("SA"); break; $rightLabel->setText("MA");
case authenticationManager::AUTH_LEVEL_ADMIN: $rightLabel->setText("AD"); break; break;
case authenticationManager::AUTH_LEVEL_OPERATOR: $rightLabel->setText("MOD"); case authenticationManager::AUTH_LEVEL_SUPERADMIN:
$rightLabel->setText("SA");
break;
case authenticationManager::AUTH_LEVEL_ADMIN:
$rightLabel->setText("AD");
break;
case authenticationManager::AUTH_LEVEL_OPERATOR:
$rightLabel->setText("MOD");
} }
$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
@ -336,6 +352,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
/** /**
* Displays the Advanced Player Window * Displays the Advanced Player Window
*
* @param Player $caller * @param Player $caller
* @param $login * @param $login
*/ */
@ -344,9 +361,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$this->showPlayerList($caller); // reopen playerlist $this->showPlayerList($caller); // reopen playerlist
} }
/** /**
* Extra window with special actions on players like warn,kick, ban, authorization levels... * Extra window with special actions on players like warn,kick, ban, authorization levels...
*
* @param $login * @param $login
* @return Frame * @return Frame
*/ */
@ -528,7 +545,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setText("Set Moderator"); $label->setText("Set Moderator");
$label->setTextColor($textColor); $label->setTextColor($textColor);
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) { if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) {
$y -= 5; $y -= 5;
// Revoke Rights // Revoke Rights
@ -549,7 +565,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setTextSize($textSize); $label->setTextSize($textSize);
$label->setText("Revoke Rights"); $label->setText("Revoke Rights");
$label->setTextColor("700"); $label->setTextColor("700");
} }
return $frame; return $frame;
@ -557,6 +572,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
/** /**
* Closes the widget * Closes the widget
*
* @param array $callback * @param array $callback
*/ */
public function closeWidget(array $callback) { public function closeWidget(array $callback) {
@ -564,9 +580,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
unset($this->playersListShown[$player->login]); unset($this->playersListShown[$player->login]);
} }
/** /**
* Closes the player advanced widget widget * Closes the player advanced widget widget
*
* @param array $callback * @param array $callback
* @param Player $player * @param Player $player
*/ */
@ -575,10 +591,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$this->showPlayerList($player); // overwrite the manialink $this->showPlayerList($player); // overwrite the manialink
} }
/** /**
* Called on ManialinkPageAnswer * Called on ManialinkPageAnswer
*
* @param array $callback * @param array $callback
*/ */
public function handleManialinkPageAnswer(array $callback) { public function handleManialinkPageAnswer(array $callback) {
@ -588,13 +603,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
// TODO maybe with ids instead of logins, lower network traffic // TODO maybe with ids instead of logins, lower network traffic
switch ($actionArray[0] . "." . $actionArray[1]) { 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],playerActions::BLUE_TEAM); $this->maniaControl->playerManager->playerActions->forcePlayerToTeam($callback[1][1], $actionArray[2],
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],playerActions::RED_TEAM); $this->maniaControl->playerManager->playerActions->forcePlayerToTeam($callback[1][1], $actionArray[2],
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],playerActions::SPECTATOR_BUT_KEEP_SELECTABLE); $this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($callback[1][1], $actionArray[2],
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($callback[1][1], $actionArray[2]);
@ -610,13 +628,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$this->advancedPlayerWidget($player, $actionArray[2]); $this->advancedPlayerWidget($player, $actionArray[2]);
break; break;
case self::ACTION_ADD_AS_MASTER: case self::ACTION_ADD_AS_MASTER:
$this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2], AuthenticationManager::AUTH_LEVEL_SUPERADMIN); $this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2],
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], AuthenticationManager::AUTH_LEVEL_ADMIN); $this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2],
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], AuthenticationManager::AUTH_LEVEL_OPERATOR); $this->maniaControl->playerManager->playerActions->grandAuthLevel($callback[1][1], $actionArray[2],
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($callback[1][1], $actionArray[2]);
@ -626,6 +647,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
/** /**
* Reopen the widget on PlayerInfoChanged / Player Connect and Disconnect * Reopen the widget on PlayerInfoChanged / Player Connect and Disconnect
*
* @param array $callback * @param array $callback
*/ */
public function updateWidget(array $callback) { public function updateWidget(array $callback) {
@ -638,7 +660,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$player = $this->maniaControl->playerManager->getPlayer($login); $player = $this->maniaControl->playerManager->getPlayer($login);
if ($player != null) { if ($player != null) {
$this->showPlayerList($player); $this->showPlayerList($player);
}else{ }
else {
// if player with the open widget disconnected remove him from the shownlist // if player with the open widget disconnected remove him from the shownlist
unset($this->playersListShown[$login]); unset($this->playersListShown[$login]);
} }