diff --git a/application/core/Admin/AdminLists.php b/application/core/Admin/AdminLists.php index 0264690c..004aece4 100644 --- a/application/core/Admin/AdminLists.php +++ b/application/core/Admin/AdminLists.php @@ -93,8 +93,8 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { $maniaLink->add($frame); // Start offsets - $x = -$width / 2; - $y = $height / 2; + $posX = -$width / 2; + $posY = $height / 2; //Predefine description Label $descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel(); @@ -103,28 +103,28 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { // Headline $headFrame = new Frame(); $frame->add($headFrame); - $headFrame->setY($y - 5); - $array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Actions" => $x + 120); + $headFrame->setY($posY - 5); + $array = array("Id" => $posX + 5, "Nickname" => $posX + 18, "Login" => $posX + 70, "Actions" => $posX + 120); $this->maniaControl->manialinkManager->labelLine($headFrame, $array); - $i = 1; - $y = $y - 10; + $index = 1; + $posY -= 10; $pageFrame = null; foreach ($admins as $admin) { - if ($i % self::MAX_PLAYERS_PER_PAGE === 1) { + if ($index % self::MAX_PLAYERS_PER_PAGE === 1) { $pageFrame = new Frame(); $frame->add($pageFrame); $paging->addPage($pageFrame); - $y = $height / 2 - 10; + $posY = $height / 2 - 10; } $playerFrame = new Frame(); $pageFrame->add($playerFrame); - $playerFrame->setY($y); + $playerFrame->setY($posY); - if ($i % 2 !== 0) { + if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); $playerFrame->add($lineQuad); $lineQuad->setSize($width, 4); @@ -132,21 +132,21 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { $lineQuad->setZ(0.001); } - $array = array($i => $x + 5, $admin->nickname => $x + 18, $admin->login => $x + 70); + $array = array($index => $posX + 5, $admin->nickname => $posX + 18, $admin->login => $posX + 70); $this->maniaControl->manialinkManager->labelLine($playerFrame, $array); // Level Quad $rightQuad = new Quad_BgRaceScore2(); $playerFrame->add($rightQuad); - $rightQuad->setX($x + 13); + $rightQuad->setX($posX + 13); $rightQuad->setZ(5); $rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher); $rightQuad->setSize(7, 3.5); $rightLabel = new Label_Text(); $playerFrame->add($rightLabel); - $rightLabel->setX($x + 13.9); + $rightLabel->setX($posX + 13.9); $rightLabel->setTextSize(0.8); $rightLabel->setZ(10); $rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($admin)); @@ -165,7 +165,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { $quad = new Quad_BgsPlayerCard(); $playerFrame->add($quad); $quad->setZ(11); - $quad->setX($x + 130); + $quad->setX($posX + 130); $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); $quad->setSize($quadWidth, $quadHeight); $quad->setAction(self::ACTION_REVOKE_RIGHTS . "." . $admin->login); @@ -173,7 +173,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { //Label $label = new Label_Button(); $playerFrame->add($label); - $label->setX($x + 130); + $label->setX($posX + 130); $quad->setZ(12); $label->setStyle($style); $label->setTextSize(1); @@ -181,8 +181,8 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { $label->setText("Revoke Rights"); } - $y -= 4; - $i++; + $posY -= 4; + $index++; } // Render and display xml diff --git a/application/core/Callbacks/LibXmlRpcCallbacks.php b/application/core/Callbacks/LibXmlRpcCallbacks.php index d515d59e..fe7bae3f 100644 --- a/application/core/Callbacks/LibXmlRpcCallbacks.php +++ b/application/core/Callbacks/LibXmlRpcCallbacks.php @@ -70,7 +70,7 @@ class LibXmlRpcCallbacks implements CallbackListener { break; case 'EndMap': case 'LibXmlRpc_EndMap': - $this->maniaControl->mapManager->handleScriptEndMap($data[1]); + $this->maniaControl->mapManager->handleScriptEndMap(); break; case 'LibXmlRpc_BeginPodium': $this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINPODIUM); diff --git a/application/core/Commands/HelpManager.php b/application/core/Commands/HelpManager.php index 7ed8cc59..2653ec77 100644 --- a/application/core/Commands/HelpManager.php +++ b/application/core/Commands/HelpManager.php @@ -19,6 +19,7 @@ use ManiaControl\Players\Player; * @copyright 2014 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ +// TODO: refactor code - i see duplicated code all over the place.. class HelpManager implements CommandListener, CallbackListener { /* * Private Properties @@ -69,8 +70,8 @@ class HelpManager implements CommandListener, CallbackListener { } } - usort($showCommands, function ($a, $b) { - return strcmp($a["Name"], $b["Name"]); + usort($showCommands, function ($commandA, $commandB) { + return strcmp($commandA['Name'], $commandB['Name']); }); $message = 'Supported Admin Commands: '; @@ -100,8 +101,8 @@ class HelpManager implements CommandListener, CallbackListener { } } - usort($showCommands, function ($a, $b) { - return strcmp($a["Name"], $b["Name"]); + usort($showCommands, function ($commandA, $commandB) { + return strcmp($commandA['Name'], $commandB['Name']); }); $message = 'Supported Player Commands: '; @@ -146,8 +147,8 @@ class HelpManager implements CommandListener, CallbackListener { } } - usort($showCommands, function ($a, $b) { - return strcmp($a["Name"], $b["Name"]); + usort($showCommands, function ($commandA, $commandB) { + return strcmp($commandA['Name'], $commandB['Name']); }); $this->showHelpAllList($showCommands, $player); @@ -174,8 +175,8 @@ class HelpManager implements CommandListener, CallbackListener { $maniaLink->add($frame); // Start offsets - $x = -$width / 2; - $y = $height / 2; + $posX = -$width / 2; + $posY = $height / 2; //Predefine description Label $descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel(); @@ -184,27 +185,27 @@ class HelpManager implements CommandListener, CallbackListener { // Headline $headFrame = new Frame(); $frame->add($headFrame); - $headFrame->setY($y - 5); - $array = array("Command" => $x + 5, "Description" => $x + 50); + $headFrame->setY($posY - 5); + $array = array('Command' => $posX + 5, 'Description' => $posX + 50); $this->maniaControl->manialinkManager->labelLine($headFrame, $array); - $i = 1; - $y = $y - 10; + $index = 1; + $posY -= 10; $pageFrame = null; foreach ($commands as $command) { - if ($i % 15 === 1) { + if ($index % 15 === 1) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height / 2 - 10; + $posY = $height / 2 - 10; $paging->addPage($pageFrame); } $playerFrame = new Frame(); $pageFrame->add($playerFrame); - $playerFrame->setY($y); + $playerFrame->setY($posY); - if ($i % 2 !== 0) { + if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); $playerFrame->add($lineQuad); $lineQuad->setSize($width, 4); @@ -212,14 +213,14 @@ class HelpManager implements CommandListener, CallbackListener { $lineQuad->setZ(0.001); } - $array = array($command['Name'] => $x + 5, $command['Description'] => $x + 50); + $array = array($command['Name'] => $posX + 5, $command['Description'] => $posX + 50); $labels = $this->maniaControl->manialinkManager->labelLine($playerFrame, $array); $label = $labels[0]; $label->setWidth(40); - $y -= 4; - $i++; + $posY -= 4; + $index++; } // Render and display xml diff --git a/application/core/Configurators/Configurator.php b/application/core/Configurators/Configurator.php index ae0e9d5e..f48e85ad 100644 --- a/application/core/Configurators/Configurator.php +++ b/application/core/Configurators/Configurator.php @@ -334,13 +334,13 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn * @return int */ public function getMenuId($title) { - $i = 0; + $index = 0; foreach ($this->menus as $menu) { - /** @var ConfiguratorMenu $menu */ + /** @var ConfiguratorMenu $menu */ if ($menu === $title || $menu->getTitle() === $title) { - return $i; + return $index; } - $i++; + $index++; } return 0; } diff --git a/application/core/Configurators/ManiaControlSettings.php b/application/core/Configurators/ManiaControlSettings.php index 37bf3d24..2c638a24 100644 --- a/application/core/Configurators/ManiaControlSettings.php +++ b/application/core/Configurators/ManiaControlSettings.php @@ -221,7 +221,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $pagerSize = 9.; $settingHeight = 5.; $pageMaxCount = 13; - $y = 0; + $posY = 0; // Pagers $pagerPrev = new Quad_Icons64x64_1(); @@ -254,7 +254,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { if ($index % $pageMaxCount === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height * 0.41; + $posY = $height * 0.41; $paging->addPage($pageFrame); } @@ -269,7 +269,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $pageFrame->add($classLabel); $classLabel->setHAlign($classLabel::LEFT); - $classLabel->setPosition($width * -0.45, $y); + $classLabel->setPosition($width * -0.45, $posY); $classLabel->setSize($width * 0.9, $settingHeight * 0.9); $classLabel->setStyle($classLabel::STYLE_TextCardSmall); $classLabel->setTextSize(2); @@ -277,7 +277,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $classLabel->setTextColor('fff'); $classLabel->setAction(self::ACTION_PREFIX_SETTINGCLASS . $settingClass); - $y -= $settingHeight; + $posY -= $settingHeight; $index++; } diff --git a/application/core/Configurators/ScriptSettings.php b/application/core/Configurators/ScriptSettings.php index 022115ad..ce794139 100644 --- a/application/core/Configurators/ScriptSettings.php +++ b/application/core/Configurators/ScriptSettings.php @@ -15,7 +15,6 @@ use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; use ManiaControl\ManiaControl; -use ManiaControl\Maps\Map; use ManiaControl\Players\Player; use Maniaplanet\DedicatedServer\Xmlrpc\Exception; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; @@ -144,11 +143,9 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { } /** - * Handle OnBegin Map Callback - * - * @param Map $map + * Handle Begin Map Callback */ - public function onBeginMap(Map $map) { + public function onBeginMap() { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN)) { $this->loadSettingsFromDatabase(); } @@ -210,7 +207,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { // Setting pages $pageFrame = null; - $y = 0.; + $posY = 0.; foreach ($scriptParams as $index => $scriptParam) { /** @var \Maniaplanet\DedicatedServer\Structures\ScriptSettings $scriptParam */ @@ -223,13 +220,13 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { if ($index % 13 === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height * 0.41; + $posY = $height * 0.41; $paging->addPage($pageFrame); } $settingFrame = new Frame(); $pageFrame->add($settingFrame); - $settingFrame->setY($y); + $settingFrame->setY($posY); $nameLabel = new Label_Text(); $settingFrame->add($nameLabel); @@ -278,7 +275,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { $descriptionLabel->setText($scriptParam->desc); $nameLabel->addTooltipFeature($descriptionLabel); - $y -= $settingHeight; + $posY -= $settingHeight; } return $frame; diff --git a/application/core/Files/AsynchronousFileReader.php b/application/core/Files/AsynchronousFileReader.php index d6a9c7ae..d449ae9d 100644 --- a/application/core/Files/AsynchronousFileReader.php +++ b/application/core/Files/AsynchronousFileReader.php @@ -16,6 +16,11 @@ use ManiaControl\ManiaControl; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class AsynchronousFileReader { + /* + * Constants + */ + const CONTENT_TYPE_JSON = 'application/json'; + /* * Private Properties */ @@ -52,53 +57,46 @@ class AsynchronousFileReader { } /** - * Load a remote file + * Load a Remote File * - * @param string $url - * @param callable $function - * @param string $contentType - * @param int $keepAlive + * @param string $url + * @param callable $function + * @param string $contentType + * @param int $keepAlive * @return bool */ - public function loadFile($url, $function, $contentType = 'UTF-8', $keepAlive = 0) { - if (!is_callable($function)) { - $this->maniaControl->log("Function is not callable"); - return false; - } - + public function loadFile($url, callable $function, $contentType = 'UTF-8', $keepAlive = 0) { if (!$url) { - $this->maniaControl->log("Url is empty"); + $this->maniaControl->log('Missing URL!'); return false; } + $headers = array('Content-Type: ' . $contentType); if ($keepAlive) { - $header = array("Content-Type: " . $contentType, "Keep-Alive: " . $keepAlive, "Connection: Keep-Alive"); - } else { - $header = array("Content-Type: " . $contentType); + array_push($headers, 'Keep-Alive: ' . $keepAlive); + array_push($headers, 'Connection: Keep-Alive'); } $request = new Request($url); - - $request->getOptions()->set(CURLOPT_TIMEOUT, 10) // - ->set(CURLOPT_HEADER, false) //don't display response header - ->set(CURLOPT_CRLF, true) //linux linefeed - ->set(CURLOPT_ENCODING, '')//accept encoding - ->set(CURLOPT_AUTOREFERER, true)//accept link reference - ->set(CURLOPT_HTTPHEADER, $header) // - ->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) // + $request->getOptions() // request options + ->set(CURLOPT_TIMEOUT, 10) // timeout + ->set(CURLOPT_HEADER, false) // don't display response header + ->set(CURLOPT_CRLF, true) // linux linefeed + ->set(CURLOPT_ENCODING, '') // accept encoding + ->set(CURLOPT_AUTOREFERER, true) // accept link reference + ->set(CURLOPT_HTTPHEADER, $headers) // headers + ->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) // user-agent ->set(CURLOPT_RETURNTRANSFER, true); $request->addListener('complete', function (Event $event) use (&$function) { $response = $event->response; - - $error = null; - $content = null; + $error = null; + $content = null; if ($response->hasError()) { $error = $response->getError()->getMessage(); } else { $content = $response->getContent(); } - call_user_func($function, $content, $error); }); diff --git a/application/core/Files/BackupUtil.php b/application/core/Files/BackupUtil.php index 5fac3b95..9449d3be 100644 --- a/application/core/Files/BackupUtil.php +++ b/application/core/Files/BackupUtil.php @@ -77,7 +77,7 @@ abstract class BackupUtil { trigger_error("Couldn't open Folder '{$folderName}' for Backup!"); return false; } - $useBaseFileNames = (count($baseFileNames) > 0); + $useBaseFileNames = !empty($baseFileNames); while (false !== ($file = readdir($folderHandle))) { if (substr($file, 0, 1) === '.') { // Skip such .files diff --git a/application/core/ManiaExchange/ManiaExchangeList.php b/application/core/ManiaExchange/ManiaExchangeList.php index 9919eaed..8b9ea339 100644 --- a/application/core/ManiaExchange/ManiaExchangeList.php +++ b/application/core/ManiaExchange/ManiaExchangeList.php @@ -152,8 +152,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener // Start offsets $width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth(); $height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight(); - $x = -$width / 2; - $y = $height / 2; + $posX = -$width / 2; + $posY = $height / 2; //Create ManiaLink $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); @@ -172,20 +172,20 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener // Headline $headFrame = new Frame(); $frame->add($headFrame); - $headFrame->setY($y - 12); - $array = array('$oId' => $x + 3.5, '$oName' => $x + 12.5, '$oAuthor' => $x + 59, '$oKarma' => $x + 85, '$oType' => $x + 103, '$oMood' => $x + 118, '$oLast Update' => $x + 130); + $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->manialinkManager->labelLine($headFrame, $array); - $i = 0; - $y = $height / 2 - 16; + $index = 0; + $posY = $height / 2 - 16; $pageFrame = null; foreach ($maps as $map) { //TODO order possibilities - if ($i % self::MAX_MX_MAPS_PER_PAGE === 0) { + if ($index % self::MAX_MX_MAPS_PER_PAGE === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height / 2 - 16; + $posY = $height / 2 - 16; $paging->addPage($pageFrame); } @@ -193,7 +193,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $mapFrame = new Frame(); $pageFrame->add($mapFrame); - if ($i % 2 === 0) { + if ($index % 2 === 0) { $lineQuad = new Quad_BgsPlayerCard(); $mapFrame->add($lineQuad); $lineQuad->setSize($width, 4); @@ -202,19 +202,19 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener } $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 => $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->manialinkManager->labelLine($mapFrame, $array); $authorLabel = $labels[2]; $authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author); - $mapFrame->setY($y); + $mapFrame->setY($posY); $mxQuad = new Quad(); $mapFrame->add($mxQuad); $mxQuad->setSize(3, 3); $mxQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON)); $mxQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER)); - $mxQuad->setX($x + 56); + $mxQuad->setX($posX + 56); $mxQuad->setUrl($map->pageurl); $mxQuad->setZ(0.01); $description = 'View $<' . $map->name . '$> on Mania-Exchange'; @@ -223,7 +223,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) { $addQuad = new Quad_Icons64x64_1(); $mapFrame->add($addQuad); - $addQuad->setX($x + 53); + $addQuad->setX($posX + 53); $addQuad->setZ(-0.1); $addQuad->setSubStyle($addQuad::SUBSTYLE_Add); $addQuad->setSize(4, 4); @@ -240,12 +240,12 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $mapFrame->add($awardQuad); $awardQuad->setSize(3, 3); $awardQuad->setSubStyle($awardQuad::SUBSTYLE_OfficialRace); - $awardQuad->setX($x + 97); + $awardQuad->setX($posX + 97); $awardQuad->setZ(0.01); $awardLabel = new Label_Text(); $mapFrame->add($awardLabel); - $awardLabel->setX($x + 98.5); + $awardLabel->setX($posX + 98.5); $awardLabel->setHAlign(Control::LEFT); $awardLabel->setText($map->awards); $awardLabel->setTextSize(1.3); @@ -258,7 +258,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $karmaGauge = new Gauge(); $mapFrame->add($karmaGauge); $karmaGauge->setZ(2); - $karmaGauge->setX($x + 89); + $karmaGauge->setX($posX + 89); $karmaGauge->setSize(16.5, 9); $karmaGauge->setDrawBg(false); $karma = floatval($karma); @@ -269,7 +269,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $karmaLabel = new Label(); $mapFrame->add($karmaLabel); $karmaLabel->setZ(2); - $karmaLabel->setX($x + 89); + $karmaLabel->setX($posX + 89); $karmaLabel->setSize(16.5 * 0.9, 5); $karmaLabel->setTextSize(0.9); $karmaLabel->setTextColor('000'); @@ -277,8 +277,8 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener } - $y -= 4; - $i++; + $posY -= 4; + $index++; } $label = new Label_Text(); diff --git a/application/core/ManiaExchange/ManiaExchangeManager.php b/application/core/ManiaExchange/ManiaExchangeManager.php index 1de29c4b..5b763e9d 100644 --- a/application/core/ManiaExchange/ManiaExchangeManager.php +++ b/application/core/ManiaExchange/ManiaExchangeManager.php @@ -2,6 +2,7 @@ namespace ManiaControl\ManiaExchange; +use ManiaControl\Files\AsynchronousFileReader; use ManiaControl\ManiaControl; use ManiaControl\Maps\Map; use ManiaControl\Maps\MapManager; @@ -94,7 +95,7 @@ class ManiaExchangeManager { return; } - $id = 0; + $index = 0; foreach ($maps as $map) { /** @var Map $map */ $fetchMapStatement->bind_param('i', $map->index); @@ -119,10 +120,10 @@ class ManiaExchangeManager { $appendString = $map->uid . ','; } - $id++; + $index++; //If Max Maplimit is reached, or string gets too long send the request - if ($id % self::MAPS_PER_MX_FETCH === 0) { + if ($index % self::MAPS_PER_MX_FETCH === 0) { $mapIdString = substr($mapIdString, 0, -1); $this->getMaplistByMixedUidIdString($mapIdString); $mapIdString = ''; @@ -179,7 +180,7 @@ class ManiaExchangeManager { } $thisRef->updateMapObjectsWithManiaExchangeIds($maps); - }, "application/json"); + }, AsynchronousFileReader::CONTENT_TYPE_JSON); return $success; } @@ -229,16 +230,16 @@ class ManiaExchangeManager { /** * Get Map Info Asynchronously * - * @param int $id + * @param int $mapId * @param callable $function * @return bool */ - public function getMapInfo($id, callable $function) { + public function getMapInfo($mapId, callable $function) { // Get Title Prefix $titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame(); // compile search URL - $url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $id; + $url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $mapId; return $this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix, $url) { $mxMapInfo = null; @@ -248,31 +249,26 @@ class ManiaExchangeManager { $mxMapList = json_decode($mapInfo); if (!is_array($mxMapList)) { trigger_error('Cannot decode searched JSON data from ' . $url); - } else if (count($mxMapList) > 0) { + } else if (!empty($mxMapList)) { $mxMapInfo = new MXMapInfo($titlePrefix, $mxMapList[0]); } } call_user_func($function, $mxMapInfo); - }, "application/json"); + }, AsynchronousFileReader::CONTENT_TYPE_JSON); } /** * Fetch a MapList Asynchronously * - * @param $function - * @param string $name - * @param string $author - * @param string $env - * @param int $maxMapsReturned - * @param int $searchOrder + * @param callable $function + * @param string $name + * @param string $author + * @param string $env + * @param int $maxMapsReturned + * @param int $searchOrder * @return bool */ - public function getMapsAsync($function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) { - if (!is_callable($function)) { - $this->maniaControl->log("Function is not callable"); - return false; - } - + public function getMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = self::SEARCH_ORDER_UPDATED_NEWEST) { // TODO: remove $env because it's not really used? // Get Title Id @@ -337,7 +333,7 @@ class ManiaExchangeManager { } call_user_func($function, $maps); - }, "application/json"); + }, AsynchronousFileReader::CONTENT_TYPE_JSON); return $success; } diff --git a/application/core/Maps/MapCommands.php b/application/core/Maps/MapCommands.php index 8683f03d..b2198a70 100644 --- a/application/core/Maps/MapCommands.php +++ b/application/core/Maps/MapCommands.php @@ -433,7 +433,9 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb } } - usort($mapList, array($this, 'sortByKarma')); + usort($mapList, function (Map $mapA, Map $mapB) { + return ($mapA->karma - $mapB->karma); + }); if ($best) { $mapList = array_reverse($mapList); } @@ -453,10 +455,9 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb private function showMapListDate($newest, Player $player) { $maps = $this->maniaControl->mapManager->getMaps(); - usort($maps, function ($a, $b) { - return ($a->index - $b->index); + usort($maps, function (Map $mapA, Map $mapB) { + return ($mapA->index - $mapB->index); }); - if ($newest) { $maps = array_reverse($maps); } @@ -473,15 +474,4 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb public function command_xList(array $chatCallback, Player $player) { $this->maniaControl->mapManager->mxList->showList($chatCallback, $player); } - - /** - * Helper Function to sort Maps by Karma - * - * @param Map $a - * @param Map $b - * @return mixed - */ - private function sortByKarma(Map $a, Map $b) { - return ($a->karma - $b->karma); - } } diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 98c9eed5..5fc16a24 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -198,8 +198,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $headFrame = new Frame(); $frame->add($headFrame); $headFrame->setY($height / 2 - 5); - $x = -$width / 2; - $array = array('Id' => $x + 5, 'Mx Id' => $x + 10, 'Map Name' => $x + 20, 'Author' => $x + 68, 'Karma' => $x + 115, 'Actions' => $width / 2 - 16); + $posX = -$width / 2; + $array = array('Id' => $posX + 5, 'Mx Id' => $posX + 10, 'Map Name' => $posX + 20, 'Author' => $posX + 68, 'Karma' => $posX + 115, 'Actions' => $width / 2 - 16); $this->maniaControl->manialinkManager->labelLine($headFrame, $array); // Predefine description Label @@ -214,11 +214,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $paging->setStartPageNumber($pageIndex + 1); $index = 0; - $id = 1 + $mapsBeginIndex; - $y = $height / 2 - 10; + $mapListId = 1 + $mapsBeginIndex; + $posY = $height / 2 - 10; $pageFrame = null; - /** @var Map $map */ $currentMap = $this->maniaControl->mapManager->getCurrentMap(); $mxIcon = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON); $mxIconHover = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER); @@ -226,10 +225,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $mxIconGreenHover = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN_MOVER); foreach ($mapList as $map) { + /** @var Map $map */ if ($index % self::MAX_MAPS_PER_PAGE === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height / 2 - 10; + $posY = $height / 2 - 10; $paging->addPage($pageFrame, $pageNumber); $pageNumber++; } @@ -237,10 +237,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { // Map Frame $mapFrame = new Frame(); $pageFrame->add($mapFrame); + $mapFrame->setY($posY); $mapFrame->setZ(0.1); - $mapFrame->setY($y); - if ($id % 2 !== 0) { + if ($mapListId % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); $mapFrame->add($lineQuad); $lineQuad->setSize($width, 4); @@ -251,7 +251,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { if ($currentMap === $map) { $currentQuad = new Quad_Icons64x64_1(); $mapFrame->add($currentQuad); - $currentQuad->setX($x + 3.5); + $currentQuad->setX($posX + 3.5); $currentQuad->setZ(0.2); $currentQuad->setSize(4, 4); $currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue); @@ -266,7 +266,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $mxQuad->setSize(3, 3); $mxQuad->setImage($mxIcon); $mxQuad->setImageFocus($mxIconHover); - $mxQuad->setX($x + 65); + $mxQuad->setX($posX + 65); $mxQuad->setUrl($map->mx->pageurl); $mxQuad->setZ(0.01); $description = 'View $<' . $map->name . '$> on Mania-Exchange'; @@ -278,7 +278,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $mxQuad->setSize(3, 3); $mxQuad->setImage($mxIconGreen); $mxQuad->setImageFocus($mxIconGreenHover); - $mxQuad->setX($x + 62); + $mxQuad->setX($posX + 62); $mxQuad->setUrl($map->mx->pageurl); $mxQuad->setZ(0.01); $description = 'Update for $<' . $map->name . '$> available on Mania-Exchange!'; @@ -292,7 +292,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { } // Display Maps - $array = array($id => $x + 5, $mxId => $x + 10, Formatter::stripDirtyCodes($map->name) => $x + 20, $map->authorNick => $x + 68); + $array = array($mapListId => $posX + 5, $mxId => $posX + 10, Formatter::stripDirtyCodes($map->name) => $posX + 20, $map->authorNick => $posX + 68); $labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array); if (isset($labels[3])) { /** @var Label $label */ @@ -359,7 +359,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $eraseLabel->setText('x'); $eraseLabel->setTextColor('a00'); - $confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $map->uid, true); + $confirmFrame = $this->buildConfirmFrame($maniaLink, $posY, $map->uid, true); $eraseLabel->addToggleFeature($confirmFrame); $description = 'Remove Map: $<' . $map->name . '$>'; $eraseLabel->addTooltipLabelFeature($descriptionLabel, $description); @@ -376,7 +376,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $switchLabel->setText('ยป'); $switchLabel->setTextColor('0f0'); - $confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $map->uid); + $confirmFrame = $this->buildConfirmFrame($maniaLink, $posY, $map->uid); $switchLabel->addToggleFeature($confirmFrame); $description = 'Switch Directly to Map: $<' . $map->name . '$>'; @@ -438,7 +438,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $karmaGauge = new Gauge(); $mapFrame->add($karmaGauge); $karmaGauge->setZ(2); - $karmaGauge->setX($x + 120); + $karmaGauge->setX($posX + 120); $karmaGauge->setSize(20, 9); $karmaGauge->setDrawBg(false); $karma = floatval($karma); @@ -449,7 +449,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $karmaLabel = new Label(); $mapFrame->add($karmaLabel); $karmaLabel->setZ(2); - $karmaLabel->setX($x + 120); + $karmaLabel->setX($posX + 120); $karmaLabel->setSize(20 * 0.9, 5); $karmaLabel->setTextSize(0.9); $karmaLabel->setTextColor('000'); @@ -457,8 +457,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { } } - $y -= 4; - $id++; + $posY -= 4; + $mapListId++; $index++; } @@ -494,12 +494,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { * Builds the confirmation frame * * @param ManiaLink $maniaLink - * @param float $y + * @param float $posY * @param bool $mapUid * @param bool $erase * @return Frame */ - public function buildConfirmFrame(Manialink $maniaLink, $y, $mapUid, $erase = false) { + public function buildConfirmFrame(Manialink $maniaLink, $posY, $mapUid, $erase = false) { // TODO: get rid of the confirm frame to decrease xml size & network usage $width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth(); @@ -508,7 +508,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $confirmFrame = new Frame(); $maniaLink->add($confirmFrame); - $confirmFrame->setPosition($width / 2 + 6, $y); + $confirmFrame->setPosition($width / 2 + 6, $posY); $confirmFrame->setVisible(false); $quad = new Quad(); diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index 7c03efe3..ecefa473 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -244,22 +244,21 @@ class MapManager implements CallbackListener { public function addMapFromMx($mapId, $login, $update = false) { if (is_numeric($mapId)) { // Check if map exists - $self = $this; - $this->maniaControl->mapManager->mxManager->getMapInfo($mapId, function (MXMapInfo $mapInfo) use (&$self, &$login, &$update) { + $this->maniaControl->mapManager->mxManager->getMapInfo($mapId, function (MXMapInfo $mapInfo) use (&$login, &$update) { if (!$mapInfo || !isset($mapInfo->uploaded)) { // Invalid id - $self->maniaControl->chat->sendError('Invalid MX-Id!', $login); + $this->maniaControl->chat->sendError('Invalid MX-Id!', $login); return; } // Download the file - $self->maniaControl->fileReader->loadFile($mapInfo->downloadurl, function ($file, $error) use (&$self, &$login, &$mapInfo, &$update) { + $this->maniaControl->fileReader->loadFile($mapInfo->downloadurl, function ($file, $error) use (&$login, &$mapInfo, &$update) { if (!$file || $error) { // Download error - $self->maniaControl->chat->sendError("Download failed: '{$error}'!", $login); + $this->maniaControl->chat->sendError("Download failed: '{$error}'!", $login); return; } - $self->processMapFile($file, $mapInfo, $login, $update); + $this->processMapFile($file, $mapInfo, $login, $update); }); }); } @@ -379,9 +378,9 @@ class MapManager implements CallbackListener { $tempList = array(); try { - $i = 0; - while (true) { - $maps = $this->maniaControl->client->getMapList(150, $i); + $offset = 0; + while ($this->maniaControl->client) { + $maps = $this->maniaControl->client->getMapList(150, $offset); foreach ($maps as $rpcMap) { if (array_key_exists($rpcMap->uId, $this->maps)) { @@ -394,7 +393,7 @@ class MapManager implements CallbackListener { } } - $i += 150; + $offset += 150; } } catch (IndexOutOfBoundException $e) { } @@ -554,14 +553,14 @@ class MapManager implements CallbackListener { $lowerMapArray = array(); $higherMapArray = array(); - $i = 0; + $index = 0; foreach ($this->maps as $map) { - if ($i < $currentIndex) { + if ($index < $currentIndex) { $lowerMapArray[] = $map->fileName; } else { $higherMapArray[] = $map->fileName; } - $i++; + $index++; } $mapArray = array_merge($higherMapArray, $lowerMapArray); @@ -708,10 +707,8 @@ class MapManager implements CallbackListener { /** * Handle Script EndMap Callback - * - * @param string $mapUid */ - public function handleScriptEndMap($mapUid) { + public function handleScriptEndMap() { $this->endMap(); } diff --git a/application/core/Maps/MapQueue.php b/application/core/Maps/MapQueue.php index c12526d0..91665a17 100644 --- a/application/core/Maps/MapQueue.php +++ b/application/core/Maps/MapQueue.php @@ -409,12 +409,12 @@ class MapQueue implements CallbackListener, CommandListener { * @return array */ public function getQueuedMapsRanking() { - $i = 1; + $index = 1; $queuedMaps = array(); foreach ($this->queuedMaps as $queuedMap) { $map = $queuedMap[1]; - $queuedMaps[$map->uid] = $i; - $i++; + $queuedMaps[$map->uid] = $index; + $index++; } return $queuedMaps; } diff --git a/application/core/Players/PlayerActions.php b/application/core/Players/PlayerActions.php index ddff20f1..bb2b29f7 100644 --- a/application/core/Players/PlayerActions.php +++ b/application/core/Players/PlayerActions.php @@ -322,17 +322,17 @@ class PlayerActions { $label->setText('Administrative Warning'); $label->setTextColor('f00'); - $y = $height / 2 - 15; + $posY = $height / 2 - 15; foreach ($message as $line) { // Message lines $label = new Label_Text(); $frame->add($label); - $label->setY($y); - $label->setStyle(Label_Text::STYLE_TextCardMedium); + $label->setY($posY); + $label->setStyle($label::STYLE_TextCardMedium); $label->setText($line); $label->setTextColor('ff0'); $label->setTextSize(1.3); - $y -= 4; + $posY -= 4; } // Display manialink diff --git a/application/core/Players/PlayerDetailed.php b/application/core/Players/PlayerDetailed.php index 0892eb42..31d919d4 100644 --- a/application/core/Players/PlayerDetailed.php +++ b/application/core/Players/PlayerDetailed.php @@ -70,13 +70,13 @@ class PlayerDetailed { $script = new Script(); $maniaLink->setScript($script); - $y = $this->height / 2 - 7; + $posY = $this->height / 2 - 7; //Nation Quad $countryQuad = new Quad(); $frame->add($countryQuad); $countryQuad->setImage("file://ZoneFlags/Login/{$targetLogin}/country"); - $countryQuad->setPosition(-$this->width / 2 + 10, $y); + $countryQuad->setPosition(-$this->width / 2 + 10, $posY); $countryQuad->setSize(5, 5); $countryQuad->setZ(-0.1); $countryQuad->setHAlign(Control::LEFT); @@ -84,111 +84,111 @@ class PlayerDetailed { //Nickname $label = new Label_Text(); $frame->add($label); - $label->setPosition(-$this->width / 2 + 15, $y); + $label->setPosition(-$this->width / 2 + 15, $posY); $label->setText($target->nickname); $label->setHAlign(Control::LEFT); //Define MainLabel (Login) - $y -= 8; + $posY -= 8; $mainLabel = new Label_Text(); $frame->add($mainLabel); - $mainLabel->setPosition(-$this->width / 2 + 10, $y); + $mainLabel->setPosition(-$this->width / 2 + 10, $posY); $mainLabel->setTextSize(1.2); $mainLabel->setHAlign(Control::LEFT); $mainLabel->setText("Login:"); - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Nation: "); - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Province:"); - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Authorization:"); - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Ladder Rank:"); - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Ladder Score:"); - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Inscribed Zone:"); - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText('Avatar'); //Login - $y = $this->height / 2 - 15; + $posY = $this->height / 2 - 15; $mainLabel = new Label_Text(); $frame->add($mainLabel); - $mainLabel->setPosition(-$this->width / 2 + 30, $y); + $mainLabel->setPosition(-$this->width / 2 + 30, $posY); $mainLabel->setText($target->login); $mainLabel->setTextSize(1.2); $mainLabel->setHAlign(Control::LEFT); //Country - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText($target->getCountry()); //Province - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText($target->getProvince()); //AuthLevel - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText($this->maniaControl->authenticationManager->getAuthLevelName($target->authLevel)); //LadderRank - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText($target->ladderRank); //LadderScore - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText(round($target->ladderScore, 2)); //Played Since - $y -= 5; + $posY -= 5; $label = clone $mainLabel; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText(date("d M Y", time() - 3600 * 24 * $target->daysSinceZoneInscription)); $quad = new Quad(); @@ -227,7 +227,7 @@ class PlayerDetailed { $playerStats = $this->maniaControl->statisticManager->getAllPlayerStats($player); $posY = $this->height / 2 - 15; $posX = -$this->width / 2 + 52; - $id = 1; + $index = 1; foreach ($playerStats as $stat) { $value = (float)$stat[1]; @@ -242,7 +242,7 @@ class PlayerDetailed { $value = round($value, 2); } - if ($id % 2 !== 0) { + if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); $frame->add($lineQuad); $lineQuad->setSize(49, 4); @@ -265,12 +265,12 @@ class PlayerDetailed { $label->setTextSize(1.5); $posY -= 4; - $id++; + $index++; - if ($id > self::STATS_PER_COLUMN) { + if ($index > self::STATS_PER_COLUMN) { $posY = $this->height / 2 - 15; $posX += 47; - $id = 0; + $index = 0; } } return $frame; diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index 3a4c68ee..0023f173 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -152,8 +152,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $maniaLink->add($frame); // Start offsets - $x = -$width / 2; - $y = $height / 2; + $posX = -$width / 2; + $posY = $height / 2; // Predefine Description Label $descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel(); @@ -162,32 +162,31 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Headline $headFrame = new Frame(); $frame->add($headFrame); - $headFrame->setY($y - 5); + $headFrame->setY($posY - 5); + $labelLineArray = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Location' => $posX + 101); if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { - $array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101, "Actions" => $x + 135); - } else { - $array = array("Id" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Location" => $x + 101); + $labelLineArray['Actions'] = $posX + 135; } - $this->maniaControl->manialinkManager->labelLine($headFrame, $array); + $this->maniaControl->manialinkManager->labelLine($headFrame, $labelLineArray); - $i = 1; - $y = $height / 2 - 10; + $index = 1; + $posY = $height / 2 - 10; $pageFrame = null; foreach ($players as $listPlayer) { - if ($i % self::MAX_PLAYERS_PER_PAGE === 1) { + if ($index % self::MAX_PLAYERS_PER_PAGE === 1) { $pageFrame = new Frame(); $frame->add($pageFrame); $paging->addPage($pageFrame); - $y = $height / 2 - 10; + $posY = $height / 2 - 10; } $path = $listPlayer->getProvince(); $playerFrame = new Frame(); $pageFrame->add($playerFrame); - if ($i % 2 !== 0) { + if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); $playerFrame->add($lineQuad); $lineQuad->setSize($width, 4); @@ -195,16 +194,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $lineQuad->setZ(0.001); } - $array = array($i => $x + 5, $listPlayer->nickname => $x + 18, $listPlayer->login => $x + 70, $path => $x + 101); + $array = array($index => $posX + 5, $listPlayer->nickname => $posX + 18, $listPlayer->login => $posX + 70, $path => $posX + 101); $this->maniaControl->manialinkManager->labelLine($playerFrame, $array); - $playerFrame->setY($y); + $playerFrame->setY($posY); // Show current Player Arrow if ($listPlayer->index === $player->index) { $currentQuad = new Quad_Icons64x64_1(); $playerFrame->add($currentQuad); - $currentQuad->setX($x + 3.5); + $currentQuad->setX($posX + 3.5); $currentQuad->setZ(0.2); $currentQuad->setSize(4, 4); $currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue); @@ -215,7 +214,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Player is in a Team $teamQuad = new Quad_Emblems(); $playerFrame->add($teamQuad); - $teamQuad->setX($x + 10); + $teamQuad->setX($posX + 10); $teamQuad->setZ(0.1); $teamQuad->setSize(3.8, 3.8); @@ -231,7 +230,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Player is in Spectator Mode $specQuad = new Quad_BgRaceScore2(); $playerFrame->add($specQuad); - $specQuad->setX($x + 10); + $specQuad->setX($posX + 10); $specQuad->setZ(0.1); $specQuad->setSubStyle($specQuad::SUBSTYLE_Spectator); $specQuad->setSize(3.8, 3.8); @@ -243,7 +242,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $countryQuad = new Quad(); $playerFrame->add($countryQuad); $countryQuad->setImage("file://ZoneFlags/Login/{$listPlayer->login}/country"); - $countryQuad->setX($x + 98); + $countryQuad->setX($posX + 98); $countryQuad->setZ(1); $countryQuad->setSize(4, 4); @@ -253,14 +252,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Level Quad $rightQuad = new Quad_BgRaceScore2(); $playerFrame->add($rightQuad); - $rightQuad->setX($x + 13); + $rightQuad->setX($posX + 13); $rightQuad->setZ(3); $rightQuad->setSize(7, 3.5); $rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher); $rightLabel = new Label_Text(); $playerFrame->add($rightLabel); - $rightLabel->setX($x + 13.9); + $rightLabel->setX($posX + 13.9); $rightLabel->setZ(3.1); $rightLabel->setText($this->maniaControl->authenticationManager->getAuthLevelAbbreviation($listPlayer->authLevel)); $rightLabel->setTextSize(0.8); @@ -272,7 +271,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Player Statistics $playerQuad = new Quad_Icons64x64_1(); $playerFrame->add($playerQuad); - $playerQuad->setX($x + 61); + $playerQuad->setX($posX + 61); $playerQuad->setZ(3); $playerQuad->setSize(2.7, 2.7); $playerQuad->setSubStyle($playerQuad::SUBSTYLE_TrackInfo); @@ -283,7 +282,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Camera Quad $playerQuad = new Quad_UIConstruction_Buttons(); $playerFrame->add($playerQuad); - $playerQuad->setX($x + 64.5); + $playerQuad->setX($posX + 64.5); $playerQuad->setZ(3); $playerQuad->setSize(3.8, 3.8); $playerQuad->setSubStyle($playerQuad::SUBSTYLE_Camera); @@ -294,7 +293,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Player Profile Quad $playerQuad = new Quad_UIConstruction_Buttons(); $playerFrame->add($playerQuad); - $playerQuad->setX($x + 68); + $playerQuad->setX($posX + 68); $playerQuad->setZ(3); $playerQuad->setSize(3.8, 3.8); $playerQuad->setSubStyle($playerQuad::SUBSTYLE_Author); @@ -308,7 +307,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Further Player actions Quad $playerQuad = new Quad_Icons64x64_1(); $playerFrame->add($playerQuad); - $playerQuad->setX($x + 132); + $playerQuad->setX($posX + 132); $playerQuad->setZ(0.1); $playerQuad->setSize(3.8, 3.8); $playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy); @@ -324,7 +323,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Force to Red-Team Quad $redQuad = new Quad_Emblems(); $playerFrame->add($redQuad); - $redQuad->setX($x + 145); + $redQuad->setX($posX + 145); $redQuad->setZ(0.1); $redQuad->setSize(3.8, 3.8); $redQuad->setSubStyle($redQuad::SUBSTYLE_2); @@ -337,7 +336,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Force to Blue-Team Quad $blueQuad = new Quad_Emblems(); $playerFrame->add($blueQuad); - $blueQuad->setX($x + 141); + $blueQuad->setX($posX + 141); $blueQuad->setZ(0.1); $blueQuad->setSize(3.8, 3.8); $blueQuad->setSubStyle($blueQuad::SUBSTYLE_1); @@ -351,7 +350,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Kick Player Vote $kickQuad = new Quad_UIConstruction_Buttons(); $playerFrame->add($kickQuad); - $kickQuad->setX($x + 141); + $kickQuad->setX($posX + 141); $kickQuad->setZ(0.1); $kickQuad->setSize(3.8, 3.8); $kickQuad->setSubStyle($kickQuad::SUBSTYLE_Validate_Step2); @@ -365,7 +364,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Force to Play $playQuad = new Quad_Emblems(); $playerFrame->add($playQuad); - $playQuad->setX($x + 143); + $playQuad->setX($posX + 143); $playQuad->setZ(0.1); $playQuad->setSize(3.8, 3.8); $playQuad->setSubStyle($playQuad::SUBSTYLE_2); @@ -380,7 +379,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Force to Spectator Quad $spectatorQuad = new Quad_BgRaceScore2(); $playerFrame->add($spectatorQuad); - $spectatorQuad->setX($x + 137); + $spectatorQuad->setX($posX + 137); $spectatorQuad->setZ(0.1); $spectatorQuad->setSize(3.8, 3.8); $spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator); @@ -393,7 +392,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Force to Spectator Quad $spectatorQuad = new Quad_BgRaceScore2(); $playerFrame->add($spectatorQuad); - $spectatorQuad->setX($x + 137); + $spectatorQuad->setX($posX + 137); $spectatorQuad->setZ(0.1); $spectatorQuad->setSize(3.8, 3.8); $spectatorQuad->setSubStyle($spectatorQuad::SUBSTYLE_Spectator); @@ -404,8 +403,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $spectatorQuad->addTooltipLabelFeature($descriptionLabel, $description); } - $y -= 4; - $i++; + $posY -= 4; + $index++; } // Show advanced window @@ -434,7 +433,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle(); //Settings - $x = $width / 2 + 2.5; + $posX = $width / 2 + 2.5; $width = 35; $height = $height * 0.75; $hAlign = Control::LEFT; @@ -446,7 +445,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // mainframe $frame = new Frame(); $frame->setSize($width, $height); - $frame->setPosition($x + $width / 2, 0); + $frame->setPosition($posX + $width / 2, 0); // Add Close Quad (X) $closeQuad = new Quad_Icons64x64_1(); @@ -494,18 +493,18 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $label->setTextColor($textColor); // Mute Player - $y = $height / 2 - 14; + $posY = $height / 2 - 14; $quad = new Quad_BgsPlayerCard(); $frame->add($quad); $quad->setX(0); - $quad->setY($y); + $quad->setY($posY); $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); $quad->setSize($quadWidth, 5); $label = new Label_Button(); $frame->add($label); $label->setX(0); - $label->setY($y); + $label->setY($posY); $label->setStyle($style); $label->setTextSize($textSize); $label->setTextColor($textColor); @@ -519,97 +518,97 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer } // Warn Player - $y -= 5; + $posY -= 5; $quad = clone $quad; $frame->add($quad); - $quad->setY($y); + $quad->setY($posY); $quad->setAction(self::ACTION_WARN_PLAYER . "." . $login); $label = clone $label; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Warn"); $label->setTextColor($textColor); - $y -= 5; + $posY -= 5; // Show Kick $quad = clone $quad; $frame->add($quad); - $quad->setY($y); + $quad->setY($posY); $quad->setAction(self::ACTION_KICK_PLAYER . "." . $login); $label = clone $label; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Kick"); $label->setTextColor("F90"); - $y -= 5; + $posY -= 5; // Show Ban $quad = clone $quad; $frame->add($quad); - $quad->setY($y); + $quad->setY($posY); $quad->setAction(self::ACTION_BAN_PLAYER . "." . $login); $label = clone $label; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Ban"); $label->setTextColor("700"); - $y -= 10; + $posY -= 10; // Show Add as Master-Admin $quad = clone $quad; $frame->add($quad); - $quad->setY($y); + $quad->setY($posY); $quad->setAction(self::ACTION_ADD_AS_MASTER . "." . $login); $label = clone $label; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Set SuperAdmin"); $label->setTextColor($textColor); - $y -= 5; + $posY -= 5; // Show Add as Admin $quad = clone $quad; $frame->add($quad); - $quad->setY($y); + $quad->setY($posY); $quad->setAction(self::ACTION_ADD_AS_ADMIN . "." . $login); $label = clone $label; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Set Admin"); $label->setTextColor($textColor); - $y -= 5; + $posY -= 5; // Show Add as Moderator $quad = clone $quad; $frame->add($quad); - $quad->setY($y); + $quad->setY($posY); $quad->setAction(self::ACTION_ADD_AS_MOD . "." . $login); $label = clone $label; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Set Moderator"); $label->setTextColor($textColor); if ($player->authLevel > 0 && $this->maniaControl->authenticationManager->checkRight($admin, $player->authLevel + 1)) { - $y -= 5; + $posY -= 5; // Revoke Rights $quad = clone $quad; $frame->add($quad); - $quad->setY($y); + $quad->setY($posY); $quad->setAction(self::ACTION_REVOKE_RIGHTS . "." . $login); $label = clone $label; $frame->add($label); - $label->setY($y); + $label->setY($posY); $label->setText("Revoke Rights"); $label->setTextColor("700"); } diff --git a/application/core/Plugins/PluginInstallMenu.php b/application/core/Plugins/PluginInstallMenu.php index ad426a9a..e3b489a6 100644 --- a/application/core/Plugins/PluginInstallMenu.php +++ b/application/core/Plugins/PluginInstallMenu.php @@ -67,7 +67,7 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink $pagerSize = 9.; $entryHeight = 5.; $labelTextSize = 2; - $y = 0.; + $posY = 0.; $pageFrame = null; // Pagers @@ -113,12 +113,12 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink $pageFrame = new Frame(); $frame->add($pageFrame); $paging->addPage($pageFrame); - $y = $height * 0.41; + $posY = $height * 0.41; } $pluginFrame = new Frame(); $pageFrame->add($pluginFrame); - $pluginFrame->setY($y); + $pluginFrame->setY($posY); $nameLabel = new Label_Text(); $pluginFrame->add($nameLabel); @@ -152,7 +152,7 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink $installButton->setText('Install'); $installButton->setAction(self::ACTION_PREFIX_INSTALL_PLUGIN . $plugin->id); - $y -= $entryHeight; + $posY -= $entryHeight; $index++; } } diff --git a/application/core/Plugins/PluginMenu.php b/application/core/Plugins/PluginMenu.php index edd8fbc6..2f46e2fb 100644 --- a/application/core/Plugins/PluginMenu.php +++ b/application/core/Plugins/PluginMenu.php @@ -129,10 +129,10 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $posY = 0.; $pluginUpdates = $this->maniaControl->updateManager->pluginUpdateManager->getPluginsUpdates(); - usort($pluginClasses, function ($a, $b) { - /** @var Plugin $a */ - /** @var Plugin $b */ - return strcmp($a::getName(), $b::getName()); + usort($pluginClasses, function ($pluginClassA, $pluginClassB) { + /** @var Plugin $pluginClassA */ + /** @var Plugin $pluginClassB */ + return strcmp($pluginClassA::getName(), $pluginClassB::getName()); }); $pageFrame = null; @@ -250,7 +250,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $settings = $this->maniaControl->settingManager->getSettingsByClass($settingClass); $pageSettingsMaxCount = 12; - $y = 0; + $posY = 0; $index = 0; $settingHeight = 5.; $pageFrame = null; @@ -260,12 +260,12 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $pageFrame = new Frame(); $frame->add($pageFrame); $paging->addPage($pageFrame); - $y = $height * 0.41; + $posY = $height * 0.41; } $settingFrame = new Frame(); $pageFrame->add($settingFrame); - $settingFrame->setY($y); + $settingFrame->setY($posY); if ($index === 0) { //Headline Label @@ -279,12 +279,12 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $headLabel->setText($setting->class); $headLabel->setTextColor("F00"); - $y -= $settingHeight; + $posY -= $settingHeight; } $settingFrame = new Frame(); $pageFrame->add($settingFrame); - $settingFrame->setY($y); + $settingFrame->setY($posY); // Headline Label finished $nameLabel = new Label_Text(); @@ -323,7 +323,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $entry->setVisible(false); } - $y -= $settingHeight; + $posY -= $settingHeight; $index++; } diff --git a/application/core/Server/UsageReporter.php b/application/core/Server/UsageReporter.php index e14bb103..4f09f1e0 100644 --- a/application/core/Server/UsageReporter.php +++ b/application/core/Server/UsageReporter.php @@ -40,11 +40,9 @@ class UsageReporter implements TimerListener { } /** - * Report Usage every xx Minutes - * - * @param float $time + * Report Usage of ManiaControl on the current Server */ - public function reportUsage($time) { + public function reportUsage() { if (DEV_MODE || !$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_REPORT_USAGE)) { return; } diff --git a/application/core/Statistics/StatisticManager.php b/application/core/Statistics/StatisticManager.php index fc139c48..1448ae02 100644 --- a/application/core/Statistics/StatisticManager.php +++ b/application/core/Statistics/StatisticManager.php @@ -515,6 +515,7 @@ class StatisticManager { * @return bool */ public function insertStat($statName, Player $player, $serverIndex = -1, $value, $statType = self::STAT_TYPE_INT) { + // TODO: statType isn't used if (!$player) { return false; } diff --git a/application/core/Update/UpdateManager.php b/application/core/Update/UpdateManager.php index b42a383a..0e902545 100644 --- a/application/core/Update/UpdateManager.php +++ b/application/core/Update/UpdateManager.php @@ -94,16 +94,14 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener /** * Perform Hourly Update Check - * - * @param float $time */ - public function hourlyUpdateCheck($time) { + public function hourlyUpdateCheck() { $updateCheckEnabled = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ENABLE_UPDATECHECK); if (!$updateCheckEnabled) { $this->setCoreUpdateData(); - return; + } else { + $this->checkUpdate(); } - $this->checkUpdate(); } /** @@ -132,6 +130,10 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener $url = ManiaControl::URL_WEBSERVICE . 'versions?current=1&channel=' . $updateChannel; $this->maniaControl->fileReader->loadFile($url, function ($dataJson, $error) use (&$function) { + if ($error) { + $this->maniaControl->log('Error on UpdateCheck: ' . $error); + return; + } $versions = json_decode($dataJson); if (!$versions || !isset($versions[0])) { call_user_func($function); diff --git a/application/core/Utils/Formatter.php b/application/core/Utils/Formatter.php index 313ae7b9..faabd65a 100644 --- a/application/core/Utils/Formatter.php +++ b/application/core/Utils/Formatter.php @@ -28,9 +28,7 @@ abstract class Formatter { * @return string */ public static function formatTime($time) { - if (!is_int($time)) { - $time = (int)$time; - } + $time = (int)$time; $milliseconds = $time % 1000; $seconds = floor($time / 1000); $minutes = floor($seconds / 60); @@ -70,6 +68,7 @@ abstract class Formatter { * @return string */ public static function time_elapsed_string($ptime) { + // TODO: refactor code: camelCase! $etime = time() - $ptime; if ($etime < 1) { diff --git a/application/plugins/MCTeam/CustomVotesPlugin.php b/application/plugins/MCTeam/CustomVotesPlugin.php index 2dcc4ba8..1cc75289 100644 --- a/application/plugins/MCTeam/CustomVotesPlugin.php +++ b/application/plugins/MCTeam/CustomVotesPlugin.php @@ -343,18 +343,16 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $itemQuad->addToggleFeature($popoutFrame); // Add items - $x = -1; + $posX = -1; foreach ($this->voteMenuItems as $menuItems) { foreach ($menuItems as $menuItem) { + /** @var Quad $menuQuad */ $menuQuad = $menuItem[0]; - /** - * @var Quad $menuQuad - */ $popoutFrame->add($menuQuad); $menuQuad->setSize($itemSize, $itemSize); - $menuQuad->setX($x); - $menuQuad->setHAlign(Control::RIGHT); - $x -= $itemSize * 1.05; + $menuQuad->setX($posX); + $menuQuad->setHAlign($menuQuad::RIGHT); + $posX -= $itemSize * 1.05; if ($menuItem[1]) { $menuQuad->removeScriptFeatures(); @@ -474,11 +472,8 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP /** * Destroy the Vote on Canceled Callback - * - * @param Player $player */ - public function handleVoteCanceled(Player $player) { - //reset vote + public function handleVoteCanceled() { $this->destroyVote(); } @@ -638,8 +633,8 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP * @param float $votePercentage */ private function showVoteWidget($timeUntilExpire, $votePercentage) { - $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX); - $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY); + $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX); + $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_WIDTH); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_HEIGHT); $maxTime = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_VOTE_TIME); @@ -654,7 +649,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $frame = new Frame(); $maniaLink->add($frame); $frame->setSize($width, $height); - $frame->setPosition($pos_x, $pos_y, 30); + $frame->setPosition($posX, $posY, 30); // Background Quad $backgroundQuad = new Quad(); @@ -676,7 +671,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $label->setY($height / 2 - 6); $label->setSize($width - 5, 2); $label->setTextSize(1); - $label->setTextColor("F80"); + $label->setTextColor('F80'); $label->setText('$sStarted by ' . $this->currentVote->voter->nickname); //Time Gauge @@ -700,7 +695,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $label->setSize($width - 5, $height); $label->setTextSize(1.1); $label->setText('$sTime left: ' . $timeUntilExpire . "s"); - $label->setTextColor("FFF"); + $label->setTextColor('FFF'); //Vote Gauge $voteGauge = new Gauge(); @@ -712,10 +707,10 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $gaugeColor = ColorUtil::floatToStatusColor($votePercentage); $voteGauge->setColor($gaugeColor . '6'); - $y = -4.4; + $posY = -4.4; $voteLabel = new Label(); $frame->add($voteLabel); - $voteLabel->setY($y); + $voteLabel->setY($posY); $voteLabel->setSize($width * 0.65, 12); $voteLabel->setStyle($labelStyle); $voteLabel->setTextSize(1); @@ -724,18 +719,18 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $positiveQuad = new Quad_BgsPlayerCard(); $frame->add($positiveQuad); - $positiveQuad->setPosition(-$width / 2 + 6, $y); + $positiveQuad->setPosition(-$width / 2 + 6, $posY); $positiveQuad->setSubStyle($positiveQuad::SUBSTYLE_BgPlayerCardBig); $positiveQuad->setSize(5, 5); $positiveLabel = new Label_Button(); $frame->add($positiveLabel); - $positiveLabel->setPosition(-$width / 2 + 6, $y); + $positiveLabel->setPosition(-$width / 2 + 6, $posY); $positiveLabel->setStyle($labelStyle); $positiveLabel->setTextSize(1); $positiveLabel->setSize(3, 3); - $positiveLabel->setTextColor("0F0"); - $positiveLabel->setText("F1"); + $positiveLabel->setTextColor('0F0'); + $positiveLabel->setText('F1'); $negativeQuad = clone $positiveQuad; $frame->add($negativeQuad); @@ -744,8 +739,8 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $negativeLabel = clone $positiveLabel; $frame->add($negativeLabel); $negativeLabel->setX($width / 2 - 6); - $negativeLabel->setTextColor("F00"); - $negativeLabel->setText("F2"); + $negativeLabel->setTextColor('F00'); + $negativeLabel->setText('F2'); // Voting Actions $positiveQuad->addActionTriggerFeature(self::ACTION_POSITIVE_VOTE); diff --git a/application/plugins/MCTeam/Dedimania/DedimaniaData.php b/application/plugins/MCTeam/Dedimania/DedimaniaData.php index b3dc20ac..132a7328 100644 --- a/application/plugins/MCTeam/Dedimania/DedimaniaData.php +++ b/application/plugins/MCTeam/Dedimania/DedimaniaData.php @@ -53,6 +53,18 @@ class DedimaniaData { $this->serverBuild = $serverVersion->build; } + /** + * Sort the Records + */ + public function sortRecords() { + usort($this->records, function (RecordData $first, RecordData $second) { + if ($first->best == $second->best) { + return ($first->rank - $second->rank); + } + return ($first->best - $second->best); + }); + } + /** * Build the Data Array * diff --git a/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 80f631ef..42981e30 100644 --- a/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/application/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -113,7 +113,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene * @see \ManiaControl\Plugins\Plugin::getDescription() */ public static function getDescription() { - return "Dedimania Plugin for TrackMania"; + return 'Dedimania Plugin for TrackMania'; } /** @@ -264,7 +264,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $self = $this; $this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) { if ($error) { - $self->maniaControl->log("Dedimania Error: " . $error); + $self->maniaControl->log('Dedimania Error: ' . $error); } $data = $self->decode($data); @@ -422,8 +422,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $records = $this->dedimaniaData->records; $title = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_TITLE); - $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX); - $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY); + $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX); + $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_WIDTH); $lines = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_LINESCOUNT); $lineHeight = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_LINEHEIGHT); @@ -435,7 +435,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $manialink = new ManiaLink(self::MLID_DEDIMANIA); $frame = new Frame(); $manialink->add($frame); - $frame->setPosition($pos_x, $pos_y); + $frame->setPosition($posX, $posY); $backgroundQuad = new Quad(); $frame->add($backgroundQuad); @@ -977,9 +977,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $this->maniaControl->callbackManager->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records); return; } - //TODO move into class dedimania data - // Sort records - usort($this->dedimaniaData->records, array($this, 'compareRecords')); + + $this->dedimaniaData->sortRecords(); // Update ranks $rank = 1; @@ -1066,8 +1065,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $maniaLink->add($frame); // Start offsets - $x = -$width / 2; - $y = $height / 2; + $posX = -$width / 2; + $posY = $height / 2; // Predefine Description Label $descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel(); @@ -1076,26 +1075,26 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene // Headline $headFrame = new Frame(); $frame->add($headFrame); - $headFrame->setY($y - 5); - $array = array("Rank" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Time" => $x + 101); + $headFrame->setY($posY - 5); + $array = array("Rank" => $posX + 5, "Nickname" => $posX + 18, "Login" => $posX + 70, "Time" => $posX + 101); $this->maniaControl->manialinkManager->labelLine($headFrame, $array); - $i = 0; - $y = $height / 2 - 10; + $index = 0; + $posY = $height / 2 - 10; $pageFrame = null; foreach ($records as $listRecord) { - if ($i % 15 === 0) { + if ($index % 15 === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height / 2 - 10; + $posY = $height / 2 - 10; $paging->addPage($pageFrame); } $recordFrame = new Frame(); $pageFrame->add($recordFrame); - if ($i % 2 !== 0) { + if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); $recordFrame->add($lineQuad); $lineQuad->setSize($width, 4); @@ -1106,13 +1105,13 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene if (strlen($listRecord->nickName) < 2) { $listRecord->nickName = $listRecord->login; } - $array = array($listRecord->rank => $x + 5, '$fff' . $listRecord->nickName => $x + 18, $listRecord->login => $x + 70, Formatter::formatTime($listRecord->best) => $x + 101); + $array = array($listRecord->rank => $posX + 5, '$fff' . $listRecord->nickName => $posX + 18, $listRecord->login => $posX + 70, Formatter::formatTime($listRecord->best) => $posX + 101); $this->maniaControl->manialinkManager->labelLine($recordFrame, $array); - $recordFrame->setY($y); + $recordFrame->setY($posY); - $y -= 4; - $i++; + $posY -= 4; + $index++; } // Render and display xml @@ -1136,26 +1135,4 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene */ public function unload() { } - - /** - * Compare function for sorting dedimania records - * - * @param \MCTeam\Dedimania\RecordData $first - * @param \MCTeam\Dedimania\RecordData $second - * @return int - */ - private function compareRecords(RecordData $first, RecordData $second) { - //TODO move into class dedimania data - if ($first->best < $second->best) { - return -1; - } else if ($first->best > $second->best) { - return 1; - } else { - if ($first->rank < $second->rank) { - return -1; - } else { - return 1; - } - } - } } \ No newline at end of file diff --git a/application/plugins/MCTeam/DonationPlugin.php b/application/plugins/MCTeam/DonationPlugin.php index 5c7fe6b9..df184cef 100644 --- a/application/plugins/MCTeam/DonationPlugin.php +++ b/application/plugins/MCTeam/DonationPlugin.php @@ -221,11 +221,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $descriptionLabel->setTextColor("0F0"); // Add items - $x = -2; + $posX = -2; foreach (array_reverse($valueArray) as $value) { $label = new Label_Button(); $popoutFrame->add($label); - $label->setX($x); + $label->setX($posX); $label->setHAlign(Control::RIGHT); $label->setText('$s$FFF' . $value . '$09FP'); $label->setTextSize(1.2); @@ -234,7 +234,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $description = "Donate {$value} Planets"; $label->addTooltipLabelFeature($descriptionLabel, $description); - $x -= strlen($value) * 2 + 1.7; + $posX -= strlen($value) * 2 + 1.7; } // Send manialink @@ -470,8 +470,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $maniaLink->add($frame); // Start offsets - $x = -$width / 2; - $y = $height / 2; + $posX = -$width / 2; + $posY = $height / 2; //Predefine description Label $descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel(); @@ -480,27 +480,27 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { // Headline $headFrame = new Frame(); $frame->add($headFrame); - $headFrame->setY($y - 5); - $array = array('$oId' => $x + 5, '$oNickname' => $x + 18, '$oDonated planets' => $x + 70); + $headFrame->setY($posY - 5); + $array = array('$oId' => $posX + 5, '$oNickname' => $posX + 18, '$oDonated planets' => $posX + 70); $this->maniaControl->manialinkManager->labelLine($headFrame, $array); - $i = 1; - $y = $y - 10; + $index = 1; + $posY = $posY - 10; $pageFrame = null; foreach ($stats as $playerIndex => $donations) { - if ($i % 15 === 1) { + if ($index % 15 === 1) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height / 2 - 10; + $posY = $height / 2 - 10; $paging->addPage($pageFrame); } $playerFrame = new Frame(); $pageFrame->add($playerFrame); - $playerFrame->setY($y); + $playerFrame->setY($posY); - if ($i % 2 !== 0) { + if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); $playerFrame->add($lineQuad); $lineQuad->setSize($width, 4); @@ -509,13 +509,13 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { } $donatingPlayer = $this->maniaControl->playerManager->getPlayerByIndex($playerIndex); - $array = array($i => $x + 5, $donatingPlayer->nickname => $x + 18, $donations => $x + 70); + $array = array($index => $posX + 5, $donatingPlayer->nickname => $posX + 18, $donations => $posX + 70); $this->maniaControl->manialinkManager->labelLine($playerFrame, $array); - $y -= 4; - $i++; + $posY -= 4; + $index++; - if ($i > 100) { + if ($index > 100) { break; } } diff --git a/application/plugins/MCTeam/KarmaPlugin.php b/application/plugins/MCTeam/KarmaPlugin.php index b7239626..ff004f1f 100644 --- a/application/plugins/MCTeam/KarmaPlugin.php +++ b/application/plugins/MCTeam/KarmaPlugin.php @@ -11,6 +11,7 @@ use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\TimerListener; +use ManiaControl\Files\AsynchronousFileReader; use ManiaControl\ManiaControl; use ManiaControl\Maps\Map; use ManiaControl\Players\Player; @@ -271,7 +272,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $self->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error); $self->mxKarma['connectionInProgress'] = false; } - }, "application/json", 1000); + }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); } /** @@ -280,6 +281,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { * @param string $mxKarmaCode */ private function activateSession($mxKarmaCode) { + // TODO: unused private method! remove? $hash = $this->buildActivationHash($this->mxKarma['session']->sessionSeed, $mxKarmaCode); $query = self::MX_KARMA_URL . self::MX_KARMA_ACTIVATESESSION; @@ -314,7 +316,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $self->maniaControl->log($error); $self->mxKarma['connectionInProgress'] = false; } - }, "application/json", 1000); + }, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000); } /** @@ -398,12 +400,12 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { return; } // TODO remove temp trigger - $self->maniaControl->errorHandler->triggerDebugNotice("Error while fetching votes: " . $data->data->message . " " . KarmaPlugin::MX_KARMA_URL . KarmaPlugin::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($self->mxKarma['session']->sessionKey)); + $self->maniaControl->errorHandler->triggerDebugNotice("Error while fetching votes: '{$data->data->message}' " . KarmaPlugin::MX_KARMA_URL . KarmaPlugin::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($self->mxKarma['session']->sessionKey)); } } else { $self->maniaControl->log($error); } - }, $content, false, 'application/json'); + }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); } /** @@ -414,11 +416,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } /** - * Handle BeginMap ManiaControl callback - * - * @param Map $map + * Handle Begin Map Callback */ - public function handleBeginMap(Map $map) { + public function handleBeginMap() { // send Map Karma to MX from previous Map if (isset($this->mxKarma['map'])) { $votes = array(); @@ -500,7 +500,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } else { $self->maniaControl->log($error); } - }, $content, false, 'application/json'); + }, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON); } /** @@ -703,13 +703,14 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $votes = array(); while ($vote = $result->fetch_object()) { - $player = $this->maniaControl->playerManager->getPlayerByIndex($vote->playerIndex); - $karma = $vote->vote; - $votes[] = array('player' => $player, 'karma' => $karma); + $player = $this->maniaControl->playerManager->getPlayerByIndex($vote->playerIndex); + $karma = $vote->vote; + $voteArray = array('player' => $player, 'karma' => $karma); + array_push($votes, $voteArray); } - usort($votes, function ($a, $b) { - return $a['karma'] - $b['karma']; + usort($votes, function ($paramA, $paramB) { + return $paramA['karma'] - $paramB['karma']; }); $votes = array_reverse($votes); @@ -876,7 +877,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } /** - * Build karma voting manialink if necessary + * Build Karma Voting Manialink if necessary * * @param bool $forceBuild */ @@ -886,8 +887,8 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } $title = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_TITLE); - $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX); - $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY); + $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX); + $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_WIDTH); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_HEIGHT); $labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle(); @@ -898,7 +899,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $frame = new Frame(); $manialink->add($frame); - $frame->setPosition($pos_x, $pos_y); + $frame->setPosition($posX, $posY); $backgroundQuad = new Quad(); $frame->add($backgroundQuad); diff --git a/application/plugins/MCTeam/LocalRecordsPlugin.php b/application/plugins/MCTeam/LocalRecordsPlugin.php index 2f9cbf58..98040c0d 100644 --- a/application/plugins/MCTeam/LocalRecordsPlugin.php +++ b/application/plugins/MCTeam/LocalRecordsPlugin.php @@ -213,8 +213,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList } $title = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_TITLE); - $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX); - $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY); + $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX); + $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_WIDTH); $lines = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_LINESCOUNT); $lineHeight = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_LINEHEIGHT); @@ -231,7 +231,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $manialink = new ManiaLink(self::MLID_RECORDS); $frame = new Frame(); $manialink->add($frame); - $frame->setPosition($pos_x, $pos_y); + $frame->setPosition($posX, $posY); $backgroundQuad = new Quad(); $frame->add($backgroundQuad); @@ -513,20 +513,16 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList } /** - * Handle PlayerConnect callback - * - * @param Player $player + * Handle Player Connect Callback */ - public function handlePlayerConnect(Player $player) { + public function handlePlayerConnect() { $this->updateManialink = true; } /** - * Handle BeginMap callback - * - * @param Map $map + * Handle Begin Map Callback */ - public function handleMapBegin(Map $map) { + public function handleMapBegin() { $this->updateManialink = true; } @@ -570,8 +566,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $maniaLink->add($frame); // Start offsets - $x = -$width / 2; - $y = $height / 2; + $posX = -$width / 2; + $posY = $height / 2; // Predefine Description Label $descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel(); @@ -580,26 +576,26 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList // Headline $headFrame = new Frame(); $frame->add($headFrame); - $headFrame->setY($y - 5); - $array = array("Rank" => $x + 5, "Nickname" => $x + 18, "Login" => $x + 70, "Time" => $x + 101); + $headFrame->setY($posY - 5); + $array = array('Rank' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Time' => $posX + 101); $this->maniaControl->manialinkManager->labelLine($headFrame, $array); - $i = 0; - $y = $height / 2 - 10; + $index = 0; + $posY = $height / 2 - 10; $pageFrame = null; foreach ($records as $listRecord) { - if ($i % 15 === 0) { + if ($index % 15 === 0) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height / 2 - 10; + $posY = $height / 2 - 10; $paging->addPage($pageFrame); } $recordFrame = new Frame(); $pageFrame->add($recordFrame); - if ($i % 2 !== 0) { + if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); $recordFrame->add($lineQuad); $lineQuad->setSize($width, 4); @@ -610,13 +606,13 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList if (strlen($listRecord->nickname) < 2) { $listRecord->nickname = $listRecord->login; } - $array = array($listRecord->rank => $x + 5, '$fff' . $listRecord->nickname => $x + 18, $listRecord->login => $x + 70, Formatter::formatTime($listRecord->time) => $x + 101); + $array = array($listRecord->rank => $posX + 5, '$fff' . $listRecord->nickname => $posX + 18, $listRecord->login => $posX + 70, Formatter::formatTime($listRecord->time) => $posX + 101); $this->maniaControl->manialinkManager->labelLine($recordFrame, $array); - $recordFrame->setY($y); + $recordFrame->setY($posY); - $y -= 4; - $i++; + $posY -= 4; + $index++; } // Render and display xml diff --git a/application/plugins/MCTeam/ServerRankingPlugin.php b/application/plugins/MCTeam/ServerRankingPlugin.php index ed7f18ef..f76db7f3 100644 --- a/application/plugins/MCTeam/ServerRankingPlugin.php +++ b/application/plugins/MCTeam/ServerRankingPlugin.php @@ -156,6 +156,25 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { } } + /** + * Check if the given Ranking Type is valid + * + * @param string $rankingType + * @return bool + */ + private function isValidRankingType($rankingType) { + return in_array($rankingType, $this->getRankingTypes()); + } + + /** + * Get the possible Ranking Types + * + * @return string[] + */ + private function getRankingTypes() { + return array(self::RANKING_TYPE_POINTS, self::RANKING_TYPE_RATIOS, self::RANKING_TYPE_RECORDS); + } + /** * Resets and rebuilds the Ranking */ @@ -473,8 +492,8 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { $maniaLink->add($frame); // Start offsets - $x = -$width / 2; - $y = $height / 2; + $posX = -$width / 2; + $posY = $height / 2; //Predefine description Label $descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel(); @@ -483,27 +502,27 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { // Headline $headFrame = new Frame(); $frame->add($headFrame); - $headFrame->setY($y - 5); - $array = array('$oRank' => $x + 5, '$oNickname' => $x + 18, '$oAverage' => $x + 70); + $headFrame->setY($posY - 5); + $array = array('$oRank' => $posX + 5, '$oNickname' => $posX + 18, '$oAverage' => $posX + 70); $this->maniaControl->manialinkManager->labelLine($headFrame, $array); - $i = 1; - $y = $y - 10; + $index = 1; + $posY -= 10; $pageFrame = null; while ($rankedPlayer = $result->fetch_object()) { - if ($i % 15 === 1) { + if ($index % 15 === 1) { $pageFrame = new Frame(); $frame->add($pageFrame); - $y = $height / 2 - 10; + $posY = $height / 2 - 10; $paging->addPage($pageFrame); } $playerFrame = new Frame(); $pageFrame->add($playerFrame); - $playerFrame->setY($y); + $playerFrame->setY($posY); - if ($i % 2 !== 0) { + if ($index % 2 !== 0) { $lineQuad = new Quad_BgsPlayerCard(); $playerFrame->add($lineQuad); $lineQuad->setSize($width, 4); @@ -512,35 +531,16 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { } $playerObject = $this->maniaControl->playerManager->getPlayerByIndex($rankedPlayer->PlayerIndex); - $array = array($rankedPlayer->Rank => $x + 5, $playerObject->nickname => $x + 18, (string)round($rankedPlayer->Avg, 2) => $x + 70); + $array = array($rankedPlayer->Rank => $posX + 5, $playerObject->nickname => $posX + 18, (string)round($rankedPlayer->Avg, 2) => $posX + 70); $this->maniaControl->manialinkManager->labelLine($playerFrame, $array); - $y -= 4; - $i++; + $posY -= 4; + $index++; } // Render and display xml $this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'TopRanks'); } - - /** - * Get the possible Ranking Types - * - * @return string[] - */ - private function getRankingTypes() { - return array(self::RANKING_TYPE_POINTS, self::RANKING_TYPE_RATIOS, self::RANKING_TYPE_RECORDS); - } - - /** - * Check if the given Ranking Type is valid - * - * @param string $rankingType - * @return bool - */ - private function isValidRankingType($rankingType) { - return in_array($rankingType, $this->getRankingTypes()); - } } /** diff --git a/application/plugins/MCTeam/WidgetPlugin.php b/application/plugins/MCTeam/WidgetPlugin.php index 9d6f7dfd..5aaec264 100644 --- a/application/plugins/MCTeam/WidgetPlugin.php +++ b/application/plugins/MCTeam/WidgetPlugin.php @@ -15,7 +15,6 @@ use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\TimerListener; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\IconManager; -use ManiaControl\Maps\Map; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; use ManiaControl\Plugins\Plugin; @@ -183,8 +182,8 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * @param string $login */ public function displayMapWidget($login = null) { - $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_POSX); - $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_POSY); + $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_POSX); + $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_POSY); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_WIDTH); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_HEIGHT); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); @@ -198,7 +197,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $frame = new Frame(); $maniaLink->add($frame); $frame->setSize($width, $height); - $frame->setPosition($pos_x, $pos_y); + $frame->setPosition($posX, $posY); // Background Quad $backgroundQuad = new Quad(); @@ -246,8 +245,8 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * @param bool $login */ public function displayClockWidget($login = false) { - $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSX); - $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSY); + $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSX); + $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_POSY); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_WIDTH); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_CLOCK_WIDGET_HEIGHT); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); @@ -259,7 +258,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $frame = new Frame(); $maniaLink->add($frame); $frame->setSize($width, $height); - $frame->setPosition($pos_x, $pos_y); + $frame->setPosition($posX, $posY); // Background Quad $backgroundQuad = new Quad(); @@ -285,8 +284,8 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * @param string $login */ public function displayServerInfoWidget($login = null) { - $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSX); - $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSY); + $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSX); + $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_POSY); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_WIDTH); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_HEIGHT); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); @@ -298,7 +297,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $frame = new Frame(); $maniaLink->add($frame); $frame->setSize($width, $height); - $frame->setPosition($pos_x, $pos_y); + $frame->setPosition($posX, $posY); // Background Quad $backgroundQuad = new Quad(); @@ -390,12 +389,9 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { } /** - * Handle on Begin Map - * - * @param Map $map + * Handle Begin Map Callback */ - public function handleOnBeginMap(Map $map) { - // Display Map Widget + public function handleOnBeginMap() { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { $this->displayMapWidget(); } @@ -403,12 +399,9 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { } /** - * Handle on End Map - * - * @param Map $map + * Handle End Map Callback */ - public function handleOnEndMap(Map $map) { - // Display Map Widget + public function handleOnEndMap() { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) { $this->displayNextMapWidget(); } @@ -420,8 +413,8 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * @param string $login */ public function displayNextMapWidget($login = null) { - $pos_x = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSX); - $pos_y = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSY); + $posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSX); + $posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_POSY); $width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_WIDTH); $height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_NEXTMAP_WIDGET_HEIGHT); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle(); @@ -434,7 +427,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $frame = new Frame(); $maniaLink->add($frame); $frame->setSize($width, $height); - $frame->setPosition($pos_x, $pos_y); + $frame->setPosition($posX, $posY); // Background Quad $backgroundQuad = new Quad(); @@ -519,11 +512,9 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { } /** - * Handle PlayerConnect callback - * - * @param Player $player + * Handle PlayerDisconnect Callback */ - public function handlePlayerDisconnect(Player $player) { + public function handlePlayerDisconnect() { if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { $this->displayServerInfoWidget(); }