Compare commits

..

3 Commits

Author SHA1 Message Date
Beu
8b3e624d1c fix other paging sizes 2023-09-08 16:00:30 +02:00
Beu
478e842230 add message when plugins update are available 2023-09-08 15:08:49 +02:00
Beu
405d6027f7 fix plugin warning 2023-09-08 14:55:38 +02:00
7 changed files with 49 additions and 20 deletions

View File

@ -37,7 +37,6 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
*/
const ACTION_OPEN_ADMIN_LIST = 'AdminList.OpenAdminList';
const ACTION_REVOKE_RIGHTS = 'AdminList.RevokeRights';
const MAX_PLAYERS_PER_PAGE = 15;
/*
* Private Properties
@ -129,9 +128,10 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
$index = 1;
$posY -= 10;
$pageFrame = null;
$pageMaxCount = $this->getPlayersPerPage();
foreach ($admins as $admin) {
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
if ($index % $pageMaxCount === 1) {
$pageFrame = new Frame();
$frame->addChild($pageFrame);
@ -236,6 +236,16 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
}
}
/**
* Get number of players per page
*
* @return int
*/
public function getPlayersPerPage() {
$pageheight = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
return floor($pageheight * 0.82 / 4);
}
/**
* Reopen the widget on Map Begin, MapListChanged, etc.
*

View File

@ -238,9 +238,10 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
$index = 1;
$posY -= 10;
$pageFrame = null;
$pageMaxCount = floor($height * 0.80 / 4);
foreach ($commands as $command) {
if ($index % 15 === 1) {
if ($index % $pageMaxCount === 1) {
$pageFrame = new Frame();
$frame->addChild($pageFrame);
$posY = $height / 2 - 10;

View File

@ -336,6 +336,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
$pagerSize = 9.;
$settingHeight = 5.;
$labelTextSize = 2;
$pageMaxCount = floor(($height * 0.85) / $settingHeight);
// Pagers
$pagerPrev = new Quad_Icons64x64_1();
@ -399,7 +400,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
);
}
if ($index % 13 === 0) {
if ($index % $pageMaxCount === 0) {
$pageFrame = new Frame();
$frame->addChild($pageFrame);
$posY = 0.41 * $height;
@ -418,6 +419,9 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
$nameLabel->setText($settingName);
$nameLabel->setTextSize($labelTextSize);
$nameLabel->setX(-0.46 * $width);
if ($scriptParam->desc === self::DESCRIPTION_HIDDEN) {
$nameLabel->setTextColor("AAAAAA");
}
if (!$isScriptMode) {
if (is_bool($settingValue[0])) {

View File

@ -243,7 +243,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
self::ACTION_PREFIX_SETTINGLINKS . $settingClass
);
$frame->addChild($mapNameButton);
$mapNameButton->setPosition(-$width / 2 + 60, -35);
$mapNameButton->setPosition(-$width / 2 + 60, $height * -0.45);
}
return $frame;

View File

@ -107,7 +107,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
// Config
$pagerSize = 9.;
$entryHeight = 5.;
$pageMaxCount = floor(($height * 0.85) / $entryHeight);
$pageMaxCount = floor(($height * 0.70) / $entryHeight);
// Pagers
$pagerPrev = new Quad_Icons64x64_1();
@ -150,6 +150,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
// Plugin pages
$posY = 0.;
$pluginUpdates = null;
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CHECK_UPDATE_WHEN_OPENING)) {
$pluginUpdates = $this->maniaControl->getUpdateManager()->getPluginUpdateManager()->getPluginsUpdates();
}
@ -197,8 +198,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$descriptionLabel = new Label();
$pageFrame->addChild($descriptionLabel);
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP);
$descriptionLabel->setPosition($width * -0.45, $height * -0.22);
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::BOTTOM);
$descriptionLabel->setPosition($width * -0.45, $height * -0.45);
$descriptionLabel->setSize($width * 0.7, $entryHeight);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setTranslate(true);
@ -235,7 +236,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$quadUpdate = new Quad_Icons128x128_1();
$pluginFrame->addChild($quadUpdate);
$quadUpdate->setSubStyle($quadUpdate::SUBSTYLE_ProfileVehicle);
$quadUpdate->setX(56);
$quadUpdate->setX($width / 2 - 3);
$quadUpdate->setZ(2);
$quadUpdate->setSize(5, 5);
$quadUpdate->setAction(self::ACTION_PREFIX_UPDATEPLUGIN . $pluginClass);
@ -248,7 +249,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$updatePluginsButton = new Label_Button();
$frame->addChild($updatePluginsButton);
$updatePluginsButton->setHorizontalAlign($updatePluginsButton::RIGHT);
$updatePluginsButton->setPosition($width * 0.5, -29, 2);
$updatePluginsButton->setPosition($width * 0.5, $height * -0.37, 2);
$updatePluginsButton->setWidth(10);
$updatePluginsButton->setStyle($updatePluginsButton::STYLE_CardButtonSmallS);
$updatePluginsButton->setText(count($pluginUpdates) . ' update(s)');
@ -277,7 +278,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$posY = 0;
$index = 0;
$settingHeight = 5.;
$pageSettingsMaxCount = floor(($height * 0.78) / $settingHeight);
$pageSettingsMaxCount = floor(($height * 0.70) / $settingHeight);
$pageFrame = null;
//Headline Label
@ -321,7 +322,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$descriptionLabel = new Label_Text();
$pageFrame->addChild($descriptionLabel);
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
$descriptionLabel->setPosition(-0.45 * $width, -0.35 * $height);
$descriptionLabel->setPosition(-0.45 * $width, $height * -0.38);
$descriptionLabel->setSize(0.9 * $width, $settingHeight);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setTranslate(true);
@ -389,7 +390,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
self::ACTION_PREFIX_MANAGE_SETTING_LINK . $settingClass
);
$frame->addChild($mapNameButton);
$mapNameButton->setPosition(-$width / 2 + 60, -35);
$mapNameButton->setPosition(-$width / 2 + 60, $height * -0.45);
}
return $frame;
@ -456,7 +457,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$descriptionLabel = new Label_Text();
$pageFrame->addChild($descriptionLabel);
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
$descriptionLabel->setPosition(-0.45 * $width, -0.35 * $height);
$descriptionLabel->setPosition(-0.45 * $width, $height * -0.40);
$descriptionLabel->setSize(0.9 * $width, $settingHeight);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setTranslate(true);

View File

@ -38,7 +38,6 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
const ACTION_OPEN_STATSLIST = 'SimpleStatsList.OpenStatsList';
const ACTION_SORT_STATS = 'SimpleStatsList.SortStats';
const ACTION_PAGING_CHUNKS = 'SimpleStatsList.PagingChunk';
const MAX_PLAYERS_PER_PAGE = 15;
const MAX_PAGES_PER_CHUNK = 10;
const CACHE_CURRENT_PAGE = 'SimpleStatsList.CurrentPage';
@ -146,7 +145,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$chunkIndex = $this->getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount);
$playerBeginIndex = $this->getChunkStatsBeginIndex($chunkIndex);
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
$pagesCount = ceil($totalPlayersCount / $this->getPlayersPerPage());
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$width = $this->statsWidth + 60;
@ -231,16 +230,17 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$posY -= 10;
$pageFrame = null;
$playerIndex = 1 + $playerBeginIndex;
$pageMaxCount = $this->getPlayersPerPage();
if (!isset($statRankings[$order])) {
return;
}
//Slice Array to chunk length
$statRankings[$order] = array_slice($statRankings[$order], $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE, true);
$statRankings[$order] = array_slice($statRankings[$order], $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * $pageMaxCount, true);
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
foreach ($statRankings[$order] as $playerId => $value) {
if ($index % self::MAX_PLAYERS_PER_PAGE === 1) {
if ($index % $pageMaxCount === 1) {
$pageFrame = new Frame();
$frame->addChild($pageFrame);
$pageFrame->setZ(1);
@ -337,7 +337,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
* @return int
*/
private function getChunkIndexFromPageNumber($pageIndex, $totalPlayersCount) {
$pagesCount = ceil($totalPlayersCount / self::MAX_PLAYERS_PER_PAGE);
$pagesCount = ceil($totalPlayersCount / $this->getPlayersPerPage());
if ($pageIndex > $pagesCount - 1) {
$pageIndex = $pagesCount - 1;
}
@ -351,9 +351,20 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
* @return int
*/
private function getChunkStatsBeginIndex($chunkIndex) {
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE;
return $chunkIndex * self::MAX_PAGES_PER_CHUNK * $this->getPlayersPerPage();
}
/**
* Get number of players per page
*
* @return int
*/
public function getPlayersPerPage() {
$pageheight = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
return floor($pageheight * 0.82 / 4);
}
/**
* Called on ManialinkPageAnswer
*

View File

@ -119,6 +119,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$message = "Plugins Update Check completed: There are {$updatesCount} Updates available!";
if ($player) {
$this->maniaControl->getChat()->sendSuccess($message, $player);
} else {
$this->maniaControl->getChat()->sendSuccessToAdmins($message . " (you can use //pluginsupdate)");
}
Logger::log($message);
}