maplist cleanup
This commit is contained in:
parent
442d06eaa5
commit
8ed8ba6069
@ -43,6 +43,8 @@ class FaultException extends Exception
|
|||||||
return new ServerOptionsException($faultString, $faultCode);
|
return new ServerOptionsException($faultString, $faultCode);
|
||||||
case 'the next map must be different from the current one.':
|
case 'the next map must be different from the current one.':
|
||||||
return new NextMapException($faultString, $faultCode);
|
return new NextMapException($faultString, $faultCode);
|
||||||
|
case 'Map not found.':
|
||||||
|
return new MapNotFoundException($faultString, $faultCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new self($faultString, $faultCode);
|
return new self($faultString, $faultCode);
|
||||||
@ -61,4 +63,5 @@ class MapNotCompatibleOrCompleteException extends FaultException{}
|
|||||||
class PlayerAlreadyIgnoredException extends FaultException{}
|
class PlayerAlreadyIgnoredException extends FaultException{}
|
||||||
class PlayerNotIgnoredException extends FaultException{}
|
class PlayerNotIgnoredException extends FaultException{}
|
||||||
class ServerOptionsException extends FaultException{}
|
class ServerOptionsException extends FaultException{}
|
||||||
class NextMapException extends FaultException{}
|
class NextMapException extends FaultException{}
|
||||||
|
class MapNotFoundException extends FaultException{}
|
@ -24,8 +24,7 @@ use ManiaControl\Manialinks\IconManager;
|
|||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
use Maniaplanet\DedicatedServer\Xmlrpc\MapNotFoundException;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\NextMapException;
|
|
||||||
use MCTeam\CustomVotesPlugin;
|
use MCTeam\CustomVotesPlugin;
|
||||||
use MCTeam\KarmaPlugin;
|
use MCTeam\KarmaPlugin;
|
||||||
|
|
||||||
@ -214,9 +213,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
|
|
||||||
$queuedMaps = $this->maniaControl->mapManager->mapQueue->getQueuedMapsRanking();
|
$queuedMaps = $this->maniaControl->mapManager->mapQueue->getQueuedMapsRanking();
|
||||||
/**
|
/** @var KarmaPlugin $karmaPlugin */
|
||||||
* @var KarmaPlugin $karmaPlugin
|
|
||||||
*/
|
|
||||||
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_KARMA_PLUGIN);
|
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_KARMA_PLUGIN);
|
||||||
|
|
||||||
$pageNumber = 1 + $chunk * self::MAX_PAGES_PER_CHUNK;
|
$pageNumber = 1 + $chunk * self::MAX_PAGES_PER_CHUNK;
|
||||||
@ -226,9 +223,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$id = 1 + $chunk * self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE;
|
$id = 1 + $chunk * self::MAX_PAGES_PER_CHUNK * self::MAX_MAPS_PER_PAGE;
|
||||||
$y = $height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$pageFrames = array();
|
$pageFrames = array();
|
||||||
/**
|
/** @var Map $map */
|
||||||
* @var Map $map
|
|
||||||
*/
|
|
||||||
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
|
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
|
||||||
$mxIcon = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON);
|
$mxIcon = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON);
|
||||||
$mxIconHover = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER);
|
$mxIconHover = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER);
|
||||||
@ -310,9 +305,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$array = array($id => $x + 5, $mxId => $x + 10, Formatter::stripDirtyCodes($map->name) => $x + 20, $map->authorNick => $x + 68);
|
$array = array($id => $x + 5, $mxId => $x + 10, Formatter::stripDirtyCodes($map->name) => $x + 20, $map->authorNick => $x + 68);
|
||||||
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
||||||
if (isset($labels[3])) {
|
if (isset($labels[3])) {
|
||||||
/**
|
/** @var Label $label */
|
||||||
* @var Label $label
|
|
||||||
*/
|
|
||||||
$label = $labels[3];
|
$label = $labels[3];
|
||||||
$description = 'Click to checkout all maps by $<' . $map->authorLogin . '$>!';
|
$description = 'Click to checkout all maps by $<' . $map->authorLogin . '$>!';
|
||||||
$label->setAction(MapCommands::ACTION_SHOW_AUTHOR . $map->authorLogin);
|
$label->setAction(MapCommands::ACTION_SHOW_AUTHOR . $map->authorLogin);
|
||||||
@ -377,7 +370,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$eraseLabel->setText('x');
|
$eraseLabel->setText('x');
|
||||||
$eraseLabel->setTextColor('a00');
|
$eraseLabel->setTextColor('a00');
|
||||||
|
|
||||||
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id, $map->uid);
|
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $map->uid, true);
|
||||||
$eraseLabel->addToggleFeature($confirmFrame);
|
$eraseLabel->addToggleFeature($confirmFrame);
|
||||||
$description = 'Remove Map: $<' . $map->name . '$>';
|
$description = 'Remove Map: $<' . $map->name . '$>';
|
||||||
$eraseLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
$eraseLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
@ -394,7 +387,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$switchLabel->setText('»');
|
$switchLabel->setText('»');
|
||||||
$switchLabel->setTextColor('0f0');
|
$switchLabel->setTextColor('0f0');
|
||||||
|
|
||||||
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id);
|
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $map->uid);
|
||||||
$switchLabel->addToggleFeature($confirmFrame);
|
$switchLabel->addToggleFeature($confirmFrame);
|
||||||
|
|
||||||
$description = 'Switch Directly to Map: $<' . $map->name . '$>';
|
$description = 'Switch Directly to Map: $<' . $map->name . '$>';
|
||||||
@ -409,7 +402,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$switchQuad->setZ(0.2);
|
$switchQuad->setZ(0.2);
|
||||||
$switchQuad->setSubStyle($switchQuad::SUBSTYLE_Validate_Step2);
|
$switchQuad->setSubStyle($switchQuad::SUBSTYLE_Validate_Step2);
|
||||||
$switchQuad->setSize(3.8, 3.8);
|
$switchQuad->setSize(3.8, 3.8);
|
||||||
$switchQuad->setAction(self::ACTION_START_SWITCH_VOTE . '.' . ($id - 1));
|
$switchQuad->setAction(self::ACTION_START_SWITCH_VOTE . '.' . $map->uid);
|
||||||
$description = 'Start Map-Switch Vote: $<' . $map->name . '$>';
|
$description = 'Start Map-Switch Vote: $<' . $map->name . '$>';
|
||||||
$switchQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
$switchQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
} else {
|
} else {
|
||||||
@ -422,7 +415,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$switchLabel->setTextSize(2);
|
$switchLabel->setTextSize(2);
|
||||||
$switchLabel->setText('»');
|
$switchLabel->setText('»');
|
||||||
$switchLabel->setTextColor('0f0');
|
$switchLabel->setTextColor('0f0');
|
||||||
$switchLabel->setAction(self::ACTION_START_SWITCH_VOTE . '.' . ($id - 1));
|
$switchLabel->setAction(self::ACTION_START_SWITCH_VOTE . '.' . ($map->uid));
|
||||||
$description = 'Start Map-Switch Vote: $<' . $map->name . '$>';
|
$description = 'Start Map-Switch Vote: $<' . $map->name . '$>';
|
||||||
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
}
|
}
|
||||||
@ -491,11 +484,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
*
|
*
|
||||||
* @param ManiaLink $maniaLink
|
* @param ManiaLink $maniaLink
|
||||||
* @param $y
|
* @param $y
|
||||||
* @param $id
|
|
||||||
* @param bool $mapUid
|
* @param bool $mapUid
|
||||||
|
* @param bool $erase
|
||||||
* @return Frame
|
* @return Frame
|
||||||
*/
|
*/
|
||||||
public function buildConfirmFrame(Manialink $maniaLink, $y, $id, $mapUid = false) {
|
public function buildConfirmFrame(Manialink $maniaLink, $y, $mapUid, $erase = false) {
|
||||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||||
@ -529,8 +522,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$buttLabel->setSize(3, 3);
|
$buttLabel->setSize(3, 3);
|
||||||
$buttLabel->setAlign(Control::CENTER, Control::CENTER);
|
$buttLabel->setAlign(Control::CENTER, Control::CENTER);
|
||||||
|
|
||||||
if (!$mapUid) {
|
if (!$erase) {
|
||||||
$quad->setAction(self::ACTION_SWITCH_MAP . '.' . ($id - 1));
|
$quad->setAction(self::ACTION_SWITCH_MAP . '.' . $mapUid);
|
||||||
$buttLabel->setText('»');
|
$buttLabel->setText('»');
|
||||||
$buttLabel->setTextColor('0f0');
|
$buttLabel->setTextColor('0f0');
|
||||||
$buttLabel->setTextSize(2);
|
$buttLabel->setTextSize(2);
|
||||||
@ -538,7 +531,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$buttLabel->setTextSize(1);
|
$buttLabel->setTextSize(1);
|
||||||
$buttLabel->setText('x');
|
$buttLabel->setText('x');
|
||||||
$buttLabel->setTextColor('a00');
|
$buttLabel->setTextColor('a00');
|
||||||
$quad->setAction(self::ACTION_ERASE_MAP . '.' . ($id - 1) . '.' . $mapUid);
|
$quad->setAction(self::ACTION_ERASE_MAP . '.' . $mapUid);
|
||||||
}
|
}
|
||||||
return $confirmFrame;
|
return $confirmFrame;
|
||||||
}
|
}
|
||||||
@ -582,29 +575,25 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$action = $actionArray[0] . '.' . $actionArray[1];
|
$action = $actionArray[0] . '.' . $actionArray[1];
|
||||||
$login = $callback[1][1];
|
$login = $callback[1][1];
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
$mapId = (int)$actionArray[2];
|
$mapUid = $actionArray[2];
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case self::ACTION_UPDATE_MAP:
|
case self::ACTION_UPDATE_MAP:
|
||||||
$mapUid = $actionArray[2];
|
|
||||||
$this->maniaControl->mapManager->updateMap($player, $mapUid);
|
$this->maniaControl->mapManager->updateMap($player, $mapUid);
|
||||||
$this->showMapList($player);
|
$this->showMapList($player);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ERASE_MAP:
|
case self::ACTION_ERASE_MAP:
|
||||||
$mapUid = $actionArray[3];
|
|
||||||
$this->maniaControl->mapManager->removeMap($player, $mapUid);
|
$this->maniaControl->mapManager->removeMap($player, $mapUid);
|
||||||
$this->showMapList($player);
|
|
||||||
break;
|
break;
|
||||||
case self::ACTION_SWITCH_MAP:
|
case self::ACTION_SWITCH_MAP:
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->client->jumpToMapIndex($mapId);
|
$this->maniaControl->client->jumpToMapIdent($mapUid);
|
||||||
} catch (Exception $e) {
|
} catch (MapNotFoundException $e) {
|
||||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
|
||||||
$this->maniaControl->chat->sendError("Error while Jumping to Map Index");
|
$this->maniaControl->chat->sendError("Error while Jumping to Map Index");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$mapList = $this->maniaControl->mapManager->getMaps();
|
|
||||||
$map = $mapList[$mapId];
|
$map = $this->maniaControl->mapManager->getMapByUid($mapUid);
|
||||||
|
|
||||||
$message = '$<' . $player->nickname . '$> skipped to Map $z$<' . $map->name . '$>!';
|
$message = '$<' . $player->nickname . '$> skipped to Map $z$<' . $map->name . '$>!';
|
||||||
$this->maniaControl->chat->sendSuccess($message);
|
$this->maniaControl->chat->sendSuccess($message);
|
||||||
@ -613,18 +602,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->playerCloseWidget($player);
|
$this->playerCloseWidget($player);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_START_SWITCH_VOTE:
|
case self::ACTION_START_SWITCH_VOTE:
|
||||||
/**
|
/** @var $votesPlugin CustomVotesPlugin */
|
||||||
* @var $votesPlugin CustomVotesPlugin
|
|
||||||
*/
|
|
||||||
$votesPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
$votesPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
||||||
$mapList = $this->maniaControl->mapManager->getMaps();
|
$map = $this->maniaControl->mapManager->getMapByUid($mapUid);
|
||||||
$map = $mapList[$mapId];
|
|
||||||
|
|
||||||
$message = '$<' . $player->nickname . '$>$s started a vote to switch to $<' . $map->name . '$>!';
|
$message = '$<' . $player->nickname . '$>$s started a vote to switch to $<' . $map->name . '$>!';
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Map $map
|
|
||||||
*/
|
|
||||||
$votesPlugin->defineVote('switchmap', "Goto " . $map->name, true, $message);
|
$votesPlugin->defineVote('switchmap', "Goto " . $map->name, true, $message);
|
||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
@ -633,18 +616,17 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$votesPlugin->undefineVote('switchmap');
|
$votesPlugin->undefineVote('switchmap');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$index = $self->maniaControl->mapManager->getMapIndex($map);
|
$self->maniaControl->client->JumpToMapIdent($map->uid);
|
||||||
$self->maniaControl->client->jumpToMapIndex($index);
|
} catch (MapNotFoundException $e) {
|
||||||
} catch (NextMapException $e) {
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
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], $mapUid);
|
||||||
$this->showMapList($player);
|
$this->showMapList($player);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_UNQUEUE_MAP:
|
case self::ACTION_UNQUEUE_MAP:
|
||||||
$this->maniaControl->mapManager->mapQueue->removeFromMapQueue($player, $actionArray[2]);
|
$this->maniaControl->mapManager->mapQueue->removeFromMapQueue($player, $mapUid);
|
||||||
$this->showMapList($player);
|
$this->showMapList($player);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user