From d531d97366f1782ce6a49f16c2097201ee3b13cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Thu, 24 Jul 2014 23:15:25 +0200 Subject: [PATCH] - static getTitle() function of configurator menu interface - removed reopenMenu() configurator function - use more intelligent showMenu() function --- .../core/Configurators/Configurator.php | 11 --------- .../core/Configurators/ConfiguratorMenu.php | 2 +- .../Configurators/ManiaControlSettings.php | 17 +++++++------ .../core/Configurators/ScriptSettings.php | 19 +++++++-------- application/core/Plugins/InstallMenu.php | 17 +++++++------ application/core/Plugins/PluginMenu.php | 24 +++++++++---------- .../core/Update/PluginUpdateManager.php | 5 ++-- 7 files changed, 40 insertions(+), 55 deletions(-) diff --git a/application/core/Configurators/Configurator.php b/application/core/Configurators/Configurator.php index 191d7fca..89daa350 100644 --- a/application/core/Configurators/Configurator.php +++ b/application/core/Configurators/Configurator.php @@ -268,17 +268,6 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn return $manialink; } - /** - * Reopen the Menu - * - * @param Player $player - * @param int $menuId - */ - public function reopenMenu(Player $player, $menuId = 0) { - // TODO: improve "reopen" to not need the $menuId param by saving the last shown menu - $this->showMenu($player, $menuId); - } - /** * Handle toggle menu action * diff --git a/application/core/Configurators/ConfiguratorMenu.php b/application/core/Configurators/ConfiguratorMenu.php index d5c9a228..525bfa7b 100644 --- a/application/core/Configurators/ConfiguratorMenu.php +++ b/application/core/Configurators/ConfiguratorMenu.php @@ -19,7 +19,7 @@ interface ConfiguratorMenu { * * @return string */ - public function getTitle(); + public static function getTitle(); /** * Get the Configurator Menu Frame diff --git a/application/core/Configurators/ManiaControlSettings.php b/application/core/Configurators/ManiaControlSettings.php index 3f6ea076..80b443ce 100644 --- a/application/core/Configurators/ManiaControlSettings.php +++ b/application/core/Configurators/ManiaControlSettings.php @@ -56,6 +56,13 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MC_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN); } + /** + * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() + */ + public static function getTitle() { + return self::TITLE; + } + /** * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu() */ @@ -337,14 +344,6 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $this->maniaControl->chat->sendSuccess('Settings saved!', $player); // Reopen the Menu - $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($player, $menuId); - } - - /** - * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() - */ - public function getTitle() { - return self::TITLE; + $this->maniaControl->configurator->showMenu($player, $this); } } diff --git a/application/core/Configurators/ScriptSettings.php b/application/core/Configurators/ScriptSettings.php index 22869204..98c17bee 100644 --- a/application/core/Configurators/ScriptSettings.php +++ b/application/core/Configurators/ScriptSettings.php @@ -89,6 +89,13 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { return true; } + /** + * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() + */ + public static function getTitle() { + return 'Script Settings'; + } + /** * Handle OnInit callback */ @@ -310,9 +317,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { $this->maniaControl->chat->sendError('Script Settings Saving failed!', $player); } - //Reopen the Menu - $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($player, $menuId); + // Reopen the Menu + $this->maniaControl->configurator->showMenu($player, $this); } /** @@ -396,11 +402,4 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { } return (string)$value; } - - /** - * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() - */ - public function getTitle() { - return 'Script Settings'; - } } diff --git a/application/core/Plugins/InstallMenu.php b/application/core/Plugins/InstallMenu.php index bfc8b5db..41e4660d 100644 --- a/application/core/Plugins/InstallMenu.php +++ b/application/core/Plugins/InstallMenu.php @@ -48,6 +48,13 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_REFRESH_LIST, $this, 'handleRefreshListAction'); } + /** + * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() + */ + public static function getTitle() { + return 'Install Plugins'; + } + /** * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu() */ @@ -262,14 +269,6 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { * @param Player $player */ public function handleRefreshListAction(array $actionCallback, Player $player) { - $menuId = $this->maniaControl->configurator->getMenuId(self::getTitle()); - $this->maniaControl->configurator->reopenMenu($player, $menuId); - } - - /** - * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() - */ - public function getTitle() { - return 'Install Plugins'; + $this->maniaControl->configurator->showMenu($player, $this); } } diff --git a/application/core/Plugins/PluginMenu.php b/application/core/Plugins/PluginMenu.php index 37b8f281..31d3ea6f 100644 --- a/application/core/Plugins/PluginMenu.php +++ b/application/core/Plugins/PluginMenu.php @@ -64,19 +64,21 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns } /** - * Returns Back to the Plugins + * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() */ - public function backToPlugins($callback, Player $player) { - $player->destroyCache($this, self::CACHE_SETTING_CLASS); - $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($player, $menuId); + public static function getTitle() { + return 'Plugins'; } /** - * @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() + * Return back to the Plugins + * + * @param array $callback + * @param Player $player */ - public function getTitle() { - return 'Plugins'; + public function backToPlugins($callback, Player $player) { + $player->destroyCache($this, self::CACHE_SETTING_CLASS); + $this->maniaControl->configurator->showMenu($player, $this); } /** @@ -381,8 +383,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns } // Reopen the Menu - $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($player, $menuId); + $this->maniaControl->configurator->showMenu($player, $this); } /** @@ -417,7 +418,6 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $this->maniaControl->chat->sendSuccess('Plugin Settings saved!', $player); // Reopen the Menu - $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); - $this->maniaControl->configurator->reopenMenu($player, $menuId); + $this->maniaControl->configurator->showMenu($player, $this); } } diff --git a/application/core/Update/PluginUpdateManager.php b/application/core/Update/PluginUpdateManager.php index e464e71c..dbbc5924 100644 --- a/application/core/Update/PluginUpdateManager.php +++ b/application/core/Update/PluginUpdateManager.php @@ -10,8 +10,8 @@ use ManiaControl\Files\BackupUtil; use ManiaControl\Files\FileUtil; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; -use ManiaControl\Plugins\Plugin; use ManiaControl\Plugins\InstallMenu; +use ManiaControl\Plugins\Plugin; use ManiaControl\Plugins\PluginManager; use ManiaControl\Plugins\PluginMenu; use ManiaControl\Utils\WebReader; @@ -312,8 +312,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis } $this->maniaControl->log($message); - $menuId = $this->maniaControl->configurator->getMenuId('Install Plugins'); - $this->maniaControl->configurator->reopenMenu($player, $menuId); + $this->maniaControl->configurator->showMenu($player, InstallMenu::getTitle()); } } });