From 7b3d0d7420695ffa202d3b672c75ce7f7210fb71 Mon Sep 17 00:00:00 2001 From: kremsy Date: Mon, 16 Dec 2013 14:21:30 +0100 Subject: [PATCH] minor things --- application/core/Maps/MapList.php | 9 ++++++--- application/core/Maps/MapManager.php | 14 +++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 457c5b63..13cf7ddb 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -75,6 +75,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { * @param Player $player */ public function showManiaExchangeList(array $chatCallback, Player $player){ + $this->maniaControl->manialinkManager->closeWidget($player); + $params = explode(' ', $chatCallback[1][2]); $serverInfo = $this->maniaControl->server->getSystemInfo(); @@ -212,6 +214,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { * @param Player $player */ public function showMapList(Player $player){ + $this->maniaControl->manialinkManager->closeWidget($player); $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); $frame = $this->buildMainFrame(); @@ -288,7 +291,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { } $y -= 4; $id++; - if($id == self::MAX_MAPS_PER_PAGE - 1) + if($id == self::MAX_MAPS_PER_PAGE + 1) break; } @@ -317,7 +320,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue); } - $mxId = ''; + $mxId = '-'; if(isset($map->mx->id)) $mxId = $map->mx->id; @@ -359,7 +362,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $player = $this->maniaControl->playerManager->getPlayer($callback[1][1]); if($addMap){ //TODO log and chat message - $this->maniaControl->mapManager->addMapFromMx($actionArray[2],$callback[1][1]); //TODO bestätigung + $this->maniaControl->mapManager->addMapFromMx(intval($actionArray[2]),$callback[1][1]); //TODO bestätigung }else if($eraseMap){ //TODO log and chat message $this->maniaControl->mapManager->eraseMap(intval($actionArray[2]), $actionArray[3]); //TODO bestätigung $this->showMapList($player); diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index 5c6de8d1..708810b4 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -48,6 +48,7 @@ class MapManager implements CallbackListener { // Register for callbacks $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleBeginMap'); + $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapListModified'); } /** @@ -220,7 +221,13 @@ class MapManager implements CallbackListener { } } - + /** + * MapList modified by other controller or web panels + * @param array $callback + */ + public function mapListModified(array $callback){ + $this->updateFullMapList(); + } /** * @return array @@ -262,8 +269,9 @@ class MapManager implements CallbackListener { // Load from MX $serverInfo = $this->maniaControl->server->getSystemInfo(); $title = strtolower(substr($serverInfo['TitleId'], 0, 2)); + // Check if map exists - $url = "http://{$title}.mania-exchange.com/api/tracks/get_track_info/id/{$mapId}?format=json"; + $url = "http://api.mania-exchange.com/{$title}/maps/{$mapId}?format=json"; $mapInfo = FileUtil::loadFile($url); if (!$mapInfo || strlen($mapInfo) <= 0) { // Invalid id @@ -300,7 +308,7 @@ class MapManager implements CallbackListener { return; } // Add map to map list - if (!$this->maniaControl->client->query('InsertMap', $mapFileName)) { + if (!$this->maniaControl->client->query('InsertMap', $mapFileName)) { //TODO irgentein bug? $this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login); return; }