Sound system improvements

- Fix sound ACP uploads
- Display soundpack names with sound files
- Soundpacks can have sounds with identical names
- Link sounds during build step
- Generate map of sound name to file name during build step
- Change how soundpacks work. It's now done via a field in plugin.json
This commit is contained in:
Peter Jaszkowiak
2017-02-16 22:56:25 -07:00
parent fd88e9fdff
commit c75391f9f5
16 changed files with 337 additions and 264 deletions

View File

@@ -37,10 +37,11 @@ module.exports = function (Plugins) {
};
Plugins.prepareForBuild = function (callback) {
Plugins.cssFiles.length = 0;
Plugins.lessFiles.length = 0;
Plugins.clientScripts.length = 0;
Plugins.acpScripts.length = 0;
Plugins.cssFiles = [];
Plugins.lessFiles = [];
Plugins.clientScripts = [];
Plugins.acpScripts = [];
Plugins.soundpacks = [];
async.waterfall([
async.apply(Plugins.getPluginPaths),
@@ -57,6 +58,7 @@ module.exports = function (Plugins) {
async.apply(mapClientSideScripts, pluginData),
async.apply(mapClientModules, pluginData),
async.apply(mapStaticDirectories, pluginData, pluginData.path),
async.apply(mapSoundpack, pluginData),
], next);
}, next);
}
@@ -93,6 +95,9 @@ module.exports = function (Plugins) {
function (next) {
mapClientModules(pluginData, next);
},
function (next) {
mapSoundpack(pluginData, next);
},
], function (err) {
if (err) {
winston.verbose('[plugins] Could not load plugin : ' + pluginData.id);
@@ -251,6 +256,35 @@ module.exports = function (Plugins) {
callback();
}
function mapSoundpack(pluginData, callback) {
var soundpack = pluginData.soundpack;
if (!soundpack || !soundpack.dir || !soundpack.sounds) {
return callback();
}
soundpack.name = soundpack.name || pluginData.name;
soundpack.id = pluginData.id;
soundpack.dir = path.join(pluginData.path, soundpack.dir);
async.each(Object.keys(soundpack.sounds), function (key, next) {
file.exists(path.join(soundpack.dir, soundpack.sounds[key]), function (exists) {
if (!exists) {
delete soundpack.sounds[key];
}
next();
});
}, function (err) {
if (err) {
return callback(err);
}
if (Object.keys(soundpack.sounds).length) {
Plugins.soundpacks.push(soundpack);
}
callback();
});
}
function resolveModulePath(fullPath, relPath) {
/**
* With npm@3, dependencies can become flattened, and appear at the root level.