mapqueue improvements
This commit is contained in:
parent
fc91133f77
commit
9505fdf974
@ -37,6 +37,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
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_QUEUED_MAP = 'MapList.QueueMap';
|
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
|
||||||
|
const ACTION_UNQUEUE_MAP = 'MapList.UnQueueMap';
|
||||||
const ACTION_CHECK_UPDATE = 'MapList.CheckUpdate';
|
const ACTION_CHECK_UPDATE = 'MapList.CheckUpdate';
|
||||||
const ACTION_CLEAR_MAPQUEUE = 'MapList.ClearMapQueue';
|
const ACTION_CLEAR_MAPQUEUE = 'MapList.ClearMapQueue';
|
||||||
const MAX_MAPS_PER_PAGE = 15;
|
const MAX_MAPS_PER_PAGE = 15;
|
||||||
@ -122,7 +123,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
|
|
||||||
//Admin Buttons
|
//Admin Buttons
|
||||||
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
|
if ($this->maniaControl->authenticationManager->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
|
||||||
//Clear Map-Queue
|
//Clear Map-Queue
|
||||||
$label = new Label_Button();
|
$label = new Label_Button();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
@ -280,7 +281,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label->setTextSize(1.5);
|
$label->setTextSize(1.5);
|
||||||
$label->setText($queuedMaps[$map->uid]);
|
$label->setText($queuedMaps[$map->uid]);
|
||||||
$label->setTextColor('fff');
|
$label->setTextColor('fff');
|
||||||
|
|
||||||
|
//Checks if the Player who openend the Widget has queued the map
|
||||||
|
$queuer = $this->maniaControl->mapManager->mapQueue->getQueuer($map->uid);
|
||||||
|
if ($queuer->login == $player->login) {
|
||||||
|
$script->addTooltip($label, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => 'Remove $<' . $map->name . '$> from the Map Queue'));
|
||||||
|
$label->setAction(self::ACTION_UNQUEUE_MAP . '.' . $map->uid);
|
||||||
|
} else {
|
||||||
$script->addTooltip($label, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => '$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid]));
|
$script->addTooltip($label, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => '$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid]));
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Map-Queue-Map-Button
|
// Map-Queue-Map-Button
|
||||||
$queueLabel = new Label_Button();
|
$queueLabel = new Label_Button();
|
||||||
@ -292,7 +302,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$queueLabel->setText('+');
|
$queueLabel->setText('+');
|
||||||
$queueLabel->setTextColor('09f');
|
$queueLabel->setTextColor('09f');
|
||||||
|
|
||||||
$script->addTooltip($queueLabel, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => 'Add Map to the Map Queue: $<' . $map->name . '$>'));
|
$script->addTooltip($queueLabel, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => 'Add $<' . $map->name . '$> to the Map Queue'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
|
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
|
||||||
@ -504,6 +514,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
case self::ACTION_QUEUED_MAP:
|
case self::ACTION_QUEUED_MAP:
|
||||||
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $actionArray[2]);
|
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $actionArray[2]);
|
||||||
break;
|
break;
|
||||||
|
case self::ACTION_UNQUEUE_MAP:
|
||||||
|
$this->maniaControl->mapManager->mapQueue->removeFromMapQueue($player, $actionArray[2]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ class MapManager implements CallbackListener {
|
|||||||
$map = $this->maps[$uid];
|
$map = $this->maps[$uid];
|
||||||
|
|
||||||
//Unset the Map everywhere
|
//Unset the Map everywhere
|
||||||
$this->mapQueue->removeFromMapQueue($admin->login, $map->uid);
|
$this->mapQueue->removeFromMapQueue($admin, $map->uid);
|
||||||
$this->mxManager->unsetMap($map->mx->id);
|
$this->mxManager->unsetMap($map->mx->id);
|
||||||
|
|
||||||
// Remove map
|
// Remove map
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace ManiaControl\Maps;
|
namespace ManiaControl\Maps;
|
||||||
|
|
||||||
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
@ -22,6 +23,7 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
|
|
||||||
const SETTING_SKIP_MAP_ON_LEAVE = 'Skip Map when the requester leaves';
|
const SETTING_SKIP_MAP_ON_LEAVE = 'Skip Map when the requester leaves';
|
||||||
const SETTING_SKIP_MAPQUEUE_ADMIN = 'Skip Map when admin leaves';
|
const SETTING_SKIP_MAPQUEUE_ADMIN = 'Skip Map when admin leaves';
|
||||||
|
const SETTING_PERMISSION_CLEAR_MAPQUEUE = 'Clear Mapqueue';
|
||||||
|
|
||||||
const ADMIN_COMMAND_CLEAR_MAPQUEUE = 'clearmapqueue';
|
const ADMIN_COMMAND_CLEAR_MAPQUEUE = 'clearmapqueue';
|
||||||
const ADMIN_COMMAND_CLEAR_JUKEBOX = 'clearjukebox';
|
const ADMIN_COMMAND_CLEAR_JUKEBOX = 'clearjukebox';
|
||||||
@ -46,6 +48,8 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SKIP_MAP_ON_LEAVE, true);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SKIP_MAPQUEUE_ADMIN, false);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SKIP_MAPQUEUE_ADMIN, false);
|
||||||
|
|
||||||
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CLEAR_MAPQUEUE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
|
|
||||||
//Register Admin Commands
|
//Register Admin Commands
|
||||||
$this->maniaControl->commandManager->registerCommandListener(self::ADMIN_COMMAND_CLEAR_JUKEBOX, $this, 'command_ClearMapQueue', true);
|
$this->maniaControl->commandManager->registerCommandListener(self::ADMIN_COMMAND_CLEAR_JUKEBOX, $this, 'command_ClearMapQueue', true);
|
||||||
$this->maniaControl->commandManager->registerCommandListener(self::ADMIN_COMMAND_CLEAR_MAPQUEUE, $this, 'command_ClearMapQueue', true);
|
$this->maniaControl->commandManager->registerCommandListener(self::ADMIN_COMMAND_CLEAR_MAPQUEUE, $this, 'command_ClearMapQueue', true);
|
||||||
@ -67,6 +71,11 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
* @param $admin
|
* @param $admin
|
||||||
*/
|
*/
|
||||||
public function clearMapQueue($admin) {
|
public function clearMapQueue($admin) {
|
||||||
|
if (!$this->maniaControl->authenticationManager->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
|
||||||
|
$this->maniaControl->authenticationManager->sendNotAllowed($admin);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
|
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
|
||||||
|
|
||||||
//Destroy map - queue list
|
//Destroy map - queue list
|
||||||
@ -105,17 +114,26 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
|
|
||||||
// Trigger callback
|
// Trigger callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revmoes a Map from the Map queue
|
* Revmoes a Map from the Map queue
|
||||||
*
|
*
|
||||||
* @param $login
|
* @param \ManiaControl\Players\Player $player
|
||||||
* @param $uid
|
* @param $uid
|
||||||
|
* @internal param $login
|
||||||
*/
|
*/
|
||||||
public function removeFromMapQueue($login, $uid) {
|
public function removeFromMapQueue(Player $player, $uid) {
|
||||||
|
if (!isset($this->queuedMaps[$uid])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$map = $this->queuedMaps[$uid][1];
|
||||||
unset($this->queuedMaps[$uid]);
|
unset($this->queuedMaps[$uid]);
|
||||||
|
|
||||||
|
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> removed $<' . $map->name . '$> from the Map Queue');
|
||||||
|
|
||||||
|
// Trigger callback
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('remove', $map));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -163,10 +181,10 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
$map = $this->nextMap[1];
|
$map = $this->nextMap[1];
|
||||||
|
|
||||||
|
|
||||||
$success = $this->maniaControl->client->chooseNextMap($map->fileName);
|
try {
|
||||||
if(!$success) { //TODO error code?
|
$this->maniaControl->client->chooseNextMap($map->fileName);
|
||||||
//trigger_error('[' . $this->maniaControl->client->getErrorCode() . '] ChooseNextMap - ' . $this->maniaControl->client->getErrorCode(), E_USER_WARNING);
|
} catch(\Exception $e) {
|
||||||
return;
|
//do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +227,16 @@ class MapQueue implements CallbackListener, CommandListener {
|
|||||||
return $queuedMaps;
|
return $queuedMaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Queuer of a Map
|
||||||
|
*
|
||||||
|
* @param $uid
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getQueuer($uid) {
|
||||||
|
return $this->queuedMaps[$uid][0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy Function for testing
|
* Dummy Function for testing
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,6 @@ use FML\Controls\Frame;
|
|||||||
use FML\Controls\Labels\Label_Button;
|
use FML\Controls\Labels\Label_Button;
|
||||||
use FML\Controls\Labels\Label_Text;
|
use FML\Controls\Labels\Label_Text;
|
||||||
use FML\Controls\Quad;
|
use FML\Controls\Quad;
|
||||||
|
|
||||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
@ -204,7 +203,9 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->removePlayerFromQueue($player->login);
|
$this->removePlayerFromQueue($player->login);
|
||||||
if(isset($this->spectators[$player->login])) unset($this->spectators[$player->login]);
|
if (isset($this->spectators[$player->login])) {
|
||||||
|
unset($this->spectators[$player->login]);
|
||||||
|
}
|
||||||
|
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach($this->showPlay as $showPlay) {
|
foreach($this->showPlay as $showPlay) {
|
||||||
@ -213,7 +214,9 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$found) $this->hideQueueWidget($player);
|
if (!$found) {
|
||||||
|
$this->hideQueueWidget($player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,7 +415,7 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
|
|||||||
$messageLabel->setText($message);
|
$messageLabel->setText($message);
|
||||||
$messageLabel->setStyle(Label_Text::STYLE_TextStaticSmall);
|
$messageLabel->setStyle(Label_Text::STYLE_TextStaticSmall);
|
||||||
|
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'Queue');
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user