slight performance improve of manialinks
This commit is contained in:
parent
a15fcefba5
commit
fc02be2352
@ -116,20 +116,30 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
if (!$this->initCompleted) {
|
||||
return;
|
||||
}
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
foreach ($players as $player) {
|
||||
$manialink = $this->buildMenuIconsManialink($player);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $player->login);
|
||||
|
||||
//Send Menu to Admins
|
||||
$admins = $this->maniaControl->getAuthenticationManager()->getConnectedAdmins(AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
if (!empty($admins)) {
|
||||
$manialink = $this->buildMenuIconsManialink(true);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $admins);
|
||||
}
|
||||
|
||||
|
||||
//Send Menu to Players - Players with No Admin Permisssions
|
||||
$players = $this->maniaControl->getAuthenticationManager()->getConnectedPlayers();
|
||||
if (!empty($players)) {
|
||||
$manialink = $this->buildMenuIconsManialink(false);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($manialink, $players);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the Manialink
|
||||
*
|
||||
* @param Player $player
|
||||
* @param $admin
|
||||
* @return ManiaLink
|
||||
*/
|
||||
private function buildMenuIconsManialink(Player $player) {
|
||||
private function buildMenuIconsManialink($admin = false) {
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSX);
|
||||
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
@ -147,7 +157,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
/*
|
||||
* Admin Menu
|
||||
*/
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if ($admin) {
|
||||
// Admin Menu Icon Frame
|
||||
$iconFrame = new Frame();
|
||||
$frame->addChild($iconFrame);
|
||||
@ -327,7 +337,12 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerJoined(Player $player) {
|
||||
$maniaLink = $this->buildMenuIconsManialink($player);
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
$maniaLink = $this->buildMenuIconsManialink(true);
|
||||
} else {
|
||||
$maniaLink = $this->buildMenuIconsManialink(false);
|
||||
}
|
||||
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player);
|
||||
}
|
||||
|
||||
|
@ -287,6 +287,24 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica
|
||||
return $admins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all connected Players with less permission than the given Auth Level
|
||||
*
|
||||
* @api
|
||||
* @param int $authLevel
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getConnectedPlayers($authLevel = self::AUTH_LEVEL_MODERATOR) {
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
$playerArray = array();
|
||||
foreach ($players as $player) {
|
||||
if (!self::checkRight($player, $authLevel)) {
|
||||
array_push($playerArray, $player);
|
||||
}
|
||||
}
|
||||
return $playerArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the Player has enough Rights
|
||||
*
|
||||
|
@ -76,11 +76,7 @@ class CustomUIManager implements CallbackListener, TimerListener, UsageInformati
|
||||
* @param Player $player
|
||||
*/
|
||||
public function updateManialink(Player $player = null) {
|
||||
if ($player) {
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->customUI, $player);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->customUI);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->customUI, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,28 +241,25 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage(null, $manialinkText, $timeout, $hideOnClick);
|
||||
}
|
||||
if (is_string($logins)) {
|
||||
$success = $this->maniaControl->getClient()->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick);
|
||||
return $success;
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage($logins, $manialinkText, $timeout, $hideOnClick);
|
||||
}
|
||||
if ($logins instanceof Player) {
|
||||
$success = $this->maniaControl->getClient()->sendDisplayManialinkPage($logins->login, $manialinkText, $timeout, $hideOnClick);
|
||||
return $success;
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage($logins->login, $manialinkText, $timeout, $hideOnClick);
|
||||
}
|
||||
if (is_array($logins)) {
|
||||
$success = true;
|
||||
$loginList = array();
|
||||
foreach ($logins as $login) {
|
||||
$subSuccess = $this->sendManialink($manialinkText, $login, $timeout, $hideOnClick);
|
||||
if (!$subSuccess) {
|
||||
$success = false;
|
||||
if($login instanceof Player){
|
||||
$loginList[] = $login->login;
|
||||
}else{
|
||||
$loginList[] = $login;
|
||||
}
|
||||
}
|
||||
return $success;
|
||||
return $this->maniaControl->getClient()->sendDisplayManialinkPage(implode(',', $loginList), $manialinkText, $timeout, $hideOnClick);
|
||||
}
|
||||
} catch (UnknownPlayerException $e) {
|
||||
return false;
|
||||
} catch (FaultException $e) {
|
||||
//TODO added 17.01.2015, remove later:
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice("Fault Exception: ManiaLink Manager, Message: " . $e->getMessage());
|
||||
return false;
|
||||
} catch (MessageException $e) {
|
||||
//TODO verify why this can happen
|
||||
|
@ -846,17 +846,12 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$karmaLabel->setText('-');
|
||||
}
|
||||
|
||||
// Loop players
|
||||
foreach ($players as $login => $player) {
|
||||
// Get player vote
|
||||
// TODO: show the player his own vote in some way
|
||||
// $vote = $this->getPlayerVote($player, $map);
|
||||
// $votesFrame = $this->manialink->votesFrame;
|
||||
// $votesFrame->removeChildren();
|
||||
|
||||
// Send manialink
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->manialink, $login);
|
||||
}
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->manialink, $players);
|
||||
// TODO: show the player his own vote in some way
|
||||
// $vote = $this->getPlayerVote($player, $map);
|
||||
// $votesFrame = $this->manialink->votesFrame;
|
||||
// $votesFrame->removeChildren();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user