- static getTitle() function of configurator menu interface

- removed reopenMenu() configurator function
- use more intelligent showMenu() function
This commit is contained in:
Steffen Schröder 2014-07-24 23:15:25 +02:00
parent 6138274a98
commit d531d97366
7 changed files with 40 additions and 55 deletions

View File

@ -268,17 +268,6 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
return $manialink; 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 * Handle toggle menu action
* *

View File

@ -19,7 +19,7 @@ interface ConfiguratorMenu {
* *
* @return string * @return string
*/ */
public function getTitle(); public static function getTitle();
/** /**
* Get the Configurator Menu Frame * Get the Configurator Menu Frame

View File

@ -56,6 +56,13 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MC_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN); $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() * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
*/ */
@ -337,14 +344,6 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
$this->maniaControl->chat->sendSuccess('Settings saved!', $player); $this->maniaControl->chat->sendSuccess('Settings saved!', $player);
// Reopen the Menu // Reopen the Menu
$menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); $this->maniaControl->configurator->showMenu($player, $this);
$this->maniaControl->configurator->reopenMenu($player, $menuId);
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
*/
public function getTitle() {
return self::TITLE;
} }
} }

View File

@ -89,6 +89,13 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
return true; return true;
} }
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
*/
public static function getTitle() {
return 'Script Settings';
}
/** /**
* Handle OnInit callback * Handle OnInit callback
*/ */
@ -310,9 +317,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
$this->maniaControl->chat->sendError('Script Settings Saving failed!', $player); $this->maniaControl->chat->sendError('Script Settings Saving failed!', $player);
} }
//Reopen the Menu // Reopen the Menu
$menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); $this->maniaControl->configurator->showMenu($player, $this);
$this->maniaControl->configurator->reopenMenu($player, $menuId);
} }
/** /**
@ -396,11 +402,4 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
} }
return (string)$value; return (string)$value;
} }
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
*/
public function getTitle() {
return 'Script Settings';
}
} }

View File

@ -48,6 +48,13 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_REFRESH_LIST, $this, 'handleRefreshListAction'); $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() * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
*/ */
@ -262,14 +269,6 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
* @param Player $player * @param Player $player
*/ */
public function handleRefreshListAction(array $actionCallback, Player $player) { public function handleRefreshListAction(array $actionCallback, Player $player) {
$menuId = $this->maniaControl->configurator->getMenuId(self::getTitle()); $this->maniaControl->configurator->showMenu($player, $this);
$this->maniaControl->configurator->reopenMenu($player, $menuId);
}
/**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
*/
public function getTitle() {
return 'Install Plugins';
} }
} }

View File

@ -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) { public static function getTitle() {
$player->destroyCache($this, self::CACHE_SETTING_CLASS); return 'Plugins';
$menuId = $this->maniaControl->configurator->getMenuId($this->getTitle());
$this->maniaControl->configurator->reopenMenu($player, $menuId);
} }
/** /**
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle() * Return back to the Plugins
*
* @param array $callback
* @param Player $player
*/ */
public function getTitle() { public function backToPlugins($callback, Player $player) {
return 'Plugins'; $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 // Reopen the Menu
$menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); $this->maniaControl->configurator->showMenu($player, $this);
$this->maniaControl->configurator->reopenMenu($player, $menuId);
} }
/** /**
@ -417,7 +418,6 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
$this->maniaControl->chat->sendSuccess('Plugin Settings saved!', $player); $this->maniaControl->chat->sendSuccess('Plugin Settings saved!', $player);
// Reopen the Menu // Reopen the Menu
$menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); $this->maniaControl->configurator->showMenu($player, $this);
$this->maniaControl->configurator->reopenMenu($player, $menuId);
} }
} }

View File

@ -10,8 +10,8 @@ use ManiaControl\Files\BackupUtil;
use ManiaControl\Files\FileUtil; use ManiaControl\Files\FileUtil;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use ManiaControl\Plugins\Plugin;
use ManiaControl\Plugins\InstallMenu; use ManiaControl\Plugins\InstallMenu;
use ManiaControl\Plugins\Plugin;
use ManiaControl\Plugins\PluginManager; use ManiaControl\Plugins\PluginManager;
use ManiaControl\Plugins\PluginMenu; use ManiaControl\Plugins\PluginMenu;
use ManiaControl\Utils\WebReader; use ManiaControl\Utils\WebReader;
@ -312,8 +312,7 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
} }
$this->maniaControl->log($message); $this->maniaControl->log($message);
$menuId = $this->maniaControl->configurator->getMenuId('Install Plugins'); $this->maniaControl->configurator->showMenu($player, InstallMenu::getTitle());
$this->maniaControl->configurator->reopenMenu($player, $menuId);
} }
} }
}); });