plugin settings menu fml value picker
This commit is contained in:
parent
7488e83cb5
commit
f6ac379dc0
@ -307,10 +307,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the Config Data
|
||||
*
|
||||
* @param array $configData
|
||||
* @param Player $player
|
||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
||||
*/
|
||||
public function saveConfigData(array $configData, Player $player) {
|
||||
if (!$this->maniaControl->authenticationManager->checkPermission($player, self::SETTING_PERMISSION_CHANGE_MC_SETTINGS)) {
|
||||
@ -322,16 +319,20 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
}
|
||||
|
||||
$prefixLength = strlen(self::ACTION_PREFIX_SETTING);
|
||||
foreach ($configData[3] as $settingData) {
|
||||
$settingIndex = substr($settingData['Name'], $prefixLength);
|
||||
$setting = $this->maniaControl->settingManager->getSettingObjectByIndex($settingIndex);
|
||||
|
||||
if (!$setting || $settingData['Value'] == $setting->value) {
|
||||
foreach ($configData[3] as $settingData) {
|
||||
$settingIndex = (int)substr($settingData['Name'], $prefixLength);
|
||||
$settingObject = $this->maniaControl->settingManager->getSettingObjectByIndex($settingIndex);
|
||||
if (!$settingObject) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$setting->value = $settingData['Value'];
|
||||
$this->maniaControl->settingManager->saveSetting($setting);
|
||||
if (!$settingData || $settingData['Value'] == $settingObject->value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$settingObject->value = $settingData['Value'];
|
||||
$this->maniaControl->settingManager->saveSetting($settingObject);
|
||||
}
|
||||
|
||||
$this->maniaControl->chat->sendSuccess('Settings saved!', $player);
|
||||
@ -342,9 +343,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Menu Title
|
||||
*
|
||||
* @return string
|
||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::getTitle()
|
||||
*/
|
||||
public function getTitle() {
|
||||
return self::TITLE;
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace ManiaControl\Plugins;
|
||||
|
||||
use FML\Components\CheckBox;
|
||||
use FML\Components\ValuePicker;
|
||||
use FML\Controls\Control;
|
||||
use FML\Controls\Entry;
|
||||
use FML\Controls\Frame;
|
||||
@ -296,14 +297,23 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$quad->setSize(4, 4);
|
||||
$checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $setting->index, $setting->value, $quad);
|
||||
$settingFrame->add($checkBox);
|
||||
} 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(self::ACTION_PREFIX_SETTING . $setting->index, $setting->set, $setting->value, $label);
|
||||
$settingFrame->add($valuePicker);
|
||||
} else {
|
||||
// Value entry
|
||||
$entry = new Entry();
|
||||
$settingFrame->add($entry);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setX($width / 2 * 0.65);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setX($width * 0.33);
|
||||
$entry->setSize($width * 0.3, $settingHeight * 0.9);
|
||||
$entry->setTextSize(1);
|
||||
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
|
||||
$entry->setName(self::ACTION_PREFIX_SETTING . $setting->index);
|
||||
$entry->setDefault($setting->value);
|
||||
}
|
||||
@ -390,19 +400,18 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
|
||||
$prefixLength = strlen(self::ACTION_PREFIX_SETTING);
|
||||
|
||||
foreach ($configData[3] as $setting) {
|
||||
$settingIndex = (int)substr($setting['Name'], $prefixLength);
|
||||
|
||||
foreach ($configData[3] as $settingData) {
|
||||
$settingIndex = (int)substr($settingData['Name'], $prefixLength);
|
||||
$settingObject = $this->maniaControl->settingManager->getSettingObjectByIndex($settingIndex);
|
||||
if (!$settingObject) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($setting['Value'] == $settingObject->value) {
|
||||
if (!$settingData || $settingData['Value'] == $settingObject->value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$settingObject->value = $setting['Value'];
|
||||
$settingObject->value = $settingData['Value'];
|
||||
$this->maniaControl->settingManager->saveSetting($settingObject);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user