From 490c9b81af975273e7a0f33a249e6c707bf51f20 Mon Sep 17 00:00:00 2001 From: Max Klaversma Date: Thu, 1 May 2014 00:31:38 +0200 Subject: [PATCH] Added support for showing list of author by clicking author. --- application/core/Maps/MapCommands.php | 16 ++++++++++++++++ application/core/Maps/MapList.php | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/application/core/Maps/MapCommands.php b/application/core/Maps/MapCommands.php index 511db66e..8bf1589d 100644 --- a/application/core/Maps/MapCommands.php +++ b/application/core/Maps/MapCommands.php @@ -5,6 +5,7 @@ namespace ManiaControl\Maps; use FML\Controls\Quad; use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_UIConstruction_Buttons; +use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Commands\CommandListener; use ManiaControl\ManiaControl; @@ -29,6 +30,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb const ACTION_OPEN_XLIST = 'MapCommands.OpenMXList'; const ACTION_RESTART_MAP = 'MapCommands.RestartMap'; const ACTION_SKIP_MAP = 'MapCommands.NextMap'; + const ACTION_SHOW_AUTHOR = 'MapList.ShowAuthorList.'; /* * Private Properties @@ -64,6 +66,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_MAPLIST, $this, 'command_List'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_RESTART_MAP, $this, 'command_RestartMap'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SKIP_MAP, $this, 'command_NextMap'); + $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); } /** @@ -309,6 +312,19 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb } } + public function handleManialinkPageAnswer(array $callback) { + $actionId = $callback[1][2]; + + $login = $callback[1][1]; + $player = $this->maniaControl->playerManager->getPlayer($login); + + if (strstr($actionId, self::ACTION_SHOW_AUTHOR)) { + $login = str_replace(self::ACTION_SHOW_AUTHOR, '', $actionId); + $this->maniaControl->mapManager->mapList->playerCloseWidget($player); + $this->showMapListAuthor($login, $player); + } + } + /** * Handle /maps command * diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index 0c9fdc02..608e40f7 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -316,7 +316,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { * @var Label $label */ $label = $labels[3]; - $description = '$<' . $map->name . '$> made by $<' . $map->authorLogin . '$>'; + $description = 'Click to checkout all maps by $<' . $map->authorLogin . '$>!'; + $label->setAction(MapCommands::ACTION_SHOW_AUTHOR . $map->authorLogin); $label->addTooltipLabelFeature($descriptionLabel, $description); }