From c70a289bbc07d3343a0724c204cac0af7ad00d56 Mon Sep 17 00:00:00 2001 From: Max Klaversma Date: Thu, 17 Apr 2014 01:46:59 +0200 Subject: [PATCH] Added manialink callback to open recordslist --- application/plugins/LocalRecords.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/application/plugins/LocalRecords.php b/application/plugins/LocalRecords.php index bde29b5e..f9148af8 100644 --- a/application/plugins/LocalRecords.php +++ b/application/plugins/LocalRecords.php @@ -45,6 +45,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList const SETTING_NOTIFY_BEST_RECORDS = 'Notify Publicly only for the X Best Records'; const SETTING_ADJUST_OUTER_BORDER = 'Adjust outer Border to Number of actual Records'; const CB_LOCALRECORDS_CHANGE = 'LocalRecords.Change'; + const ACTION_SHOW_RECORDSLIST = 'LocalRecords.ShowRecordsList'; /* * Private Properties @@ -91,6 +92,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this, 'handlePlayerFinish'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->callbackManager->registerCallbackListener(SettingManager::CB_SETTINGS_CHANGED, $this, 'handleSettingsChanged'); + $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); $this->maniaControl->commandManager->registerCommandListener('records', $this, 'showRecordsList'); return true; @@ -286,6 +288,22 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList } } + /** + * Handle PlayerManialinkPageAnswer callback + * + * @param array $callback + */ + public function handleManialinkPageAnswer(array $callback) { + $actionId = $callback[1][2]; + + $login = $callback[1][1]; + $player = $this->maniaControl->playerManager->getPlayer($login); + + if($actionId == self::ACTION_SHOW_RECORDSLIST) { + $this->showRecordsList(array(), $player); + } + } + /** * Shows a ManiaLink list with the local records. * @@ -408,6 +426,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $height = 7. + ($adjustOuterBorder ? count($records) : $lines) * $lineHeight; $backgroundQuad->setSize($width * 1.05, $height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); + $backgroundQuad->setAction(self::ACTION_SHOW_RECORDSLIST); $titleLabel = new Label(); $frame->add($titleLabel);