phpdoc & closure improvements
This commit is contained in:
parent
683e6f30a2
commit
0a7bc3b234
@ -3,7 +3,6 @@
|
|||||||
namespace ManiaControl\Commands;
|
namespace ManiaControl\Commands;
|
||||||
|
|
||||||
use FML\Controls\Frame;
|
use FML\Controls\Frame;
|
||||||
use FML\Controls\Label;
|
|
||||||
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use FML\Script\Features\Paging;
|
use FML\Script\Features\Paging;
|
||||||
@ -216,7 +215,6 @@ class HelpManager implements CommandListener, CallbackListener {
|
|||||||
$array = array($command['Name'] => $x + 5, $command['Description'] => $x + 50);
|
$array = array($command['Name'] => $x + 5, $command['Description'] => $x + 50);
|
||||||
$labels = $this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
|
$labels = $this->maniaControl->manialinkManager->labelLine($playerFrame, $array);
|
||||||
|
|
||||||
/** @var Label $label */
|
|
||||||
$label = $labels[0];
|
$label = $labels[0];
|
||||||
$label->setWidth(40);
|
$label->setWidth(40);
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
|
|
||||||
// search for matching maps
|
// search for matching maps
|
||||||
$self = $this;
|
$self = $this;
|
||||||
$this->maniaControl->mapManager->mxManager->getMapsAsync(function ($maps) use (&$self, &$player) {
|
$this->maniaControl->mapManager->mxManager->getMapsAsync(function (array $maps) use (&$self, &$player) {
|
||||||
if (!$maps) {
|
if (!$maps) {
|
||||||
$self->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
|
$self->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
|
||||||
return;
|
return;
|
||||||
@ -143,11 +143,11 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
/**
|
/**
|
||||||
* Display the Mania Exchange List
|
* Display the Mania Exchange List
|
||||||
*
|
*
|
||||||
* @param $maps
|
* @param MXMapInfo[] $maps
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @internal param array $chatCallback
|
* @internal param array $chatCallback
|
||||||
*/
|
*/
|
||||||
private function showManiaExchangeList($maps, Player $player) {
|
private function showManiaExchangeList(array $maps, Player $player) {
|
||||||
// Start offsets
|
// Start offsets
|
||||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
@ -181,7 +181,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
|
|
||||||
foreach ($maps as $map) {
|
foreach ($maps as $map) {
|
||||||
//TODO order possibilities
|
//TODO order possibilities
|
||||||
/** @var MxMapInfo $map */
|
|
||||||
if ($i % self::MAX_MX_MAPS_PER_PAGE === 0) {
|
if ($i % self::MAX_MX_MAPS_PER_PAGE === 0) {
|
||||||
$pageFrame = new Frame();
|
$pageFrame = new Frame();
|
||||||
$frame->add($pageFrame);
|
$frame->add($pageFrame);
|
||||||
@ -201,11 +200,9 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
$lineQuad->setZ(0.001);
|
$lineQuad->setZ(0.001);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var MxMapInfo $map */
|
$time = Formatter::time_elapsed_string(strtotime($map->updated));
|
||||||
$time = Formatter::time_elapsed_string(strtotime($map->updated));
|
$array = array('$s' . $map->id => $x + 3.5, '$s' . $map->name => $x + 12.5, '$s' . $map->author => $x + 59, '$s' . str_replace("Arena", "", $map->maptype) => $x + 103, '$s' . $map->mood => $x + 118, '$s' . $time => $x + 130);
|
||||||
$array = array('$s' . $map->id => $x + 3.5, '$s' . $map->name => $x + 12.5, '$s' . $map->author => $x + 59, '$s' . str_replace("Arena", "", $map->maptype) => $x + 103, '$s' . $map->mood => $x + 118, '$s' . $time => $x + 130);
|
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
||||||
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
|
||||||
/** @var Label_Text $authorLabel */
|
|
||||||
$authorLabel = $labels[2];
|
$authorLabel = $labels[2];
|
||||||
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
|
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
|
||||||
|
|
||||||
|
@ -310,21 +310,21 @@ class ManiaExchangeManager {
|
|||||||
$success = $this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix) {
|
$success = $this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix) {
|
||||||
if ($error) {
|
if ($error) {
|
||||||
trigger_error($error);
|
trigger_error($error);
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mxMapList = json_decode($mapInfo);
|
$mxMapList = json_decode($mapInfo);
|
||||||
|
|
||||||
if (!isset($mxMapList->results)) {
|
if (!isset($mxMapList->results)) {
|
||||||
trigger_error('Cannot decode searched JSON data');
|
trigger_error('Cannot decode searched JSON data');
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mxMapList = $mxMapList->results;
|
$mxMapList = $mxMapList->results;
|
||||||
|
|
||||||
if ($mxMapList === null) {
|
if ($mxMapList === null) {
|
||||||
trigger_error('Cannot decode searched JSON data');
|
trigger_error('Cannot decode searched JSON data');
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$maps = array();
|
$maps = array();
|
||||||
@ -335,7 +335,6 @@ class ManiaExchangeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
call_user_func($function, $maps);
|
call_user_func($function, $maps);
|
||||||
return true;
|
|
||||||
}, "application/json");
|
}, "application/json");
|
||||||
|
|
||||||
return $success;
|
return $success;
|
||||||
|
Loading…
Reference in New Issue
Block a user