2014-01-05 19:00:11 +01:00
|
|
|
<?php
|
|
|
|
|
2014-07-25 15:45:10 +02:00
|
|
|
namespace ManiaControl\Configurator;
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2014-06-15 02:13:00 +02:00
|
|
|
use FML\Components\CheckBox;
|
2014-05-18 23:35:39 +02:00
|
|
|
use FML\Components\ValuePicker;
|
2014-01-05 21:48:49 +01:00
|
|
|
use FML\Controls\Entry;
|
2014-01-05 19:10:11 +01:00
|
|
|
use FML\Controls\Frame;
|
2014-05-02 17:50:30 +02:00
|
|
|
use FML\Controls\Labels\Label_Button;
|
2014-01-05 19:20:54 +01:00
|
|
|
use FML\Controls\Labels\Label_Text;
|
2014-06-15 02:13:00 +02:00
|
|
|
use FML\Controls\Quad;
|
2014-01-05 19:20:54 +01:00
|
|
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
2014-04-27 16:22:12 +02:00
|
|
|
use FML\Script\Features\Paging;
|
2014-01-05 19:00:11 +01:00
|
|
|
use FML\Script\Script;
|
2014-01-31 16:55:01 +01:00
|
|
|
use ManiaControl\Admin\AuthenticationManager;
|
2014-01-05 22:51:21 +01:00
|
|
|
use ManiaControl\Callbacks\CallbackListener;
|
|
|
|
use ManiaControl\Callbacks\CallbackManager;
|
2014-01-05 19:00:11 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use ManiaControl\Players\Player;
|
2014-05-13 14:32:30 +02:00
|
|
|
use ManiaControl\Settings\Setting;
|
2014-01-05 19:00:11 +01:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/**
|
|
|
|
* Class offering a Configurator for ManiaControl Settings
|
2014-05-02 17:50:30 +02:00
|
|
|
*
|
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2019-01-05 21:02:24 +01:00
|
|
|
* @copyright 2014-2019 ManiaControl Team
|
2014-05-02 17:50:30 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-04-12 12:14:37 +02:00
|
|
|
*/
|
2014-01-05 22:51:21 +01:00
|
|
|
class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-01-05 19:00:11 +01:00
|
|
|
* Constants
|
|
|
|
*/
|
2014-05-02 17:50:30 +02:00
|
|
|
const TITLE = 'ManiaControl Settings';
|
|
|
|
const ACTION_PREFIX_SETTING = 'MCSetting.';
|
|
|
|
const ACTION_PREFIX_SETTINGCLASS = 'MCSettingClass.';
|
|
|
|
const ACTION_SETTINGCLASS_BACK = 'MCSettingClassBack';
|
2014-01-31 16:55:01 +01:00
|
|
|
const SETTING_PERMISSION_CHANGE_MC_SETTINGS = 'Change ManiaControl Settings';
|
2014-05-18 21:50:15 +02:00
|
|
|
const CACHE_CLASS_OPENED = 'ClassOpened';
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-07-25 16:28:47 +02:00
|
|
|
* Private properties
|
2014-01-05 19:00:11 +01:00
|
|
|
*/
|
2014-08-02 22:31:46 +02:00
|
|
|
/** @var ManiaControl $maniaControl */
|
2014-01-05 19:00:11 +01:00
|
|
|
private $maniaControl = null;
|
|
|
|
|
|
|
|
/**
|
2014-08-03 01:34:18 +02:00
|
|
|
* Construct a new ManiaControl Settings instance
|
2014-05-02 17:50:30 +02:00
|
|
|
*
|
2014-01-05 19:00:11 +01:00
|
|
|
* @param ManiaControl $maniaControl
|
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-08-03 01:34:18 +02:00
|
|
|
// Callbacks
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-08-03 01:34:18 +02:00
|
|
|
// Permissions
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MC_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
2014-04-30 05:27:23 +02:00
|
|
|
}
|
|
|
|
|
2014-07-24 23:15:25 +02:00
|
|
|
/**
|
2017-03-25 18:40:15 +01:00
|
|
|
* @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle()
|
2014-07-24 23:15:25 +02:00
|
|
|
*/
|
|
|
|
public static function getTitle() {
|
|
|
|
return self::TITLE;
|
|
|
|
}
|
|
|
|
|
2014-01-05 19:00:11 +01:00
|
|
|
/**
|
2017-03-25 18:40:15 +01:00
|
|
|
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
|
2014-04-30 05:27:23 +02:00
|
|
|
*/
|
|
|
|
public function getMenu($width, $height, Script $script, Player $player) {
|
2014-05-18 21:50:15 +02:00
|
|
|
$openedClass = $player->getCache($this, self::CACHE_CLASS_OPENED);
|
|
|
|
if ($openedClass) {
|
|
|
|
return $this->getMenuSettingsForClass($openedClass, $width, $height, $script, $player);
|
2014-04-30 05:27:23 +02:00
|
|
|
}
|
2014-05-18 21:50:15 +02:00
|
|
|
return $this->getMenuSettingClasses($width, $height, $script, $player);
|
2014-04-30 05:27:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Menu showing the Settings for the given Class
|
2014-05-02 17:50:30 +02:00
|
|
|
*
|
2014-04-30 05:27:23 +02:00
|
|
|
* @param string $settingClass
|
2014-05-02 17:50:30 +02:00
|
|
|
* @param float $width
|
|
|
|
* @param float $height
|
2014-04-30 05:27:23 +02:00
|
|
|
* @param Script $script
|
|
|
|
* @param Player $player
|
|
|
|
* @return \FML\Controls\Frame
|
|
|
|
*/
|
|
|
|
private function getMenuSettingsForClass($settingClass, $width, $height, Script $script, Player $player) {
|
2014-08-13 11:05:52 +02:00
|
|
|
$settings = $this->maniaControl->getSettingManager()->getSettingsByClass($settingClass);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-04-30 05:27:23 +02:00
|
|
|
$paging = new Paging();
|
|
|
|
$script->addFeature($paging);
|
|
|
|
$frame = new Frame();
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-04-30 05:27:23 +02:00
|
|
|
// Config
|
2014-05-02 17:50:30 +02:00
|
|
|
$pagerSize = 9.;
|
2014-04-30 05:27:23 +02:00
|
|
|
$settingHeight = 5.;
|
|
|
|
$labelTextSize = 2;
|
2014-06-15 01:58:25 +02:00
|
|
|
$pageMaxCount = 11;
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-04-30 05:27:23 +02:00
|
|
|
// Pagers
|
|
|
|
$pagerPrev = new Quad_Icons64x64_1();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pagerPrev);
|
2014-04-30 05:27:23 +02:00
|
|
|
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
|
|
|
$pagerPrev->setSize($pagerSize, $pagerSize);
|
|
|
|
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-04-30 05:27:23 +02:00
|
|
|
$pagerNext = new Quad_Icons64x64_1();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pagerNext);
|
2014-04-30 05:27:23 +02:00
|
|
|
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
|
|
|
$pagerNext->setSize($pagerSize, $pagerSize);
|
|
|
|
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2017-03-25 18:40:15 +01:00
|
|
|
$paging->addButtonControl($pagerNext);
|
|
|
|
$paging->addButtonControl($pagerPrev);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-04-30 05:27:23 +02:00
|
|
|
$pageCountLabel = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pageCountLabel);
|
|
|
|
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
2014-04-30 05:27:23 +02:00
|
|
|
$pageCountLabel->setPosition($width * 0.35, $height * -0.44);
|
|
|
|
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
|
|
|
$pageCountLabel->setTextSize(2);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-04-30 05:27:23 +02:00
|
|
|
$paging->setLabel($pageCountLabel);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-04-30 05:27:23 +02:00
|
|
|
$backLabel = new Label_Button();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($backLabel);
|
2014-05-25 10:10:01 +02:00
|
|
|
$backLabel->setStyle($backLabel::STYLE_CardMain_Quit);
|
|
|
|
$backLabel->setPosition(-$width / 2 + 7, -$height / 2 + 7);
|
2017-03-25 19:15:50 +01:00
|
|
|
$backLabel->setHorizontalAlign($backLabel::LEFT);
|
2014-04-30 05:27:23 +02:00
|
|
|
$backLabel->setTextSize(2);
|
|
|
|
$backLabel->setText('Back');
|
|
|
|
$backLabel->setAction(self::ACTION_SETTINGCLASS_BACK);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-06-15 01:58:25 +02:00
|
|
|
$headLabel = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($headLabel);
|
|
|
|
$headLabel->setHorizontalAlign($headLabel::LEFT);
|
2014-06-15 01:58:25 +02:00
|
|
|
$headLabel->setPosition($width * -0.46, $height * 0.41);
|
|
|
|
$headLabel->setSize($width * 0.6, $settingHeight);
|
|
|
|
$headLabel->setStyle($headLabel::STYLE_TextCardSmall);
|
|
|
|
$headLabel->setTextSize(3);
|
|
|
|
$headLabel->setText($settingClass);
|
|
|
|
$headLabel->setTextColor('ff0');
|
|
|
|
|
2014-04-30 05:27:23 +02:00
|
|
|
$pageFrame = null;
|
2014-05-02 17:50:30 +02:00
|
|
|
$index = 0;
|
2014-06-15 01:58:25 +02:00
|
|
|
$posY = 0;
|
2014-04-30 05:27:23 +02:00
|
|
|
foreach ($settings as $setting) {
|
2014-06-14 14:32:29 +02:00
|
|
|
if ($index % $pageMaxCount === 0) {
|
2014-01-05 19:20:54 +01:00
|
|
|
$pageFrame = new Frame();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pageFrame);
|
2017-03-25 18:40:15 +01:00
|
|
|
$paging->addPageControl($pageFrame);
|
2014-06-15 01:58:25 +02:00
|
|
|
$posY = $height * 0.41 - $settingHeight * 1.5;
|
2014-01-05 19:20:54 +01:00
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-01-05 19:20:54 +01:00
|
|
|
$settingFrame = new Frame();
|
2017-03-25 19:15:50 +01:00
|
|
|
$pageFrame->addChild($settingFrame);
|
2014-06-15 01:58:25 +02:00
|
|
|
$settingFrame->setY($posY);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-01-05 19:20:54 +01:00
|
|
|
$nameLabel = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$settingFrame->addChild($nameLabel);
|
|
|
|
$nameLabel->setHorizontalAlign($nameLabel::LEFT);
|
2014-01-05 19:20:54 +01:00
|
|
|
$nameLabel->setX($width * -0.46);
|
2014-01-05 21:48:49 +01:00
|
|
|
$nameLabel->setSize($width * 0.6, $settingHeight);
|
2014-01-05 19:20:54 +01:00
|
|
|
$nameLabel->setStyle($nameLabel::STYLE_TextCardSmall);
|
|
|
|
$nameLabel->setTextSize($labelTextSize);
|
|
|
|
$nameLabel->setText($setting->setting);
|
2014-06-22 19:02:18 +02:00
|
|
|
$nameLabel->setTextColor('fff');
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-05-18 23:35:39 +02:00
|
|
|
$settingName = self::ACTION_PREFIX_SETTING . $setting->index;
|
2014-05-13 14:32:30 +02:00
|
|
|
if ($setting->type === Setting::TYPE_BOOL) {
|
2014-06-15 02:13:00 +02:00
|
|
|
// Boolean checkbox
|
|
|
|
$quad = new Quad();
|
2014-05-18 23:35:39 +02:00
|
|
|
$quad->setPosition($width * 0.33, 0, -0.01);
|
2014-01-05 21:48:49 +01:00
|
|
|
$quad->setSize(4, 4);
|
2014-06-15 02:13:00 +02:00
|
|
|
$checkBox = new CheckBox($settingName, $setting->value, $quad);
|
2017-03-25 19:15:50 +01:00
|
|
|
$settingFrame->addChild($checkBox);
|
2014-05-18 23:35:39 +02:00
|
|
|
} else if ($setting->type === Setting::TYPE_SET) {
|
|
|
|
// SET value picker
|
|
|
|
$label = new Label_Text();
|
|
|
|
$label->setX($width * 0.33);
|
|
|
|
$label->setSize($width * 0.3, $settingHeight * 0.9);
|
|
|
|
$label->setStyle($label::STYLE_TextValueSmall);
|
|
|
|
$label->setTextSize(1);
|
|
|
|
$valuePicker = new ValuePicker($settingName, $setting->set, $setting->value, $label);
|
2017-03-25 19:15:50 +01:00
|
|
|
$settingFrame->addChild($valuePicker);
|
2014-05-02 17:50:30 +02:00
|
|
|
} else {
|
2014-05-18 23:35:39 +02:00
|
|
|
// Standard entry
|
2014-04-30 05:27:23 +02:00
|
|
|
$entry = new Entry();
|
2017-03-25 19:15:50 +01:00
|
|
|
$settingFrame->addChild($entry);
|
2014-05-18 23:35:39 +02:00
|
|
|
$entry->setX($width * 0.33);
|
|
|
|
$entry->setSize($width * 0.3, $settingHeight * 0.9);
|
2014-04-30 05:27:23 +02:00
|
|
|
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
|
|
|
$entry->setTextSize(1);
|
2014-05-18 23:35:39 +02:00
|
|
|
$entry->setName($settingName);
|
2014-04-30 05:27:23 +02:00
|
|
|
$entry->setDefault($setting->value);
|
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-06-15 01:58:25 +02:00
|
|
|
$posY -= $settingHeight;
|
2014-01-05 19:20:54 +01:00
|
|
|
$index++;
|
2014-01-05 19:10:11 +01:00
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-01-05 19:10:11 +01:00
|
|
|
return $frame;
|
2014-01-05 19:00:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-02 17:50:30 +02:00
|
|
|
* Get the Menu showing all possible Classes
|
|
|
|
*
|
|
|
|
* @param float $width
|
|
|
|
* @param float $height
|
|
|
|
* @param Script $script
|
2014-01-05 19:00:11 +01:00
|
|
|
* @param Player $player
|
2014-05-02 17:50:30 +02:00
|
|
|
* @return \FML\Controls\Frame
|
2014-01-05 19:00:11 +01:00
|
|
|
*/
|
2014-05-02 17:50:30 +02:00
|
|
|
private function getMenuSettingClasses($width, $height, Script $script, Player $player) {
|
2014-08-13 11:05:52 +02:00
|
|
|
$settingClasses = $this->maniaControl->getSettingManager()->getSettingClasses(true);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
|
|
|
$paging = new Paging();
|
|
|
|
$script->addFeature($paging);
|
|
|
|
$frame = new Frame();
|
|
|
|
|
|
|
|
// Config
|
|
|
|
$pagerSize = 9.;
|
|
|
|
$settingHeight = 5.;
|
|
|
|
$pageMaxCount = 13;
|
2014-06-14 15:48:27 +02:00
|
|
|
$posY = 0;
|
2014-05-02 17:50:30 +02:00
|
|
|
|
|
|
|
// Pagers
|
|
|
|
$pagerPrev = new Quad_Icons64x64_1();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pagerPrev);
|
2014-05-02 17:50:30 +02:00
|
|
|
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2);
|
|
|
|
$pagerPrev->setSize($pagerSize, $pagerSize);
|
|
|
|
$pagerPrev->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
|
|
|
|
|
|
|
$pagerNext = new Quad_Icons64x64_1();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pagerNext);
|
2014-05-02 17:50:30 +02:00
|
|
|
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
|
|
|
$pagerNext->setSize($pagerSize, $pagerSize);
|
|
|
|
$pagerNext->setSubStyle($pagerNext::SUBSTYLE_ArrowNext);
|
|
|
|
|
2017-03-25 18:40:15 +01:00
|
|
|
$paging->addButtonControl($pagerNext);
|
|
|
|
$paging->addButtonControl($pagerPrev);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
|
|
|
$pageCountLabel = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pageCountLabel);
|
|
|
|
$pageCountLabel->setHorizontalAlign($pageCountLabel::RIGHT);
|
2014-05-02 17:50:30 +02:00
|
|
|
$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) {
|
2014-06-14 14:32:29 +02:00
|
|
|
if ($index % $pageMaxCount === 0) {
|
2014-05-02 17:50:30 +02:00
|
|
|
$pageFrame = new Frame();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($pageFrame);
|
2014-06-14 15:48:27 +02:00
|
|
|
$posY = $height * 0.41;
|
2017-03-25 18:40:15 +01:00
|
|
|
$paging->addPageControl($pageFrame);
|
2014-01-05 21:48:49 +01:00
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
|
|
|
|
$classLabel = new Label_Text();
|
|
|
|
|
|
|
|
$settingClassArray = explode('\\', $settingClass);
|
2014-06-14 14:32:29 +02:00
|
|
|
$className = '';
|
2014-05-02 17:50:30 +02:00
|
|
|
for ($i = 1; $i < count($settingClassArray); $i++) {
|
2014-06-14 14:32:29 +02:00
|
|
|
$className .= $settingClassArray[$i] . ' - ';
|
2014-05-02 17:50:30 +02:00
|
|
|
}
|
|
|
|
$className = substr($className, 0, -3);
|
|
|
|
|
2017-03-25 19:15:50 +01:00
|
|
|
$pageFrame->addChild($classLabel);
|
|
|
|
$classLabel->setHorizontalAlign($classLabel::LEFT);
|
2014-06-14 15:48:27 +02:00
|
|
|
$classLabel->setPosition($width * -0.45, $posY);
|
2014-05-02 17:50:30 +02:00
|
|
|
$classLabel->setSize($width * 0.9, $settingHeight * 0.9);
|
|
|
|
$classLabel->setStyle($classLabel::STYLE_TextCardSmall);
|
|
|
|
$classLabel->setTextSize(2);
|
|
|
|
$classLabel->setText($className);
|
|
|
|
$classLabel->setTextColor('fff');
|
|
|
|
$classLabel->setAction(self::ACTION_PREFIX_SETTINGCLASS . $settingClass);
|
|
|
|
|
2014-06-14 15:48:27 +02:00
|
|
|
$posY -= $settingHeight;
|
2014-05-02 17:50:30 +02:00
|
|
|
$index++;
|
2014-01-05 21:48:49 +01:00
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
|
|
|
|
return $frame;
|
2014-01-05 19:00:11 +01:00
|
|
|
}
|
2014-01-05 22:51:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle ManialinkPageAnswer Callback
|
2014-05-02 17:50:30 +02:00
|
|
|
*
|
2014-01-05 22:51:21 +01:00
|
|
|
* @param array $callback
|
|
|
|
*/
|
|
|
|
public function handleManialinkPageAnswer(array $callback) {
|
2014-04-30 05:27:23 +02:00
|
|
|
$actionId = $callback[1][2];
|
|
|
|
if ($actionId === self::ACTION_SETTINGCLASS_BACK) {
|
|
|
|
// Back to classes list
|
2014-05-02 17:50:30 +02:00
|
|
|
$login = $callback[1][1];
|
2014-08-13 11:05:52 +02:00
|
|
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
2014-05-18 21:50:15 +02:00
|
|
|
$player->destroyCache($this, self::CACHE_CLASS_OPENED);
|
2014-08-13 11:05:52 +02:00
|
|
|
$menuId = $this->maniaControl->getConfigurator()->getMenuId($this);
|
|
|
|
$this->maniaControl->getConfigurator()->showMenu($player, $menuId);
|
2014-05-02 17:50:30 +02:00
|
|
|
} else if (strpos($actionId, self::ACTION_PREFIX_SETTINGCLASS) === 0) {
|
2014-04-30 05:27:23 +02:00
|
|
|
// Setting class selected
|
|
|
|
$settingClass = substr($actionId, strlen(self::ACTION_PREFIX_SETTINGCLASS));
|
2014-05-02 17:50:30 +02:00
|
|
|
|
|
|
|
$login = $callback[1][1];
|
2014-08-13 11:05:52 +02:00
|
|
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
2014-05-18 21:50:15 +02:00
|
|
|
$player->setCache($this, self::CACHE_CLASS_OPENED, $settingClass);
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-08-13 11:05:52 +02:00
|
|
|
$menuId = $this->maniaControl->getConfigurator()->getMenuId($this);
|
|
|
|
$this->maniaControl->getConfigurator()->showMenu($player, $menuId);
|
2014-01-05 22:51:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
/**
|
2014-06-15 03:23:44 +02:00
|
|
|
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
2014-05-02 17:50:30 +02:00
|
|
|
*/
|
|
|
|
public function saveConfigData(array $configData, Player $player) {
|
2014-08-13 11:05:52 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_MC_SETTINGS)
|
2014-08-05 02:17:41 +02:00
|
|
|
) {
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
2014-05-02 17:50:30 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!$configData[3] || strpos($configData[3][0]['Name'], self::ACTION_PREFIX_SETTING) !== 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$prefixLength = strlen(self::ACTION_PREFIX_SETTING);
|
2014-06-15 03:23:44 +02:00
|
|
|
|
2014-05-18 23:35:39 +02:00
|
|
|
foreach ($configData[3] as $settingData) {
|
2014-06-15 03:23:44 +02:00
|
|
|
$settingIndex = (int)substr($settingData['Name'], $prefixLength);
|
2014-08-13 11:05:52 +02:00
|
|
|
$settingObject = $this->maniaControl->getSettingManager()->getSettingObjectByIndex($settingIndex);
|
2014-06-15 03:23:44 +02:00
|
|
|
if (!$settingObject) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
|
2014-06-15 03:23:44 +02:00
|
|
|
if (!$settingData || $settingData['Value'] == $settingObject->value) {
|
2014-05-02 17:50:30 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-06-15 03:23:44 +02:00
|
|
|
$settingObject->value = $settingData['Value'];
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getSettingManager()->saveSetting($settingObject);
|
2014-05-02 17:50:30 +02:00
|
|
|
}
|
|
|
|
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getChat()->sendSuccess('Settings saved!', $player);
|
2014-05-16 20:42:37 +02:00
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
// Reopen the Menu
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getConfigurator()->showMenu($player, $this);
|
2014-05-02 17:50:30 +02:00
|
|
|
}
|
2014-04-30 05:27:23 +02:00
|
|
|
}
|