From afb0b35540fc49d06d7f3569ca3f1f15d8123999 Mon Sep 17 00:00:00 2001 From: kremsy Date: Mon, 9 Dec 2013 20:31:02 +0100 Subject: [PATCH] begin plugin menu --- .../core/Configurators/ScriptSettings.php | 2 +- application/core/Plugins/PluginManager.php | 21 +++++- application/core/Plugins/PluginMenu.php | 69 +++++++++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/application/core/Configurators/ScriptSettings.php b/application/core/Configurators/ScriptSettings.php index 3f62f2fa..838f729c 100644 --- a/application/core/Configurators/ScriptSettings.php +++ b/application/core/Configurators/ScriptSettings.php @@ -53,7 +53,7 @@ class ScriptSettings implements ConfiguratorMenu { public function getTitle() { return $this->maniaControl->settingManager->getSetting($this, self::SETTING_TITLE); } - + //TODO: boolean values not as entry /** * * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu() diff --git a/application/core/Plugins/PluginManager.php b/application/core/Plugins/PluginManager.php index 1122e6fe..10990392 100644 --- a/application/core/Plugins/PluginManager.php +++ b/application/core/Plugins/PluginManager.php @@ -26,6 +26,7 @@ class PluginManager { private $activePlugins = array(); private $pluginClasses = array(); + /** * Construct plugin manager * @@ -74,7 +75,7 @@ class PluginManager { * @param bool $active * @return bool */ - private function savePluginStatus($className, $active) { + public function savePluginStatus($className, $active) { $mysqli = $this->maniaControl->database->mysqli; $pluginStatusQuery = "INSERT INTO `" . self::TABLE_PLUGINS . "` ( `className`, @@ -106,7 +107,7 @@ class PluginManager { * @param string $className * @return bool */ - private function getPluginStatus($className) { + public function getPluginStatus($className) { $mysqli = $this->maniaControl->database->mysqli; $pluginStatusQuery = "SELECT `active` FROM `" . self::TABLE_PLUGINS . "` WHERE `className` = ?;"; @@ -168,6 +169,22 @@ class PluginManager { } } } + + /** + * @return array + */ + public function getPluginClasses() + { + return $this->pluginClasses; + } + + /** + * @return array + */ + public function getActivePlugins() + { + return $this->activePlugins; + } } ?> diff --git a/application/core/Plugins/PluginMenu.php b/application/core/Plugins/PluginMenu.php index 43b9652f..5a790b75 100644 --- a/application/core/Plugins/PluginMenu.php +++ b/application/core/Plugins/PluginMenu.php @@ -2,12 +2,17 @@ namespace ManiaControl\Plugins; +use FML\Controls\Quad; +use FML\Controls\Quads\Quad_Icons64x64_1; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Configurators\ConfiguratorMenu; use FML\Script\Pages; use FML\Script\Tooltips; use FML\Controls\Frame; +use FML\Controls\Label; +use FML\Controls\Labels\Label_Text; +use FML\Controls\Control; /** * Configurator for enabling and disabling plugins @@ -43,6 +48,70 @@ class PluginMenu implements ConfiguratorMenu { */ public function getMenu($width, $height, Pages $pages, Tooltips $tooltips) { $frame = new Frame(); + + $pluginClasses = $this->maniaControl->pluginManager->getPluginClasses(); + //$labelStyleSetting = $this->maniaControl->settingManager->getSetting($this, self::SETTING_STYLE_SETTING); + $labelStyleSetting = Label_Text::STYLE_TextStaticSmall; + // $pagerSize = 9.; + $entryHeight = 5.; + $labelTextSize = 2; + // $pageMaxCount = 13; + $pageFrames = array(); + $y = 0.; + foreach ($pluginClasses as $pluginClass) { + if (!isset($pageFrame)) { + $pageFrame = new Frame(); + $frame->add($pageFrame); + array_push($pageFrames, $pageFrame); + $y = $height * 0.41; + } + + //check if plugin is aktiv + $active = $this->maniaControl->pluginManager->getPluginStatus($pluginClass); + + + $settingFrame = new Frame(); + $pageFrame->add($settingFrame); + $settingFrame->setY($y); + + //TODO: Red or Green quad to see if the plugin is aktiv (not working yet) + $aktivQuad = new Quad_Icons64x64_1(); + $settingFrame->add($aktivQuad); + $aktivQuad->setStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowRed); + $aktivQuad->setHeight(10); + $aktivQuad->setWidth(10); + $aktivQuad->setX($width * 0.2); + + $nameLabel = new Label(); + $settingFrame->add($nameLabel); + $nameLabel->setHAlign(Control::LEFT); + $nameLabel->setX($width * -0.4); + $nameLabel->setSize($width * 0.4, $entryHeight); + $nameLabel->setStyle($labelStyleSetting); + $nameLabel->setTextSize($labelTextSize); + $nameLabel->setText($pluginClass); + + //TODO description + $descriptionLabel = new Label(); + $pageFrame->add($descriptionLabel); + $descriptionLabel->setHAlign(Control::LEFT); + $descriptionLabel->setPosition($width * -0.45, $height * -0.44); + //$descriptionLabel->setSize($width * 0.7, $settingHeight); + //$descriptionLabel->setStyle($labelStyleDescription); + $descriptionLabel->setTranslate(true); + $descriptionLabel->setTextPrefix('Desc: '); + //$descriptionLabel->setText($scriptParam['Desc']); + $tooltips->add($nameLabel, $descriptionLabel); + + //TODO set aktive button + $y -= $entryHeight; + // if ($index % $pageMaxCount == $pageMaxCount - 1) { + // unset($pageFrame); + //} + } + //TODO multiple pages + //$pages->add(array(-1 => $pagerPrev, 1 => $pagerNext), $pageFrames, $pageCountLabel); + return $frame; }