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