Fixed sound packs dropdown sometimes being empty.
This commit is contained in:
parent
852d64776b
commit
33257e367b
1 changed files with 18 additions and 1 deletions
|
@ -456,12 +456,17 @@ Umi.UI.Settings = (function() {
|
||||||
if(display.disabled === true)
|
if(display.disabled === true)
|
||||||
input.disabled = true;
|
input.disabled = true;
|
||||||
|
|
||||||
if(display.type === 'select') {
|
const updateSelectOptions = () => {
|
||||||
const options = display.options();
|
const options = display.options();
|
||||||
|
$rc(input);
|
||||||
for(const name in options)
|
for(const name in options)
|
||||||
input.appendChild(<option class={['setting__style', `setting__style--${display.name}-${name}`]} value={name}>
|
input.appendChild(<option class={['setting__style', `setting__style--${display.name}-${name}`]} value={name}>
|
||||||
{options[name]}
|
{options[name]}
|
||||||
</option>);
|
</option>);
|
||||||
|
};
|
||||||
|
|
||||||
|
if(display.type === 'select') {
|
||||||
|
updateSelectOptions();
|
||||||
} else if(display.type === 'button') {
|
} else if(display.type === 'button') {
|
||||||
input.value = display.title;
|
input.value = display.title;
|
||||||
input.addEventListener('click', () => {
|
input.addEventListener('click', () => {
|
||||||
|
@ -503,6 +508,18 @@ Umi.UI.Settings = (function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
// hack: do this more gracefully when an actual API for the settings sidebar is exposed
|
||||||
|
// specifically for the sound pack
|
||||||
|
if(display.type === 'select')
|
||||||
|
input.addEventListener('click', () => {
|
||||||
|
if(input.childElementCount > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const value = mami.settings.get(setting.name);
|
||||||
|
updateSelectOptions();
|
||||||
|
input.value = value;
|
||||||
|
});
|
||||||
|
|
||||||
mami.settings.watch(setting.name, ev => input.value = ev.detail.value);
|
mami.settings.watch(setting.name, ev => input.value = ev.detail.value);
|
||||||
input.addEventListener('change', () => mami.settings.set(setting.name, input.value));
|
input.addEventListener('change', () => mami.settings.set(setting.name, input.value));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue