improvements on mapadd

This commit is contained in:
kremsy 2014-01-12 17:15:59 +01:00 committed by Steffen Schröder
parent 8593f10ecc
commit 7a9627f41d
3 changed files with 17 additions and 17 deletions

View File

@ -52,7 +52,7 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager
*
* @param $mxMapInfos
*/
private function updateMapObjectWithManiaExchangeIds($mxMapInfos) {
public function updateMapObjectsWithManiaExchangeIds($mxMapInfos) {
$mysqli = $this->maniaControl->database->mysqli;
// Save map data
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
@ -132,14 +132,14 @@ class ManiaExchangeInfoSearcher { //TODO rename to ManiaExchangeManager
//if($id % self::MAPS_PER_MX_FETCH == 0) {
if($id % 6 == 0) { //TODO 6 is temporary
$maps = $this->getMaplistByMixedUidIdString($mapIdString);
$this->updateMapObjectWithManiaExchangeIds($maps);
$this->updateMapObjectsWithManiaExchangeIds($maps);
$mapIdString = '';
}
}
if($mapIdString != '') {
$maps = $this->getMaplistByMixedUidIdString($mapIdString);
$this->updateMapObjectWithManiaExchangeIds($maps);
$this->updateMapObjectsWithManiaExchangeIds($maps);
}
$fetchMapStatement->close();

View File

@ -340,19 +340,16 @@ class MapManager implements CallbackListener {
$title = strtolower(substr($serverInfo['TitleId'], 0, 2));
// Check if map exists
$url = "http://api.mania-exchange.com/{$title}/maps/{$mapId}?format=json";
$mxMapInfos = $this->maniaControl->mapManager->mxInfoSearcher->getMaplistByMixedUidIdString($mapId);
$mapInfo = $mxMapInfos[0];
/** @var MXMapInfo $mapInfo */
$mapInfo = FileUtil::loadFile($url, "application/json");
if(!$mapInfo || strlen($mapInfo) <= 0) {
if(!$mapInfo || !isset($mapInfo->uploaded)) {
// Invalid id
$this->maniaControl->chat->sendError('Invalid MX-Id!', $login);
return;
}
$mapInfo = json_decode($mapInfo, true);
$mapInfo = $mapInfo[0];
$url = "http://{$title}.mania-exchange.com/tracks/download/{$mapId}";
$file = FileUtil::loadFile($url);
if(!$file) {
@ -361,7 +358,7 @@ class MapManager implements CallbackListener {
return;
}
// Save map
$fileName = $mapId . '_' . $mapInfo['Name'] . '.Map.Gbx';
$fileName = $mapId . '_' . $mapInfo->name . '.Map.Gbx';
$fileName = FileUtil::getClearedFileName($fileName);
if(!file_put_contents($mapDir . $fileName, $file)) {
// Save error
@ -387,12 +384,15 @@ class MapManager implements CallbackListener {
$this->maniaControl->chat->sendError("Couldn't add map to match settings!", $login);
return;
}
$this->maniaControl->chat->sendSuccess('Map $<' . $mapInfo['Name'] . '$> added!');
$this->maniaControl->chat->sendSuccess('Map $<' . $mapInfo->name . '$> added!');
$this->updateFullMapList();
//Update Mx MapInfo
$this->maniaControl->mapManager->mxInfoSearcher->updateMapObjectsWithManiaExchangeIds($mxMapInfos);
// Queue requested Map
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($login, $mapInfo['MapUID']);
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($login, $mapInfo->uid);
}
// TODO: add local map by filename
}

View File

@ -486,7 +486,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize(5, 5);
$quad->setAction(self::ACTION_NEGATIVE_VOTE);
$quad->setActionKey($quad::ACTIONKEY_F5);
$quad->setActionKey($quad::ACTIONKEY_F7);
$label = new Label_Button();
$frame->add($label);
@ -497,19 +497,19 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
$label->setTextSize(1);
$label->setSize(3, 3);
$label->setTextColor("F00");
$label->setText("F5");
$label->setText("F7");
$quad = clone $quad;
$frame->add($quad);
$quad->setX($width / 2 - 4);
$quad->setAction(self::ACTION_POSITIVE_VOTE);
$quad->setActionKey($quad::ACTIONKEY_F6);
$quad->setActionKey($quad::ACTIONKEY_F8);
$label = clone $label;
$frame->add($label);
$label->setX($width / 2 - 4);
$label->setTextColor("0F0");
$label->setText("F6");
$label->setText("F8");
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();