From 7912336509eac1a79f434d9e0f43ce3a052b44ea Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 18 Jan 2014 21:05:45 +0100 Subject: [PATCH] configurator bug fixes --- .../core/Configurators/Configurator.php | 11 +--- .../Configurators/ManiaControlSettings.php | 2 +- .../core/Configurators/ScriptSettings.php | 2 +- .../core/Configurators/ServerSettings.php | 2 +- application/core/Plugins/PluginMenu.php | 55 +++++++++++++------ 5 files changed, 44 insertions(+), 28 deletions(-) diff --git a/application/core/Configurators/Configurator.php b/application/core/Configurators/Configurator.php index cdd5ed8b..003fa8f3 100644 --- a/application/core/Configurators/Configurator.php +++ b/application/core/Configurators/Configurator.php @@ -119,13 +119,8 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn * * @param array $callback */ - public function reopenMenu($menuId = 0) { - foreach($this->playersMenuShown as $login => $shown) { - if($shown == true) { - $player = $this->maniaControl->playerManager->getPlayer($login); - $this->showMenu($player, $menuId); - } - } + public function reopenMenu($player, $menuId = 0) { + $this->showMenu($player, $menuId); } /** @@ -318,7 +313,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn $closeQuad->setPosition($menuWidth * 0.483, $menuHeight * 0.467, 3); $closeQuad->setSize(6, 6); $closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace); - $closeQuad->setAction(self::ACTION_TOGGLEMENU); + $closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET); // Add close button $closeButton = new Label(); diff --git a/application/core/Configurators/ManiaControlSettings.php b/application/core/Configurators/ManiaControlSettings.php index eac1bff0..0d23f9e0 100644 --- a/application/core/Configurators/ManiaControlSettings.php +++ b/application/core/Configurators/ManiaControlSettings.php @@ -245,7 +245,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { //Reopen the Menu $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($menuId); + $this->maniaControl->configurator->reopenMenu($player, $menuId); } /** diff --git a/application/core/Configurators/ScriptSettings.php b/application/core/Configurators/ScriptSettings.php index e5533675..11814c63 100644 --- a/application/core/Configurators/ScriptSettings.php +++ b/application/core/Configurators/ScriptSettings.php @@ -316,7 +316,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { //Reopen the Menu $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($menuId); + $this->maniaControl->configurator->reopenMenu($player, $menuId); } /** diff --git a/application/core/Configurators/ServerSettings.php b/application/core/Configurators/ServerSettings.php index 1d1d17e9..b6248fd6 100644 --- a/application/core/Configurators/ServerSettings.php +++ b/application/core/Configurators/ServerSettings.php @@ -297,7 +297,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { //Reopen the Menu $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($menuId); + $this->maniaControl->configurator->reopenMenu($player, $menuId); } /** diff --git a/application/core/Plugins/PluginMenu.php b/application/core/Plugins/PluginMenu.php index 663a5071..38945a32 100644 --- a/application/core/Plugins/PluginMenu.php +++ b/application/core/Plugins/PluginMenu.php @@ -10,14 +10,13 @@ use FML\Controls\Labels\Label_Button; use FML\Controls\Labels\Label_Text; use FML\Controls\Quads\Quad_Icons128x32_1; use FML\Controls\Quads\Quad_Icons64x64_1; -use FML\Script\Pages; use FML\Script\Script; -use FML\Script\Tooltips; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Configurators\ConfiguratorMenu; use ManiaControl\Formatter; use ManiaControl\ManiaControl; +use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; /** @@ -25,7 +24,7 @@ use ManiaControl\Players\Player; * * @author steeffeen */ -class PluginMenu implements CallbackListener, ConfiguratorMenu { +class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAnswerListener { /** * Constants */ @@ -34,11 +33,13 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { const ACTION_PREFIX_SETTINGS = 'PluginMenu.Settings.'; const ACTION_PREFIX_SETTING = 'PluginMenuSetting'; const ACTION_SETTING_BOOL = 'PluginMenuActionBoolSetting.'; + const ACTION_BACK_TO_PLUGINS = 'PluginMenu.BackToPlugins'; + /** * Private properties */ private $maniaControl = null; - private $settingsClass = ''; + private $settingsClass = ''; //TODO needs to be improved /** * Create a new plugin menu instance @@ -48,6 +49,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { public function __construct(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; + $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BACK_TO_PLUGINS, $this, 'backToPlugins'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); } @@ -59,6 +61,15 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { return 'Plugins'; } + /** + * Returns Back to the Plugins + */ + public function backToPlugins($callback, Player $player) { + $this->settingsClass = ''; //TODO specify player + $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); + $this->maniaControl->configurator->reopenMenu($player, $menuId); + } + /** * * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu() @@ -102,13 +113,14 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { //Show Settings Menu - if($this->settingsClass != '') { + if($this->settingsClass != '') { //TODO improve /** @var ManiaControl/SettingManager $this->maniaControl->settingManager */ - $settings = $this->maniaControl->settingManager->getSettingsByClass($this->settingsClass); - $pageFrames = array(); - $y = 0; - $index = 1; - $settingHeight = 5.; + $settings = $this->maniaControl->settingManager->getSettingsByClass($this->settingsClass); + $pageFrames = array(); + $pageSettingsMaxCount = 12; + $y = 0; + $index = 1; + $settingHeight = 5.; foreach($settings as $id => $setting) { if(!isset($pageFrame)) { $pageFrame = new Frame(); @@ -139,7 +151,6 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { $y -= $settingHeight; - if($index % $pageMaxCount == $pageMaxCount - 1) { $pageFrame = new Frame(); $frame->add($pageFrame); @@ -151,7 +162,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { $script->addPage($pageFrame, count($pageFrames), $pagesId); } } - $index++; + $settingFrame = new Frame(); $pageFrame->add($settingFrame); @@ -201,19 +212,28 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { } $y -= $settingHeight; - if($index % $pageMaxCount == $pageMaxCount - 1) { + + if($index % $pageSettingsMaxCount == $pageSettingsMaxCount - 1) { unset($pageFrame); } $index++; - } - $this->settingsClass = ''; + $quad = new Label_Button(); + $frame->add($quad); + $quad->setStyle($quad::STYLE_CardMain_Quit); + $quad->setHAlign(Control::LEFT); + $quad->setScale(0.75); + $quad->setText("Back"); + $quad->setPosition(-$width / 2 + 7, -$height / 2 + 7); + $quad->setAction(self::ACTION_BACK_TO_PLUGINS); + return $frame; } + //Display normal Plugin List // Plugin pages $pageFrames = array(); $y = 0.; @@ -273,6 +293,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { $pluginFrame->add($quad); $quad->setSubStyle($quad::SUBSTYLE_Settings); $quad->setX(15); + $quad->setZ(1); $quad->setSize(5, 5); $quad->setAction(self::ACTION_PREFIX_SETTINGS . $pluginClass); @@ -327,7 +348,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { //Reopen the Menu $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($menuId); + $this->maniaControl->configurator->reopenMenu($player, $menuId); } /** @@ -389,7 +410,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($menuId); + $this->maniaControl->configurator->reopenMenu($player, $menuId); } /**