Merge pull request #316 from nofficalfs/PR-Purify-ImportFix

[Purify] `game.import` fused of `lib.gnc`.
This commit is contained in:
Spmario233 2023-09-11 19:04:19 +08:00 committed by GitHub
commit 4dcec776da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 21 deletions

View File

@ -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){

View File

@ -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();