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

View File

@ -36,7 +36,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
const ACTION_FORCE_RED = 'PlayerList.ForceRed';
const ACTION_FORCE_BLUE = 'PlayerList.ForceBlue';
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
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_MOD = 'PlayerList.PlayerAddAsModerator';
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
const SHOWN_MAIN_WINDOW = -1;
/**
* Private properties
@ -66,22 +64,24 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
public function __construct(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(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswer');
// Update Widget Events
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $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
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
$this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
}
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);
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{
}
else {
$array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 60, "Location" => $x + 91);
}
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
@ -137,7 +138,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$i = 1;
$y -= 10;
foreach ($players as $listPlayer) {
/** @var Player $listPlayer */
/**
*
* @var Player $listPlayer
*/
$path = $listPlayer->getProvince();
$playerFrame = new Frame();
@ -151,10 +155,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$lineQuad->setZ(0.001);
}
//$array = array($i => $x + 5, $listPlayer->nickname => $x + 10, $listPlayer->login => $x + 50, $listPlayer->ladderRank => $x + 60, $listPlayer->ladderScore => $x + 70, $path => $x + 85);
// $array = array($i => $x + 5, $listPlayer->nickname => $x + 10, $listPlayer->login => $x + 50, $listPlayer->ladderRank =>
// $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);
$this->maniaControl->manialinkManager->labelLine($playerFrame,$array);
$properties = array('profile' => $listPlayer->login, 'script' => $script);
$this->maniaControl->manialinkManager->labelLine($playerFrame, $array, $properties);
$playerFrame->setY($y);
// Team Emblem
@ -166,10 +171,15 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$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;
case 0:
$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();
$playerFrame->add($neutralQuad);
$neutralQuad->setX($x + 10);
@ -178,7 +188,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$neutralQuad->setSize(3.8, 3.8);
}
// Display country quad only on normal players
if (!$listPlayer->isFakePlayer()) {
// Nation Quad
@ -224,19 +233,26 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$descriptionLabel->setSize($this->width * 0.7, 4);
$descriptionLabel->setTextSize(2);
$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);
switch ($listPlayer->authLevel) {
case authenticationManager::AUTH_LEVEL_MASTERADMIN: $rightLabel->setText("MA"); break;
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");
case authenticationManager::AUTH_LEVEL_MASTERADMIN:
$rightLabel->setText("MA");
break;
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");
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) {
// Further Player actions Quad
@ -336,6 +352,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
/**
* Displays the Advanced Player Window
*
* @param Player $caller
* @param $login
*/
@ -344,9 +361,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$this->showPlayerList($caller); // reopen playerlist
}
/**
* Extra window with special actions on players like warn,kick, ban, authorization levels...
*
* @param $login
* @return Frame
*/
@ -528,7 +545,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setText("Set Moderator");
$label->setTextColor($textColor);
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)) {
$y -= 5;
// Revoke Rights
@ -549,7 +565,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setTextSize($textSize);
$label->setText("Revoke Rights");
$label->setTextColor("700");
}
return $frame;
@ -557,6 +572,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
/**
* Closes the widget
*
* @param array $callback
*/
public function closeWidget(array $callback) {
@ -564,9 +580,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
unset($this->playersListShown[$player->login]);
}
/**
* Closes the player advanced widget widget
*
* @param array $callback
* @param Player $player
*/
@ -575,10 +591,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$this->showPlayerList($player); // overwrite the manialink
}
/**
* Called on ManialinkPageAnswer
*
* @param 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
switch ($actionArray[0] . "." . $actionArray[1]) {
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;
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;
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;
case self::ACTION_WARN_PLAYER:
$this->maniaControl->playerManager->playerActions->warnPlayer($callback[1][1], $actionArray[2]);
@ -610,13 +628,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$this->advancedPlayerWidget($player, $actionArray[2]);
break;
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;
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;
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;
case self::ACTION_REVOKE_RIGHTS:
$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
*
* @param array $callback
*/
public function updateWidget(array $callback) {
@ -638,7 +660,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$player = $this->maniaControl->playerManager->getPlayer($login);
if ($player != null) {
$this->showPlayerList($player);
}else{
}
else {
// if player with the open widget disconnected remove him from the shownlist
unset($this->playersListShown[$login]);
}