async.
This commit is contained in:
parent
d3a575900d
commit
e7d5a64b76
52
game/game.js
52
game/game.js
|
@ -8415,13 +8415,16 @@
|
||||||
styleToLoad--;
|
styleToLoad--;
|
||||||
if(styleToLoad==0){
|
if(styleToLoad==0){
|
||||||
if(extensionlist.length&&(lib.config.mode!='connect'||show_splash)){
|
if(extensionlist.length&&(lib.config.mode!='connect'||show_splash)){
|
||||||
var extToLoad=extensionlist.length;
|
_status.extensionLoading=[];
|
||||||
var extLoaded=function(){
|
let extToLoad=extensionlist.length;
|
||||||
extToLoad--;
|
const extLoaded=gnc.async(function*(){
|
||||||
|
--extToLoad;
|
||||||
if(extToLoad==0){
|
if(extToLoad==0){
|
||||||
|
yield Promise.allSettled(_status.extensionLoading);
|
||||||
|
delete _status.extensionLoading;
|
||||||
loadPack();
|
loadPack();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
//读取扩展
|
//读取扩展
|
||||||
var alerted=false;
|
var alerted=false;
|
||||||
for(var i=0;i<extensionlist.length;i++){
|
for(var i=0;i<extensionlist.length;i++){
|
||||||
|
@ -9695,7 +9698,7 @@
|
||||||
try{
|
try{
|
||||||
_status.extension=lib.extensions[i][0];
|
_status.extension=lib.extensions[i][0];
|
||||||
_status.evaluatingExtension=lib.extensions[i][3];
|
_status.evaluatingExtension=lib.extensions[i][3];
|
||||||
if (typeof lib.extensions[i][1]=="function") lib.extensions[i][1](lib.extensions[i][2],lib.extensions[i][4]);
|
if (typeof lib.extensions[i][1]=="function") yield lib.extensions[i][1](lib.extensions[i][2],lib.extensions[i][4]);
|
||||||
if(lib.extensions[i][4]){
|
if(lib.extensions[i][4]){
|
||||||
if(lib.extensions[i][4].character){
|
if(lib.extensions[i][4].character){
|
||||||
for(var j in lib.extensions[i][4].character.character){
|
for(var j in lib.extensions[i][4].character.character){
|
||||||
|
@ -33448,27 +33451,30 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
import:function(type,content){
|
import:function(type,content){
|
||||||
if(type=='extension'){
|
const asyncFn=gnc.async(function*(){
|
||||||
//Anti-Cheat system updated, no need to work here
|
if(type=='extension'){
|
||||||
//var backup_onload=lib.init.onload;
|
yield game.loadExtension(content);
|
||||||
game.loadExtension(content);
|
|
||||||
//lib.init.onload=backup_onload;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(!lib.imported[type]){
|
|
||||||
lib.imported[type]={};
|
|
||||||
}
|
}
|
||||||
var content2=content(lib,game,ui,get,ai,_status);
|
else{
|
||||||
if(content2.name){
|
if(!lib.imported[type]){
|
||||||
lib.imported[type][content2.name]=content2;
|
lib.imported[type]={};
|
||||||
delete content2.name;
|
}
|
||||||
|
var content2=yield content(lib,game,ui,get,ai,_status);
|
||||||
|
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;
|
||||||
},
|
},
|
||||||
loadExtension:function(obj){
|
loadExtension:gnc.async(function*(obj){
|
||||||
var noeval=false;
|
var noeval=false;
|
||||||
if(typeof obj=='function'){
|
if(typeof obj=='function'){
|
||||||
obj=obj(lib,game,ui,get,ai,_status);
|
obj=yield obj(lib,game,ui,get,ai,_status);
|
||||||
noeval=true;
|
noeval=true;
|
||||||
}
|
}
|
||||||
lib.extensionMenu['extension_'+obj.name]={
|
lib.extensionMenu['extension_'+obj.name]={
|
||||||
|
@ -33586,7 +33592,7 @@
|
||||||
}
|
}
|
||||||
if(obj.precontent){
|
if(obj.precontent){
|
||||||
_status.extension=obj.name;
|
_status.extension=obj.name;
|
||||||
obj.precontent(cfg);
|
yield obj.precontent(cfg);
|
||||||
delete _status.extension;
|
delete _status.extension;
|
||||||
}
|
}
|
||||||
if(obj.content){
|
if(obj.content){
|
||||||
|
@ -33601,7 +33607,7 @@
|
||||||
else{
|
else{
|
||||||
game.importedPack=obj;
|
game.importedPack=obj;
|
||||||
}
|
}
|
||||||
},
|
}),
|
||||||
createDir:function(dir,success,error){
|
createDir:function(dir,success,error){
|
||||||
var nullFC=function(){};
|
var nullFC=function(){};
|
||||||
success=success||nullFC;
|
success=success||nullFC;
|
||||||
|
|
Loading…
Reference in New Issue