fixed menu pagings
This commit is contained in:
		| @@ -61,6 +61,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { | ||||
| 	 * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu() | ||||
| 	 */ | ||||
| 	public function getMenu($width, $height, Script $script) { | ||||
| 		$pagesId = 'ScriptSettingsPages'; | ||||
| 		$frame = new Frame(); | ||||
| 		 | ||||
| 		$this->maniaControl->client->query('GetModeScriptInfo'); | ||||
| @@ -96,8 +97,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { | ||||
| 		$pagerNext->setSize($pagerSize, $pagerSize); | ||||
| 		$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext); | ||||
| 		 | ||||
| 		$script->addPager($pagerPrev, -1); | ||||
| 		$script->addPager($pagerNext, 1); | ||||
| 		$script->addPager($pagerPrev, -1, $pagesId); | ||||
| 		$script->addPager($pagerNext, 1, $pagesId); | ||||
| 		 | ||||
| 		$pageCountLabel = new Label(); | ||||
| 		$frame->add($pageCountLabel); | ||||
| @@ -106,7 +107,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { | ||||
| 		$pageCountLabel->setStyle('TextTitle1'); | ||||
| 		$pageCountLabel->setTextSize(2); | ||||
| 		 | ||||
| 		$script->addPageLabel($pageCountLabel); | ||||
| 		$script->addPageLabel($pageCountLabel, $pagesId); | ||||
| 		 | ||||
| 		// Setting pages | ||||
| 		$pageFrames = array(); | ||||
| @@ -124,7 +125,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { | ||||
| 				} | ||||
| 				array_push($pageFrames, $pageFrame); | ||||
| 				$y = $height * 0.41; | ||||
| 				$script->addPage($pageFrame, count($pageFrames)); | ||||
| 				$script->addPage($pageFrame, count($pageFrames), $pagesId); | ||||
| 			} | ||||
| 			 | ||||
| 			$settingFrame = new Frame(); | ||||
| @@ -282,8 +283,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { | ||||
| 		foreach ($newSettings as $setting => $value) { | ||||
| 			$title = $this->maniaControl->authenticationManager->getAuthLevelName($player->authLevel); | ||||
| 			$chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting '; | ||||
| 			$chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $setting) . '$z$s$ff0 to $fff' . $this->parseSettingValue($value) . | ||||
| 					 '$>!'; | ||||
| 			$chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $setting) . '$z$s$ff0 '; | ||||
| 			$chatMessage .= 'to $fff' . $this->parseSettingValue($value) . '$>!'; | ||||
| 			 | ||||
| 			$this->maniaControl->chat->sendInformation($chatMessage); | ||||
| 			$this->maniaControl->log(Formatter::stripCodes($chatMessage)); | ||||
|   | ||||
| @@ -16,6 +16,7 @@ use FML\Controls\Quads\Quad_Icons64x64_1; | ||||
| use FML\Controls\Labels\Label_Button; | ||||
| use ManiaControl\Callbacks\CallbackManager; | ||||
| use ManiaControl\Callbacks\CallbackListener; | ||||
| use ManiaControl\Formatter; | ||||
|  | ||||
| /** | ||||
|  * Configurator for enabling and disabling plugins | ||||
| @@ -59,6 +60,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { | ||||
| 	 * @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu() | ||||
| 	 */ | ||||
| 	public function getMenu($width, $height, Script $script) { | ||||
| 		$pagesId = 'PluginPages'; | ||||
| 		$frame = new Frame(); | ||||
| 		 | ||||
| 		$pluginClasses = $this->maniaControl->pluginManager->getPluginClasses(); | ||||
| @@ -82,6 +84,9 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { | ||||
| 		$pagerNext->setSize($pagerSize, $pagerSize); | ||||
| 		$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext); | ||||
| 		 | ||||
| 		$script->addPager($pagerPrev, -1, $pagesId); | ||||
| 		$script->addPager($pagerNext, 1, $pagesId); | ||||
| 		 | ||||
| 		$pageCountLabel = new Label_Text(); | ||||
| 		$frame->add($pageCountLabel); | ||||
| 		$pageCountLabel->setHAlign(Control::RIGHT); | ||||
| @@ -89,6 +94,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { | ||||
| 		$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1); | ||||
| 		$pageCountLabel->setTextSize(2); | ||||
| 		 | ||||
| 		$script->addPageLabel($pageCountLabel, $pagesId); | ||||
| 		 | ||||
| 		// Plugin pages | ||||
| 		$pageFrames = array(); | ||||
| 		$y = 0.; | ||||
| @@ -96,7 +103,11 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { | ||||
| 			if (!isset($pageFrame)) { | ||||
| 				$pageFrame = new Frame(); | ||||
| 				$frame->add($pageFrame); | ||||
| 				if (!empty($pageFrames)) { | ||||
| 					$pageFrame->setVisible(false); | ||||
| 				} | ||||
| 				array_push($pageFrames, $pageFrame); | ||||
| 				$script->addPage($pageFrame, count($pageFrames), $pagesId); | ||||
| 				$y = $height * 0.41; | ||||
| 			} | ||||
| 			 | ||||
| @@ -158,15 +169,10 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { | ||||
| 			 | ||||
| 			$y -= $entryHeight; | ||||
| 			if ($index % $pageMaxCount == $pageMaxCount - 1) { | ||||
| 				$script->addPage($pageFrame, 1, "test"); | ||||
| 				unset($pageFrame); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// $script->addPager($pageFrames, 1 , $pageCountLabel); | ||||
| 		// $script->addPage(array(-1 => $pagerPrev, 1 => $pagerNext), $pageFrames, $pageCountLabel); | ||||
| 		// $pages->add(array(-1 => $pagerPrev, 1 => $pagerNext), $pageFrames, $pageCountLabel); | ||||
| 		 | ||||
| 		return $frame; | ||||
| 	} | ||||
|  | ||||
| @@ -200,6 +206,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { | ||||
| 			if ($activated) { | ||||
| 				$this->maniaControl->chat->sendSuccess($pluginClass::getName() . ' activated!', $player->login); | ||||
| 				$this->maniaControl->configurator->showMenu($player); | ||||
| 				$this->maniaControl->log(Formatter::stripCodes("{$player->login} activated '{$pluginClass}'!")); | ||||
| 			} | ||||
| 			else { | ||||
| 				$this->maniaControl->chat->sendError('Error activating ' . $pluginClass::getName() . '!', $player->login); | ||||
| @@ -211,6 +218,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu { | ||||
| 			if ($deactivated) { | ||||
| 				$this->maniaControl->chat->sendSuccess($pluginClass::getName() . ' deactivated!', $player->login); | ||||
| 				$this->maniaControl->configurator->showMenu($player); | ||||
| 				$this->maniaControl->log(Formatter::stripCodes("{$player->login} deactivated '{$pluginClass}'!")); | ||||
| 			} | ||||
| 			else { | ||||
| 				$this->maniaControl->chat->sendError('Error deactivating ' . $pluginClass::getName() . '!', $player->login); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user