hide / display scoreboard on alt + some print methods

This commit is contained in:
kremsy 2017-05-06 15:07:22 +02:00
parent 8d376702b9
commit 6078507a46
2 changed files with 69 additions and 25 deletions

View File

@ -14,7 +14,6 @@ use ManiaControl\Logger;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\Xmlrpc\FaultException; use Maniaplanet\DedicatedServer\Xmlrpc\FaultException;
use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
use Maniaplanet\DedicatedServer\Xmlrpc\MessageException; use Maniaplanet\DedicatedServer\Xmlrpc\MessageException;
use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
@ -273,22 +272,6 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
return true; 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 * Closes a widget via the callback
* *
@ -338,19 +321,22 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
/** /**
* Enable the alt menu for the player * Enable the alt menu for the player
* *
* @api
* @param mixed $player * @param mixed $player
* @return bool
*/ */
public function enableAltMenu($player) { public function enableAltMenu($player) {
$login = Player::parseLogin($player); $this->maniaControl->getModeScriptEventManager()->displayScoreBoardOnAlt($player);
try {
$success = $this->maniaControl->getClient()->triggerModeScriptEvent('LibXmlRpc_EnableAltMenu', $login);
} catch (GameModeException $e) {
return false;
}
return $success;
} }
/**
* 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 * Adds a line of labels

View File

@ -4,9 +4,12 @@ namespace ManiaControl\Script;
use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Callbacks\Structures\XmlRpc\CallbackListStructure; 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\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait; use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
/** /**
* Manager for Mode Script Events * Manager for Mode Script Events
@ -49,6 +52,7 @@ class ModeScriptEventManager implements UsageInformationAble {
$this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('false')); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.EnableCallbacks', array('false'));
} }
/** /**
* Request a list of all available callbacks. This method will trigger the "XmlRpc.CallbacksList" callback. * 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); 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 * 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); 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 * Sets the Api Version
* *
@ -208,6 +234,17 @@ class ModeScriptEventManager implements UsageInformationAble {
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_DOCUMENTATION, $responseId); 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 * Gets a List of All Api Version
* *
@ -220,6 +257,27 @@ class ModeScriptEventManager implements UsageInformationAble {
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_ALLAPIVERSIONS, $responseId); 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. * Extend the duration of any ongoing warmup.