improved plugin settings saving
This commit is contained in:
parent
b92b592900
commit
8b89289784
@ -36,7 +36,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
|||||||
const ACTION_PREFIX_ENABLEPLUGIN = 'PluginMenu.Enable.';
|
const ACTION_PREFIX_ENABLEPLUGIN = 'PluginMenu.Enable.';
|
||||||
const ACTION_PREFIX_DISABLEPLUGIN = 'PluginMenu.Disable.';
|
const ACTION_PREFIX_DISABLEPLUGIN = 'PluginMenu.Disable.';
|
||||||
const ACTION_PREFIX_SETTINGS = 'PluginMenu.Settings.';
|
const ACTION_PREFIX_SETTINGS = 'PluginMenu.Settings.';
|
||||||
const ACTION_PREFIX_SETTING = 'PluginMenuSetting';
|
const ACTION_PREFIX_SETTING = 'PluginMenuSetting.';
|
||||||
const ACTION_SETTING_BOOL = 'PluginMenuActionBoolSetting.';
|
const ACTION_SETTING_BOOL = 'PluginMenuActionBoolSetting.';
|
||||||
const ACTION_BACK_TO_PLUGINS = 'PluginMenu.BackToPlugins';
|
const ACTION_BACK_TO_PLUGINS = 'PluginMenu.BackToPlugins';
|
||||||
const ACTION_PREFIX_UPDATEPLUGIN = 'PluginMenu.Update.';
|
const ACTION_PREFIX_UPDATEPLUGIN = 'PluginMenu.Update.';
|
||||||
@ -305,10 +305,9 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
|||||||
$entry->setX($width / 2 * 0.65);
|
$entry->setX($width / 2 * 0.65);
|
||||||
$entry->setTextSize(1);
|
$entry->setTextSize(1);
|
||||||
$entry->setSize($width * 0.3, $settingHeight * 0.9);
|
$entry->setSize($width * 0.3, $settingHeight * 0.9);
|
||||||
$entry->setName(self::ACTION_PREFIX_SETTING . '.' . $setting->index);
|
$entry->setName(self::ACTION_PREFIX_SETTING . $setting->index);
|
||||||
$entry->setDefault($setting->value);
|
$entry->setDefault($setting->value);
|
||||||
|
|
||||||
|
|
||||||
if ($setting->type === Setting::TYPE_BOOL) {
|
if ($setting->type === Setting::TYPE_BOOL) {
|
||||||
if ($setting->value) {
|
if ($setting->value) {
|
||||||
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
$substyle = Quad_Icons64x64_1::SUBSTYLE_LvlGreen;
|
||||||
@ -438,23 +437,22 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$maniaControlSettings = $this->maniaControl->settingManager->getSettings();
|
|
||||||
|
|
||||||
$prefixLength = strlen(self::ACTION_PREFIX_SETTING);
|
$prefixLength = strlen(self::ACTION_PREFIX_SETTING);
|
||||||
|
|
||||||
foreach ($configData[3] as $setting) {
|
foreach ($configData[3] as $setting) {
|
||||||
$settingName = substr($setting['Name'], $prefixLength + 1);
|
$settingIndex = (int)substr($setting['Name'], $prefixLength);
|
||||||
|
|
||||||
if (!isset($maniaControlSettings[$settingName])) {
|
$settingObject = $this->maniaControl->settingManager->getSettingObjectByIndex($settingIndex);
|
||||||
|
if (!$settingObject) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldSetting = $maniaControlSettings[$settingName];
|
if ($setting['Value'] == $settingObject->value || $settingObject->type === $setting::TYPE_BOOL) {
|
||||||
if ($setting['Value'] == $oldSetting->value || $oldSetting->type == 'bool') {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->maniaControl->settingManager->setSetting($oldSetting->class, $oldSetting->setting, $setting['Value']);
|
$settingObject->value = $setting['Value'];
|
||||||
|
$this->maniaControl->settingManager->saveSetting($settingObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->maniaControl->chat->sendSuccess('Plugin Settings saved!', $player);
|
$this->maniaControl->chat->sendSuccess('Plugin Settings saved!', $player);
|
||||||
|
Loading…
Reference in New Issue
Block a user