Removed forEach methods from sounds and packs registries.
This commit is contained in:
parent
af09fc7716
commit
11fe3ebcd1
4 changed files with 17 additions and 20 deletions
|
@ -70,11 +70,8 @@ const MamiSoundLibrary = function(soundMgr) {
|
||||||
clear: () => {
|
clear: () => {
|
||||||
sounds.clear();
|
sounds.clear();
|
||||||
},
|
},
|
||||||
forEach: body => {
|
info: name => getSound(name),
|
||||||
if(typeof body !== 'function')
|
names: () => Array.from(sounds.keys()),
|
||||||
return;
|
|
||||||
sounds.forEach(body);
|
|
||||||
},
|
|
||||||
has: name => sounds.has(name),
|
has: name => sounds.has(name),
|
||||||
get: getSound,
|
get: getSound,
|
||||||
getSources: getSoundSources,
|
getSources: getSoundSources,
|
||||||
|
|
|
@ -116,6 +116,12 @@ const MamiSoundPacks = function() {
|
||||||
return packInfo;
|
return packInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getPack = name => {
|
||||||
|
if(!packs.has(name))
|
||||||
|
throw 'No pack with this name has been registered.';
|
||||||
|
return packs.get(name);
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
register: registerPack,
|
register: registerPack,
|
||||||
unregister: name => {
|
unregister: name => {
|
||||||
|
@ -124,16 +130,9 @@ const MamiSoundPacks = function() {
|
||||||
clear: () => {
|
clear: () => {
|
||||||
packs.clear();
|
packs.clear();
|
||||||
},
|
},
|
||||||
forEach: body => {
|
info: name => getPack(name),
|
||||||
if(typeof body !== 'function')
|
names: () => Array.from(packs.keys()),
|
||||||
return;
|
|
||||||
packs.forEach(body);
|
|
||||||
},
|
|
||||||
has: name => packs.has(name),
|
has: name => packs.has(name),
|
||||||
get: name => {
|
get: getPack,
|
||||||
if(!packs.has(name))
|
|
||||||
throw 'No pack with this name has been registered.';
|
|
||||||
return packs.get(name);
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,8 +57,7 @@ const MamiDomainTransition = function(onImport, onDismiss) {
|
||||||
|
|
||||||
const soundLib = mami.getSoundLibrary();
|
const soundLib = mami.getSoundLibrary();
|
||||||
const soundRNG = new MamiRNG();
|
const soundRNG = new MamiRNG();
|
||||||
const soundNames = [];
|
const soundNames = soundLib.names();
|
||||||
soundLib.forEach((info, name) => soundNames.push(name));
|
|
||||||
|
|
||||||
const playRandomSound = () => soundLib.play(soundNames[soundRNG.next(soundNames.length)]);
|
const playRandomSound = () => soundLib.play(soundNames[soundRNG.next(soundNames.length)]);
|
||||||
|
|
||||||
|
|
|
@ -138,10 +138,12 @@ Umi.UI.Settings = (function() {
|
||||||
title: 'Sound pack',
|
title: 'Sound pack',
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: () => {
|
options: () => {
|
||||||
|
const registry = mami.getSoundPacks();
|
||||||
const packs = {};
|
const packs = {};
|
||||||
mami.getSoundPacks().forEach(function(pack) {
|
|
||||||
packs[pack.getName()] = pack.getTitle();
|
for(const name of registry.names())
|
||||||
});
|
packs[name] = registry.info(name).getTitle();
|
||||||
|
|
||||||
return packs;
|
return packs;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue