Fix currentcolors on sprites with many frames

This commit is contained in:
jdescottes 2015-04-29 04:00:46 +02:00
parent ce8d71f47e
commit ac9ccd04e2
2 changed files with 23 additions and 6 deletions

View File

@ -10,7 +10,7 @@ SETLOCAL
set MISC_FOLDER=%PISKEL_HOME%\misc set MISC_FOLDER=%PISKEL_HOME%\misc
set RELEASES_FOLDER=%PISKEL_HOME%\dest\desktop set RELEASES_FOLDER=%PISKEL_HOME%\dest\desktop
set DEST_FOLDER=%RELEASES_FOLDER%\piskel\win64 set DEST_FOLDER=%RELEASES_FOLDER%\piskel\win32
ECHO "Updating Piskel icon -- Using Resource Hacker" ECHO "Updating Piskel icon -- Using Resource Hacker"
%RESOURCE_HACKER_PATH%\ResHacker -addoverwrite "%DEST_FOLDER%\piskel.exe", "%DEST_FOLDER%\piskel-logo.exe", "%MISC_FOLDER%\desktop\logo.ico", ICONGROUP, IDR_MAINFRAME, 1033 %RESOURCE_HACKER_PATH%\ResHacker -addoverwrite "%DEST_FOLDER%\piskel.exe", "%DEST_FOLDER%\piskel-logo.exe", "%MISC_FOLDER%\desktop\logo.ico", ICONGROUP, IDR_MAINFRAME, 1033

View File

@ -48,15 +48,32 @@
} }
}; };
var batchAll = function (frames, job) {
var batches = [];
frames = frames.slice(0);
while (frames.length) {
batches.push(frames.splice(0, 10));
}
var result = Q([]);
batches.forEach(function (batch) {
result = result.then(function (results) {
return Q.all(batch.map(job)).then(function (partials) {
return results.concat(partials);
});
});
});
return result;
};
ns.CurrentColorsService.prototype.updateCurrentColors_ = function () { ns.CurrentColorsService.prototype.updateCurrentColors_ = function () {
var layers = this.piskelController.getLayers(); var layers = this.piskelController.getLayers();
var frames = layers.map(function (l) {return l.getFrames();}).reduce(function (p, n) {return p.concat(n);}); var frames = layers.map(function (l) {return l.getFrames();}).reduce(function (p, n) {return p.concat(n);});
Q.all( var job = function (frame) {
frames.map(function (frame) { return this.cachedFrameProcessor.get(frame);
return this.cachedFrameProcessor.get(frame); }.bind(this);
}.bind(this))
).done(function (results) { batchAll(frames, job).then(function (results) {
var colors = {}; var colors = {};
results.forEach(function (result) { results.forEach(function (result) {
Object.keys(result).forEach(function (color) { Object.keys(result).forEach(function (color) {