slashcommand /movingui to set a MUI preset

This commit is contained in:
RossAscends 2023-11-23 22:32:47 +09:00
parent 4f7c925dc6
commit 73d6801406
1 changed files with 23 additions and 0 deletions

View File

@ -2352,6 +2352,28 @@ async function setThemeCallback(_, text) {
saveSettingsDebounced();
}
async function setmovingUIPreset(_, text) {
const fuse = new Fuse(movingUIPresets, {
keys: [
{ name: 'name', weight: 1 },
],
});
const results = fuse.search(text);
console.debug('movingUI preset fuzzy search results for ' + text, results);
const preset = results[0]?.item;
if (!preset) {
toastr.warning(`Could not find preset with name: ${text}`);
return;
}
power_user.movingUIPreset = preset.name;
applyMovingUIPreset(preset.name);
$("#movingUIPresets").val(preset.name);
saveSettingsDebounced();
}
/**
* Gets the custom stopping strings from the power user settings.
* @param {number | undefined} limit Number of strings to return. If 0 or undefined, returns all strings.
@ -3027,4 +3049,5 @@ $(document).ready(() => {
registerSlashCommand('resetpanels', doResetPanels, ['resetui'], ' resets UI panels to original state.', true, true);
registerSlashCommand('bgcol', setAvgBG, [], ' WIP test of auto-bg avg coloring', true, true);
registerSlashCommand('theme', setThemeCallback, [], '<span class="monospace">(name)</span> sets a UI theme by name', true, true);
registerSlashCommand('movingui', setmovingUIPreset, [], '<span class="monospace">(name)</span> activates a movingUI preset by name', true, true);
});