From 46c570637564bc0f2c4f47fee00362e7625f7ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sat, 26 Jul 2014 16:31:47 +0200 Subject: [PATCH] minor coding improvements --- application/core/Maps/MapList.php | 5 ++--- application/core/Players/PlayerList.php | 2 +- application/core/Plugins/PluginManager.php | 2 +- .../core/Statistics/SimpleStatsList.php | 20 +++++++------------ .../plugins/MCTeam/CustomVotesPlugin.php | 3 +-- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 401b5449..7c1f91b8 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -421,8 +421,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $switchLabel->setTextSize(2); $switchLabel->setText('ยป'); $switchLabel->setTextColor('0f0'); - $switchLabel->setAction(self::ACTION_START_SWITCH_VOTE . '.' . ($map->uid)); - $description = 'Start Map-Switch Vote: $<' . $map->name . '$>'; + $switchLabel->setAction(self::ACTION_START_SWITCH_VOTE . '.' . $map->uid); + $description = 'Start Map-Switch Vote: ' . $map->getEscapedName(); $switchLabel->addTooltipLabelFeature($descriptionLabel, $description); } } @@ -596,7 +596,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { public function handleManialinkPageAnswer(array $callback) { $actionId = $callback[1][2]; $actionArray = explode('.', $actionId); - if (count($actionArray) <= 2) { return; } diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index d3d8135c..2eb3d866 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -703,7 +703,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $this->maniaControl->client->forceSpectator($target->login, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE); $this->maniaControl->client->spectatorReleasePlayerSlot($target->login); } catch (PlayerStateException $e) { - } catch (UnknownPlayerException $e){ + } catch (UnknownPlayerException $e) { } }); break; diff --git a/application/core/Plugins/PluginManager.php b/application/core/Plugins/PluginManager.php index 01508b42..8bccf108 100644 --- a/application/core/Plugins/PluginManager.php +++ b/application/core/Plugins/PluginManager.php @@ -276,7 +276,7 @@ class PluginManager { } $pluginFiles = scandir($directory); foreach ($pluginFiles as $pluginFile) { - if (stripos($pluginFile, '.') === 0) { + if (substr($pluginFile, 0, 1) === '.') { continue; } diff --git a/application/core/Statistics/SimpleStatsList.php b/application/core/Statistics/SimpleStatsList.php index 6d7e22a6..02a16d73 100644 --- a/application/core/Statistics/SimpleStatsList.php +++ b/application/core/Statistics/SimpleStatsList.php @@ -169,8 +169,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $array['$oId'] = $posX + 5; $array['$oNickname'] = $posX + 14; - - //Compute Headline + // Headline $posX = $xStart + 55; $statRankings = array(); foreach ($this->statArray as $key => $stat) { @@ -186,14 +185,14 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $labels = $this->maniaControl->manialinkManager->labelLine($headFrame, $array); - //Description Label + // Description Label $index = 2; foreach ($this->statArray as $statArray) { if (!isset($labels[$index])) { break; } - /** @var Label_Text $label [] */ + /** @var Label_Text $label */ $label = $labels[$index]; $label->setAction(self::ACTION_SORT_STATS . '.' . $statArray["Name"]); @@ -223,7 +222,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $playerFrame = new Frame(); $frame->add($playerFrame); - //Show current Player Arrow + // Show current Player Arrow if ($playerId == $player->index) { $currentQuad = new Quad_Icons64x64_1(); $playerFrame->add($currentQuad); @@ -245,14 +244,12 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $statValue = round(floatval($statValue), 2); } } - $displayArray[$stat['Name']] = array("Value" => strval($statValue), "Width" => $stat['Width']); + $displayArray[$stat['Name']] = array('Value' => strval($statValue), 'Width' => $stat['Width']); } - $array = array($index => $xStart + 5, $listPlayer->nickname => $xStart + 14); $this->maniaControl->manialinkManager->labelLine($playerFrame, $array); - $posX = $xStart + 55; foreach ($displayArray as $key => $array) { $label = new Label_Text(); @@ -267,7 +264,6 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $posX += $array['Width']; } - $playerFrame->setY($posY); if ($index % 2 !== 0) { @@ -278,12 +274,10 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, $lineQuad->setZ(0.001); } - $index++; $posY -= 4; } - // Render and display xml $this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'SimpleStatsList'); } @@ -299,7 +293,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, return; } - $action = $actionArray[0] . "." . $actionArray[1]; + $action = $actionArray[0] . '.' . $actionArray[1]; switch ($action) { case self::ACTION_SORT_STATS: @@ -309,4 +303,4 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, break; } } -} \ No newline at end of file +} diff --git a/application/plugins/MCTeam/CustomVotesPlugin.php b/application/plugins/MCTeam/CustomVotesPlugin.php index ce2106f4..75af47a2 100644 --- a/application/plugins/MCTeam/CustomVotesPlugin.php +++ b/application/plugins/MCTeam/CustomVotesPlugin.php @@ -917,5 +917,4 @@ class CurrentVote { public function getVoteCount() { return count($this->playersVoted); } - -} \ No newline at end of file +}