mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 12:36:02 +01:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user