improved paging code

This commit is contained in:
Steffen Schröder 2014-05-15 17:45:08 +02:00
parent d37acbd116
commit 74658044fc
10 changed files with 50 additions and 120 deletions

View File

@ -189,17 +189,14 @@ class HelpManager implements CommandListener, CallbackListener {
$array = array("Command" => $x + 5, "Description" => $x + 50);
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
$i = 1;
$y = $y - 10;
$pageFrames = array();
$i = 1;
$y = $y - 10;
$pageFrame = null;
foreach ($commands as $command) {
if (!isset($pageFrame)) {
if ($i % 15 === 1) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height / 2 - 10;
$paging->addPage($pageFrame);
}
@ -225,9 +222,6 @@ class HelpManager implements CommandListener, CallbackListener {
$y -= 4;
$i++;
if (($i - 1) % 15 == 0) {
unset($pageFrame);
}
}
// Render and display xml

View File

@ -182,7 +182,6 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
$pagerSize = 9.;
$settingHeight = 5.;
$labelTextSize = 2;
$pageMaxCount = 13;
// Pagers
$pagerPrev = new Quad_Icons64x64_1();
@ -210,8 +209,9 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
$paging->setLabel($pageCountLabel);
// Setting pages
$pageFrames = array();
$y = 0.;
$pageFrame = null;
$y = 0.;
foreach ($scriptParams as $index => $scriptParam) {
/** @var \Maniaplanet\DedicatedServer\Structures\ScriptSettings $scriptParam */
$settingName = $scriptParam->name;
@ -220,13 +220,9 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
continue;
}
if (!isset($pageFrame)) {
if ($index % 13 === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height * 0.41;
$paging->addPage($pageFrame);
}
@ -285,9 +281,6 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
$nameLabel->addTooltipFeature($descriptionLabel);
$y -= $settingHeight;
if ($index % $pageMaxCount == $pageMaxCount - 1) {
unset($pageFrame);
}
}
return $frame;

View File

@ -169,9 +169,10 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
$paging->setLabel($pageCountLabel);
// Setting pages
$pageFrames = array();
$y = 0.;
$id = 0;
$y = 0.;
$id = 0;
$pageFrame = null;
foreach ($serverSettings as $name => $value) {
// Continue on CurrentMaxPlayers...
$pos = strpos($name, "Current"); // TODO maybe display current somewhere
@ -179,13 +180,9 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
continue;
}
if (!isset($pageFrame)) {
if ($id % 13 === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height * 0.41;
$paging->addPage($pageFrame);
}
@ -244,10 +241,6 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
}
$y -= $settingHeight;
if ($id % $pageMaxCount == $pageMaxCount - 1) {
unset($pageFrame);
}
$id++;
}

View File

@ -16,8 +16,6 @@ use FML\ManiaLink;
use FML\Script\Features\Paging;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Utils\ColorUtil;
use ManiaControl\Utils\Formatter;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\IconManager;
use ManiaControl\Manialinks\ManialinkManager;
@ -25,6 +23,8 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Maps\MapCommands;
use ManiaControl\Maps\MapManager;
use ManiaControl\Players\Player;
use ManiaControl\Utils\ColorUtil;
use ManiaControl\Utils\Formatter;
/**
* ManiaExchange List Widget Class
@ -175,20 +175,17 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$array = array('$oId' => $x + 3.5, '$oName' => $x + 12.5, '$oAuthor' => $x + 59, '$oKarma' => $x + 85, '$oType' => $x + 103, '$oMood' => $x + 118, '$oLast Update' => $x + 130);
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
$i = 0;
$y = $height / 2 - 16;
$pageFrames = array();
foreach ($maps as $map) { //TODO order possibilities
$i = 0;
$y = $height / 2 - 16;
$pageFrame = null;
foreach ($maps as $map) {
//TODO order possibilities
/** @var MxMapInfo $map */
if (!isset($pageFrame)) {
if ($i % self::MAX_MX_MAPS_PER_PAGE === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height / 2 - 16;
$paging->addPage($pageFrame);
}
@ -285,9 +282,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$y -= 4;
$i++;
if ($i % self::MAX_MX_MAPS_PER_PAGE == 0) {
unset($pageFrame);
}
}
$label = new Label_Text();

View File

@ -216,9 +216,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
$paging->setStartPageNumber($pageIndex + 1);
$id = 1 + $mapsBeginIndex;
$y = $height / 2 - 10;
$pageFrames = array();
$id = 1 + $mapsBeginIndex;
$y = $height / 2 - 10;
$pageFrame = null;
/** @var Map $map */
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
$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);
foreach ($mapList as $map) {
if (!isset($pageFrame)) {
if ($id % self::MAX_MAPS_PER_PAGE === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height / 2 - 10;
$paging->addPage($pageFrame, $pageNumber);
$pageNumber++;
}
@ -466,9 +462,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
}
$y -= 4;
if ($id % self::MAX_MAPS_PER_PAGE == 0) {
unset($pageFrame);
}
$id++;
}

View File

@ -67,9 +67,8 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink
$pagerSize = 9.;
$entryHeight = 5.;
$labelTextSize = 2;
$pageMaxCount = 10;
$y = 0.;
$pageFrames = array();
$pageFrame = null;
// Pagers
$pagerPrev = new Quad_Icons64x64_1();
@ -110,14 +109,9 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink
foreach ($pluginList as $plugin) {
if (!in_array($plugin->id, $pluginIds)) {
if (!isset($pageFrame)) {
if ($index % 10 === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$paging->addPage($pageFrame);
$y = $height * 0.41;
}
@ -159,10 +153,6 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink
$installButton->setAction(self::ACTION_PREFIX_INSTALLPLUGIN . $plugin->id);
$y -= $entryHeight;
if ($index % $pageMaxCount == $pageMaxCount - 1) {
unset($pageFrame);
}
$index++;
}
}

View File

@ -1078,17 +1078,14 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
$array = array("Rank" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Time" => $x + 101);
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
$i = 0;
$y = $height / 2 - 10;
$pageFrames = array();
$i = 0;
$y = $height / 2 - 10;
$pageFrame = null;
foreach ($records as $listRecord) {
if (!isset($pageFrame)) {
if ($i % 15 === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height / 2 - 10;
$paging->addPage($pageFrame);
}
@ -1114,9 +1111,6 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
$y -= 4;
$i++;
if ($i % 15 == 0) {
unset($pageFrame);
}
}
// Render and display xml

View File

@ -484,22 +484,18 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$array = array('$oId' => $x + 5, '$oNickname' => $x + 18, '$oDonated planets' => $x + 70);
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
$i = 1;
$y = $y - 10;
$pageFrames = array();
$i = 1;
$y = $y - 10;
$pageFrame = null;
foreach ($stats as $playerIndex => $donations) {
if (!isset($pageFrame)) {
if ($i % 15 === 1) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height / 2 - 10;
$paging->addPage($pageFrame);
}
$playerFrame = new Frame();
$pageFrame->add($playerFrame);
$playerFrame->setY($y);
@ -518,9 +514,6 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$y -= 4;
$i++;
if (($i - 1) % 15 == 0) {
unset($pageFrame);
}
if ($i > 100) {
break;

View File

@ -573,19 +573,15 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
$array = array("Rank" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Time" => $x + 101);
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
$i = 0;
$y = $height / 2 - 10;
$pageFrames = array();
$i = 0;
$y = $height / 2 - 10;
$pageFrame = null;
foreach ($records as $listRecord) {
if (!isset($pageFrame)) {
if ($i % 15 === 0) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height / 2 - 10;
$paging->addPage($pageFrame);
}
@ -610,9 +606,6 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
$y -= 4;
$i++;
if ($i % 15 == 0) {
unset($pageFrame);
}
}
// Render and display xml

View File

@ -487,22 +487,18 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
$array = array('$oRank' => $x + 5, '$oNickname' => $x + 18, '$oAverage' => $x + 70);
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
$i = 1;
$y = $y - 10;
$pageFrames = array();
$i = 1;
$y = $y - 10;
$pageFrame = null;
while ($rankedPlayer = $result->fetch_object()) {
if (!isset($pageFrame)) {
if ($i % 15 === 1) {
$pageFrame = new Frame();
$frame->add($pageFrame);
if (!empty($pageFrames)) {
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
$y = $height / 2 - 10;
$paging->addPage($pageFrame);
}
$playerFrame = new Frame();
$pageFrame->add($playerFrame);
$playerFrame->setY($y);
@ -521,9 +517,6 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
$y -= 4;
$i++;
if (($i - 1) % 15 == 0) {
unset($pageFrame);
}
}
// Render and display xml