diff --git a/game/game.js b/game/game.js index e4c0159ba..7a110467a 100644 --- a/game/game.js +++ b/game/game.js @@ -8337,15 +8337,23 @@ if(!arrayLengths.length) return previousValue+1; return previousValue+Math.min(...arrayLengths); },0); - const packLoaded=()=>{ + const packLoaded=gnc.async(function*(){ toLoad--; if(toLoad) return; + if(_status.importing){ + let promises=lib.creation.a; + for(const type in _status.importing){ + promises.addArray(_status.importing[type]) + } + yield Promise.allSettled(promises); + delete _status.importing; + } if(_status.windowLoaded){ delete _status.windowLoaded; lib.init.onload(); } else _status.packLoaded=true; - }; + }); if(localStorage.getItem(`${lib.configprefix}playback`)){ toLoad++; lib.init.js(`${lib.assetURL}mode`,lib.config.mode,packLoaded,packLoaded); @@ -9733,7 +9741,7 @@ try{ _status.extension=lib.extensions[i][0]; _status.evaluatingExtension=lib.extensions[i][3]; - if (typeof lib.extensions[i][1]=="function") yield lib.extensions[i][1](lib.extensions[i][2],lib.extensions[i][4]); + if (typeof lib.extensions[i][1]=="function") yield gnc.await(lib.extensions[i][1](lib.extensions[i][2],lib.extensions[i][4])); if(lib.extensions[i][4]){ if(lib.extensions[i][4].character){ for(var j in lib.extensions[i][4].character.character){ @@ -33488,30 +33496,30 @@ } }, import:function(type,content){ - const asyncFn=gnc.async(function*(){ - if(type=='extension'){ - yield game.loadExtension(content); - } - else{ - if(!lib.imported[type]){ - lib.imported[type]={}; - } - var content2=yield content(lib,game,ui,get,ai,_status); + if(type=='extension'){ + if(typeof _status.extensionLoading=="undefined")_status.extensionLoading=[]; + const promise=game.loadExtension(content); + _status.extensionLoading.add(promise); + return promise; + } + else{ + if(!lib.imported[type])lib.imported[type]={}; + if(typeof _status.importing=="undefined")_status.importing={}; + if(!_status.importing[type])_status.importing[type]=[]; + const promise=gnc.await(content(lib,game,ui,get,ai,_status)).then(content2=>{ if(content2.name){ lib.imported[type][content2.name]=content2; delete content2.name; } - } - }); - if(typeof _status.extensionLoading=="undefined")_status.extensionLoading=[]; - const promise=asyncFn(); - _status.extensionLoading.add(promise); - return promise; + }); + _status.importing[type].add(promise); + return promise; + } }, loadExtension:gnc.async(function*(obj){ var noeval=false; if(typeof obj=='function'){ - obj=yield obj(lib,game,ui,get,ai,_status); + obj=yield gnc.await(obj(lib,game,ui,get,ai,_status)); noeval=true; } lib.extensionMenu['extension_'+obj.name]={ @@ -33629,7 +33637,7 @@ } if(obj.precontent){ _status.extension=obj.name; - yield obj.precontent(cfg); + yield gnc.await(obj.precontent(cfg)); delete _status.extension; } if(obj.content){ diff --git a/mode/identity.js b/mode/identity.js index 8ec7f6943..50eb32c45 100644 --- a/mode/identity.js +++ b/mode/identity.js @@ -134,7 +134,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ step4(); } }; - var step4=lib.genAsync(function*(){ + var step4=lib.gnc.async(function*(){ clear(); ui.window.classList.add('noclick_important'); ui.click.configMenu();