Added buttons to reload sound packs and libraries.

This commit is contained in:
flash 2024-04-23 15:32:28 +00:00
parent 33257e367b
commit f82785a9cb
3 changed files with 67 additions and 43 deletions

View file

@ -32,8 +32,6 @@ const MamiSoundLibrary = function(soundMgr) {
throw 'soundInfo must contain a name field';
if(typeof soundInfo.sources !== 'object')
throw 'soundInfo must contain a sources field';
if(sounds.has(soundInfo.name))
throw 'a sound with that name has already been registered';
let sources = {},
sCount = 0;

View file

@ -71,8 +71,6 @@ const MamiSoundPacks = function() {
throw 'packInfo must contain a name field';
if(typeof packInfo.events !== 'object')
throw 'packInfo must contain a events field';
if(packs.has(packInfo.name))
throw 'a pack with that name has already been registered';
const events = new Map;
for(const eventName in packInfo.events) {

View file

@ -270,49 +270,17 @@ Umi.UI.Settings = (function() {
title: 'Messages to keep on clear',
type: 'number',
},
{
title: 'Reload emoticons',
type: 'button',
invoke: button => {
const emotes = futami.get('emotes');
setTimeout(() => {
button.disabled = true;
futami.getJson('emotes', true)
.then(emotes => {
MamiEmotes.clear();
MamiEmotes.loadLegacy(emotes);
})
.finally(() => {
Umi.UI.Emoticons.Init();
button.disabled = false;
});
}, 200);
},
},
{
title: 'Reload joke triggers',
type: 'button',
invoke: button => {
button.disabled = true;
const triggers = mami.textTriggers;
triggers.clearTriggers();
if(mami.settings.get('playJokeSounds'))
futami.getJson('texttriggers', true)
.then(trigInfos => triggers.addTriggers(trigInfos))
.finally(() => button.disabled = false);
},
},
],
},
{
name: 'actions',
title: 'Actions',
items: [
{
title: 'Open compatibility client',
type: 'button',
invoke: () => {
const meow = $e('a', { href: window.AMI_URL, target: '_blank', style: { display: 'none' } });
document.body.appendChild(meow);
meow.click();
$r(meow);
window.open(window.AMI_URL, '_blank', 'noopener');
},
},
{
@ -337,6 +305,66 @@ Umi.UI.Settings = (function() {
}
},
},
{
title: 'Reload emoticons',
type: 'button',
invoke: async button => {
const textOrig = button.value;
button.disabled = true;
button.value = 'Reloading emoticons...';
try {
const emotes = await futami.getJson('emotes', true);
MamiEmotes.clear();
MamiEmotes.loadLegacy(emotes);
} finally {
Umi.UI.Emoticons.Init();
button.value = textOrig;
button.disabled = false;
}
},
},
{
title: 'Reload sound library',
type: 'button',
invoke: async button => {
const textOrig = button.value;
button.disabled = true;
button.value = 'Reloading sound library...';
try {
const sounds = await futami.getJson('sounds2');
if(Array.isArray(sounds.library))
mami.sound.library.register(sounds.library, true);
if(Array.isArray(sounds.packs)) {
mami.sound.packs.register(sounds.packs, true);
mami.settings.touch('soundPack', true);
}
} finally {
button.value = textOrig;
button.disabled = false;
}
},
},
{
title: 'Reload joke triggers',
type: 'button',
invoke: async button => {
const textOrig = button.value;
button.disabled = true;
button.value = 'Reloading joke triggers...';
try {
const triggers = await futami.getJson('texttriggers', true);
mami.textTriggers.clearTriggers();
mami.textTriggers.addTriggers(triggers)
} finally {
button.value = textOrig;
button.disabled = false;
}
},
},
],
},
{