|
|
|
@ -15,6 +15,11 @@ use ManiaControl\Callbacks\CallbackListener;
|
|
|
|
|
use ManiaControl\Callbacks\CallbackManager;
|
|
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
|
use ManiaControl\Players\Player;
|
|
|
|
|
use ManiaControl\Callbacks\Callbacks;
|
|
|
|
|
use ManiaControl\Players\PlayerManager;
|
|
|
|
|
use FML\Types\Playable;
|
|
|
|
|
use FML\Controls\Labels\Label_Button;
|
|
|
|
|
use ManiaControl\Settings\SettingManager;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class offering a Configurator for ManiaControl Settings
|
|
|
|
@ -28,14 +33,17 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
* Constants
|
|
|
|
|
*/
|
|
|
|
|
const TITLE = 'ManiaControl Settings';
|
|
|
|
|
const ACTION_PREFIX_SETTING = 'ManiaControlSettings';
|
|
|
|
|
const ACTION_SETTING_BOOL = 'ManiaControlSettings.ActionBoolSetting.';
|
|
|
|
|
const ACTION_PREFIX_SETTING = 'MCSetting.';
|
|
|
|
|
const ACTION_PREFIX_SETTINGCLASS = 'MCSettingClass.';
|
|
|
|
|
const ACTION_SETTINGCLASS_BACK = 'MCSettingClassBack';
|
|
|
|
|
const ACTION_SETTING_BOOL = 'MCSettings.ActionBoolSetting.';
|
|
|
|
|
const SETTING_PERMISSION_CHANGE_MC_SETTINGS = 'Change ManiaControl Settings';
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Private Properties
|
|
|
|
|
*/
|
|
|
|
|
private $maniaControl = null;
|
|
|
|
|
private $playersSettingCategoryOpened = array();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new Script Settings Instance
|
|
|
|
@ -47,7 +55,18 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
|
|
|
|
|
// Register for callbacks
|
|
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
|
|
|
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MC_SETTINGS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
|
|
|
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
|
|
|
|
|
|
|
|
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MC_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle Player Disconnect Callback
|
|
|
|
|
*
|
|
|
|
|
* @param Player $player
|
|
|
|
|
*/
|
|
|
|
|
public function handlePlayerDisconnect(Player $player) {
|
|
|
|
|
unset($this->playersSettingCategoryOpened[$player->login]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -60,14 +79,111 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the Configurator Menu Frame
|
|
|
|
|
*
|
|
|
|
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::getMenu()
|
|
|
|
|
*/
|
|
|
|
|
public function getMenu($width, $height, Script $script, Player $player) {
|
|
|
|
|
if (isset($this->playersSettingCategoryOpened[$player->login]) && strlen($this->playersSettingCategoryOpened[$player->login]) > 0) {
|
|
|
|
|
return $this->getMenuSettingsForClass($this->playersSettingCategoryOpened[$player->login], $width, $height, $script, $player);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return $this->getMenuSettingClasses($width, $height, $script, $player);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the Menu showing all possible Classes
|
|
|
|
|
*
|
|
|
|
|
* @param float $width
|
|
|
|
|
* @param float $height
|
|
|
|
|
* @param Script $script
|
|
|
|
|
* @param Player $player
|
|
|
|
|
* @return \FML\Controls\Frame
|
|
|
|
|
*/
|
|
|
|
|
public function getMenu($width, $height, Script $script) {
|
|
|
|
|
private function getMenuSettingClasses($width, $height, Script $script, Player $player) {
|
|
|
|
|
$settingClasses = $this->maniaControl->settingManager->getSettingClasses(true);
|
|
|
|
|
|
|
|
|
|
$paging = new Paging();
|
|
|
|
|
$script->addFeature($paging);
|
|
|
|
|
$frame = new Frame();
|
|
|
|
|
|
|
|
|
|
// Config
|
|
|
|
|
$pagerSize = 9.;
|
|
|
|
|
$settingHeight = 5.;
|
|
|
|
|
$pageMaxCount = 13;
|
|
|
|
|
$y = 0;
|
|
|
|
|
|
|
|
|
|
// Pagers
|
|
|
|
|
$pagerPrev = new Quad_Icons64x64_1();
|
|
|
|
|
$frame->add($pagerPrev);
|
|
|
|
|
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
|
|
|
|
$pagerPrev->setSize($pagerSize, $pagerSize);
|
|
|
|
|
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
|
|
|
|
|
|
|
|
|
$pagerNext = new Quad_Icons64x64_1();
|
|
|
|
|
$frame->add($pagerNext);
|
|
|
|
|
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
|
|
|
|
$pagerNext->setSize($pagerSize, $pagerSize);
|
|
|
|
|
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
|
|
|
|
|
|
|
|
|
$paging->addButton($pagerNext);
|
|
|
|
|
$paging->addButton($pagerPrev);
|
|
|
|
|
|
|
|
|
|
$pageCountLabel = new Label_Text();
|
|
|
|
|
$frame->add($pageCountLabel);
|
|
|
|
|
$pageCountLabel->setHAlign($pageCountLabel::RIGHT);
|
|
|
|
|
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
|
|
|
|
|
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
|
|
|
|
$pageCountLabel->setTextSize(2);
|
|
|
|
|
|
|
|
|
|
$paging->setLabel($pageCountLabel);
|
|
|
|
|
|
|
|
|
|
$pageFrame = null;
|
|
|
|
|
$index = 0;
|
|
|
|
|
foreach ($settingClasses as $settingClass) {
|
|
|
|
|
if (!$pageFrame) {
|
|
|
|
|
$pageFrame = new Frame();
|
|
|
|
|
$frame->add($pageFrame);
|
|
|
|
|
$y = $height * 0.41;
|
|
|
|
|
$paging->addPage($pageFrame);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$classLabel = new Label_Text();
|
|
|
|
|
$pageFrame->add($classLabel);
|
|
|
|
|
$classLabel->setHAlign($classLabel::LEFT);
|
|
|
|
|
$classLabel->setPosition($width * -0.45, $y);
|
|
|
|
|
$classLabel->setSize($width * 0.9, $settingHeight * 0.9);
|
|
|
|
|
$classLabel->setStyle($classLabel::STYLE_TextCardSmall);
|
|
|
|
|
$classLabel->setTextSize(2);
|
|
|
|
|
$classLabel->setText($settingClass);
|
|
|
|
|
$classLabel->setTextColor('fff');
|
|
|
|
|
$classLabel->setAction(self::ACTION_PREFIX_SETTINGCLASS . $settingClass);
|
|
|
|
|
|
|
|
|
|
$y -= $settingHeight;
|
|
|
|
|
|
|
|
|
|
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
|
|
|
|
$pageFrame = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $frame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the Menu showing the Settings for the given Class
|
|
|
|
|
*
|
|
|
|
|
* @param string $settingClass
|
|
|
|
|
* @param float $width
|
|
|
|
|
* @param float $height
|
|
|
|
|
* @param Script $script
|
|
|
|
|
* @param Player $player
|
|
|
|
|
* @return \FML\Controls\Frame
|
|
|
|
|
*/
|
|
|
|
|
private function getMenuSettingsForClass($settingClass, $width, $height, Script $script, Player $player) {
|
|
|
|
|
$settings = $this->maniaControl->settingManager->getSettingsByClass($settingClass);
|
|
|
|
|
|
|
|
|
|
$paging = new Paging();
|
|
|
|
|
$script->addFeature($paging);
|
|
|
|
|
$frame = new Frame();
|
|
|
|
@ -83,48 +199,40 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
$frame->add($pagerPrev);
|
|
|
|
|
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
|
|
|
|
$pagerPrev->setSize($pagerSize, $pagerSize);
|
|
|
|
|
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
|
|
|
|
|
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
|
|
|
|
|
|
|
|
|
$pagerNext = new Quad_Icons64x64_1();
|
|
|
|
|
$frame->add($pagerNext);
|
|
|
|
|
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
|
|
|
|
$pagerNext->setSize($pagerSize, $pagerSize);
|
|
|
|
|
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
|
|
|
|
|
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
|
|
|
|
|
|
|
|
|
$paging->addButton($pagerNext);
|
|
|
|
|
$paging->addButton($pagerPrev);
|
|
|
|
|
|
|
|
|
|
$pageCountLabel = new Label();
|
|
|
|
|
$pageCountLabel = new Label_Text();
|
|
|
|
|
$frame->add($pageCountLabel);
|
|
|
|
|
$pageCountLabel->setHAlign(Control::RIGHT);
|
|
|
|
|
$pageCountLabel->setPosition($width * 0.35, $height * -0.44, 1);
|
|
|
|
|
$pageCountLabel->setStyle('TextTitle1');
|
|
|
|
|
$pageCountLabel->setHAlign($pageCountLabel::RIGHT);
|
|
|
|
|
$pageCountLabel->setPosition($width * 0.35, $height * -0.44);
|
|
|
|
|
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
|
|
|
|
$pageCountLabel->setTextSize(2);
|
|
|
|
|
|
|
|
|
|
$paging->setLabel($pageCountLabel);
|
|
|
|
|
|
|
|
|
|
/** @var ManiaControl/SettingManager $this->maniaControl->settingManager */
|
|
|
|
|
$settings = $this->maniaControl->settingManager->getSettings();
|
|
|
|
|
$backLabel = new Label_Button();
|
|
|
|
|
$frame->add($backLabel);
|
|
|
|
|
$backLabel->setPosition($width * -0.49, $height * -0.44);
|
|
|
|
|
$backLabel->setHAlign($backLabel::LEFT);
|
|
|
|
|
$backLabel->setTextSize(2);
|
|
|
|
|
$backLabel->setText('Back');
|
|
|
|
|
$backLabel->setAction(self::ACTION_SETTINGCLASS_BACK);
|
|
|
|
|
|
|
|
|
|
$pluginClasses = $this->maniaControl->pluginManager->getPluginClasses();
|
|
|
|
|
|
|
|
|
|
$pageFrames = array();
|
|
|
|
|
$y = 0;
|
|
|
|
|
$index = 1;
|
|
|
|
|
$prevClass = '';
|
|
|
|
|
$pageFrame = null;
|
|
|
|
|
$index = 0;
|
|
|
|
|
foreach ($settings as $setting) {
|
|
|
|
|
//Don't display Plugin Settings
|
|
|
|
|
if (array_search($setting->class, $pluginClasses) !== FALSE) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isset($pageFrame)) {
|
|
|
|
|
if (!$pageFrame) {
|
|
|
|
|
$pageFrame = new Frame();
|
|
|
|
|
$frame->add($pageFrame);
|
|
|
|
|
if (!empty($pageFrames)) {
|
|
|
|
|
$pageFrame->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
array_push($pageFrames, $pageFrame);
|
|
|
|
|
$y = $height * 0.41;
|
|
|
|
|
$paging->addPage($pageFrame);
|
|
|
|
|
}
|
|
|
|
@ -133,8 +241,10 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
$pageFrame->add($settingFrame);
|
|
|
|
|
$settingFrame->setY($y);
|
|
|
|
|
|
|
|
|
|
// TODO: display currently select setting class
|
|
|
|
|
|
|
|
|
|
// Headline Label
|
|
|
|
|
if ($prevClass != $setting->class) {
|
|
|
|
|
if (false) {
|
|
|
|
|
$headLabel = new Label_Text();
|
|
|
|
|
$settingFrame->add($headLabel);
|
|
|
|
|
$headLabel->setHAlign(Control::LEFT);
|
|
|
|
@ -144,27 +254,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
$headLabel->setTextSize($labelTextSize);
|
|
|
|
|
$headLabel->setText($setting->class);
|
|
|
|
|
$headLabel->setTextColor("F00");
|
|
|
|
|
|
|
|
|
|
$y -= $settingHeight;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
|
|
|
|
$pageFrame = new Frame();
|
|
|
|
|
$frame->add($pageFrame);
|
|
|
|
|
if (!empty($pageFrames)) {
|
|
|
|
|
$pageFrame->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
array_push($pageFrames, $pageFrame);
|
|
|
|
|
$y = $height * 0.41;
|
|
|
|
|
$paging->addPage($pageFrame);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$index++;
|
|
|
|
|
|
|
|
|
|
$settingFrame = new Frame();
|
|
|
|
|
$pageFrame->add($settingFrame);
|
|
|
|
|
$settingFrame->setY($y);
|
|
|
|
|
} //Headline Label finished
|
|
|
|
|
} // Headline
|
|
|
|
|
|
|
|
|
|
$nameLabel = new Label_Text();
|
|
|
|
|
$settingFrame->add($nameLabel);
|
|
|
|
@ -176,44 +266,29 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
$nameLabel->setText($setting->setting);
|
|
|
|
|
$nameLabel->setTextColor("FFF");
|
|
|
|
|
|
|
|
|
|
$substyle = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$entry = new Entry();
|
|
|
|
|
$settingFrame->add($entry);
|
|
|
|
|
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
|
|
|
|
$entry->setHAlign(Control::CENTER);
|
|
|
|
|
$entry->setX($width / 2 * 0.65);
|
|
|
|
|
$entry->setTextSize(1);
|
|
|
|
|
$entry->setSize($width * 0.3, $settingHeight * 0.9);
|
|
|
|
|
$entry->setName(self::ACTION_PREFIX_SETTING . '.' . $setting->index);
|
|
|
|
|
$entry->setDefault($setting->value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($setting->type == "bool") {
|
|
|
|
|
if ($setting->value == "0") {
|
|
|
|
|
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlRed;
|
|
|
|
|
} else if ($setting->value == "1") {
|
|
|
|
|
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($setting->type === SettingManager::TYPE_BOOL) {
|
|
|
|
|
$quad = new Quad_Icons64x64_1();
|
|
|
|
|
$settingFrame->add($quad);
|
|
|
|
|
$quad->setX($width / 2 * 0.6);
|
|
|
|
|
$quad->setZ(-0.01);
|
|
|
|
|
$quad->setSubStyle($substyle);
|
|
|
|
|
$quad->setSubStyle(($setting->value ? $quad::SUBSTYLE_LvlGreen : $quad::SUBSTYLE_LvlRed));
|
|
|
|
|
$quad->setSize(4, 4);
|
|
|
|
|
$quad->setHAlign(Control::CENTER2);
|
|
|
|
|
$quad->setAction(self::ACTION_SETTING_BOOL . $setting->index);
|
|
|
|
|
$entry->setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$prevClass = $setting->class;
|
|
|
|
|
else {
|
|
|
|
|
$entry = new Entry();
|
|
|
|
|
$settingFrame->add($entry);
|
|
|
|
|
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
|
|
|
|
$entry->setX($width / 2 * 0.65);
|
|
|
|
|
$entry->setTextSize(1);
|
|
|
|
|
$entry->setSize($width * 0.3, $settingHeight * 0.9);
|
|
|
|
|
$entry->setName(self::ACTION_PREFIX_SETTING . $setting->index);
|
|
|
|
|
$entry->setDefault($setting->value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$y -= $settingHeight;
|
|
|
|
|
if ($index % $pageMaxCount == $pageMaxCount - 1) {
|
|
|
|
|
unset($pageFrame);
|
|
|
|
|
$pageFrame = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$index++;
|
|
|
|
@ -233,9 +308,8 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$prefix = explode(".", $configData[3][0]['Name']);
|
|
|
|
|
if ($prefix[0] != self::ACTION_PREFIX_SETTING) {
|
|
|
|
|
if (!$configData[3] || strpos($configData[3][0]['Name'], self::ACTION_PREFIX_SETTING) !== 0) {
|
|
|
|
|
// TODO: improve needed, this won't save configData passed by boolean setting change
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -244,7 +318,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
$prefixLength = strlen(self::ACTION_PREFIX_SETTING);
|
|
|
|
|
|
|
|
|
|
foreach ($configData[3] as $setting) {
|
|
|
|
|
$settingName = substr($setting['Name'], $prefixLength + 1);
|
|
|
|
|
$settingName = substr($setting['Name'], $prefixLength);
|
|
|
|
|
|
|
|
|
|
$oldSetting = $maniaControlSettings[$settingName];
|
|
|
|
|
if ($setting['Value'] == $oldSetting->value || $oldSetting->type == 'bool') {
|
|
|
|
@ -266,50 +340,68 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
|
|
|
|
*/
|
|
|
|
|
public function handleManialinkPageAnswer(array $callback) {
|
|
|
|
|
$actionId = $callback[1][2];
|
|
|
|
|
$boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0);
|
|
|
|
|
if (!$boolSetting) {
|
|
|
|
|
return;
|
|
|
|
|
if ($actionId === self::ACTION_SETTINGCLASS_BACK) {
|
|
|
|
|
// Back to classes list
|
|
|
|
|
$login = $callback[1][1];
|
|
|
|
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
|
|
|
unset($this->playersSettingCategoryOpened[$player->login]);
|
|
|
|
|
$menuId = $this->maniaControl->configurator->getMenuId($this);
|
|
|
|
|
$this->maniaControl->configurator->showMenu($player, $menuId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$actionArray = explode(".", $actionId);
|
|
|
|
|
$setting = $actionArray[2];
|
|
|
|
|
else if (strpos($actionId, self::ACTION_SETTING_BOOL) === 0) {
|
|
|
|
|
// Bool setting change
|
|
|
|
|
$settingIndex = (int) substr($actionId, strlen(self::ACTION_SETTING_BOOL));
|
|
|
|
|
|
|
|
|
|
$login = $callback[1][1];
|
|
|
|
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
|
|
|
|
|
|
|
|
// Toggle the Boolean Setting
|
|
|
|
|
$this->toggleBooleanSetting($setting, $player);
|
|
|
|
|
$this->toggleBooleanSetting($settingIndex, $player);
|
|
|
|
|
|
|
|
|
|
if ($callback[1][3]) {
|
|
|
|
|
// Save all Changes
|
|
|
|
|
$this->saveConfigData($callback[1], $player);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Reopen menu directly
|
|
|
|
|
$menuId = $this->maniaControl->configurator->getMenuId($this);
|
|
|
|
|
$this->maniaControl->configurator->reopenMenu($player, $menuId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (strpos($actionId, self::ACTION_PREFIX_SETTINGCLASS) === 0) {
|
|
|
|
|
// Setting class selected
|
|
|
|
|
$settingClass = substr($actionId, strlen(self::ACTION_PREFIX_SETTINGCLASS));
|
|
|
|
|
|
|
|
|
|
$login = $callback[1][1];
|
|
|
|
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
|
|
|
|
|
|
|
|
|
$this->playersSettingCategoryOpened[$player->login] = $settingClass;
|
|
|
|
|
|
|
|
|
|
$menuId = $this->maniaControl->configurator->getMenuId($this);
|
|
|
|
|
$this->maniaControl->configurator->showMenu($player, $menuId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Toggles a Boolean Value
|
|
|
|
|
*
|
|
|
|
|
* @param $setting
|
|
|
|
|
* @param int $settingIndex
|
|
|
|
|
* @param Player $player
|
|
|
|
|
*/
|
|
|
|
|
public function toggleBooleanSetting($setting, Player $player) {
|
|
|
|
|
public function toggleBooleanSetting($settingIndex, Player $player) {
|
|
|
|
|
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_MC_SETTINGS)) {
|
|
|
|
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$oldSetting = $this->maniaControl->settingManager->getSettingByIndex($setting);
|
|
|
|
|
$oldSetting = $this->maniaControl->settingManager->getSettingByIndex($settingIndex);
|
|
|
|
|
|
|
|
|
|
if (!isset($oldSetting)) {
|
|
|
|
|
var_dump('no setting ' . $setting);
|
|
|
|
|
var_dump('no setting ' . $settingIndex);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Toggle value
|
|
|
|
|
if ($oldSetting->value == "1") {
|
|
|
|
|
$this->maniaControl->settingManager->setSetting($oldSetting->class, $oldSetting->setting, "0");
|
|
|
|
|
} else {
|
|
|
|
|
$this->maniaControl->settingManager->setSetting($oldSetting->class, $oldSetting->setting, "1");
|
|
|
|
|
$this->maniaControl->settingManager->setSetting($oldSetting->class, $oldSetting->setting, !$oldSetting->value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|