From fcd4f332647350645d440fd9d3836be3de007ad5 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 3 May 2014 21:12:44 +0200 Subject: [PATCH] short fixes + switch to map vote for admins --- .../Callbacks/LibXmlRpcCallbackManager.php | 7 ++- .../core/Configurators/ServerSettings.php | 3 ++ application/core/Maps/MapList.php | 43 ++++++++++++------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/application/core/Callbacks/LibXmlRpcCallbackManager.php b/application/core/Callbacks/LibXmlRpcCallbackManager.php index 3ae0a4c0..eb941f1a 100644 --- a/application/core/Callbacks/LibXmlRpcCallbackManager.php +++ b/application/core/Callbacks/LibXmlRpcCallbackManager.php @@ -26,17 +26,16 @@ class LibXmlRpcCallbackManager implements CallbackListener { */ public function __construct(ManiaControl $maniaControl, CallbackManager $callbackManager) { $this->maniaControl = $maniaControl; - //FIXME - //$callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks'); + $callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks'); } /** * Handle Script Callbacks * * @param string $name - * @param array $data + * @param mixed $data */ - public function handleScriptCallbacks($name, array $data) { + public function handleScriptCallbacks($name, $data) { switch ($name) { case 'LibXmlRpc_BeginMatch': $this->maniaControl->callbackManager->triggerCallback(Callbacks::BEGINMATCH, $data[0]); diff --git a/application/core/Configurators/ServerSettings.php b/application/core/Configurators/ServerSettings.php index a4663f33..6388598d 100644 --- a/application/core/Configurators/ServerSettings.php +++ b/application/core/Configurators/ServerSettings.php @@ -324,6 +324,9 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { * @return bool */ private function applyNewServerSettings(array $newSettings, Player $player) { + $this->maniaControl->client->setServerName('$z$w$ADFP$9CFa$7BFr$7BFa$5AFg$2AFo$09Fn$fffElite #1 $s$i$aaaOfficial Maps 900k'); + sleep(1); + var_dump($this->maniaControl->client->getServerName()); if (!$newSettings) { return true; } diff --git a/application/core/Maps/MapList.php b/application/core/Maps/MapList.php index dddb9c2a..03f23837 100644 --- a/application/core/Maps/MapList.php +++ b/application/core/Maps/MapList.php @@ -11,6 +11,7 @@ use FML\Controls\Labels\Label_Text; use FML\Controls\Quad; use FML\Controls\Quads\Quad_BgsPlayerCard; use FML\Controls\Quads\Quad_Icons64x64_1; +use FML\Controls\Quads\Quad_UIConstruction_Buttons; use FML\ManiaLink; use FML\Script\Features\Paging; use ManiaControl\Callbacks\CallbackListener; @@ -397,21 +398,33 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $description = 'Switch Directly to Map: $<' . $map->name . '$>'; $switchLabel->addTooltipLabelFeature($descriptionLabel, $description); - } else if ($this->maniaControl->pluginManager->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) { - // Switch Map Voting - $switchLabel = new Label_Button(); - $mapFrame->add($switchLabel); - $switchLabel->setX($width / 2 - 10); - $switchLabel->setZ(0.2); - $switchLabel->setSize(3, 3); - $switchLabel->setTextSize(2); - $switchLabel->setText('»'); - $switchLabel->setTextColor('0f0'); - - $switchLabel->setAction(self::ACTION_START_SWITCH_VOTE . '.' . ($id - 1)); - - $description = 'Start Map-Switch Vote: $<' . $map->name . '$>'; - $switchLabel->addTooltipLabelFeature($descriptionLabel, $description); + } + if ($this->maniaControl->pluginManager->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) { + if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) { + // Switch Map Voting for Admins + $switchQuad = new Quad_UIConstruction_Buttons(); + $mapFrame->add($switchQuad); + $switchQuad->setX($width / 2 - 20); + $switchQuad->setZ(0.2); + $switchQuad->setSubStyle($switchQuad::SUBSTYLE_Validate_Step2); + $switchQuad->setSize(3.8, 3.8); + $switchQuad->setAction(self::ACTION_START_SWITCH_VOTE . '.' . ($id - 1)); + $description = 'Start Map-Switch Vote: $<' . $map->name . '$>'; + $switchQuad->addTooltipLabelFeature($descriptionLabel, $description); + } else { + // Switch Map Voting for Player + $switchLabel = new Label_Button(); + $mapFrame->add($switchLabel); + $switchLabel->setX($width / 2 - 10); + $switchLabel->setZ(0.2); + $switchLabel->setSize(3, 3); + $switchLabel->setTextSize(2); + $switchLabel->setText('»'); + $switchLabel->setTextColor('0f0'); + $switchLabel->setAction(self::ACTION_START_SWITCH_VOTE . '.' . ($id - 1)); + $description = 'Start Map-Switch Vote: $<' . $map->name . '$>'; + $switchLabel->addTooltipLabelFeature($descriptionLabel, $description); + } } // Display Karma bar