From 29c90cc3d8a9a752cecec492b271804651b1e6bc Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 28 Oct 2020 08:44:10 +0100 Subject: [PATCH] tweaked wait-until-assets-are-loaded mechanism --- HISTORY.md | 9 ++++++--- snap.html | 2 +- src/gui.js | 12 +++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index e43f8c81..2ee6de9d 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -8,19 +8,22 @@ * added getProjectXML() method to the API * new noCloud flag that disables cloud access, thanks, Bernat * **Notable Changes:** - * security: pause generic WHEN hat blocks when loading a project or importing a sprite until the user clicks the green flag or un-pauses the red stop sign, unless opening it with #run:&noRun + * security: pause generic WHEN hat blocks when loading a project or importing a sprite until the user clicks the green flag or un-pauses the red stop sign, unless opening it with #present:&noRun * **Documentation Updates:** * API update * **Notable Fixes:** * fixed a translation bug for zero-value menu selection entries - * wait until all assets have loaded before auto-triggering the green-flag event, not on - sigh - Safari + * wait until all assets have loaded before auto-triggering the green-flag event * don't show some development-only blocks as search results * **Translation Updates:** * Russian, thanks, Pavel! * German +### 2020-10-28 +* gui: tweaked wait-until-assets-are-loaded mechanism + ### 2020-10-27 -* gui, objects, store: pause generic WHEN hat blocks when loading a project or importing a sprite until the user clicks the green flag or un-pauses the red stop sign, unless opening it with #run:&noRun +* gui, objects, store: pause generic WHEN hat blocks when loading a project or importing a sprite until the user clicks the green flag or un-pauses the red stop sign, unless opening it with #present:&noRun * morphic: prevent unclosable menus, thanks, Brian B.! ### 2020-10-26 diff --git a/snap.html b/snap.html index bbe5cfae..1810060e 100755 --- a/snap.html +++ b/snap.html @@ -11,7 +11,7 @@ - + diff --git a/src/gui.js b/src/gui.js index ff52a735..fa97237d 100644 --- a/src/gui.js +++ b/src/gui.js @@ -78,7 +78,7 @@ Animation, BoxMorph, BlockEditorMorph, BlockDialogMorph, Note, ZERO, BLACK*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2020-October-27'; +modules.gui = '2020-October-28'; // Declarations @@ -370,21 +370,19 @@ IDE_Morph.prototype.openIn = function (world) { } function autoRun () { - // wait until all costumes are loaded + // wait until all costumes and sounds are loaded if (isLoadingAssets()) { myself.world().animations.push( new Animation(nop, nop, 0, 200, nop, autoRun) ); } else { - // wait a few more frames for the sprites to wear their costumes - myself.world().animations.push( - new Animation(nop, nop, 0, 200, nop, () => myself.runScripts()) - ); + myself.runScripts(); } } function isLoadingAssets() { - myself.sprites.asArray().concat([myself.stage]).some(any => + return myself.sprites.asArray().concat([myself.stage]).some(any => + (any.costume ? any.costume.loaded !== true : false) || any.costumes.asArray().some(each => each.loaded !== true) || any.sounds.asArray().some(each => each.loaded !== true) );