From c5ab8fc1db88e9e8ed1729c3cb188c02719b47cf Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 15 Dec 2013 11:55:44 +0100 Subject: [PATCH] added labelline --- .../core/Manialinks/ManialinkManager.php | 28 +++++++++++++++++++ application/core/Maps/MapList.php | 26 +++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/application/core/Manialinks/ManialinkManager.php b/application/core/Manialinks/ManialinkManager.php index e3e90ecb..7b424c6e 100644 --- a/application/core/Manialinks/ManialinkManager.php +++ b/application/core/Manialinks/ManialinkManager.php @@ -2,6 +2,9 @@ namespace ManiaControl\Manialinks; +use FML\Controls\Control; +use FML\Controls\Frame; +use FML\Controls\Labels\Label_Text; use FML\ManiaLink; use ManiaControl\ManiaControl; use ManiaControl\Callbacks\CallbackListener; @@ -188,5 +191,30 @@ class ManialinkManager implements CallbackListener { //unset($this->playersMenuShown[$player->login]); } + /** + * Adds a line of labels + * @param Frame $frame + * @param array $labelStrings + * @param array $properties + */ + public function labelLine(Frame $frame, array $labelStrings, array $properties = array()){ + //TODO overwrite standard properties with properties from array + + //define standard properties + $hAlign = Control::LEFT; + $style = Label_Text::STYLE_TextCardSmall; + $textSize = 1.5; + $textColor = 'FFF'; + foreach($labelStrings as $text => $x){ + $label = new Label_Text(); + $frame->add($label); + $label->setHAlign($hAlign); + $label->setX($x); + $label->setStyle($style); + $label->setTextSize($textSize); + $label->setText($text); + $label->setTextColor($textColor); + } + } } diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 4781816c..899f9ad0 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -141,7 +141,16 @@ class MapList implements ManialinkPageAnswerListener { $frame = $this->buildMainFrame(); $maniaLink->add($frame); - //TODO headline + + //Headline + $headFrame = new Frame(); + $frame->add($headFrame); + $headFrame->setY($this->height / 2 - 3); + $x = -$this->width / 2; + $array = array("Id" => $x + 5, "Mx ID" => $x + 10, "MapName" => $x + 20, "Author" => $x + 70); + $this->maniaControl->manialinkManager->labelLine($headFrame,$array); + + //Get Maplist $mapList = $this->maniaControl->mapManager->getMapList(); $id = 1; @@ -160,11 +169,22 @@ class MapList implements ManialinkPageAnswerListener { } private function displayMap($id, Map $map, Frame $frame){ - $frame->setZ(-0.01); + //set starting x-value $x = -$this->width / 2; + + $mxId = ''; + if(isset($map->mx->id)) + $mxId = $map->mx->id; + + //Display Maps + $array = array($id => $x + 5, $mxId => $x + 10, $map->name => $x + 20, $map->authorNick => $x + 70); + $this->maniaControl->manialinkManager->labelLine($frame,$array); + + +/* //TODO detailed mx info page with link to mx $x +=5; $idLabel = new Label_Text(); @@ -218,7 +238,7 @@ class MapList implements ManialinkPageAnswerListener { //TODO later add buttons for jukebox, admin control buttons (remove map, change to map) //TODO side switch - //var_dump($map); + //var_dump($map);*/ }