fixed tripple endmap cb problem
This commit is contained in:
parent
5bc897cf33
commit
19a8f3e2dc
@ -55,7 +55,7 @@ class CallbackManager {
|
|||||||
private $last1Second = -1;
|
private $last1Second = -1;
|
||||||
private $last5Second = -1;
|
private $last5Second = -1;
|
||||||
private $last1Minute = -1;
|
private $last1Minute = -1;
|
||||||
|
private $mapEnded = false;
|
||||||
/**
|
/**
|
||||||
* Construct callbacks manager
|
* Construct callbacks manager
|
||||||
*
|
*
|
||||||
@ -204,11 +204,15 @@ class CallbackManager {
|
|||||||
case 'ManiaPlanet.BeginMap':
|
case 'ManiaPlanet.BeginMap':
|
||||||
{
|
{
|
||||||
$this->triggerCallback(self::CB_MC_BEGINMAP, $callback);
|
$this->triggerCallback(self::CB_MC_BEGINMAP, $callback);
|
||||||
|
$this->mapEnded = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'ManiaPlanet.EndMap':
|
case 'ManiaPlanet.EndMap':
|
||||||
{
|
{
|
||||||
|
if(!$this->mapEnded){
|
||||||
$this->triggerCallback(self::CB_MC_ENDMAP, $callback);
|
$this->triggerCallback(self::CB_MC_ENDMAP, $callback);
|
||||||
|
$this->mapEnded = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case self::CB_MP_MODESCRIPTCALLBACK:
|
case self::CB_MP_MODESCRIPTCALLBACK:
|
||||||
@ -244,13 +248,19 @@ class CallbackManager {
|
|||||||
case 'EndMap':
|
case 'EndMap':
|
||||||
{
|
{
|
||||||
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
||||||
|
if(!$this->mapEnded){
|
||||||
$this->triggerCallback(self::CB_MC_ENDMAP, $callback);
|
$this->triggerCallback(self::CB_MC_ENDMAP, $callback);
|
||||||
|
$this->mapEnded = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'LibXmlRpc_EndMap':
|
case 'LibXmlRpc_EndMap':
|
||||||
{
|
{
|
||||||
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
||||||
|
if(!$this->mapEnded){
|
||||||
$this->triggerCallback(self::CB_MC_ENDMAP, $callback);
|
$this->triggerCallback(self::CB_MC_ENDMAP, $callback);
|
||||||
|
$this->mapEnded = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ManiaControl\Maps;
|
namespace ManiaControl\Maps;
|
||||||
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,7 +10,7 @@ use ManiaControl\ManiaControl;
|
|||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class Jukebox {
|
class Jukebox implements CallbackListener {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -28,10 +30,17 @@ class Jukebox {
|
|||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this,'beginMap');
|
||||||
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this,'endMap');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addMapToJukebox($uid){
|
/**
|
||||||
|
* Adds a Map to the jukebox
|
||||||
|
* @param $login
|
||||||
|
* @param $uid
|
||||||
|
*/
|
||||||
|
public function addMapToJukebox($login, $uid){
|
||||||
|
|
||||||
//Check if the map is already juked
|
//Check if the map is already juked
|
||||||
if(array_key_exists($uid, $this->jukedMaps)){
|
if(array_key_exists($uid, $this->jukedMaps)){
|
||||||
@ -41,11 +50,77 @@ class Jukebox {
|
|||||||
|
|
||||||
//TODO recently maps not able to add to jukebox setting, and management
|
//TODO recently maps not able to add to jukebox setting, and management
|
||||||
|
|
||||||
$this->jukedMaps[$uid] = $this->maniaControl->mapManager->getMapByUid($uid);
|
//$this->jukedMapsUid[$uid] = array($login, $this->maniaControl->mapManager->getMapByUid($uid));
|
||||||
|
$this->jukedMaps[$uid] = array($login, $this->maniaControl->mapManager->getMapByUid($uid));
|
||||||
|
|
||||||
//TODO Message
|
//TODO Message
|
||||||
|
|
||||||
// Trigger callback
|
// Trigger callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_JUKEBOX_CHANGED, array('add', $this->jukedMaps[$uid]));
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_JUKEBOX_CHANGED, array('add', $this->jukedMaps[$uid]));
|
||||||
|
|
||||||
|
$this->printAllMaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Revmoes a Map from the jukebox
|
||||||
|
* @param $login
|
||||||
|
* @param $uid
|
||||||
|
*/
|
||||||
|
public function removeFromJukebox($login, $uid){
|
||||||
|
//unset($this->jukedMapsUid[$uid]);
|
||||||
|
unset($this->jukedMaps[$uid]);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function beginMap(){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function endMap(){
|
||||||
|
var_dump("endmap");
|
||||||
|
|
||||||
|
//TODO setting admin no skip
|
||||||
|
//TODO setting skip map if requester left
|
||||||
|
//Skip Map if requester has left
|
||||||
|
for($i = 0; $i < count($this->jukedMaps); $i++){
|
||||||
|
$jukedMap = reset($this->jukedMaps);
|
||||||
|
|
||||||
|
//found player, so play this map
|
||||||
|
if($this->maniaControl->playerManager->getPlayer($jukedMap[0]) == null){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger callback
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_JUKEBOX_CHANGED, array('skip', $jukedMap[0]));
|
||||||
|
|
||||||
|
//Player not found, so remove the map from the jukebox
|
||||||
|
array_shift($this->jukedMaps);
|
||||||
|
|
||||||
|
//TODO Message, report skip
|
||||||
|
}
|
||||||
|
|
||||||
|
$nextMap = array_shift($this->jukedMaps);
|
||||||
|
|
||||||
|
//Check if Jukebox is empty
|
||||||
|
if(!isset($nextMap))
|
||||||
|
return;
|
||||||
|
|
||||||
|
$nextMap = $nextMap[1];
|
||||||
|
//var_dump($nextMap);
|
||||||
|
var_dump($nextMap->name);
|
||||||
|
$this->printAllMaps();
|
||||||
|
|
||||||
|
//Set pointer back to last map
|
||||||
|
end($this->jukedMaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function printAllMaps(){
|
||||||
|
foreach($this->jukedMaps as $map){
|
||||||
|
$map = $map[1];
|
||||||
|
var_dump($map->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -46,7 +46,7 @@ class Map {
|
|||||||
* @param array $rpc_infos
|
* @param array $rpc_infos
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl, $rpc_infos = null) {
|
public function __construct(ManiaControl $maniaControl, $rpc_infos = null) {
|
||||||
$this->maniaControl = $maniaControl;
|
// $this->maniaControl = $maniaControl;
|
||||||
$this->startTime = time();
|
$this->startTime = time();
|
||||||
|
|
||||||
if (!$rpc_infos) {
|
if (!$rpc_infos) {
|
||||||
@ -67,7 +67,7 @@ class Map {
|
|||||||
|
|
||||||
$this->authorNick = $this->authorLogin;
|
$this->authorNick = $this->authorLogin;
|
||||||
|
|
||||||
$mapsDirectory = $this->maniaControl->server->getMapsDirectory();
|
/*$mapsDirectory = $this->maniaControl->server->getMapsDirectory();
|
||||||
if ($this->maniaControl->server->checkAccess($mapsDirectory)) {
|
if ($this->maniaControl->server->checkAccess($mapsDirectory)) {
|
||||||
$this->mapFetcher = new \GBXChallMapFetcher(true);
|
$this->mapFetcher = new \GBXChallMapFetcher(true);
|
||||||
try {
|
try {
|
||||||
@ -86,6 +86,6 @@ class Map {
|
|||||||
// TODO: define timeout if mx is down,todo fetch all map infos at once (maybe way faster)
|
// TODO: define timeout if mx is down,todo fetch all map infos at once (maybe way faster)
|
||||||
$serverInfo = $this->maniaControl->server->getSystemInfo();
|
$serverInfo = $this->maniaControl->server->getSystemInfo();
|
||||||
$title = strtoupper(substr($serverInfo['TitleId'], 0, 2));
|
$title = strtoupper(substr($serverInfo['TitleId'], 0, 2));
|
||||||
$this->mx = new \MXInfoFetcher($title, $this->uid, false);
|
$this->mx = new \MXInfoFetcher($title, $this->uid, false);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,6 +34,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
const ACTION_ADD_MAP = 'MapList.AddMap';
|
const ACTION_ADD_MAP = 'MapList.AddMap';
|
||||||
const ACTION_ERASE_MAP = 'MapList.EraseMap';
|
const ACTION_ERASE_MAP = 'MapList.EraseMap';
|
||||||
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
||||||
|
const ACTION_JUKE_MAP = 'MapList.JukeMap';
|
||||||
const MAX_MAPS_PER_PAGE = 15;
|
const MAX_MAPS_PER_PAGE = 15;
|
||||||
|
|
||||||
|
|
||||||
@ -173,7 +174,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO add MX info screen
|
//TODO add MX info screen
|
||||||
//TODO add download Map button
|
|
||||||
|
|
||||||
//render and display xml
|
//render and display xml
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
||||||
@ -242,7 +242,17 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->displayMap($id, $map, $mapFrame, $tooltips);
|
$this->displayMap($id, $map, $mapFrame, $tooltips);
|
||||||
$mapFrame->setY($y);
|
$mapFrame->setY($y);
|
||||||
|
|
||||||
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)){ //todoSET as setting who can add maps
|
//Juke-Map-Button
|
||||||
|
$jukeQuad = new Quad_UIConstruction_Buttons();
|
||||||
|
$mapFrame->add($jukeQuad);
|
||||||
|
$jukeQuad->setX($this->width/2 - 15);
|
||||||
|
$jukeQuad->setZ(0.2);
|
||||||
|
$jukeQuad->setSize(4,4);
|
||||||
|
$jukeQuad->setSubStyle($jukeQuad::SUBSTYLE_Erase);
|
||||||
|
$jukeQuad->setAction(self::ACTION_JUKE_MAP . "." . $map->uid);
|
||||||
|
//TODO description and jukebox button
|
||||||
|
|
||||||
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)){ //TODO SET as setting who can add maps
|
||||||
//erase map quad
|
//erase map quad
|
||||||
$eraseQuad = new Quad_UIConstruction_Buttons();
|
$eraseQuad = new Quad_UIConstruction_Buttons();
|
||||||
$mapFrame->add($eraseQuad);
|
$mapFrame->add($eraseQuad);
|
||||||
@ -263,7 +273,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$descriptionLabel->setText("Remove Map: {$map->name}");
|
$descriptionLabel->setText("Remove Map: {$map->name}");
|
||||||
$tooltips->add($eraseQuad, $descriptionLabel);
|
$tooltips->add($eraseQuad, $descriptionLabel);
|
||||||
}
|
}
|
||||||
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)){ //todoSET as setting who can add maps
|
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_OPERATOR)){ //TODO SET as setting who can add maps
|
||||||
//switch to map quad
|
//switch to map quad
|
||||||
$switchToQuad = new Quad_Icons64x64_1();
|
$switchToQuad = new Quad_Icons64x64_1();
|
||||||
$mapFrame->add($switchToQuad);
|
$mapFrame->add($switchToQuad);
|
||||||
@ -349,8 +359,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$addMap = (strpos($actionId, self::ACTION_ADD_MAP) === 0);
|
$addMap = (strpos($actionId, self::ACTION_ADD_MAP) === 0);
|
||||||
$eraseMap = (strpos($actionId, self::ACTION_ERASE_MAP) === 0);
|
$eraseMap = (strpos($actionId, self::ACTION_ERASE_MAP) === 0);
|
||||||
$switchMap = (strpos($actionId, self::ACTION_SWITCH_MAP) === 0);
|
$switchMap = (strpos($actionId, self::ACTION_SWITCH_MAP) === 0);
|
||||||
|
$jukeMap = (strpos($actionId, self::ACTION_JUKE_MAP) === 0);
|
||||||
|
|
||||||
if(!$addMap && !$eraseMap && !$switchMap)
|
if(!$addMap && !$eraseMap && !$switchMap && !$jukeMap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$actionArray = explode(".", $actionId);
|
$actionArray = explode(".", $actionId);
|
||||||
@ -368,6 +379,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
$this->maniaControl->chat->sendSuccess('Map switched to $z$<' . $mapList[$actionArray[2]]->name . '$>!'); //TODO specified message, who done it?
|
$this->maniaControl->chat->sendSuccess('Map switched to $z$<' . $mapList[$actionArray[2]]->name . '$>!'); //TODO specified message, who done it?
|
||||||
$this->maniaControl->log('Skipped to $z$<' . $mapList[$actionArray[2]]->name . '$>!');
|
$this->maniaControl->log('Skipped to $z$<' . $mapList[$actionArray[2]]->name . '$>!');
|
||||||
|
}else if($jukeMap){
|
||||||
|
$this->maniaControl->mapManager->jukebox->addMapToJukebox($callback[1][1], $actionArray[2]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user