Fixed a display bug in WidgetPlugin, minor fixes LocalRecordsPlugin

This commit is contained in:
Jocy 2017-05-19 13:33:02 +02:00
parent f8363441bb
commit 0631c53ed9
2 changed files with 31 additions and 28 deletions

View File

@ -21,6 +21,7 @@ use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Maps\Map;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
@ -36,12 +37,12 @@ use ManiaControl\Utils\Formatter;
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerListener, Plugin {
class LocalRecordsPlugin implements ManialinkPageAnswerListener,CallbackListener, CommandListener, TimerListener, Plugin {
/*
* Constants
*/
const ID = 7;
const VERSION = 0.3;
const VERSION = 0.4;
const NAME = 'Local Records Plugin';
const AUTHOR = 'MCTeam';
const MLID_RECORDS = 'ml_local_records';
@ -149,6 +150,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
$this->maniaControl->getCommandManager()->registerCommandListener(array('recs', 'records'), $this, 'showRecordsList', false, 'Shows a list of Local Records on the current map.');
$this->maniaControl->getCommandManager()->registerCommandListener('delrec', $this, 'deleteRecord', true, 'Removes a record from the database.');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SHOW_RECORDSLIST,$this,'handleShowRecordsList');
$this->updateManialink = true;
return true;
@ -265,11 +268,10 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
$titleLabel->setText($title);
$titleLabel->setTranslate(true);
$preGeneratedRecordsFrame = $this->generateRecordsFrame($records, $lines - 2 * $recordsBeforeAfter - 1);
$topRecordsCount = $lines - $recordsBeforeAfter * 2 - 1;
$preGeneratedRecordsFrame = $this->generateRecordsFrame($records, $topRecordsCount);
$players = $this->maniaControl->getPlayerManager()->getPlayers();
$topRecordsCount = $lines - $recordsBeforeAfter * 2 - 1;
foreach ($players as $player) {
if (isset($playerRecords[$player->index]) && $playerRecords[$player->index] >= $topRecordsCount) {
@ -415,6 +417,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
/**
* Handle Setting Changed Callback
*
* @internal
* @param Setting $setting
*/
public function handleSettingChanged(Setting $setting) {
@ -440,6 +443,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
/**
* Handle Checkpoint Callback
*
* @internal
* @param OnWayPointEventStructure $callback
*/
public function handleCheckpointCallback(OnWayPointEventStructure $structure) {
@ -453,6 +457,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
/**
* Handle Finish Callback
*
* @internal
* @param \ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure $structure
*/
public function handleFinishCallback(OnWayPointEventStructure $structure) {
@ -469,7 +474,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
return;
}
$checkpointsString = $this->getCheckpoints($player->login);
$checkpointsString = $this->getCheckpointmas($player->login);
$this->checkpoints[$player->login] = array();
// Check old record of the player
@ -591,6 +596,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
/**
* Handle Player Connect Callback
* @internal
*/
public function handlePlayerConnect() {
$this->updateManialink = true;
@ -598,27 +604,23 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
/**
* Handle Begin Map Callback
* @internal
*/
public function handleMapBegin() {
$this->updateManialink = true;
}
/**
* Handle PlayerManialinkPageAnswer callback
* Handle the ManiaLink answer of the showRecordsList action
*
* @internal
* @param array $callback
* @param \ManiaControl\Players\Player $player
*/
public function handleManialinkPageAnswer(array $callback) {
$actionId = $callback[1][2];
//TODO manialinkpageanswerlsitener
$login = $callback[1][1];
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
if ($actionId === self::ACTION_SHOW_RECORDSLIST) {
public function handleShowRecordsList(array $callback, Player $player){
$this->showRecordsList(array(), $player);
}
}
/**
* Shows a ManiaLink list with the local records.

View File

@ -334,7 +334,6 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
$label->setTextSize(1.3);
$label->setText(Formatter::stripDirtyCodes($serverName));
$label->setTextColor('fff');
//$label->setAutoNewLine(true);
// Player Quad / Label
$label = new Label_Text();
@ -345,6 +344,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
$label->setScale(0.8);
$label->setText($playerCount . " / " . $maxPlayers['NextValue']);
$label->setTextColor('fff');
$label->setWidth($width / 2 - 8);
$quad = new Quad_Icons128x128_1();
$frame->addChild($quad);
@ -355,17 +355,18 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
// Spectator Quad / Label
$label = new Label_Text();
$frame->addChild($label);
$label->setPosition(2, -1.5, 0.2);
$label->setPosition(3, -1.5, 0.2);
$label->setHorizontalAlign($label::LEFT);
$label->setTextSize(1);
$label->setScale(0.8);
$label->setText($spectatorCount . " / " . $maxSpectators['NextValue']);
$label->setTextColor('fff');
$label->setWidth($width / 2 - 8);
$quad = new Quad_Icons64x64_1();
$frame->addChild($quad);
$quad->setSubStyle($quad::SUBSTYLE_Camera);
$quad->setPosition(0, -1.6, 0.2);
$quad->setPosition(1, -1.6, 0.2);
$quad->setSize(3.3, 2.5);
// Favorite quad