Fix favorite mode related code.
This commit is contained in:
parent
29645b8414
commit
94874588cf
64
game/game.js
64
game/game.js
|
@ -48085,48 +48085,37 @@
|
||||||
ui.shortcut.autobutton.dataset.position=2;
|
ui.shortcut.autobutton.dataset.position=2;
|
||||||
ui.favmodelist=ui.create.div('.favmodelist',ui.shortcut);
|
ui.favmodelist=ui.create.div('.favmodelist',ui.shortcut);
|
||||||
ui.favmodelist.update=function(){
|
ui.favmodelist.update=function(){
|
||||||
|
const favouriteMode=lib.config.favouriteMode;
|
||||||
|
let removed=false;
|
||||||
|
for(let index=0;index<favouriteMode.length;index++){
|
||||||
|
if(typeof favouriteMode[index]=='string') continue;
|
||||||
|
favouriteMode.splice(index--,1);
|
||||||
|
if(!removed) removed=true;
|
||||||
|
}
|
||||||
|
if(removed) game.saveConfigValue('favouriteMode');
|
||||||
this.innerHTML='';
|
this.innerHTML='';
|
||||||
var num=Math.min(6,lib.config.favouriteMode.length);
|
favouriteMode.slice(0,6).forEach((value,index)=>this.add(value,index));
|
||||||
for(var i=0;i<num;i++){
|
let mode=lib.config.mode;
|
||||||
this.add(lib.config.favouriteMode[i],i);
|
const config=get.config(`${mode}_mode`);
|
||||||
}
|
if(typeof config=='string') mode+=`|${config}`;
|
||||||
var mode=get.mode();
|
if(favouriteMode.contains(mode)) ui.favmode.classList.add('glow');
|
||||||
if(typeof get.config(mode+'_mode')=='string'){
|
else ui.favmode.classList.remove('glow');
|
||||||
mode+='|'+get.config(mode+'_mode');
|
|
||||||
}
|
|
||||||
if(lib.config.favouriteMode.contains(mode)){
|
|
||||||
ui.favmode.classList.add('glow');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
ui.favmode.classList.remove('glow');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
ui.favmodelist.add=function(name,index){
|
ui.favmodelist.add=function(name,index){
|
||||||
var info=name.split('|');
|
const info=name.split('|'),mode=info[0],submode=info[1],node=ui.create.div('.menubutton.large',this),dataset=node.dataset;
|
||||||
var mode=info[0];
|
dataset.type=Math.min(6,lib.config.favouriteMode.length)%2==0?'even':'odd';
|
||||||
var submode=info[1];
|
dataset.position=index;
|
||||||
var node=ui.create.div('.menubutton.large',this);
|
let str=lib.translate[name]||lib.translate[mode]||'';
|
||||||
var num=Math.min(6,lib.config.favouriteMode.length);
|
if(str.length==2) str+='模式';
|
||||||
node.dataset.type=num%2==0?'even':'odd';
|
|
||||||
node.dataset.position=index;
|
|
||||||
var str=lib.translate[name]||lib.translate[mode]||'';
|
|
||||||
if(str.length==2){
|
|
||||||
str+='模式';
|
|
||||||
}
|
|
||||||
node.innerHTML=str;
|
node.innerHTML=str;
|
||||||
node.listen(function(){
|
node.listen(()=>{
|
||||||
game.saveConfig('mode',mode);
|
game.saveConfig('mode',mode);
|
||||||
if(submode){
|
if(submode) game.saveConfig(`${mode}_mode`,submode,mode);
|
||||||
game.saveConfig(mode+'_mode',submode,mode);
|
|
||||||
}
|
|
||||||
game.reload();
|
game.reload();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
ui.favmode=ui.create.system('收藏',function(){
|
ui.favmode=ui.create.system('收藏',function(){
|
||||||
var mode=get.mode();
|
const mode=typeof _status.mode=='string'?`${lib.config.mode}|${_status.mode}`:lib.config.mode;
|
||||||
if(typeof _status.mode=='string'){
|
|
||||||
mode+='|'+_status.mode;
|
|
||||||
}
|
|
||||||
if(this.classList.contains('glow')){
|
if(this.classList.contains('glow')){
|
||||||
this.classList.remove('glow');
|
this.classList.remove('glow');
|
||||||
lib.config.favouriteMode.remove(mode);
|
lib.config.favouriteMode.remove(mode);
|
||||||
|
@ -54225,14 +54214,7 @@
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
mode:function(){
|
mode:()=>lib[_status.connectMode?'configOL':'config'].mode,
|
||||||
if(_status.connectMode){
|
|
||||||
return lib.configOL.mode;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return lib.config.mode;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
idDialog:function(id){
|
idDialog:function(id){
|
||||||
for(var i=0;i<ui.dialogs.length;i++){
|
for(var i=0;i<ui.dialogs.length;i++){
|
||||||
if(ui.dialogs[i].videoId==id){
|
if(ui.dialogs[i].videoId==id){
|
||||||
|
|
Loading…
Reference in New Issue