MapList now show local record if plugin is activated (#191)
This commit is contained in:
parent
f6d48341f4
commit
2177858368
@ -31,6 +31,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\NextMapException;
|
|||||||
use Maniaplanet\DedicatedServer\Xmlrpc\NotInListException;
|
use Maniaplanet\DedicatedServer\Xmlrpc\NotInListException;
|
||||||
use MCTeam\CustomVotesPlugin;
|
use MCTeam\CustomVotesPlugin;
|
||||||
use MCTeam\KarmaPlugin;
|
use MCTeam\KarmaPlugin;
|
||||||
|
use MCTeam\LocalRecordsPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MapList Widget Class
|
* MapList Widget Class
|
||||||
@ -43,24 +44,25 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ACTION_UPDATE_MAP = 'MapList.UpdateMap';
|
const ACTION_UPDATE_MAP = 'MapList.UpdateMap';
|
||||||
const ACTION_REMOVE_MAP = 'MapList.RemoveMap';
|
const ACTION_REMOVE_MAP = 'MapList.RemoveMap';
|
||||||
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
||||||
const ACTION_START_SWITCH_VOTE = 'MapList.StartMapSwitchVote';
|
const ACTION_START_SWITCH_VOTE = 'MapList.StartMapSwitchVote';
|
||||||
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
|
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
|
||||||
const ACTION_UNQUEUE_MAP = 'MapList.UnQueueMap';
|
const ACTION_UNQUEUE_MAP = 'MapList.UnQueueMap';
|
||||||
const ACTION_CHECK_UPDATE = 'MapList.CheckUpdate';
|
const ACTION_CHECK_UPDATE = 'MapList.CheckUpdate';
|
||||||
const ACTION_CLEAR_MAPQUEUE = 'MapList.ClearMapQueue';
|
const ACTION_CLEAR_MAPQUEUE = 'MapList.ClearMapQueue';
|
||||||
const ACTION_PAGING_CHUNKS = 'MapList.PagingChunk.';
|
const ACTION_PAGING_CHUNKS = 'MapList.PagingChunk.';
|
||||||
const ACTION_SEARCH_MAP_NAME = 'MapList.SearchMapName';
|
const ACTION_SEARCH_MAP_NAME = 'MapList.SearchMapName';
|
||||||
const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor';
|
const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor';
|
||||||
const ACTION_RESET = 'MapList.ResetMapList';
|
const ACTION_RESET = 'MapList.ResetMapList';
|
||||||
const MAX_MAPS_PER_PAGE = 13;
|
const MAX_MAPS_PER_PAGE = 13;
|
||||||
const MAX_PAGES_PER_CHUNK = 2;
|
const MAX_PAGES_PER_CHUNK = 2;
|
||||||
const DEFAULT_KARMA_PLUGIN = 'MCTeam\KarmaPlugin';
|
const DEFAULT_KARMA_PLUGIN = 'MCTeam\KarmaPlugin';
|
||||||
const DEFAULT_CUSTOM_VOTE_PLUGIN = 'MCTeam\CustomVotesPlugin';
|
const DEFAULT_CUSTOM_VOTE_PLUGIN = 'MCTeam\CustomVotesPlugin';
|
||||||
const CACHE_CURRENT_PAGE = 'CurrentPage';
|
const DEFAULT_LOCAL_RECORDS_PLUGIN = 'MCTeam\LocalRecordsPlugin';
|
||||||
const WIDGET_NAME = 'MapList';
|
const CACHE_CURRENT_PAGE = 'CurrentPage';
|
||||||
|
const WIDGET_NAME = 'MapList';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private properties
|
* Private properties
|
||||||
@ -232,11 +234,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$headFrame->setY($height / 2 - 5);
|
$headFrame->setY($height / 2 - 5);
|
||||||
$posX = -$width / 2;
|
$posX = -$width / 2;
|
||||||
|
|
||||||
|
$localRecordsPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_LOCAL_RECORDS_PLUGIN);
|
||||||
|
|
||||||
$labelLine = new LabelLine($headFrame);
|
$labelLine = new LabelLine($headFrame);
|
||||||
$labelLine->addLabelEntryText('Id', $posX + 5);
|
$labelLine->addLabelEntryText('Id', $posX + 5);
|
||||||
$labelLine->addLabelEntryText('Mx Id', $posX + 10);
|
$labelLine->addLabelEntryText('Mx Id', $posX + 10);
|
||||||
$labelLine->addLabelEntryText('Map Name', $posX + 20);
|
if ($localRecordsPlugin) {
|
||||||
$labelLine->addLabelEntryText('Author', $posX + 68);
|
$labelLine->addLabelEntryText('Rank', $posX + 20);
|
||||||
|
}
|
||||||
|
$labelLine->addLabelEntryText('Map Name', $posX + 30);
|
||||||
|
$labelLine->addLabelEntryText('Author', $posX + 78);
|
||||||
$labelLine->addLabelEntryText('Actions', $width / 2 - 16);
|
$labelLine->addLabelEntryText('Actions', $width / 2 - 16);
|
||||||
$labelLine->setY(-7);
|
$labelLine->setY(-7);
|
||||||
$labelLine->render();
|
$labelLine->render();
|
||||||
@ -252,6 +259,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
/** @var KarmaPlugin $karmaPlugin */
|
/** @var KarmaPlugin $karmaPlugin */
|
||||||
$karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_KARMA_PLUGIN);
|
$karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_KARMA_PLUGIN);
|
||||||
|
|
||||||
|
|
||||||
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
|
$pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK;
|
||||||
$paging->setStartPageNumber($pageIndex + 1);
|
$paging->setStartPageNumber($pageIndex + 1);
|
||||||
|
|
||||||
@ -337,12 +345,24 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$labelLine = new LabelLine($mapFrame);
|
$labelLine = new LabelLine($mapFrame);
|
||||||
$labelLine->addLabelEntryText($mapListId, $posX + 5, 5);
|
$labelLine->addLabelEntryText($mapListId, $posX + 5, 5);
|
||||||
$labelLine->addLabelEntryText($mxId, $posX + 10, 10);
|
$labelLine->addLabelEntryText($mxId, $posX + 10, 10);
|
||||||
$labelLine->addLabelEntryText(Formatter::stripDirtyCodes($map->name), $posX + 20, 42);
|
|
||||||
|
// Map rank
|
||||||
|
if ($localRecordsPlugin) {
|
||||||
|
$record = $localRecordsPlugin->getLocalRecord($map, $player);
|
||||||
|
$playerCurrentRank = '-';
|
||||||
|
if ($record) {
|
||||||
|
$playerCurrentRank = strval($record->rank);
|
||||||
|
}
|
||||||
|
$labelLine->addLabelEntryText($playerCurrentRank, $posX + 22, 22);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map Name
|
||||||
|
$labelLine->addLabelEntryText(Formatter::stripDirtyCodes($map->name), $posX + 30, 42);
|
||||||
|
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$mapFrame->addChild($label);
|
$mapFrame->addChild($label);
|
||||||
$label->setText($map->authorNick);
|
$label->setText($map->authorNick);
|
||||||
$label->setX($posX + 68);
|
$label->setX($posX + 78);
|
||||||
$label->setSize(47, 0);
|
$label->setSize(47, 0);
|
||||||
$label->setAction(MapCommands::ACTION_SHOW_AUTHOR . $map->authorLogin);
|
$label->setAction(MapCommands::ACTION_SHOW_AUTHOR . $map->authorLogin);
|
||||||
$description = 'Click to checkout all maps by $<' . $map->authorLogin . '$>!';
|
$description = 'Click to checkout all maps by $<' . $map->authorLogin . '$>!';
|
||||||
|
Loading…
Reference in New Issue
Block a user