From 067536458ec7382cb89dc4e7fed8bdf5eeb6c94a Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 7 Apr 2017 18:30:48 +0200 Subject: [PATCH] added direct invoke callback for methods --- core/Callbacks/Callbacks.php | 37 +++-- core/Callbacks/LibXmlRpcCallbacks.php | 21 +++ core/Callbacks/ShootManiaCallbacks.php | 6 +- .../Common/BaseResponseStructure.php | 29 ++++ .../Common/CommonScoresStructure.php | 12 +- .../XmlRpc/CallbacksListStructure.php | 13 +- core/Script/InvokeScriptCallback.php | 58 +++++++ core/Script/ModeScriptEventManager.php | 156 +++++++++++++----- 8 files changed, 256 insertions(+), 76 deletions(-) create mode 100644 core/Callbacks/Structures/Common/BaseResponseStructure.php create mode 100644 core/Script/InvokeScriptCallback.php diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index c6363971..f90dc17b 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -30,7 +30,15 @@ interface Callbacks { */ //NEW Callbacks - const XMLRPC_CALLBACKSLIST = 'XmlRpc.CallbacksList'; + const XMLRPC_CALLBACKSLIST = 'XmlRpc.CallbacksList'; + const XMLRPC_ENABLEDCALLBACKS = 'XmlRpc.CallbacksList_Enabled'; + const XMLRPC_DISABLEDCALLBACKS = 'XmlRpc.CallbacksList_Disabled'; + const XMLRPC_CALLBACKHELP = 'XmlRpc.CallbackHelp'; + const XMLRPC_METHODSLIST = 'XmlRpc.MethodsList'; + const XMLRPC_METHODHELP = 'XmlRpc.MethodHelp'; + const XMLRPC_DOCUMENTATION = 'XmlRpc.MethodHelp'; + const XMLRPC_APIVERSION = 'XmlRpc.ApiVersion'; + const XMLRPC_ALLAPIVERSIONS = 'XmlRpc.AllApiVersions'; const MP_STARTSERVERSTART = 'Maniaplanet.StartServer_Start'; const MP_STARTSERVEREND = 'Maniaplanet.StartServer_End'; @@ -61,11 +69,12 @@ interface Callbacks { const MP_PODIUMSTART = 'Maniaplanet.Podium_Start'; const MP_PODIUMEND = 'Maniaplanet.Podium_End'; - const MP_WARMUP_START = 'Maniaplanet.WarmUp.Start'; - const MP_WARMUP_END = 'Maniaplanet.WarmUp.End'; + const MP_WARMUP_START = 'Maniaplanet.WarmUp.Start'; + const MP_WARMUP_END = 'Maniaplanet.WarmUp.End'; const MP_WARMUP_STATUS = 'Maniaplanet.WarmUp.Status'; - const SM_SCORES = "Shootmania.Scores"; + const SM_UIPROPERTIES = 'Shootmania.UIProperties'; + const SM_SCORES = "Shootmania.Scores"; const SM_ONEVENTDEFAULT = "Shootmania.Event.Default"; const SM_ONSHOOT = "Shootmania.Event.OnShoot"; @@ -86,15 +95,15 @@ interface Callbacks { const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange"; //SM GameMode Callbacks - const SM_COMBO_PAUSE = 'Shootmania.Combo.Pause'; - const SM_ELITE_STARTTURN = 'Shootmania.Elite.StartTurn'; - const SM_ELITE_ENDTURN = 'Shootmania.Elite.EndTurn'; - const SM_JOUST_ONRELOAD = 'Shootmania.Joust.OnReload'; + const SM_COMBO_PAUSESTATUS = 'Shootmania.Combo.Pause'; + const SM_ELITE_STARTTURN = 'Shootmania.Elite.StartTurn'; + const SM_ELITE_ENDTURN = 'Shootmania.Elite.EndTurn'; + const SM_JOUST_ONRELOAD = 'Shootmania.Joust.OnReload'; const SM_JOUST_SELECTEDPLAYERS = 'Shootmania.Joust.SelectedPlayers'; - const SM_JOUST_ROUNDRESULT = 'Shootmania.Joust.RoundResult'; - const SM_ROYAL_POINTS = 'Shootmania.Royal.Points'; - const SM_ROYAL_PLAYERSPAWN = 'Shootmania.Royal.PlayerSpawn'; - const SM_ROYAL_ROUNDWINNER = 'Shootmania.Royal.RoundWinner'; + const SM_JOUST_ROUNDRESULT = 'Shootmania.Joust.RoundResult'; + const SM_ROYAL_POINTS = 'Shootmania.Royal.Points'; + const SM_ROYAL_PLAYERSPAWN = 'Shootmania.Royal.PlayerSpawn'; + const SM_ROYAL_ROUNDWINNER = 'Shootmania.Royal.RoundWinner'; // New TM Callbacks const TM_ONEVENTDEFAULT = "Trackmania.Event.Default"; @@ -113,6 +122,10 @@ interface Callbacks { const TM_WARMUPENDROUND = "Trackmania.WarmUp.EndRound"; const TM_WARMUPEND = "Trackmania.WarmUp.End"; + const TM_UIPROPERTIES = 'Trackmania.UIProperties'; + + const TM_POINTSREPARTITION = 'Trackmania.PointsRepartition'; + //ManiaControl Callbacks /** BeginMap Callback: Map */ const BEGINMAP = 'Callbacks.BeginMap'; diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index 01ea9233..3f58831e 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -52,6 +52,27 @@ class LibXmlRpcCallbacks implements CallbackListener { case Callbacks::XMLRPC_CALLBACKSLIST: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data)); break; + case Callbacks::XMLRPC_ENABLEDCALLBACKS: + //TODO + break; + case Callbacks::XMLRPC_DISABLEDCALLBACKS: + //TODO + break; + case Callbacks::XMLRPC_APIVERSION: + //TODO + break; + case Callbacks::XMLRPC_ALLAPIVERSIONS: + //TODO + break; + case Callbacks::XMLRPC_DOCUMENTATION: + //TODO + break; + case Callbacks::XMLRPC_METHODSLIST: + //TODO + break; + case Callbacks::XMLRPC_METHODHELP: + //TODO + break; case Callbacks::MP_STARTSERVERSTART: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVERSTART, new StartServerStructure($this->maniaControl, $data)); break; diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index 3434b698..4a68891b 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -71,7 +71,9 @@ class ShootManiaCallbacks implements CallbackListener { case Callbacks::SM_SCORES: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_SCORES, new OnScoresStructure($this->maniaControl, $data)); break; - //TODO UI Properties Later + case Callbacks::SM_UIPROPERTIES: + //TODO + break; case Callbacks::SM_ONEVENTDEFAULT: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data)); break; @@ -117,7 +119,7 @@ class ShootManiaCallbacks implements CallbackListener { case Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE: $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE, new OnPlayerRequestActionChange($this->maniaControl, $data)); break; - case Callbacks::SM_COMBO_PAUSE: + case Callbacks::SM_COMBO_PAUSESTATUS: //TODO break; case Callbacks::SM_ELITE_STARTTURN: diff --git a/core/Callbacks/Structures/Common/BaseResponseStructure.php b/core/Callbacks/Structures/Common/BaseResponseStructure.php new file mode 100644 index 00000000..d0114f52 --- /dev/null +++ b/core/Callbacks/Structures/Common/BaseResponseStructure.php @@ -0,0 +1,29 @@ +responseId; + } + + public function __construct(ManiaControl $maniaControl, $data) { + parent::__construct($maniaControl, $data); + } +} \ No newline at end of file diff --git a/core/Callbacks/Structures/Common/CommonScoresStructure.php b/core/Callbacks/Structures/Common/CommonScoresStructure.php index ebbf73fd..90ac4f8f 100644 --- a/core/Callbacks/Structures/Common/CommonScoresStructure.php +++ b/core/Callbacks/Structures/Common/CommonScoresStructure.php @@ -16,8 +16,7 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CommonScoresStructure extends BaseStructure { - protected $responseId; +class CommonScoresStructure extends BaseResponseStructure { protected $section; protected $useTeams; protected $winnerTeam; @@ -64,15 +63,6 @@ class CommonScoresStructure extends BaseStructure { return $this->winnerPlayer; } - /** - * Get the Response Id - * - * @return string - */ - public function getResponseId() { - return $this->responseId; - } - /** * < Current progress of the match. Can be "" | "EndRound" | "EndMap" | "EndMatch" * diff --git a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php index f4c5cb0c..d600616f 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbacksListStructure.php @@ -2,6 +2,7 @@ namespace ManiaControl\Callbacks\Structures\XmlRpc; +use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure; use ManiaControl\Callbacks\Structures\Common\BaseStructure; use ManiaControl\ManiaControl; @@ -12,9 +13,7 @@ use ManiaControl\ManiaControl; * @copyright 2014-2017 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class CallbacksListStructure extends BaseStructure { - /** @var string $responseId */ - private $responseId; +class CallbacksListStructure extends BaseResponseStructure { /** @var array $callbacks */ private $callbacks; @@ -31,14 +30,6 @@ class CallbacksListStructure extends BaseStructure { $this->callbacks = $this->getPlainJsonObject()->callbacks; } - /** - * Get the Response Id //TODO Trait for all Response Ids - * - * @return string - */ - public function getResponseId() { - return $this->responseId; - } /** * Get Array of the Callbacks diff --git a/core/Script/InvokeScriptCallback.php b/core/Script/InvokeScriptCallback.php new file mode 100644 index 00000000..104aa1c3 --- /dev/null +++ b/core/Script/InvokeScriptCallback.php @@ -0,0 +1,58 @@ +maniaControl = $maniaControl; + $this->callbackName = $callbackName; + $this->responseId = $responseId; + } + + /** + * Sets a Callable to be called back with the Information + * + * @api + * @param callable $function async Function to Call back + */ + public function setCallable(callable $function) { + $this->maniaControl->getCallbackManager()->registerCallbackListener($this->callbackName, $this, function(BaseResponseStructure $callBackData) use (&$function){ + if($callBackData == $this->responseId){ + call_user_func_array($function, array($callBackData)); + } + }); + } + + /** + * Returns the Generated ResponseId + * + * @api + * @return mixed + */ + public function getResponseId() { + return $this->responseId; + } +} \ No newline at end of file diff --git a/core/Script/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php index 924249a9..24ad5ba7 100644 --- a/core/Script/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -2,6 +2,7 @@ namespace ManiaControl\Script; +use ManiaControl\Callbacks\Callbacks; use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationTrait; use ManiaControl\ManiaControl; @@ -49,15 +50,19 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Request a list of all available callbacks. This method will trigger the "XmlRpc.CallbacksList" callback. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getCallbacksList($responseId = "DefaultResponseId") { + public function getCallbacksList() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbacksList', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_CALLBACKSLIST, $responseId); } /** * Provide a Array of Callbacks you want to Block * + * @api * @param array $callbackNames */ public function blockCallbacks($callbackNames) { @@ -67,6 +72,7 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Block a Single Callback * + * @api * @param $callbackName */ public function blockCallback($callbackName) { @@ -76,6 +82,7 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Provide a Array of Callbacks you want to Block * + * @api * @param array $callbackNames */ public function unBlockCallbacks($callbackNames) { @@ -85,6 +92,7 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Block a Single Callback * + * @api * @param $callbackName */ public function unBlockCallback($callbackName) { @@ -93,40 +101,52 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Request a list of all enabled callbacks. This method will trigger the "XmlRpc.CallbacksList_Enabled" callback. + *@api * - * @param string $responseId + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getListOfEnabledCallbacks($responseId = "DefaultResponseId") { + public function getListOfEnabledCallbacks() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbacksList_Enabled', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_ENABLEDCALLBACKS, $responseId); } /** * Request a list of all disabled callbacks. This method will trigger the "XmlRpc.CallbacksList_Enabled" callback. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getListOfDisabledCallbacks($responseId) { + public function getListOfDisabledCallbacks() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbacksList_Disabled', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_DISABLEDCALLBACKS, $responseId); } /** * Description: Request help about a callback. This method will trigger the "XmlRpc.CallbackHelp" callback. * + * @api * @param $callbackName - * @param string $responseId + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getCallbackHelp($callbackName, $responseId = "DefaultResponseId") { + public function getCallbackHelp($callbackName) { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetCallbackHelp', array($callbackName, $responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_CALLBACKHELP, $responseId); } /** * Request a list of all available methods. This method will trigger the "XmlRpc.MethodsList" callback.s * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getMethodsList($responseId = "DefaultResponseId") { + public function getMethodsList() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetMethodsList', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_METHODSLIST, $responseId); } /** @@ -141,44 +161,57 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Gets the Api Version * - * @param string $version + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getApiVersion($responseId = "DefaultResponseId") { + public function getApiVersion() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetApiVersion', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_APIVERSION, $responseId); } /** * Request help about a method. This method will trigger the "XmlRpc.MethodHelp" callback. * - * @param $callbackName - * @param string $responseId + * @api + * @param $methodName + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getMethodHelp($methodName, $responseId = "DefaultResponseId") { + public function getMethodHelp($methodName) { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetMethodHelp', array($methodName, $responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_METHODHELP, $responseId); } /** * Request the current game mode xmlrpc callbacks and methods documentation. This method will trigger the "XmlRpc.Documentation" callback. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getDocumentation($responseId = "DefaultResponseId") { + public function getDocumentation() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetDocumentation', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_DOCUMENTATION, $responseId); } /** * Gets a List of All Api Version * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getAllApiVersions($responseId = "DefaultResponseId") { + public function getAllApiVersions() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetAllApiVersions', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_ALLAPIVERSIONS, $responseId); } /** * Extend the duration of any ongoing warmup. * + * @api * @param $milisec < the duration of the extension in milliseconds. */ public function extendManiaPlanetWarmup($milisec) { @@ -187,6 +220,7 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Stop any ongoing warmup. + * @api */ public function stopManiaPlanetWarmup() { $this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.WarmUp.Stop'); @@ -195,42 +229,55 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Get the status of the warmup. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getWarmupStatus($responseId = "DefaultResponseId") { + public function getWarmupStatus() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.WarmUp.GetStatus', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::MP_WARMUP_STATUS, $responseId); } /** * Get the status of the pause. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getComboPauseStatus($responseId = "DefaultResponseId") { + public function getComboPauseStatus() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.Combo.GetPause', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_COMBO_PAUSESTATUS, $responseId); } /** - * Start a Pause in Combo + * Start a Pause in Combo and triggers a Callback for the Pause Status * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback To get The Pause Status You can directly set a callable on it via setCallable() */ - public function startComboPause($responseId = "DefaultResponseId") { + public function startComboPause() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.Combo.SetPause', array(true, $responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_COMBO_PAUSESTATUS, $responseId); } /** - * End a Pause in Combo + * End a Pause in Combo and triggers a Callback for the Pause Status * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback To get The Pause Status You can directly set a callable on it via setCallable() */ - public function endComboPause($responseId = "DefaultResponseId") { + public function endComboPause() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.Combo.SetPause', array(false, $responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_COMBO_PAUSESTATUS, $responseId); } /** * Move the spectators' timers UI. * + * @api * @param $x * @param $y * @param $z @@ -242,6 +289,7 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Move the progression UI. * + * @api * @param $x * @param $y * @param $z @@ -254,24 +302,31 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Request the current scores. This method will trigger the "Shootmania.Scores" callback. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getShootmaniaScores($responseId = "DefaultResponseId") { + public function getShootmaniaScores() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetScores', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_SCORES, $responseId); } /** * Request the current ui properties. This method will trigger the "Shootmania.UIProperties" callback. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getShootmaniaUIProperties($responseId = "DefaultResponseId") { + public function getShootmaniaUIProperties() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetUIProperties', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_UIPROPERTIES, $responseId); } /** * Update the ui properties. * + * @api * @param string Json-Encoded Xml UI Property String */ public function setShootmaniaUIProperties($properties) { @@ -281,24 +336,31 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Request the current scores. This method will trigger the "Trackmania.Scores" callback. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getTrackmaniaScores($responseId = "DefaultResponseId") { + public function getTrackmaniaScores() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetScores', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_SCORES, $responseId); } /** * Request the current points repartition. This method will trigger the "Trackmania.PointsRepartition" callback. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getTrackmaniaPointsRepartition($responseId = "DefaultResponseId") { + public function getTrackmaniaPointsRepartition() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetPointsRepartition', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_POINTSREPARTITION, $responseId); } /** * Update the points repartition. * + * @api * @param array String Array of Points */ public function setTrackmaniaPointsRepartition($pointArray) { @@ -308,15 +370,18 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Request the current ui properties. This method will trigger the "Shootmania.UIProperties" callback. * - * @param string $responseId + * @api + * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() */ - public function getTrackmaniaUIProperties($responseId = "DefaultResponseId") { + public function getTrackmaniaUIProperties() { + $responseId = $this->generateResponseId(); $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetUIProperties', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_SCORES, $responseId); } /** * Update the ui properties. - * + * @api * @param string Json-Encoded Xml UI Property String */ public function setTrackmaniaUIProperties($properties) { @@ -325,6 +390,7 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Stop the whole warm up sequence. + * @api */ public function stopTrackmaniaWarmup() { $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.WarmUp.Stop'); @@ -332,6 +398,7 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Stop the current warm up round. + * @api */ public function stopTrackmaniaRound() { $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.WarmUp.StopRound'); @@ -340,8 +407,17 @@ class ModeScriptEventManager implements UsageInformationAble { /** * Stop the current round. Only available in Cup, Rounds and Team modes. + * @api */ public function forceTrackmaniaRoundEnd() { $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.ForceEndRound'); } + + /** + * Generates the needed Unique ResponseId + * @return string + */ + private function generateResponseId() { + return uniqid("ManiaControl."); + } } \ No newline at end of file