added draft of new callback structure (made example)

This commit is contained in:
kremsy 2017-03-22 18:10:21 +01:00
parent ba86708e22
commit 496039a627
4 changed files with 83 additions and 4 deletions

View File

@ -28,6 +28,12 @@ interface Callbacks {
/* /*
* Common Callbacks * Common Callbacks
*/ */
//NEW Callbacks
const XMLRPC_CALLBACKSLIST = 'Callbacks.XmlRpcCallbacksList';
//OLD Callbacks
/** BeginMatch Callback: MatchNumber */ /** BeginMatch Callback: MatchNumber */
const BEGINMATCH = 'Callbacks.BeginMatch'; const BEGINMATCH = 'Callbacks.BeginMatch';
/** LoadingMap Callback: MapNumber */ /** LoadingMap Callback: MapNumber */
@ -126,14 +132,14 @@ interface Callbacks {
* TrackMania Callbacks * TrackMania Callbacks
*/ */
/** OnStartLine Callback */ /** OnStartLine Callback */
const STARTLINE = 'Callbacks.StartLine'; const ONSTARTLINE = 'Callbacks.StartLine';
/** OnWayPoint Callback */ /** OnWayPoint Callback */
const WAYPOINT = 'Callbacks.WayPoint'; const ONWAYPOINT = 'Callbacks.WayPoint';
/** OnGiveUp Callback */ /** OnGiveUp Callback */
const GIVEUP = 'Callbacks.GiveUp'; const ONGIVEUP = 'Callbacks.GiveUp';
/** OnRespawn Callback */ /** OnRespawn Callback */
const ONRESPAWN = 'Callbacks.Respawn'; const ONRESPAWN = 'Callbacks.Respawn';
/** OnStunt Callback */ /** OnStunt Callback */
const STUNT = 'Callbacks.Stunt'; const ONSTUNT = 'Callbacks.Stunt';
} }

View File

@ -4,6 +4,7 @@ namespace ManiaControl\Callbacks;
use ManiaControl\Callbacks\Structures\ArmorEmptyStructure; use ManiaControl\Callbacks\Structures\ArmorEmptyStructure;
use ManiaControl\Callbacks\Structures\CaptureStructure; use ManiaControl\Callbacks\Structures\CaptureStructure;
use ManiaControl\Callbacks\Structures\ManiaPlanet\CallbacksListStructure;
use ManiaControl\Callbacks\Structures\NearMissStructure; use ManiaControl\Callbacks\Structures\NearMissStructure;
use ManiaControl\Callbacks\Structures\PlayerHitStructure; use ManiaControl\Callbacks\Structures\PlayerHitStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -42,6 +43,11 @@ class LibXmlRpcCallbacks implements CallbackListener {
*/ */
public function handleScriptCallback($name, $data) { public function handleScriptCallback($name, $data) {
switch ($name) { switch ($name) {
//New callbacks
case 'XmlRpc.CallbacksList':
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::XMLRPC_CALLBACKSLIST, new CallbacksListStructure($this->maniaControl, $data));
break;
//OLD Callbacks
case 'LibXmlRpc_BeginMatch': case 'LibXmlRpc_BeginMatch':
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]); $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::BEGINMATCH, $data[0]);
break; break;

View File

@ -0,0 +1,53 @@
<?php
namespace ManiaControl\Callbacks\Structures\ManiaPlanet;
use ManiaControl\ManiaControl;
/**
* Structure Class for the List Structure Callback
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class CallbacksListStructure {
/** @var string $responseId */
private $responseId;
/** @var array $callbacks */
private $callbacks;
/** @var ManiaControl $maniaControl */
private $maniaControl;
/**
* Construct a new Armor Empty Structure
*
* @param ManiaControl $maniaControl
* @param array $data
*/
public function __construct(ManiaControl $maniaControl, $data) {
$this->maniaControl = $maniaControl;
//Not tested yet, TODO test
$json = json_decode($data);
$this->responseId = $json->responseId;
$this->callbacks = $json->callbacks;
}
/**
* @return string
*/
public function getResponseId() {
return $this->responseId;
}
/**
* @return array
*/
public function getCallbacks() {
return $this->callbacks;
}
}

View File

@ -0,0 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: Lukas
* Date: 22. Mär. 2017
* Time: 18:02
*/
namespace ManiaControl\Callbacks\Structures\Trackmania;
class DefaultEventStructure {
}