minor things

This commit is contained in:
kremsy 2013-12-16 14:21:30 +01:00
parent 6f69ab30a0
commit 7b3d0d7420
2 changed files with 17 additions and 6 deletions

View File

@ -75,6 +75,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
* @param Player $player * @param Player $player
*/ */
public function showManiaExchangeList(array $chatCallback, Player $player){ public function showManiaExchangeList(array $chatCallback, Player $player){
$this->maniaControl->manialinkManager->closeWidget($player);
$params = explode(' ', $chatCallback[1][2]); $params = explode(' ', $chatCallback[1][2]);
$serverInfo = $this->maniaControl->server->getSystemInfo(); $serverInfo = $this->maniaControl->server->getSystemInfo();
@ -212,6 +214,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
* @param Player $player * @param Player $player
*/ */
public function showMapList(Player $player){ public function showMapList(Player $player){
$this->maniaControl->manialinkManager->closeWidget($player);
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$frame = $this->buildMainFrame(); $frame = $this->buildMainFrame();
@ -288,7 +291,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
} }
$y -= 4; $y -= 4;
$id++; $id++;
if($id == self::MAX_MAPS_PER_PAGE - 1) if($id == self::MAX_MAPS_PER_PAGE + 1)
break; break;
} }
@ -317,7 +320,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue); $currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue);
} }
$mxId = ''; $mxId = '-';
if(isset($map->mx->id)) if(isset($map->mx->id))
$mxId = $map->mx->id; $mxId = $map->mx->id;
@ -359,7 +362,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]); $player = $this->maniaControl->playerManager->getPlayer($callback[1][1]);
if($addMap){ //TODO log and chat message 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 }else if($eraseMap){ //TODO log and chat message
$this->maniaControl->mapManager->eraseMap(intval($actionArray[2]), $actionArray[3]); //TODO bestätigung $this->maniaControl->mapManager->eraseMap(intval($actionArray[2]), $actionArray[3]); //TODO bestätigung
$this->showMapList($player); $this->showMapList($player);

View File

@ -48,6 +48,7 @@ class MapManager implements CallbackListener {
// Register for callbacks // Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit'); $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_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 * @return array
@ -262,8 +269,9 @@ class MapManager implements CallbackListener {
// Load from MX // Load from MX
$serverInfo = $this->maniaControl->server->getSystemInfo(); $serverInfo = $this->maniaControl->server->getSystemInfo();
$title = strtolower(substr($serverInfo['TitleId'], 0, 2)); $title = strtolower(substr($serverInfo['TitleId'], 0, 2));
// Check if map exists // 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); $mapInfo = FileUtil::loadFile($url);
if (!$mapInfo || strlen($mapInfo) <= 0) { if (!$mapInfo || strlen($mapInfo) <= 0) {
// Invalid id // Invalid id
@ -300,7 +308,7 @@ class MapManager implements CallbackListener {
return; return;
} }
// Add map to map list // 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); $this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login);
return; return;
} }