libxmlrpc callbacks
This commit is contained in:
parent
8f1b5ae791
commit
335901edd8
@ -251,6 +251,6 @@ class CallbackManager {
|
||||
$scriptCallbackData = $callback[1];
|
||||
$scriptCallbackName = $scriptCallbackData[0];
|
||||
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
||||
$this->triggerCallback(Callbacks::ScriptCallback, $scriptCallbackName, $scriptCallbackData[1]);
|
||||
$this->triggerCallback(Callbacks::SCRIPTCALLBACK, $scriptCallbackName, $scriptCallbackData[1]);
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,31 @@ namespace ManiaControl\Callbacks;
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface Callbacks {
|
||||
const ScriptCallback = 'Callbacks.ScriptCallback';
|
||||
/** BeginMatch Callback, param1 MapNumber */
|
||||
const BeginMatch = "Callbacks.BeginMatch";
|
||||
/** LoadingMap Callback, param1 MapNumber */
|
||||
const LoadingMap = "Callbacks.LoadingMap";
|
||||
/** BeginMap Callback, param1 MapNumber */
|
||||
const BeginMap = "Callbacks.BeginMap";
|
||||
const SCRIPTCALLBACK = 'Callbacks.ScriptCallback';
|
||||
/** BeginMatch Callback, param1 MatchNumber */
|
||||
const BEGINMATCH = "Callbacks.BeginMatch";
|
||||
/** LoadingMap Callback, Number of Map */
|
||||
const LOADINGMAP = "Callbacks.LoadingMap";
|
||||
/** BeginMap Callback, triggered by MapManager, param1 Map Object */
|
||||
const BEGINMAP = "Callbacks.BeginMap";
|
||||
/** BeginSubMatch Callback, param1 Number of Submatch */
|
||||
const BEGINSUBMATCH = "Callbacks.BeginSubmatch";
|
||||
/** BeginRound Callback, param1 Number of Round */
|
||||
const BEGINROUND = "Callbacks.BeginRound";
|
||||
/** BeginTurn Callback, param1 Number of Turn */
|
||||
const BEGINTURN = "Callbacks.BeginTurn";
|
||||
/** EndTurn Callback, param1 Number of Turn */
|
||||
const ENDTURN = "Callbacks.EndTurn";
|
||||
/** EndRound Callback, param1 Number of Round */
|
||||
const ENDROUND = "Callbacks.EndRound";
|
||||
/** EndSubMatch Callback, param1 Number of Submatch */
|
||||
const ENDSUBMATCH = "Callbacks.EndSubmatch";
|
||||
/** BeginMap Callback, triggered by MapManager, param1 Map Object */
|
||||
const ENDMAP = "Callbacks.EndMap";
|
||||
/** EndMatch Callback, param1 MatchNumber */
|
||||
const ENDMATCH = "Callbacks.EndMatch";
|
||||
/** BeginWarmup Callback, no parameters */
|
||||
const BEGINWARMUP = "Callbacks.BeginWarmUp";
|
||||
/** EndWarmup Callback, no parameters */
|
||||
const ENDWARMUP = "Callbacks.EndWarmUp";
|
||||
}
|
@ -1,10 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Lukas
|
||||
* Date: 24.04.14
|
||||
* Time: 16:57
|
||||
*/
|
||||
|
||||
namespace ManiaControl\Callbacks;
|
||||
|
||||
@ -18,34 +12,55 @@ class LibXmlRpcCallbackManager implements CallbackListener{
|
||||
private $maniaControl = null;
|
||||
|
||||
/**
|
||||
* Create a new ShootMania Callbacks Instance
|
||||
* Create a new LibXmlRpc Callbacks Instance
|
||||
*
|
||||
* @param ManiaControl $maniaControl
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
$callbackManager->registerCallbackListener(Callbacks::ScriptCallback, $this, 'handleScriptCallbacks');
|
||||
$callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks');
|
||||
}
|
||||
|
||||
public function handleScriptCallbacks($name, $data) {
|
||||
switch($name) {
|
||||
case 'LibXmlRpc_BeginMatch':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BeginMatch, $data[0]);
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMATCH, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_LoadingMap':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::LoadingMap, $data[0]);
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::LOADINGMAP, $data[0]);
|
||||
break;
|
||||
case 'BeginMap':
|
||||
case 'LibXmlRpc_BeginMap':
|
||||
//$this->maniaControl->callbackManager->triggerCallback(Callbacks::BeginMap, $data[0]);
|
||||
$this->maniaControl->mapManager->handleScriptBeginMap($data[0]);
|
||||
break;
|
||||
|
||||
|
||||
case 'LibXmlRpc_BeginSubmatch':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINSUBMATCH, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_BeginTurn':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINTURN, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_EndTurn':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDTURN, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_EndRound':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDROUND, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_EndSubmatch':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDSUBMATCH, $data[0]);
|
||||
break;
|
||||
case 'EndMap':
|
||||
case 'LibXmlRpc_EndMap':
|
||||
$this->maniaControl->mapManager->handleScriptEndMap($data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_EndMatch':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDMATCH, $data[0]);
|
||||
break;
|
||||
case 'LibXmlRpc_BeginWarmUp':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINWARMUP);
|
||||
break;
|
||||
case 'LibXmlRpc_EndWarmUp':
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDWARMUP);
|
||||
break;
|
||||
}
|
||||
var_dump($name);
|
||||
var_dump($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -15,10 +15,6 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const SCB_LIBXMLRPC_BEGINMAP = 'LibXmlRpc_BeginMap';
|
||||
const SCB_LIBXMLRPC_ENDMAP = 'LibXmlRpc_EndMap';
|
||||
const SCB_OLD_BEGINMAP = 'BeginMap';
|
||||
const SCB_OLD_ENDMAP = 'EndMap';
|
||||
const SCB_TIMEATTACK_ONSTART = 'TimeAttack_OnStart';
|
||||
const SCB_TIMEATTACK_ONRESTART = 'TimeAttack_OnRestart';
|
||||
const SCB_TIMEATTACK_ONCHECKPOINT = 'TimeAttack_OnCheckpoint';
|
||||
@ -38,33 +34,10 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Register for script callbacks
|
||||
$callbackManager->registerScriptCallbackListener(self::SCB_LIBXMLRPC_BEGINMAP, $this, 'callback_LibXmlRpc_BeginMap');
|
||||
$callbackManager->registerScriptCallbackListener(self::SCB_OLD_BEGINMAP, $this, 'callback_LibXmlRpc_BeginMap');
|
||||
$callbackManager->registerScriptCallbackListener(self::SCB_LIBXMLRPC_ENDMAP, $this, 'callback_LibXmlRpc_EndMap');
|
||||
$callbackManager->registerScriptCallbackListener(self::SCB_OLD_ENDMAP, $this, 'callback_LibXmlRpc_EndMap');
|
||||
|
||||
$callbackManager->registerScriptCallbackListener(self::SCB_TIMEATTACK_ONCHECKPOINT, $this, 'callback_TimeAttack_OnCheckpoint');
|
||||
$callbackManager->registerScriptCallbackListener(self::SCB_TIMEATTACK_ONFINISH, $this, 'callback_TimeAttack_OnFinish');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle LibXmlRpc BeginMap Script Callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function callback_LibXmlRpc_BeginMap(array $callback) {
|
||||
$this->maniaControl->mapManager->handleScriptBeginMap($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle LibXmlRpc EndMap Script Callback
|
||||
*
|
||||
* @param array $callback
|
||||
*/
|
||||
public function callback_LibXmlRpc_EndMap(array $callback) {
|
||||
$this->maniaControl->mapManager->handleScriptEndMap($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle TimeAttack OnCheckpoint Script Callback
|
||||
*
|
||||
@ -79,8 +52,7 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
}
|
||||
// Trigger trackmania player checkpoint callback
|
||||
$checkpointCallback = array($player->pid, $player->login, $time, 0, 0);
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT,
|
||||
array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback));
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT, array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $checkpointCallback));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,7 +69,6 @@ class ShootManiaCallbacks implements CallbackListener {
|
||||
}
|
||||
// Trigger trackmania player finish callback
|
||||
$finishCallback = array($player->pid, $player->login, $time);
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH,
|
||||
array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback));
|
||||
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERFINISH, array(CallbackManager::CB_TM_PLAYERFINISH, $finishCallback));
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace ManiaControl\Maps;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Files\FileUtil;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\ManiaExchange\ManiaExchangeList;
|
||||
@ -30,7 +31,9 @@ class MapManager implements CallbackListener {
|
||||
* Constants
|
||||
*/
|
||||
const TABLE_MAPS = 'mc_maps';
|
||||
/** @deprecated CB_BEGINMAP */
|
||||
const CB_BEGINMAP = 'MapManager.BeginMap';
|
||||
/** @deprecated CB_ENDMAP */
|
||||
const CB_ENDMAP = 'MapManager.EndMap';
|
||||
const CB_MAPS_UPDATED = 'MapManager.MapsUpdated';
|
||||
const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated';
|
||||
@ -503,16 +506,18 @@ class MapManager implements CallbackListener {
|
||||
// Update the mx of the map (for update checks, etc.)
|
||||
$this->mxManager->fetchManiaExchangeMapInformations($this->currentMap);
|
||||
|
||||
// Trigger own BeginMap callback
|
||||
// Trigger own BeginMap callback (
|
||||
//TODO remove deprecated callback later
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_BEGINMAP, $this->currentMap);
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMAP, $this->currentMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Script BeginMap callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param int $mapNumber
|
||||
*/
|
||||
public function handleScriptBeginMap(array $callback) {
|
||||
public function handleScriptBeginMap($mapNumber) {
|
||||
$this->handleBeginMap(array());
|
||||
}
|
||||
|
||||
@ -530,22 +535,17 @@ class MapManager implements CallbackListener {
|
||||
|
||||
// Trigger own EndMap callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_ENDMAP, $this->currentMap);
|
||||
//TODO remove deprecated callback later
|
||||
$this->maniaControl->callbackManager->triggerCallback(Callbacks::ENDMAP, $this->currentMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Script EndMap Callback
|
||||
*
|
||||
* @param array $callback
|
||||
* @param int $mapNumber
|
||||
*/
|
||||
public function handleScriptEndMap(array $callback) {
|
||||
if ($this->mapEnded) {
|
||||
return;
|
||||
}
|
||||
$this->mapEnded = true;
|
||||
$this->mapBegan = false;
|
||||
|
||||
// Trigger own EndMap callback
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_ENDMAP, $this->currentMap);
|
||||
public function handleScriptEndMap($mapNumber) {
|
||||
$this->handleEndMap(array());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user