code refactoring
- variable names - unused parameters
This commit is contained in:
@ -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);
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user