added direct invoke callback for methods

This commit is contained in:
kremsy 2017-04-07 18:30:48 +02:00
parent 6ad6768caa
commit 067536458e
8 changed files with 256 additions and 76 deletions

View File

@ -30,7 +30,15 @@ interface Callbacks {
*/ */
//NEW 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_STARTSERVERSTART = 'Maniaplanet.StartServer_Start';
const MP_STARTSERVEREND = 'Maniaplanet.StartServer_End'; const MP_STARTSERVEREND = 'Maniaplanet.StartServer_End';
@ -61,11 +69,12 @@ interface Callbacks {
const MP_PODIUMSTART = 'Maniaplanet.Podium_Start'; const MP_PODIUMSTART = 'Maniaplanet.Podium_Start';
const MP_PODIUMEND = 'Maniaplanet.Podium_End'; const MP_PODIUMEND = 'Maniaplanet.Podium_End';
const MP_WARMUP_START = 'Maniaplanet.WarmUp.Start'; const MP_WARMUP_START = 'Maniaplanet.WarmUp.Start';
const MP_WARMUP_END = 'Maniaplanet.WarmUp.End'; const MP_WARMUP_END = 'Maniaplanet.WarmUp.End';
const MP_WARMUP_STATUS = 'Maniaplanet.WarmUp.Status'; 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_ONEVENTDEFAULT = "Shootmania.Event.Default";
const SM_ONSHOOT = "Shootmania.Event.OnShoot"; const SM_ONSHOOT = "Shootmania.Event.OnShoot";
@ -86,15 +95,15 @@ interface Callbacks {
const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange"; const SM_ONPLAYERREQUESTACTIONCHANGE = "Shootmania.Event.OnPlayerRequestActionChange";
//SM GameMode Callbacks //SM GameMode Callbacks
const SM_COMBO_PAUSE = 'Shootmania.Combo.Pause'; const SM_COMBO_PAUSESTATUS = 'Shootmania.Combo.Pause';
const SM_ELITE_STARTTURN = 'Shootmania.Elite.StartTurn'; const SM_ELITE_STARTTURN = 'Shootmania.Elite.StartTurn';
const SM_ELITE_ENDTURN = 'Shootmania.Elite.EndTurn'; const SM_ELITE_ENDTURN = 'Shootmania.Elite.EndTurn';
const SM_JOUST_ONRELOAD = 'Shootmania.Joust.OnReload'; const SM_JOUST_ONRELOAD = 'Shootmania.Joust.OnReload';
const SM_JOUST_SELECTEDPLAYERS = 'Shootmania.Joust.SelectedPlayers'; const SM_JOUST_SELECTEDPLAYERS = 'Shootmania.Joust.SelectedPlayers';
const SM_JOUST_ROUNDRESULT = 'Shootmania.Joust.RoundResult'; const SM_JOUST_ROUNDRESULT = 'Shootmania.Joust.RoundResult';
const SM_ROYAL_POINTS = 'Shootmania.Royal.Points'; const SM_ROYAL_POINTS = 'Shootmania.Royal.Points';
const SM_ROYAL_PLAYERSPAWN = 'Shootmania.Royal.PlayerSpawn'; const SM_ROYAL_PLAYERSPAWN = 'Shootmania.Royal.PlayerSpawn';
const SM_ROYAL_ROUNDWINNER = 'Shootmania.Royal.RoundWinner'; const SM_ROYAL_ROUNDWINNER = 'Shootmania.Royal.RoundWinner';
// New TM Callbacks // New TM Callbacks
const TM_ONEVENTDEFAULT = "Trackmania.Event.Default"; const TM_ONEVENTDEFAULT = "Trackmania.Event.Default";
@ -113,6 +122,10 @@ interface Callbacks {
const TM_WARMUPENDROUND = "Trackmania.WarmUp.EndRound"; const TM_WARMUPENDROUND = "Trackmania.WarmUp.EndRound";
const TM_WARMUPEND = "Trackmania.WarmUp.End"; const TM_WARMUPEND = "Trackmania.WarmUp.End";
const TM_UIPROPERTIES = 'Trackmania.UIProperties';
const TM_POINTSREPARTITION = 'Trackmania.PointsRepartition';
//ManiaControl Callbacks //ManiaControl Callbacks
/** BeginMap Callback: Map */ /** BeginMap Callback: Map */
const BEGINMAP = 'Callbacks.BeginMap'; const BEGINMAP = 'Callbacks.BeginMap';

View File

@ -52,6 +52,27 @@ class LibXmlRpcCallbacks implements CallbackListener {
case Callbacks::XMLRPC_CALLBACKSLIST: case Callbacks::XMLRPC_CALLBACKSLIST:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data)); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data));
break; 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: case Callbacks::MP_STARTSERVERSTART:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVERSTART, new StartServerStructure($this->maniaControl, $data)); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::MP_STARTSERVERSTART, new StartServerStructure($this->maniaControl, $data));
break; break;

View File

@ -71,7 +71,9 @@ class ShootManiaCallbacks implements CallbackListener {
case Callbacks::SM_SCORES: case Callbacks::SM_SCORES:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_SCORES, new OnScoresStructure($this->maniaControl, $data)); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_SCORES, new OnScoresStructure($this->maniaControl, $data));
break; break;
//TODO UI Properties Later case Callbacks::SM_UIPROPERTIES:
//TODO
break;
case Callbacks::SM_ONEVENTDEFAULT: case Callbacks::SM_ONEVENTDEFAULT:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data)); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONEVENTDEFAULT, new OnDefaultEventStructure($this->maniaControl, $data));
break; break;
@ -117,7 +119,7 @@ class ShootManiaCallbacks implements CallbackListener {
case Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE: case Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE:
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE, new OnPlayerRequestActionChange($this->maniaControl, $data)); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::SM_ONPLAYERREQUESTACTIONCHANGE, new OnPlayerRequestActionChange($this->maniaControl, $data));
break; break;
case Callbacks::SM_COMBO_PAUSE: case Callbacks::SM_COMBO_PAUSESTATUS:
//TODO //TODO
break; break;
case Callbacks::SM_ELITE_STARTTURN: case Callbacks::SM_ELITE_STARTTURN:

View File

@ -0,0 +1,29 @@
<?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 07. Apr. 2017
* Time: 17:56
*/
namespace ManiaControl\Callbacks\Structures\Common;
use ManiaControl\ManiaControl;
class BaseResponseStructure extends BaseStructure {
protected $responseId;
/**
* Get the Response Id
*
* @return string
*/
public function getResponseId() {
return $this->responseId;
}
public function __construct(ManiaControl $maniaControl, $data) {
parent::__construct($maniaControl, $data);
}
}

View File

@ -16,8 +16,7 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team * @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CommonScoresStructure extends BaseStructure { class CommonScoresStructure extends BaseResponseStructure {
protected $responseId;
protected $section; protected $section;
protected $useTeams; protected $useTeams;
protected $winnerTeam; protected $winnerTeam;
@ -64,15 +63,6 @@ class CommonScoresStructure extends BaseStructure {
return $this->winnerPlayer; 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" * < Current progress of the match. Can be "" | "EndRound" | "EndMap" | "EndMatch"
* *

View File

@ -2,6 +2,7 @@
namespace ManiaControl\Callbacks\Structures\XmlRpc; namespace ManiaControl\Callbacks\Structures\XmlRpc;
use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure;
use ManiaControl\Callbacks\Structures\Common\BaseStructure; use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -12,9 +13,7 @@ use ManiaControl\ManiaControl;
* @copyright 2014-2017 ManiaControl Team * @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CallbacksListStructure extends BaseStructure { class CallbacksListStructure extends BaseResponseStructure {
/** @var string $responseId */
private $responseId;
/** @var array $callbacks */ /** @var array $callbacks */
private $callbacks; private $callbacks;
@ -31,14 +30,6 @@ class CallbacksListStructure extends BaseStructure {
$this->callbacks = $this->getPlainJsonObject()->callbacks; $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 * Get Array of the Callbacks

View File

@ -0,0 +1,58 @@
<?php
namespace ManiaControl\Script;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure;
use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait;
//TODO test
class InvokeScriptCallback implements CallbackListener, UsageInformationAble {
use UsageInformationTrait;
/**
* @var \ManiaControl\ManiaControl $maniaControl
*/
private $maniaControl;
private $callbackName;
private $responseId;
/**
* InvokeScriptCallback constructor.
*
* @param $maniaControl
* @param $callbackName
* @param $responseId
*/
public function __construct($maniaControl, $callbackName, $responseId) {
$this->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;
}
}

View File

@ -2,6 +2,7 @@
namespace ManiaControl\Script; namespace ManiaControl\Script;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait; use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl; 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. * 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)); $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 * Provide a Array of Callbacks you want to Block
* *
* @api
* @param array $callbackNames * @param array $callbackNames
*/ */
public function blockCallbacks($callbackNames) { public function blockCallbacks($callbackNames) {
@ -67,6 +72,7 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Block a Single Callback * Block a Single Callback
* *
* @api
* @param $callbackName * @param $callbackName
*/ */
public function blockCallback($callbackName) { public function blockCallback($callbackName) {
@ -76,6 +82,7 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Provide a Array of Callbacks you want to Block * Provide a Array of Callbacks you want to Block
* *
* @api
* @param array $callbackNames * @param array $callbackNames
*/ */
public function unBlockCallbacks($callbackNames) { public function unBlockCallbacks($callbackNames) {
@ -85,6 +92,7 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Block a Single Callback * Block a Single Callback
* *
* @api
* @param $callbackName * @param $callbackName
*/ */
public function unBlockCallback($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. * 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)); $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. * 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)); $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. * Description: Request help about a callback. This method will trigger the "XmlRpc.CallbackHelp" callback.
* *
* @api
* @param $callbackName * @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)); $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 * 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)); $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 * 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)); $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. * Request help about a method. This method will trigger the "XmlRpc.MethodHelp" callback.
* *
* @param $callbackName * @api
* @param string $responseId * @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)); $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. * 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)); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetDocumentation', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_DOCUMENTATION, $responseId);
} }
/** /**
* Gets a List of All Api Version * 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)); $this->maniaControl->getClient()->triggerModeScriptEvent('XmlRpc.GetAllApiVersions', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::XMLRPC_ALLAPIVERSIONS, $responseId);
} }
/** /**
* Extend the duration of any ongoing warmup. * Extend the duration of any ongoing warmup.
* *
* @api
* @param $milisec < the duration of the extension in milliseconds. * @param $milisec < the duration of the extension in milliseconds.
*/ */
public function extendManiaPlanetWarmup($milisec) { public function extendManiaPlanetWarmup($milisec) {
@ -187,6 +220,7 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Stop any ongoing warmup. * Stop any ongoing warmup.
* @api
*/ */
public function stopManiaPlanetWarmup() { public function stopManiaPlanetWarmup() {
$this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.WarmUp.Stop'); $this->maniaControl->getClient()->triggerModeScriptEvent('Maniaplanet.WarmUp.Stop');
@ -195,42 +229,55 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Get the status of the warmup. * 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)); $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. * 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)); $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)); $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)); $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. * Move the spectators' timers UI.
* *
* @api
* @param $x * @param $x
* @param $y * @param $y
* @param $z * @param $z
@ -242,6 +289,7 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Move the progression UI. * Move the progression UI.
* *
* @api
* @param $x * @param $x
* @param $y * @param $y
* @param $z * @param $z
@ -254,24 +302,31 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Request the current scores. This method will trigger the "Shootmania.Scores" callback. * 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)); $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. * 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)); $this->maniaControl->getClient()->triggerModeScriptEvent('Shootmania.GetUIProperties', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::SM_UIPROPERTIES, $responseId);
} }
/** /**
* Update the ui properties. * Update the ui properties.
* *
* @api
* @param string Json-Encoded Xml UI Property String * @param string Json-Encoded Xml UI Property String
*/ */
public function setShootmaniaUIProperties($properties) { public function setShootmaniaUIProperties($properties) {
@ -281,24 +336,31 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Request the current scores. This method will trigger the "Trackmania.Scores" callback. * 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)); $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. * 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)); $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetPointsRepartition', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_POINTSREPARTITION, $responseId);
} }
/** /**
* Update the points repartition. * Update the points repartition.
* *
* @api
* @param array String Array of Points * @param array String Array of Points
*/ */
public function setTrackmaniaPointsRepartition($pointArray) { 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. * 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)); $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.GetUIProperties', array($responseId));
return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_SCORES, $responseId);
} }
/** /**
* Update the ui properties. * Update the ui properties.
* * @api
* @param string Json-Encoded Xml UI Property String * @param string Json-Encoded Xml UI Property String
*/ */
public function setTrackmaniaUIProperties($properties) { public function setTrackmaniaUIProperties($properties) {
@ -325,6 +390,7 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Stop the whole warm up sequence. * Stop the whole warm up sequence.
* @api
*/ */
public function stopTrackmaniaWarmup() { public function stopTrackmaniaWarmup() {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.WarmUp.Stop'); $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.WarmUp.Stop');
@ -332,6 +398,7 @@ class ModeScriptEventManager implements UsageInformationAble {
/** /**
* Stop the current warm up round. * Stop the current warm up round.
* @api
*/ */
public function stopTrackmaniaRound() { public function stopTrackmaniaRound() {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.WarmUp.StopRound'); $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. * Stop the current round. Only available in Cup, Rounds and Team modes.
* @api
*/ */
public function forceTrackmaniaRoundEnd() { public function forceTrackmaniaRoundEnd() {
$this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.ForceEndRound'); $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.ForceEndRound');
} }
/**
* Generates the needed Unique ResponseId
* @return string
*/
private function generateResponseId() {
return uniqid("ManiaControl.");
}
} }