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: () => {
|
||||
sounds.clear();
|
||||
},
|
||||
forEach: body => {
|
||||
if(typeof body !== 'function')
|
||||
return;
|
||||
sounds.forEach(body);
|
||||
},
|
||||
info: name => getSound(name),
|
||||
names: () => Array.from(sounds.keys()),
|
||||
has: name => sounds.has(name),
|
||||
get: getSound,
|
||||
getSources: getSoundSources,
|
||||
|
|
|
@ -116,6 +116,12 @@ const MamiSoundPacks = function() {
|
|||
return packInfo;
|
||||
};
|
||||
|
||||
const getPack = name => {
|
||||
if(!packs.has(name))
|
||||
throw 'No pack with this name has been registered.';
|
||||
return packs.get(name);
|
||||
};
|
||||
|
||||
return {
|
||||
register: registerPack,
|
||||
unregister: name => {
|
||||
|
@ -124,16 +130,9 @@ const MamiSoundPacks = function() {
|
|||
clear: () => {
|
||||
packs.clear();
|
||||
},
|
||||
forEach: body => {
|
||||
if(typeof body !== 'function')
|
||||
return;
|
||||
packs.forEach(body);
|
||||
},
|
||||
info: name => getPack(name),
|
||||
names: () => Array.from(packs.keys()),
|
||||
has: name => packs.has(name),
|
||||
get: name => {
|
||||
if(!packs.has(name))
|
||||
throw 'No pack with this name has been registered.';
|
||||
return packs.get(name);
|
||||
},
|
||||
get: getPack,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -57,8 +57,7 @@ const MamiDomainTransition = function(onImport, onDismiss) {
|
|||
|
||||
const soundLib = mami.getSoundLibrary();
|
||||
const soundRNG = new MamiRNG();
|
||||
const soundNames = [];
|
||||
soundLib.forEach((info, name) => soundNames.push(name));
|
||||
const soundNames = soundLib.names();
|
||||
|
||||
const playRandomSound = () => soundLib.play(soundNames[soundRNG.next(soundNames.length)]);
|
||||
|
||||
|
|
|
@ -138,10 +138,12 @@ Umi.UI.Settings = (function() {
|
|||
title: 'Sound pack',
|
||||
type: 'select',
|
||||
options: () => {
|
||||
const registry = mami.getSoundPacks();
|
||||
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;
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue