From 7c2b718e3c8c067ac82a50640ab10c8f022ea246 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 15 Dec 2013 12:34:35 +0100 Subject: [PATCH] simple xlist first version --- .../core/Manialinks/ManialinkManager.php | 5 ++ application/core/Maps/MapList.php | 47 ++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/application/core/Manialinks/ManialinkManager.php b/application/core/Manialinks/ManialinkManager.php index 9d89e082..6f4e35af 100644 --- a/application/core/Manialinks/ManialinkManager.php +++ b/application/core/Manialinks/ManialinkManager.php @@ -196,6 +196,7 @@ class ManialinkManager implements CallbackListener { * @param Frame $frame * @param array $labelStrings * @param array $properties + * @return array Returns the frames (to add special Properties later) */ public function labelLine(Frame $frame, array $labelStrings, array $properties = array()){ //TODO overwrite standard properties with properties from array @@ -206,6 +207,7 @@ class ManialinkManager implements CallbackListener { $textSize = 1.5; $textColor = 'FFF'; + $frames = array(); foreach($labelStrings as $text => $x){ $label = new Label_Text(); $frame->add($label); @@ -215,6 +217,9 @@ class ManialinkManager implements CallbackListener { $label->setTextSize($textSize); $label->setText($text); $label->setTextColor($textColor); + + $frames[] = $frame; //add Frame to the frames array } + return $frames; } } diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 899f9ad0..65665763 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -24,7 +24,7 @@ use MXInfoSearcher; class MapList implements ManialinkPageAnswerListener { const ACTION_CLOSEWIDGET = 'MapList.CloseWidget'; - + const MAX_MAPS_PER_PAGE = 15; /** * Private properties */ @@ -55,6 +55,11 @@ class MapList implements ManialinkPageAnswerListener { } + /** + * Displays the Mania Exchange List + * @param array $chatCallback + * @param Player $player + */ public function showManiaExchangeList(array $chatCallback, Player $player){ $params = explode(' ', $chatCallback[1][2]); //$commandCount = count(explode(' ', $chatCallback[1][2])); @@ -99,7 +104,36 @@ class MapList implements ManialinkPageAnswerListener { $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); $frame = $this->buildMainFrame(); + $maniaLink->add($frame); + //Start offsets + $x = -$this->width / 2; + $y = $this->height / 2; + + //Headline + $headFrame = new Frame(); + $frame->add($headFrame); + $headFrame->setY($y - 3); + $array = array("Id" => $x + 5, "MapName" => $x + 15, "MapAuthor" => $x + 70, "MapMood" => $x + 90, "MapType" => $x + 105); + $this->maniaControl->manialinkManager->labelLine($headFrame,$array); + + $i = 0; + $y -= 10; + foreach($maps as $map){ + $mapFrame = new Frame(); + $frame->add($mapFrame); + $array = array($map->id => $x + 5, $map->name => $x + 15, $map->author => $x + 70, $map->mood => $x + 90, $map->maptype => $x + 105); + $this->maniaControl->manialinkManager->labelLine($mapFrame,$array); + $mapFrame->setY($y); + $y -= 4; + + $i++; + if($i == self::MAX_MAPS_PER_PAGE) + break; + } + + //TODO add MX info screen + //TODO add download Map button //render and display xml $this->maniaControl->manialinkManager->displayWidget($maniaLink, $player); @@ -153,6 +187,9 @@ class MapList implements ManialinkPageAnswerListener { //Get Maplist $mapList = $this->maniaControl->mapManager->getMapList(); + $mapList = array_slice($mapList, 0, self::MAX_MAPS_PER_PAGE); + //TODO add pages + $id = 1; $y = $this->height / 2 - 10; foreach($mapList as $map){ @@ -162,12 +199,20 @@ class MapList implements ManialinkPageAnswerListener { $mapFrame->setY($y); $y -= 4; $id++; + if($id == self::MAX_MAPS_PER_PAGE - 1) + break; } //render and display xml $this->maniaControl->manialinkManager->displayWidget($maniaLink, $player); } + /** + * Displays a single Map in the Maplist + * @param $id + * @param Map $map + * @param Frame $frame + */ private function displayMap($id, Map $map, Frame $frame){ $frame->setZ(-0.01);