Statslist and Playerlist now have Chunking
This commit is contained in:
parent
a3d7bdbb8a
commit
d6419cea97
@ -4,6 +4,7 @@ namespace ManiaControl\Callbacks\Structures\TrackMania;
|
|||||||
|
|
||||||
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
|
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
|
||||||
use ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore;
|
use ManiaControl\Callbacks\Structures\TrackMania\Models\PlayerScore;
|
||||||
|
use ManiaControl\Callbacks\Structures\TrackMania\Models\TeamScore;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,16 +27,16 @@ class OnScoresStructure extends CommonScoresStructure {
|
|||||||
parent::__construct($maniaControl, $data);
|
parent::__construct($maniaControl, $data);
|
||||||
|
|
||||||
$jsonObj = $this->getPlainJsonObject();
|
$jsonObj = $this->getPlainJsonObject();
|
||||||
|
var_dump($jsonObj);
|
||||||
foreach ($jsonObj->players as $jsonPlayer) {
|
foreach ($jsonObj->players as $jsonPlayer) {
|
||||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login);
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login);
|
||||||
if ($player) {
|
if ($player) {
|
||||||
$playerScore = new PlayerScore();
|
$playerScore = new PlayerScore();
|
||||||
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
|
$playerScore->setPlayer($this->maniaControl->getPlayerManager()->getPlayer($jsonPlayer->login));
|
||||||
$playerScore->setRank($jsonPlayer->rank);
|
$playerScore->setRank($jsonPlayer->rank);
|
||||||
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
|
|
||||||
$playerScore->setMapPoints($jsonPlayer->mappoints);
|
$playerScore->setMapPoints($jsonPlayer->mappoints);
|
||||||
$playerScore->setMatchPoints($jsonPlayer->matchpoints);
|
$playerScore->setMatchPoints($jsonPlayer->matchpoints);
|
||||||
|
$playerScore->setRoundPoints($jsonPlayer->roundpoints);
|
||||||
$playerScore->setBestRaceTime($jsonPlayer->bestracetime);
|
$playerScore->setBestRaceTime($jsonPlayer->bestracetime);
|
||||||
$playerScore->setBestLapTime($jsonPlayer->bestlaptime);
|
$playerScore->setBestLapTime($jsonPlayer->bestlaptime);
|
||||||
$playerScore->setStuntScore($jsonPlayer->stuntsscore);
|
$playerScore->setStuntScore($jsonPlayer->stuntsscore);
|
||||||
|
@ -55,9 +55,12 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
|
const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights';
|
||||||
const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed';
|
const ACTION_OPEN_PLAYER_DETAILED = 'PlayerList.OpenPlayerDetailed';
|
||||||
const ACTION_SPECTATE_PLAYER = 'PlayerList.SpectatePlayer';
|
const ACTION_SPECTATE_PLAYER = 'PlayerList.SpectatePlayer';
|
||||||
|
const ACTION_PAGING_CHUNKS = 'PlayerList.PagingChunks';
|
||||||
|
const CACHE_CURRENT_PAGE = 'PlayerList.CurrentPage';
|
||||||
const DEFAULT_CUSTOM_VOTE_PLUGIN = 'MCTeam\CustomVotesPlugin';
|
const DEFAULT_CUSTOM_VOTE_PLUGIN = 'MCTeam\CustomVotesPlugin';
|
||||||
const SHOWN_MAIN_WINDOW = -1;
|
const SHOWN_MAIN_WINDOW = -1;
|
||||||
const MAX_PLAYERS_PER_PAGE = 15;
|
const MAX_PLAYERS_PER_PAGE = 15;
|
||||||
|
const MAX_PAGES_PER_CHUNK = 2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private properties
|
* Private properties
|
||||||
@ -135,18 +138,33 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
*
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showPlayerList(Player $player) {
|
public function showPlayerList(Player $player, $pageIndex = -1) {
|
||||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||||
|
|
||||||
// get PlayerList
|
// get PlayerList
|
||||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||||
|
|
||||||
|
if ($pageIndex < 0) {
|
||||||
|
$pageIndex = (int) $player->getCache($this, self::CACHE_CURRENT_PAGE);
|
||||||
|
}
|
||||||
|
$player->setCache($this, self::CACHE_CURRENT_PAGE, $pageIndex);
|
||||||
|
|
||||||
|
$totalPlayersCount = count($players);
|
||||||
|
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount);
|
||||||
|
$playerBeginIndex = $this->getChunkStatsBeginIndex($chunkIndex);
|
||||||
|
|
||||||
|
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
|
||||||
|
|
||||||
//create manialink
|
//create manialink
|
||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
$script = $maniaLink->getScript();
|
$script = $maniaLink->getScript();
|
||||||
$paging = new Paging();
|
$paging = new Paging();
|
||||||
$script->addFeature($paging);
|
$script->addFeature($paging);
|
||||||
|
$paging->setCustomMaxPageNumber($pagesCount);
|
||||||
|
$paging->setChunkActionAppendsPageNumber(true);
|
||||||
|
$paging->setChunkActions(self::ACTION_PAGING_CHUNKS);
|
||||||
|
$paging->setStartPageNumber($pageIndex + 1);
|
||||||
|
|
||||||
// Main frame
|
// Main frame
|
||||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||||
@ -182,13 +200,19 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
$index = 1;
|
$index = 1;
|
||||||
$posY = $height / 2 - 10;
|
$posY = $height / 2 - 10;
|
||||||
$pageFrame = null;
|
$pageFrame = null;
|
||||||
|
$playerIndex = 1 + $playerBeginIndex;
|
||||||
|
|
||||||
|
//Slice Array to chunk length
|
||||||
|
$players = array_slice($players, $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE, true);
|
||||||
|
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
|
||||||
|
|
||||||
foreach ($players as $listPlayer) {
|
foreach ($players as $listPlayer) {
|
||||||
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
|
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->addChild($pageFrame);
|
$frame->addChild($pageFrame);
|
||||||
|
|
||||||
$paging->addPageControl($pageFrame);
|
$paging->addPageControl($pageFrame, $pageNumber);
|
||||||
|
$pageNumber++;
|
||||||
$posY = $height / 2 - 10;
|
$posY = $height / 2 - 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +229,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
}
|
}
|
||||||
$labelLine = new LabelLine($playerFrame);
|
$labelLine = new LabelLine($playerFrame);
|
||||||
|
|
||||||
$labelLine->addLabelEntryText($index, $posX + 5, 13);
|
$labelLine->addLabelEntryText($playerIndex, $posX + 5, 13);
|
||||||
$labelLine->addLabelEntryText($listPlayer->nickname, $posX + 18, 43);
|
$labelLine->addLabelEntryText($listPlayer->nickname, $posX + 18, 43);
|
||||||
$labelLine->addLabelEntryText($listPlayer->login, $posX + 70, 26);
|
$labelLine->addLabelEntryText($listPlayer->login, $posX + 70, 26);
|
||||||
$labelLine->addLabelEntryText($path, $posX + 101, 27);
|
$labelLine->addLabelEntryText($path, $posX + 101, 27);
|
||||||
@ -404,6 +428,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
|
|
||||||
$posY -= 4;
|
$posY -= 4;
|
||||||
$index++;
|
$index++;
|
||||||
|
$playerIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show advanced window
|
// Show advanced window
|
||||||
@ -616,6 +641,30 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
return $frame;
|
return $frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Chunk Index with the given Page Index
|
||||||
|
*
|
||||||
|
* @param int $pageIndex
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount) {
|
||||||
|
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
|
||||||
|
if ($pageIndex > $pagesCount - 1) {
|
||||||
|
$pageIndex = $pagesCount - 1;
|
||||||
|
}
|
||||||
|
return floor($pageIndex / self::MAX_PAGES_PER_CHUNK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the First Player Index to show for the given Chunk
|
||||||
|
*
|
||||||
|
* @param int $chunkIndex
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getChunkStatsBeginIndex($chunkIndex) {
|
||||||
|
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on ManialinkPageAnswer
|
* Called on ManialinkPageAnswer
|
||||||
*
|
*
|
||||||
@ -624,11 +673,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$actionArray = explode('.', $actionId, 3);
|
$actionArray = explode('.', $actionId, 3);
|
||||||
if (count($actionArray) <= 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$action = $actionArray[0] . '.' . $actionArray[1];
|
$action = $actionArray[0] . '.' . $actionArray[1];
|
||||||
|
if (count($actionArray) > 2) {
|
||||||
|
|
||||||
$adminLogin = $callback[1][1];
|
$adminLogin = $callback[1][1];
|
||||||
$targetLogin = $actionArray[2];
|
$targetLogin = $actionArray[2];
|
||||||
|
|
||||||
@ -738,6 +785,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (count($actionArray) == 2) {
|
||||||
|
$playerLogin = $callback[1][1];
|
||||||
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($playerLogin);
|
||||||
|
if (substr($action, 0, strlen(self::ACTION_PAGING_CHUNKS)) === self::ACTION_PAGING_CHUNKS) {
|
||||||
|
// Paging chunks
|
||||||
|
$neededPage = (int) substr($action, strlen(self::ACTION_PAGING_CHUNKS));
|
||||||
|
$this->showPlayerList($player, $neededPage - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,11 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
*/
|
*/
|
||||||
const ACTION_OPEN_STATSLIST = 'SimpleStatsList.OpenStatsList';
|
const ACTION_OPEN_STATSLIST = 'SimpleStatsList.OpenStatsList';
|
||||||
const ACTION_SORT_STATS = 'SimpleStatsList.SortStats';
|
const ACTION_SORT_STATS = 'SimpleStatsList.SortStats';
|
||||||
|
const ACTION_PAGING_CHUNKS = 'SimpleStatsList.PagingChunk';
|
||||||
const MAX_PLAYERS_PER_PAGE = 15;
|
const MAX_PLAYERS_PER_PAGE = 15;
|
||||||
|
const MAX_PAGES_PER_CHUNK = 2;
|
||||||
|
const CACHE_CURRENT_PAGE = 'SimpleStatsList.CurrentPage';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private properties
|
* Private properties
|
||||||
@ -123,13 +127,22 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param string $order
|
* @param string $order
|
||||||
*/
|
*/
|
||||||
public function showStatsList(Player $player, $order = PlayerManager::STAT_SERVERTIME) {
|
public function showStatsList(Player $player, $order = PlayerManager::STAT_SERVERTIME, $pageIndex = -1) {
|
||||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
||||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||||
|
|
||||||
|
if ($pageIndex < 0) {
|
||||||
|
$pageIndex = (int) $player->getCache($this, self::CACHE_CURRENT_PAGE);
|
||||||
|
}
|
||||||
|
$player->setCache($this, self::CACHE_CURRENT_PAGE, $pageIndex);
|
||||||
|
|
||||||
|
$totalPlayersCount = $this->maniaControl->getStatisticManager()->getTotalStatsPlayerCount(-1);
|
||||||
|
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount);
|
||||||
|
$playerBeginIndex = $this->getChunkStatsBeginIndex($chunkIndex);
|
||||||
|
|
||||||
|
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
|
||||||
|
|
||||||
$order = StatisticCollector::STAT_ARROW_HIT;
|
|
||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
$width = $this->statsWidth + 60;
|
$width = $this->statsWidth + 60;
|
||||||
//TODO handle size when stats are empty
|
//TODO handle size when stats are empty
|
||||||
@ -137,6 +150,10 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$script = $maniaLink->getScript();
|
$script = $maniaLink->getScript();
|
||||||
$paging = new Paging();
|
$paging = new Paging();
|
||||||
$script->addFeature($paging);
|
$script->addFeature($paging);
|
||||||
|
$paging->setCustomMaxPageNumber($pagesCount);
|
||||||
|
$paging->setChunkActionAppendsPageNumber(true);
|
||||||
|
$paging->setChunkActions(self::ACTION_PAGING_CHUNKS);
|
||||||
|
$paging->setStartPageNumber($pageIndex + 1);
|
||||||
|
|
||||||
// Main frame
|
// Main frame
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
@ -182,8 +199,9 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$posX = $xStart + 55;
|
$posX = $xStart + 55;
|
||||||
$statRankings = array();
|
$statRankings = array();
|
||||||
|
|
||||||
|
|
||||||
foreach ($this->statArray as $key => $stat) {
|
foreach ($this->statArray as $key => $stat) {
|
||||||
$ranking = $this->maniaControl->getStatisticManager()->getStatsRanking($stat["Name"]);
|
$ranking = $this->maniaControl->getStatisticManager()->getStatsRanking($stat["Name"], -1, -1, 20000);
|
||||||
if (!empty($ranking)) {
|
if (!empty($ranking)) {
|
||||||
$statRankings[$stat["Name"]] = $ranking;
|
$statRankings[$stat["Name"]] = $ranking;
|
||||||
|
|
||||||
@ -207,19 +225,23 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$index = 1;
|
$index = 1;
|
||||||
$posY -= 10;
|
$posY -= 10;
|
||||||
$pageFrame = null;
|
$pageFrame = null;
|
||||||
|
$playerIndex = 1 + $playerBeginIndex;
|
||||||
|
|
||||||
if (!isset($statRankings[$order])) {
|
if (!isset($statRankings[$order])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Slice Array to chunk length
|
||||||
|
$statRankings[$order] = array_slice($statRankings{$order}, $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE, true);
|
||||||
|
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
|
||||||
foreach ($statRankings[$order] as $playerId => $value) {
|
foreach ($statRankings[$order] as $playerId => $value) {
|
||||||
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
|
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->addChild($pageFrame);
|
$frame->addChild($pageFrame);
|
||||||
$pageFrame->setZ(1);
|
$pageFrame->setZ(1);
|
||||||
|
|
||||||
$paging->addPageControl($pageFrame);
|
$paging->addPageControl($pageFrame, $pageNumber);
|
||||||
|
$pageNumber++;
|
||||||
$posY = $height / 2 - 10;
|
$posY = $height / 2 - 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +286,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$labelLine->addLabelEntryText($index, $xStart + 5, 9);
|
$labelLine->addLabelEntryText($playerIndex, $xStart + 5, 9);
|
||||||
$labelLine->addLabelEntryText($listPlayer->login, $xStart + 14, 41);
|
$labelLine->addLabelEntryText($listPlayer->login, $xStart + 14, 41);
|
||||||
$labelLine->render();
|
$labelLine->render();
|
||||||
|
|
||||||
@ -279,6 +301,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
$index++;
|
$index++;
|
||||||
|
$playerIndex++;
|
||||||
$posY -= 4;
|
$posY -= 4;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -301,6 +324,31 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'SimpleStatsList');
|
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'SimpleStatsList');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Chunk Index with the given Page Index
|
||||||
|
*
|
||||||
|
* @param int $pageIndex
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount) {
|
||||||
|
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
|
||||||
|
if ($pageIndex > $pagesCount - 1) {
|
||||||
|
$pageIndex = $pagesCount - 1;
|
||||||
|
}
|
||||||
|
return floor($pageIndex / self::MAX_PAGES_PER_CHUNK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the First Player Index to show for the given Chunk
|
||||||
|
*
|
||||||
|
* @param int $chunkIndex
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getChunkStatsBeginIndex($chunkIndex) {
|
||||||
|
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on ManialinkPageAnswer
|
* Called on ManialinkPageAnswer
|
||||||
*
|
*
|
||||||
@ -309,18 +357,24 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$actionArray = explode('.', $actionId, 3);
|
$actionArray = explode('.', $actionId, 3);
|
||||||
if (count($actionArray) <= 2) {
|
if (count($actionArray) < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = $actionArray[0] . '.' . $actionArray[1];
|
$action = $actionArray[0] . '.' . $actionArray[1];
|
||||||
|
|
||||||
switch ($action) {
|
|
||||||
case self::ACTION_SORT_STATS:
|
|
||||||
$playerLogin = $callback[1][1];
|
$playerLogin = $callback[1][1];
|
||||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($playerLogin);
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($playerLogin);
|
||||||
|
switch ($action) {
|
||||||
|
case self::ACTION_SORT_STATS:
|
||||||
$this->showStatsList($player, $actionArray[2]);
|
$this->showStatsList($player, $actionArray[2]);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
if (substr($actionId, 0, strlen(self::ACTION_PAGING_CHUNKS)) === self::ACTION_PAGING_CHUNKS) {
|
||||||
|
// Paging chunks
|
||||||
|
$neededPage = (int) substr($actionId, strlen(self::ACTION_PAGING_CHUNKS));
|
||||||
|
$this->showStatsList($player, PlayerManager::STAT_SERVERTIME, $neededPage - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ use ManiaControl\General\UsageInformationAble;
|
|||||||
use ManiaControl\General\UsageInformationTrait;
|
use ManiaControl\General\UsageInformationTrait;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
|
use ManiaControl\Players\PlayerManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Statistic Manager Class
|
* Statistic Manager Class
|
||||||
@ -347,6 +348,16 @@ class StatisticManager implements UsageInformationAble {
|
|||||||
return $statsArray;
|
return $statsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the total amount of players who were on the server once
|
||||||
|
*
|
||||||
|
* @param $serverIndex
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getTotalStatsPlayerCount($serverIndex){
|
||||||
|
return count($this->getStatsRanking(PlayerManager::STAT_SERVERTIME,$serverIndex,-1,20000));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Stat Id
|
* Return the Stat Id
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user