From b3ce20819ea6880fec69b7dbff072b1916f4a4f9 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 28 Dec 2013 23:52:09 +0100 Subject: [PATCH] begin added jukebox places into maplist --- application/core/Maps/Jukebox.php | 14 ++++++++++++++ application/core/Maps/MapList.php | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/application/core/Maps/Jukebox.php b/application/core/Maps/Jukebox.php index 9949b444..5143ec5c 100644 --- a/application/core/Maps/Jukebox.php +++ b/application/core/Maps/Jukebox.php @@ -120,6 +120,20 @@ class Jukebox implements CallbackListener { } + /** + * Returns a list with the indexes of the juked maps + * @return array + */ + public function getJukeBoxRanking(){ + $i = 1; + $jukedMaps = array(); + foreach($this->jukedMaps as $map){ + $map = $map[1]; + $jukedMaps[$map->uid] = $i; + $i++; + } + return $jukedMaps; + } public function printAllMaps(){ foreach($this->jukedMaps as $map){ diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index b83503fb..487d3ef7 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -3,6 +3,7 @@ namespace ManiaControl\Maps; use FML\Controls\Control; use FML\Controls\Label; +use FML\Controls\Labels\Label_Text; use FML\Controls\Quads\Quad_Icons128x128_1; use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_UIConstruction_Buttons; @@ -63,6 +64,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); + $this->maniaControl->callbackManager->registerCallbackListener(Jukebox::CB_JUKEBOX_CHANGED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPLIST_UPDATED, $this, 'updateWidget'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'updateWidget'); //TODO not working yet @@ -244,6 +246,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { //TODO add pages + $jukedMaps = $this->maniaControl->mapManager->jukebox->getJukeBoxRanking(); + $id = 1; $y = $this->height / 2 - 10; foreach($mapList as $map){ @@ -252,6 +256,21 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $this->displayMap($id, $map, $mapFrame, $tooltips); $mapFrame->setY($y); + + //Juke-Map-Label + if(isset($jukedMaps[$map->uid])){ + echo "yes"; + var_dump($jukedMaps[$map->uid]); + $jukeLabel = new Label_Text(); + $mapFrame->add($jukeLabel); + $jukeLabel->setX($this->width/2 - 25); + $jukeLabel->setAlign(Control::CENTER,Control::CENTER); + $jukeLabel->setZ(0.2); + $jukeLabel->setTextSize(1.5); + $jukeLabel->setText($jukedMaps[$map->uid]); + $jukeLabel->setTextColor("FFF"); + } + //Juke-Map-Button $jukeQuad = new Quad_Icons128x128_1(); $mapFrame->add($jukeQuad);