performed code formatting
This commit is contained in:
@ -58,12 +58,17 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showList');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'showList');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showList');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'showList');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +85,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
|
||||
$action = $actionArray[0] . '.' . $actionArray[1];
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$mapId = (int)$actionArray[2];
|
||||
|
||||
switch ($action) {
|
||||
@ -89,7 +95,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$this->showList($callback, $player);
|
||||
break;
|
||||
case self::ACTION_ADD_MAP:
|
||||
$this->maniaControl->getMapManager()->addMapFromMx($mapId, $player->login);
|
||||
$this->maniaControl->getMapManager()
|
||||
->addMapFromMx($mapId, $player->login);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -131,9 +138,12 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
}
|
||||
|
||||
// search for matching maps
|
||||
$this->maniaControl->getMapManager()->getMXManager()->fetchMapsAsync(function (array $maps) use (&$player) {
|
||||
$this->maniaControl->getMapManager()
|
||||
->getMXManager()
|
||||
->fetchMapsAsync(function (array $maps) use (&$player) {
|
||||
if (!$maps) {
|
||||
$this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player->login);
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('No maps found, or MX is down!', $player->login);
|
||||
return;
|
||||
}
|
||||
$this->showManiaExchangeList($maps, $player);
|
||||
@ -149,8 +159,12 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
*/
|
||||
private function showManiaExchangeList(array $maps, Player $player) {
|
||||
// Start offsets
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$posX = -$width / 2;
|
||||
$posY = $height / 2;
|
||||
|
||||
@ -161,11 +175,15 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
//Predefine description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
// Headline
|
||||
@ -173,7 +191,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($posY - 12);
|
||||
$array = array('$oId' => $posX + 3.5, '$oName' => $posX + 12.5, '$oAuthor' => $posX + 59, '$oKarma' => $posX + 85, '$oType' => $posX + 103, '$oMood' => $posX + 118, '$oLast Update' => $posX + 130);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($headFrame, $array);
|
||||
|
||||
$index = 0;
|
||||
$posY = $height / 2 - 16;
|
||||
@ -202,7 +221,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
|
||||
$time = Formatter::time_elapsed_string(strtotime($map->updated));
|
||||
$array = array('$s' . $map->id => $posX + 3.5, '$s' . $map->name => $posX + 12.5, '$s' . $map->author => $posX + 59, '$s' . str_replace('Arena', '', $map->maptype) => $posX + 103, '$s' . $map->mood => $posX + 118, '$s' . $time => $posX + 130);
|
||||
$labels = $this->maniaControl->getManialinkManager()->labelLine($mapFrame, $array);
|
||||
$labels = $this->maniaControl->getManialinkManager()
|
||||
->labelLine($mapFrame, $array);
|
||||
$authorLabel = $labels[2];
|
||||
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
|
||||
|
||||
@ -211,15 +231,21 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$mxQuad = new Quad();
|
||||
$mapFrame->add($mxQuad);
|
||||
$mxQuad->setSize(3, 3);
|
||||
$mxQuad->setImage($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
|
||||
$mxQuad->setImageFocus($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
|
||||
$mxQuad->setImage($this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON));
|
||||
$mxQuad->setImageFocus($this->maniaControl->getManialinkManager()
|
||||
->getIconManager()
|
||||
->getIcon(IconManager::MX_ICON_MOVER));
|
||||
$mxQuad->setX($posX + 56);
|
||||
$mxQuad->setUrl($map->pageurl);
|
||||
$mxQuad->setZ(0.01);
|
||||
$description = 'View $<' . $map->name . '$> on Mania-Exchange';
|
||||
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
|
||||
) {
|
||||
$addQuad = new Quad_Icons64x64_1();
|
||||
$mapFrame->add($addQuad);
|
||||
$addQuad->setX($posX + 53);
|
||||
@ -326,7 +352,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$quad->setAction(self::ACTION_SEARCH_AUTHOR);
|
||||
|
||||
// render and display xml
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'ManiaExchangeList');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'ManiaExchangeList');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,10 +81,12 @@ class ManiaExchangeManager {
|
||||
$maps = array($maps);
|
||||
} else {
|
||||
// Fetch Information for whole MapList
|
||||
$maps = $this->maniaControl->getMapManager()->getMaps();
|
||||
$maps = $this->maniaControl->getMapManager()
|
||||
->getMaps();
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mapIdString = '';
|
||||
|
||||
// Fetch mx ids
|
||||
@ -100,7 +102,8 @@ class ManiaExchangeManager {
|
||||
foreach ($maps as $map) {
|
||||
if (!$map) {
|
||||
// TODO: remove after resolving of error report about "non-object"
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('Non-Object-Map', $map, $maps);
|
||||
$this->maniaControl->getErrorHandler()
|
||||
->triggerDebugNotice('Non-Object-Map', $map, $maps);
|
||||
continue;
|
||||
}
|
||||
/** @var Map $map */
|
||||
@ -153,13 +156,15 @@ class ManiaExchangeManager {
|
||||
*/
|
||||
public function fetchMaplistByMixedUidIdString($string) {
|
||||
// Get Title Prefix
|
||||
$titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()
|
||||
->getGame();
|
||||
$titlePrefix = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap()
|
||||
->getGame();
|
||||
|
||||
// compile search URL
|
||||
$url = "http://api.mania-exchange.com/{$titlePrefix}/maps/?ids={$string}";
|
||||
|
||||
$this->maniaControl->getFileReader()->loadFile($url, function ($mapInfo, $error) use ($titlePrefix, $url) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->loadFile($url, function ($mapInfo, $error) use ($titlePrefix, $url) {
|
||||
if ($error) {
|
||||
trigger_error("Error: '{$error}' for Url '{$url}'");
|
||||
return;
|
||||
@ -194,7 +199,8 @@ class ManiaExchangeManager {
|
||||
* @param array $mxMapInfos
|
||||
*/
|
||||
public function updateMapObjectsWithManiaExchangeIds(array $mxMapInfos) {
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
// Save map data
|
||||
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
||||
SET `mxid` = ?
|
||||
@ -220,7 +226,8 @@ class ManiaExchangeManager {
|
||||
} else {
|
||||
$uid = $mxMapInfo->uid;
|
||||
}
|
||||
$map = $this->maniaControl->getMapManager()->getMapByUid($uid);
|
||||
$map = $this->maniaControl->getMapManager()
|
||||
->getMapByUid($uid);
|
||||
if ($map) {
|
||||
// TODO: how does it come that $map can be empty here? we got an error report for that
|
||||
/** @var Map $map */
|
||||
@ -247,13 +254,15 @@ class ManiaExchangeManager {
|
||||
*/
|
||||
public function fetchMapInfo($mapId, callable $function) {
|
||||
// Get Title Prefix
|
||||
$titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()
|
||||
->getGame();
|
||||
$titlePrefix = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap()
|
||||
->getGame();
|
||||
|
||||
// compile search URL
|
||||
$url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $mapId;
|
||||
|
||||
$this->maniaControl->getFileReader()->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix, $url) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix, $url) {
|
||||
$mxMapInfo = null;
|
||||
if ($error) {
|
||||
trigger_error($error);
|
||||
@ -295,8 +304,9 @@ class ManiaExchangeManager {
|
||||
|
||||
// Get Title Id
|
||||
$titleId = $this->maniaControl->getServer()->titleId;
|
||||
$titlePrefix = $this->maniaControl->getMapManager()->getCurrentMap()
|
||||
->getGame();
|
||||
$titlePrefix = $this->maniaControl->getMapManager()
|
||||
->getCurrentMap()
|
||||
->getGame();
|
||||
|
||||
// compile search URL
|
||||
$url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on';
|
||||
@ -322,13 +332,15 @@ class ManiaExchangeManager {
|
||||
|
||||
// Get MapTypes
|
||||
try {
|
||||
$scriptInfos = $this->maniaControl->getClient()->getModeScriptInfo();
|
||||
$scriptInfos = $this->maniaControl->getClient()
|
||||
->getModeScriptInfo();
|
||||
$mapTypes = $scriptInfos->compatibleMapTypes;
|
||||
$url .= '&mtype=' . $mapTypes;
|
||||
} catch (GameModeException $e) {
|
||||
}
|
||||
|
||||
$this->maniaControl->getFileReader()->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix) {
|
||||
$this->maniaControl->getFileReader()
|
||||
->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix) {
|
||||
if ($error) {
|
||||
trigger_error($error);
|
||||
return;
|
||||
|
Reference in New Issue
Block a user