improved paging code
This commit is contained in:
parent
d37acbd116
commit
74658044fc
@ -191,15 +191,12 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$y = $y - 10;
|
$y = $y - 10;
|
||||||
$pageFrames = array();
|
$pageFrame = null;
|
||||||
|
|
||||||
foreach ($commands as $command) {
|
foreach ($commands as $command) {
|
||||||
if (!isset($pageFrame)) {
|
if ($i % 15 === 1) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
}
|
}
|
||||||
@ -225,9 +222,6 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
$i++;
|
$i++;
|
||||||
if (($i - 1) % 15 == 0) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render and display xml
|
// Render and display xml
|
||||||
|
@ -182,7 +182,6 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$pagerSize = 9.;
|
$pagerSize = 9.;
|
||||||
$settingHeight = 5.;
|
$settingHeight = 5.;
|
||||||
$labelTextSize = 2;
|
$labelTextSize = 2;
|
||||||
$pageMaxCount = 13;
|
|
||||||
|
|
||||||
// Pagers
|
// Pagers
|
||||||
$pagerPrev = new Quad_Icons64x64_1();
|
$pagerPrev = new Quad_Icons64x64_1();
|
||||||
@ -210,8 +209,9 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$paging->setLabel($pageCountLabel);
|
$paging->setLabel($pageCountLabel);
|
||||||
|
|
||||||
// Setting pages
|
// Setting pages
|
||||||
$pageFrames = array();
|
$pageFrame = null;
|
||||||
$y = 0.;
|
$y = 0.;
|
||||||
|
|
||||||
foreach ($scriptParams as $index => $scriptParam) {
|
foreach ($scriptParams as $index => $scriptParam) {
|
||||||
/** @var \Maniaplanet\DedicatedServer\Structures\ScriptSettings $scriptParam */
|
/** @var \Maniaplanet\DedicatedServer\Structures\ScriptSettings $scriptParam */
|
||||||
$settingName = $scriptParam->name;
|
$settingName = $scriptParam->name;
|
||||||
@ -220,13 +220,9 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($pageFrame)) {
|
if ($index % 13 === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height * 0.41;
|
$y = $height * 0.41;
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
}
|
}
|
||||||
@ -285,9 +281,6 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$nameLabel->addTooltipFeature($descriptionLabel);
|
$nameLabel->addTooltipFeature($descriptionLabel);
|
||||||
|
|
||||||
$y -= $settingHeight;
|
$y -= $settingHeight;
|
||||||
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $frame;
|
return $frame;
|
||||||
|
@ -169,9 +169,10 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$paging->setLabel($pageCountLabel);
|
$paging->setLabel($pageCountLabel);
|
||||||
|
|
||||||
// Setting pages
|
// Setting pages
|
||||||
$pageFrames = array();
|
|
||||||
$y = 0.;
|
$y = 0.;
|
||||||
$id = 0;
|
$id = 0;
|
||||||
|
$pageFrame = null;
|
||||||
|
|
||||||
foreach ($serverSettings as $name => $value) {
|
foreach ($serverSettings as $name => $value) {
|
||||||
// Continue on CurrentMaxPlayers...
|
// Continue on CurrentMaxPlayers...
|
||||||
$pos = strpos($name, "Current"); // TODO maybe display current somewhere
|
$pos = strpos($name, "Current"); // TODO maybe display current somewhere
|
||||||
@ -179,13 +180,9 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($pageFrame)) {
|
if ($id % 13 === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height * 0.41;
|
$y = $height * 0.41;
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
}
|
}
|
||||||
@ -244,10 +241,6 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$y -= $settingHeight;
|
$y -= $settingHeight;
|
||||||
if ($id % $pageMaxCount == $pageMaxCount - 1) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
$id++;
|
$id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@ use FML\ManiaLink;
|
|||||||
use FML\Script\Features\Paging;
|
use FML\Script\Features\Paging;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Utils\ColorUtil;
|
|
||||||
use ManiaControl\Utils\Formatter;
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\IconManager;
|
use ManiaControl\Manialinks\IconManager;
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
@ -25,6 +23,8 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
|||||||
use ManiaControl\Maps\MapCommands;
|
use ManiaControl\Maps\MapCommands;
|
||||||
use ManiaControl\Maps\MapManager;
|
use ManiaControl\Maps\MapManager;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
|
use ManiaControl\Utils\ColorUtil;
|
||||||
|
use ManiaControl\Utils\Formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaExchange List Widget Class
|
* ManiaExchange List Widget Class
|
||||||
@ -177,18 +177,15 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$y = $height / 2 - 16;
|
$y = $height / 2 - 16;
|
||||||
$pageFrames = array();
|
$pageFrame = null;
|
||||||
foreach ($maps as $map) { //TODO order possibilities
|
|
||||||
|
foreach ($maps as $map) {
|
||||||
|
//TODO order possibilities
|
||||||
/** @var MxMapInfo $map */
|
/** @var MxMapInfo $map */
|
||||||
if (!isset($pageFrame)) {
|
if ($i % self::MAX_MX_MAPS_PER_PAGE === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height / 2 - 16;
|
$y = $height / 2 - 16;
|
||||||
|
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,9 +282,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
$i++;
|
$i++;
|
||||||
if ($i % self::MAX_MX_MAPS_PER_PAGE == 0) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
|
@ -218,7 +218,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
$id = 1 + $mapsBeginIndex;
|
$id = 1 + $mapsBeginIndex;
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$pageFrames = array();
|
$pageFrame = null;
|
||||||
|
|
||||||
/** @var Map $map */
|
/** @var Map $map */
|
||||||
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
|
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
|
||||||
$mxIcon = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON);
|
$mxIcon = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON);
|
||||||
@ -227,15 +228,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$mxIconGreenHover = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN_MOVER);
|
$mxIconGreenHover = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN_MOVER);
|
||||||
|
|
||||||
foreach ($mapList as $map) {
|
foreach ($mapList as $map) {
|
||||||
if (!isset($pageFrame)) {
|
if ($id % self::MAX_MAPS_PER_PAGE === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
|
|
||||||
$paging->addPage($pageFrame, $pageNumber);
|
$paging->addPage($pageFrame, $pageNumber);
|
||||||
$pageNumber++;
|
$pageNumber++;
|
||||||
}
|
}
|
||||||
@ -466,9 +462,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
if ($id % self::MAX_MAPS_PER_PAGE == 0) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
$id++;
|
$id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +67,8 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink
|
|||||||
$pagerSize = 9.;
|
$pagerSize = 9.;
|
||||||
$entryHeight = 5.;
|
$entryHeight = 5.;
|
||||||
$labelTextSize = 2;
|
$labelTextSize = 2;
|
||||||
$pageMaxCount = 10;
|
|
||||||
$y = 0.;
|
$y = 0.;
|
||||||
$pageFrames = array();
|
$pageFrame = null;
|
||||||
|
|
||||||
// Pagers
|
// Pagers
|
||||||
$pagerPrev = new Quad_Icons64x64_1();
|
$pagerPrev = new Quad_Icons64x64_1();
|
||||||
@ -110,14 +109,9 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink
|
|||||||
|
|
||||||
foreach ($pluginList as $plugin) {
|
foreach ($pluginList as $plugin) {
|
||||||
if (!in_array($plugin->id, $pluginIds)) {
|
if (!in_array($plugin->id, $pluginIds)) {
|
||||||
if (!isset($pageFrame)) {
|
if ($index % 10 === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
$y = $height * 0.41;
|
$y = $height * 0.41;
|
||||||
}
|
}
|
||||||
@ -159,10 +153,6 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink
|
|||||||
$installButton->setAction(self::ACTION_PREFIX_INSTALLPLUGIN . $plugin->id);
|
$installButton->setAction(self::ACTION_PREFIX_INSTALLPLUGIN . $plugin->id);
|
||||||
|
|
||||||
$y -= $entryHeight;
|
$y -= $entryHeight;
|
||||||
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1080,15 +1080,12 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$pageFrames = array();
|
$pageFrame = null;
|
||||||
|
|
||||||
foreach ($records as $listRecord) {
|
foreach ($records as $listRecord) {
|
||||||
if (!isset($pageFrame)) {
|
if ($i % 15 === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
}
|
}
|
||||||
@ -1114,9 +1111,6 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
|||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
$i++;
|
$i++;
|
||||||
if ($i % 15 == 0) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render and display xml
|
// Render and display xml
|
||||||
|
@ -486,20 +486,16 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$y = $y - 10;
|
$y = $y - 10;
|
||||||
$pageFrames = array();
|
$pageFrame = null;
|
||||||
|
|
||||||
foreach ($stats as $playerIndex => $donations) {
|
foreach ($stats as $playerIndex => $donations) {
|
||||||
if (!isset($pageFrame)) {
|
if ($i % 15 === 1) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$playerFrame = new Frame();
|
$playerFrame = new Frame();
|
||||||
$pageFrame->add($playerFrame);
|
$pageFrame->add($playerFrame);
|
||||||
$playerFrame->setY($y);
|
$playerFrame->setY($y);
|
||||||
@ -518,9 +514,6 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
$i++;
|
$i++;
|
||||||
if (($i - 1) % 15 == 0) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($i > 100) {
|
if ($i > 100) {
|
||||||
break;
|
break;
|
||||||
|
@ -575,17 +575,13 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$pageFrames = array();
|
$pageFrame = null;
|
||||||
|
|
||||||
foreach ($records as $listRecord) {
|
foreach ($records as $listRecord) {
|
||||||
if (!isset($pageFrame)) {
|
if ($i % 15 === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
|
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,9 +606,6 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
|
|||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
$i++;
|
$i++;
|
||||||
if ($i % 15 == 0) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render and display xml
|
// Render and display xml
|
||||||
|
@ -489,20 +489,16 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$y = $y - 10;
|
$y = $y - 10;
|
||||||
$pageFrames = array();
|
$pageFrame = null;
|
||||||
|
|
||||||
while ($rankedPlayer = $result->fetch_object()) {
|
while ($rankedPlayer = $result->fetch_object()) {
|
||||||
if (!isset($pageFrame)) {
|
if ($i % 15 === 1) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
if (!empty($pageFrames)) {
|
|
||||||
$pageFrame->setVisible(false);
|
|
||||||
}
|
|
||||||
array_push($pageFrames, $pageFrame);
|
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$paging->addPage($pageFrame);
|
$paging->addPage($pageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$playerFrame = new Frame();
|
$playerFrame = new Frame();
|
||||||
$pageFrame->add($playerFrame);
|
$pageFrame->add($playerFrame);
|
||||||
$playerFrame->setY($y);
|
$playerFrame->setY($y);
|
||||||
@ -521,9 +517,6 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
|||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
$i++;
|
$i++;
|
||||||
if (($i - 1) % 15 == 0) {
|
|
||||||
unset($pageFrame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render and display xml
|
// Render and display xml
|
||||||
|
Loading…
Reference in New Issue
Block a user