From 6078507a4603a44150eb005f3f77d799d28fde25 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 6 May 2017 15:07:22 +0200 Subject: [PATCH] hide / display scoreboard on alt + some print methods --- core/Manialinks/ManialinkManager.php | 36 +++++----------- core/Script/ModeScriptEventManager.php | 58 ++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 25 deletions(-) diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index bad429f5..cc1eb84f 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -14,7 +14,6 @@ use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use Maniaplanet\DedicatedServer\Xmlrpc\FaultException; -use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; use Maniaplanet\DedicatedServer\Xmlrpc\MessageException; use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; @@ -273,22 +272,6 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, return true; } - /** - * Disable the alt menu for the player - * - * @param mixed $player - * @return bool - */ - public function disableAltMenu($player) { - $login = Player::parseLogin($player); - try { - $success = $this->maniaControl->getClient()->triggerModeScriptEvent('LibXmlRpc_DisableAltMenu', $login); - } catch (GameModeException $e) { - return false; - } - return $success; - } - /** * Closes a widget via the callback * @@ -338,19 +321,22 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, /** * Enable the alt menu for the player * + * @api * @param mixed $player - * @return bool */ public function enableAltMenu($player) { - $login = Player::parseLogin($player); - try { - $success = $this->maniaControl->getClient()->triggerModeScriptEvent('LibXmlRpc_EnableAltMenu', $login); - } catch (GameModeException $e) { - return false; - } - return $success; + $this->maniaControl->getModeScriptEventManager()->displayScoreBoardOnAlt($player); } + /** + * Disable the alt menu for the player + * + * @api + * @param mixed $player + */ + public function disableAltMenu($player) { + $this->maniaControl->getModeScriptEventManager()->hideScoreBoardOnAlt($player); + } /** * Adds a line of labels diff --git a/core/Script/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php index 0accc389..ce9583b4 100644 --- a/core/Script/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -4,9 +4,12 @@ namespace ManiaControl\Script; use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\Structures\XmlRpc\CallbackListStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\DocumentationStructure; +use ManiaControl\Callbacks\Structures\XmlRpc\MethodListStructure; use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; +use ManiaControl\Players\Player; /** * Manager for Mode Script Events @@ -49,6 +52,7 @@ class ModeScriptEventManager implements UsageInformationAble { $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('false')); } + /** * Request a list of all available callbacks. This method will trigger the "XmlRpc.CallbacksList" callback. * @@ -61,6 +65,17 @@ class ModeScriptEventManager implements UsageInformationAble { return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_CALLBACKSLIST, $responseId); } + /** + * Prints the List of XMLRPC Callbacks in the Console + * + * @api + */ + public function printCallbacksList() { + $this->getCallbacksList()->setCallable(function (CallbackListStructure $structure) { + var_dump($structure->getCallbacks()); + }); + } + /** * Provide a Array of Callbacks you want to Block * @@ -162,6 +177,17 @@ class ModeScriptEventManager implements UsageInformationAble { return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_METHODSLIST, $responseId); } + /** + * Prints the List of XMLRPC Methods in the Console + * + * @api + */ + public function printMethodsList() { + $this->getMethodsList()->setCallable(function (MethodListStructure $structure) { + var_dump($structure->getMethods()); + }); + } + /** * Sets the Api Version * @@ -208,6 +234,17 @@ class ModeScriptEventManager implements UsageInformationAble { return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_DOCUMENTATION, $responseId); } + /** + * Printes the XMLRPC Documentation in the Console + * + * @api + */ + public function printDocumentation() { + $this->getDocumentation()->setCallable(function (DocumentationStructure $structure) { + var_dump($structure->getDocumentation()); + }); + } + /** * Gets a List of All Api Version * @@ -220,6 +257,27 @@ class ModeScriptEventManager implements UsageInformationAble { return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_ALLAPIVERSIONS, $responseId); } + /** + * Hides the Scoreboard on Pressing Alt + * + * @api + * @param \ManiaControl\Players\Player $player + */ + public function hideScoreBoardOnAlt(Player $player) { + $login = Player::parseLogin($player); + $this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.UI.SetAltScoresTableVisibility', array($login, "False")); + } + + /** + * Displays the Scoreboard on Pressing Alt + * + * @api + * @param \ManiaControl\Players\Player $player + */ + public function displayScoreBoardOnAlt(Player $player) { + $login = Player::parseLogin($player); + $this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.UI.SetAltScoresTableVisibility', array($login, "True")); + } /** * Extend the duration of any ongoing warmup.