configurator bug fixes

This commit is contained in:
kremsy 2014-01-18 21:05:45 +01:00 committed by Steffen Schröder
parent aabd84c48f
commit 7912336509
5 changed files with 44 additions and 28 deletions

View File

@ -119,13 +119,8 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
* *
* @param array $callback * @param array $callback
*/ */
public function reopenMenu($menuId = 0) { public function reopenMenu($player, $menuId = 0) {
foreach($this->playersMenuShown as $login => $shown) { $this->showMenu($player, $menuId);
if($shown == true) {
$player = $this->maniaControl->playerManager->getPlayer($login);
$this->showMenu($player, $menuId);
}
}
} }
/** /**
@ -318,7 +313,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
$closeQuad->setPosition($menuWidth * 0.483, $menuHeight * 0.467, 3); $closeQuad->setPosition($menuWidth * 0.483, $menuHeight * 0.467, 3);
$closeQuad->setSize(6, 6); $closeQuad->setSize(6, 6);
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace); $closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
$closeQuad->setAction(self::ACTION_TOGGLEMENU); $closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
// Add close button // Add close button
$closeButton = new Label(); $closeButton = new Label();

View File

@ -245,7 +245,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
//Reopen the Menu //Reopen the Menu
$menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle());
$this->maniaControl->configurator->reopenMenu($menuId); $this->maniaControl->configurator->reopenMenu($player, $menuId);
} }
/** /**

View File

@ -316,7 +316,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
//Reopen the Menu //Reopen the Menu
$menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle());
$this->maniaControl->configurator->reopenMenu($menuId); $this->maniaControl->configurator->reopenMenu($player, $menuId);
} }
/** /**

View File

@ -297,7 +297,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
//Reopen the Menu //Reopen the Menu
$menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle());
$this->maniaControl->configurator->reopenMenu($menuId); $this->maniaControl->configurator->reopenMenu($player, $menuId);
} }
/** /**

View File

@ -10,14 +10,13 @@ use FML\Controls\Labels\Label_Button;
use FML\Controls\Labels\Label_Text; use FML\Controls\Labels\Label_Text;
use FML\Controls\Quads\Quad_Icons128x32_1; use FML\Controls\Quads\Quad_Icons128x32_1;
use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Script\Pages;
use FML\Script\Script; use FML\Script\Script;
use FML\Script\Tooltips;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Configurators\ConfiguratorMenu; use ManiaControl\Configurators\ConfiguratorMenu;
use ManiaControl\Formatter; use ManiaControl\Formatter;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
/** /**
@ -25,7 +24,7 @@ use ManiaControl\Players\Player;
* *
* @author steeffeen * @author steeffeen
*/ */
class PluginMenu implements CallbackListener, ConfiguratorMenu { class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAnswerListener {
/** /**
* Constants * Constants
*/ */
@ -34,11 +33,13 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu {
const ACTION_PREFIX_SETTINGS = 'PluginMenu.Settings.'; const ACTION_PREFIX_SETTINGS = 'PluginMenu.Settings.';
const ACTION_PREFIX_SETTING = 'PluginMenuSetting'; const ACTION_PREFIX_SETTING = 'PluginMenuSetting';
const ACTION_SETTING_BOOL = 'PluginMenuActionBoolSetting.'; const ACTION_SETTING_BOOL = 'PluginMenuActionBoolSetting.';
const ACTION_BACK_TO_PLUGINS = 'PluginMenu.BackToPlugins';
/** /**
* Private properties * Private properties
*/ */
private $maniaControl = null; private $maniaControl = null;
private $settingsClass = ''; private $settingsClass = ''; //TODO needs to be improved
/** /**
* Create a new plugin menu instance * Create a new plugin menu instance
@ -48,6 +49,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu {
public function __construct(ManiaControl $maniaControl) { public function __construct(ManiaControl $maniaControl) {
$this->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'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
} }
@ -59,6 +61,15 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu {
return 'Plugins'; 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() * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
@ -102,13 +113,14 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu {
//Show Settings Menu //Show Settings Menu
if($this->settingsClass != '') { if($this->settingsClass != '') { //TODO improve
/** @var ManiaControl/SettingManager $this->maniaControl->settingManager */ /** @var ManiaControl/SettingManager $this->maniaControl->settingManager */
$settings = $this->maniaControl->settingManager->getSettingsByClass($this->settingsClass); $settings = $this->maniaControl->settingManager->getSettingsByClass($this->settingsClass);
$pageFrames = array(); $pageFrames = array();
$y = 0; $pageSettingsMaxCount = 12;
$index = 1; $y = 0;
$settingHeight = 5.; $index = 1;
$settingHeight = 5.;
foreach($settings as $id => $setting) { foreach($settings as $id => $setting) {
if(!isset($pageFrame)) { if(!isset($pageFrame)) {
$pageFrame = new Frame(); $pageFrame = new Frame();
@ -139,7 +151,6 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu {
$y -= $settingHeight; $y -= $settingHeight;
if($index % $pageMaxCount == $pageMaxCount - 1) { if($index % $pageMaxCount == $pageMaxCount - 1) {
$pageFrame = new Frame(); $pageFrame = new Frame();
$frame->add($pageFrame); $frame->add($pageFrame);
@ -151,7 +162,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu {
$script->addPage($pageFrame, count($pageFrames), $pagesId); $script->addPage($pageFrame, count($pageFrames), $pagesId);
} }
} }
$index++;
$settingFrame = new Frame(); $settingFrame = new Frame();
$pageFrame->add($settingFrame); $pageFrame->add($settingFrame);
@ -201,19 +212,28 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu {
} }
$y -= $settingHeight; $y -= $settingHeight;
if($index % $pageMaxCount == $pageMaxCount - 1) {
if($index % $pageSettingsMaxCount == $pageSettingsMaxCount - 1) {
unset($pageFrame); unset($pageFrame);
} }
$index++; $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; return $frame;
} }
//Display normal Plugin List
// Plugin pages // Plugin pages
$pageFrames = array(); $pageFrames = array();
$y = 0.; $y = 0.;
@ -273,6 +293,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu {
$pluginFrame->add($quad); $pluginFrame->add($quad);
$quad->setSubStyle($quad::SUBSTYLE_Settings); $quad->setSubStyle($quad::SUBSTYLE_Settings);
$quad->setX(15); $quad->setX(15);
$quad->setZ(1);
$quad->setSize(5, 5); $quad->setSize(5, 5);
$quad->setAction(self::ACTION_PREFIX_SETTINGS . $pluginClass); $quad->setAction(self::ACTION_PREFIX_SETTINGS . $pluginClass);
@ -327,7 +348,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu {
//Reopen the Menu //Reopen the Menu
$menuId = $this->maniaControl->configurator->getMenuId($this->getTitle()); $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()); $menuId = $this->maniaControl->configurator->getMenuId($this->getTitle());
$this->maniaControl->configurator->reopenMenu($menuId); $this->maniaControl->configurator->reopenMenu($player, $menuId);
} }
/** /**