Fixed sound packs dropdown sometimes being empty.

This commit is contained in:
flash 2024-04-23 15:01:18 +00:00
parent 852d64776b
commit 33257e367b

View file

@ -456,12 +456,17 @@ Umi.UI.Settings = (function() {
if(display.disabled === true)
input.disabled = true;
if(display.type === 'select') {
const updateSelectOptions = () => {
const options = display.options();
$rc(input);
for(const name in options)
input.appendChild(<option class={['setting__style', `setting__style--${display.name}-${name}`]} value={name}>
{options[name]}
</option>);
};
if(display.type === 'select') {
updateSelectOptions();
} else if(display.type === 'button') {
input.value = display.title;
input.addEventListener('click', () => {
@ -503,6 +508,18 @@ Umi.UI.Settings = (function() {
}
});
} 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);
input.addEventListener('change', () => mami.settings.set(setting.name, input.value));
}