diff --git a/game/game.js b/game/game.js index dd6d76fa5..c514de2df 100644 --- a/game/game.js +++ b/game/game.js @@ -39342,7 +39342,11 @@ active.link.remove(); active=this; this.classList.add('active'); - rightPane.appendChild(this.link); + if(this.link) rightPane.appendChild(this.link); + else{ + this._initLink(); + rightPane.appendChild(this.link); + } if(connectMenu){ if(updateActive) updateActive(); if(updateActiveCard) updateActiveCard(); @@ -39353,198 +39357,201 @@ var info=lib.mode[mode]; var page=ui.create.div(''); var node=ui.create.div('.menubutton.large',info.name,position,clickMode); - node.link=page; - node.mode=mode; - if(connectMenu){ - if(mode==lib.config.connect_mode){ - node.classList.add('active'); - } - } - else{ - if(mode==lib.config.mode){ - node.classList.add('active'); - } - } - var map={}; - var infoconfig=connectMenu?info.connect:info.config; - if(infoconfig){ - var hiddenNodes=[]; - var config=lib.config.mode_config[mode]||{}; + node._initLink=function(){ + node.link=page; + node.mode=mode; if(connectMenu){ - infoconfig.connect_choose_timeout={ - name:'出牌时限', - init:'30', - item:{ - '10':'10秒', - '15':'15秒', - '30':'30秒', - '60':'60秒', - '90':'90秒', - }, - connect:true, - frequent:true - }; - infoconfig.connect_observe={ - name:'允许旁观', - init:true, - connect:true - }; - infoconfig.connect_observe_handcard={ - name:'允许观看手牌', - init:false, - connect:true - }; - } - for(var j in infoconfig){ - if(j==='update'){ - continue; - } - var cfg=copyObj(infoconfig[j]); - cfg._name=j; - cfg.mode=mode; - if(!config.hasOwnProperty(j)){ - game.saveConfig(j,cfg.init,mode); - } - else{ - cfg.init=config[j]; - } - if(!cfg.onclick){ - cfg.onclick=function(result){ - var cfg=this._link.config; - game.saveConfig(cfg._name,result,mode); - if(cfg.onsave){ - cfg.onsave.call(this,result); - } - if(!_status.connectMode||game.online){ - if(typeof cfg.restart=='function'){ - if(cfg.restart()){ - startButton.classList.add('glowing'); - } - } - else if(cfg.restart){ - startButton.classList.add('glowing'); - } - } - }; - } - if(infoconfig.update){ - cfg.update=function(){ - infoconfig.update(config,map); - }; - } - var cfgnode=createConfig(cfg); - map[j]=cfgnode; - if(cfg.frequent){ - page.appendChild(cfgnode); - } - else{ - cfgnode.classList.add('auto-hide'); - hiddenNodes.push(cfgnode); - } - } - if(!connectMenu){ - var move=ui.create.div('.auto-hide.config','
上移↑
下移↓
'); - move.firstChild.listen(function(){ - if(node.previousSibling){ - node.parentNode.insertBefore(node,node.previousSibling); - var order=[]; - for(var i=0;i>',page); - morenodes.listen(clickmore); - morenodes._onclick=clickmore; - page.morenodes=morenodes; - } - else{ - page.classList.add('expanded'); - if(!connectMenu){ - page.classList.add('expanded2'); - } - } - for(var k=0;k隐藏此模式',page,function(){ - if(this.firstChild.innerHTML=='隐藏此模式'){ - this.firstChild.innerHTML='此模式将在重启后隐藏'; - lib.config.hiddenModePack.add(mode); - if(!lib.config.prompt_hidepack){ - alert('隐藏的扩展包可通过选项-其它-重置隐藏内容恢复'); - game.saveConfig('prompt_hidepack',true); - } + //“更多”下的内容 + var map={}; + var infoconfig=connectMenu?info.connect:info.config; + if(infoconfig){ + var hiddenNodes=[]; + var config=lib.config.mode_config[mode]||{}; + if(connectMenu){ + infoconfig.connect_choose_timeout={ + name:'出牌时限', + init:'30', + item:{ + '10':'10秒', + '15':'15秒', + '30':'30秒', + '60':'60秒', + '90':'90秒', + }, + connect:true, + frequent:true + }; + infoconfig.connect_observe={ + name:'允许旁观', + init:true, + connect:true + }; + infoconfig.connect_observe_handcard={ + name:'允许观看手牌', + init:false, + connect:true + }; + } + for(var j in infoconfig){ + if(j==='update'){ + continue; + } + var cfg=copyObj(infoconfig[j]); + cfg._name=j; + cfg.mode=mode; + if(!config.hasOwnProperty(j)){ + game.saveConfig(j,cfg.init,mode); } else{ - this.firstChild.innerHTML='隐藏此模式'; - lib.config.hiddenModePack.remove(mode); + cfg.init=config[j]; + } + if(!cfg.onclick){ + cfg.onclick=function(result){ + var cfg=this._link.config; + game.saveConfig(cfg._name,result,mode); + if(cfg.onsave){ + cfg.onsave.call(this,result); + } + if(!_status.connectMode||game.online){ + if(typeof cfg.restart=='function'){ + if(cfg.restart()){ + startButton.classList.add('glowing'); + } + } + else if(cfg.restart){ + startButton.classList.add('glowing'); + } + } + }; + } + if(infoconfig.update){ + cfg.update=function(){ + infoconfig.update(config,map); + }; + } + var cfgnode=createConfig(cfg); + map[j]=cfgnode; + if(cfg.frequent){ + page.appendChild(cfgnode); + } + else{ + cfgnode.classList.add('auto-hide'); + hiddenNodes.push(cfgnode); } - game.saveConfig('hiddenModePack',lib.config.hiddenModePack); - }); - if(hasexpand){ - hidemode.classList.add('auto-hide'); } - } - if(infoconfig.update){ - infoconfig.update(config,map); - node.update=function(){ + if(!connectMenu){ + var move=ui.create.div('.auto-hide.config','
上移↑
下移↓
'); + move.firstChild.listen(function(){ + if(node.previousSibling){ + node.parentNode.insertBefore(node,node.previousSibling); + var order=[]; + for(var i=0;i>',page); + morenodes.listen(clickmore); + morenodes._onclick=clickmore; + page.morenodes=morenodes; + } + else{ + page.classList.add('expanded'); + if(!connectMenu){ + page.classList.add('expanded2'); + } + } + for(var k=0;k隐藏此模式',page,function(){ + if(this.firstChild.innerHTML=='隐藏此模式'){ + this.firstChild.innerHTML='此模式将在重启后隐藏'; + lib.config.hiddenModePack.add(mode); + if(!lib.config.prompt_hidepack){ + alert('隐藏的扩展包可通过选项-其它-重置隐藏内容恢复'); + game.saveConfig('prompt_hidepack',true); + } + } + else{ + this.firstChild.innerHTML='隐藏此模式'; + lib.config.hiddenModePack.remove(mode); + } + game.saveConfig('hiddenModePack',lib.config.hiddenModePack); + }); + if(hasexpand){ + hidemode.classList.add('auto-hide'); + } + } + if(infoconfig.update){ infoconfig.update(config,map); + node.update=function(){ + infoconfig.update(config,map); + } } } - } - if(connectMenu){ - menuUpdates.push(function(){ - if(_status.waitingForPlayer){ - if(map.connect_player_number){ - map.connect_player_number.style.display='none'; + if(connectMenu){ + menuUpdates.push(function(){ + if(_status.waitingForPlayer){ + if(map.connect_player_number){ + map.connect_player_number.style.display='none'; + } + if(map.connect_versus_mode){ + map.connect_versus_mode.style.display='none'; + } } - if(map.connect_versus_mode){ - map.connect_versus_mode.style.display='none'; - } - } - }) - } + }) + } + }; return node; }; var modeorder=lib.config.modeorder||[]; @@ -39570,6 +39577,7 @@ active=start.firstChild.firstChild; active.classList.add('active'); } + if(!active.link) active._initLink(); rightPane.appendChild(active.link); if(lib.config.fold_mode){ rightPane.addEventListener('mousewheel',function(e){ @@ -39599,8 +39607,12 @@ active.classList.remove('active'); active.link.remove(); active=this; - this.classList.add('active'); - rightPane.appendChild(this.link); + active.classList.add('active'); + if(this.link) rightPane.appendChild(this.link); + else{ + this._initLink(); + rightPane.appendChild(this.link); + } }; var clickAutoSkill=function(bool){ @@ -39678,393 +39690,395 @@ var info=lib.configMenu[mode]; var page=ui.create.div(''); var node=ui.create.div('.menubutton.large',info.name,position,clickMode); - node.link=page; - node.mode=mode; - var map={}; - if(info.config){ - var hiddenNodes=[]; - var autoskillNodes=[]; - var banskillNodes=[]; - var custombanskillNodes=[]; - var banskill; + node._initLink=function(){ + node.link=page; + node.mode=mode; + var map={}; + if(info.config){ + var hiddenNodes=[]; + var autoskillNodes=[]; + var banskillNodes=[]; + var custombanskillNodes=[]; + var banskill; - if(mode=='skill'){ - var autoskillexpanded=false; - var banskillexpanded=false; - ui.create.div('.config.more','自动发动
>
',page,function(){ - if(autoskillexpanded){ - this.classList.remove('on'); - for(var k=0;k>',page,function(){ + if(autoskillexpanded){ + this.classList.remove('on'); + for(var k=0;k>',page,function(){ - if(banskillexpanded){ - this.classList.remove('on'); - for(var k=0;k>',page,function(){ + if(banskillexpanded){ + this.classList.remove('on'); + for(var k=0;k添加...',page,function(){ - this.nextSibling.classList.toggle('hidden'); - }); - banskilladd.style.display='none'; - banskillNodes.push(banskilladd); - - var banskilladdNode=ui.create.div('.config.indent.hidden.banskilladd',page); - banskilladdNode.style.display='none'; - banskillNodes.push(banskilladdNode); - - var matchBanSkill=function(skills1,skills2){ - if(skills1.length!=skills2.length) return false; - for(var i=0;ibb?1:-1; - } - return a>b?1:-1; + banskillexpanded=!banskillexpanded; }); - var list2=[]; - var skills=lib.character[list[0][0]][3]; - for(var i=0;i添加...',page,function(){ + this.nextSibling.classList.toggle('hidden'); + }); + banskilladd.style.display='none'; + banskillNodes.push(banskilladd); + + var banskilladdNode=ui.create.div('.config.indent.hidden.banskilladd',page); + banskilladdNode.style.display='none'; + banskillNodes.push(banskilladdNode); + + var matchBanSkill=function(skills1,skills2){ + if(skills1.length!=skills2.length) return false; + for(var i=0;ibb?1:-1; + } + return a>b?1:-1; + }); + + var list2=[]; + var skills=lib.character[list[0][0]][3]; + for(var i=0;i>',page,function(){ + // if(expanded){ + // this.classList.remove('on'); + // this.parentNode.classList.remove('expanded'); + // } + // else{ + // this.classList.add('on'); + // this.parentNode.classList.add('expanded'); + // } + // expanded=!expanded; + // }); + page.classList.add('morenodes'); + for(var k=0;k>',page,function(){ - // if(expanded){ - // this.classList.remove('on'); - // this.parentNode.classList.remove('expanded'); - // } - // else{ - // this.classList.add('on'); - // this.parentNode.classList.add('expanded'); - // } - // expanded=!expanded; - // }); - page.classList.add('morenodes'); - for(var k=0;k>',pageboard,function(){ - if(importextensionexpanded){ - this.classList.remove('on'); - importExtension.style.display='none'; - } - else{ - this.classList.add('on'); - importExtension.style.display=''; - } - importextensionexpanded=!importextensionexpanded; - }); - extensionnode.style.padding='13px 33px 4px'; - extensionnode.style.left='0px'; - importExtension=ui.create.div('.new_character.export.import',pageboard); - importExtension.style.padding='0px 33px 10px'; - importExtension.style.display='none'; - importExtension.style.width='100%'; - importExtension.style.textAlign='left'; - ui.create.div('','',importExtension); - var promptnode=ui.create.div('','
',importExtension); - promptnode.style.display='none'; - importExtension.firstChild.lastChild.onclick=function(){ - if(promptnode.style.display!='none') return; - var fileToLoad=this.previousSibling.files[0]; - if(fileToLoad){ - promptnode.style.display=''; - promptnode.firstChild.innerHTML='正在解压...'; - var fileReader = new FileReader(); - fileReader.onload = function(fileLoadedEvent) - { - var data = fileLoadedEvent.target.result; - var loadData=function(){ - var zip=new JSZip(); - zip.load(data); - var images=[],audios=[],fonts=[],directories={},directorylist=[]; - for(var i in zip.files){ - var ext=i.slice(i.lastIndexOf('.')+1); - if(i.indexOf('audio/')==0&&(ext=='mp3'||ext=='ogg')){ - audios.push(i); - } - else if(i.indexOf('font/')==0&&ext=='ttf'){ - fonts.push(i); - } - else if(i.indexOf('image/')==0&&(ext=='jpg'||ext=='png')){ - images.push(i); - } - else{ - continue; - } - var index=i.lastIndexOf('/'); - var str=i.slice(0,index); - if(!directories[str]){ - directories[str]=[]; - directorylist.push(str); - } - directories[str].push(i.slice(index+1)); - } - if(audios.length||fonts.length||images.length){ - var str=''; - if(audios.length){ - str+=audios.length+'个音频文件'; - } - if(fonts.length){ - if(str.length) str+='、' - str+=fonts.length+'个字体文件'; - } - if(images.length){ - if(str.length) str+='、' - str+=images.length+'个图片文件'; - } - var filelist=audios.concat(fonts).concat(images); - if(filelist.length>200){ - str+=',导入时间可能较长'; - } - var assetLoaded=function(){ - promptnode.firstChild.innerHTML='导入成功。重新启动×'; - promptnode.firstChild.querySelectorAll('span')[0].onclick=game.reload; - promptnode.firstChild.querySelectorAll('span')[1].onclick=function(){ - promptnode.style.display='none'; + var importextensionexpanded=false; + var importExtension; + var extensionnode=ui.create.div('.config.more','导入素材包
>
',pageboard,function(){ + if(importextensionexpanded){ + this.classList.remove('on'); + importExtension.style.display='none'; + } + else{ + this.classList.add('on'); + importExtension.style.display=''; + } + importextensionexpanded=!importextensionexpanded; + }); + extensionnode.style.padding='13px 33px 4px'; + extensionnode.style.left='0px'; + importExtension=ui.create.div('.new_character.export.import',pageboard); + importExtension.style.padding='0px 33px 10px'; + importExtension.style.display='none'; + importExtension.style.width='100%'; + importExtension.style.textAlign='left'; + ui.create.div('','',importExtension); + var promptnode=ui.create.div('','
',importExtension); + promptnode.style.display='none'; + importExtension.firstChild.lastChild.onclick=function(){ + if(promptnode.style.display!='none') return; + var fileToLoad=this.previousSibling.files[0]; + if(fileToLoad){ + promptnode.style.display=''; + promptnode.firstChild.innerHTML='正在解压...'; + var fileReader = new FileReader(); + fileReader.onload = function(fileLoadedEvent) + { + var data = fileLoadedEvent.target.result; + var loadData=function(){ + var zip=new JSZip(); + zip.load(data); + var images=[],audios=[],fonts=[],directories={},directorylist=[]; + for(var i in zip.files){ + var ext=i.slice(i.lastIndexOf('.')+1); + if(i.indexOf('audio/')==0&&(ext=='mp3'||ext=='ogg')){ + audios.push(i); } - }; - if(confirm('本次将导入'+str+',是否继续?')){ - promptnode.firstChild.innerHTML='正在导入... 详细信息'; - promptnode.firstChild.querySelector('span.hrefnode').onclick=ui.click.consoleMenu; - if(lib.node&&lib.node.fs){ - var writeFile=function(){ - if(filelist.length){ - var str=filelist.shift(); - game.print(str.slice(str.lastIndexOf('/')+1)); - lib.node.fs.writeFile(__dirname+'/'+str,zip.files[str].asNodeBuffer(),null,writeFile); - } - else{ - assetLoaded(); - } - }; - game.ensureDirectory(directorylist,writeFile); - + else if(i.indexOf('font/')==0&&ext=='ttf'){ + fonts.push(i); + } + else if(i.indexOf('image/')==0&&(ext=='jpg'||ext=='png')){ + images.push(i); } else{ - var getDirectory=function(){ - if(directorylist.length){ - var dir=directorylist.shift(); - var filelist=directories[dir]; - window.resolveLocalFileSystemURL(lib.assetURL+dir,function(entry){ - var writeFile=function(){ - if(filelist.length){ - var filename=filelist.shift(); - game.print(filename); - entry.getFile(filename,{create:true},function(fileEntry){ - fileEntry.createWriter(function(fileWriter){ - fileWriter.onwriteend=writeFile; - fileWriter.onerror = function(e) { - game.print('Write failed: ' + e.toString()); - }; - fileWriter.write(zip.files[dir+'/'+filename].asArrayBuffer()); + continue; + } + var index=i.lastIndexOf('/'); + var str=i.slice(0,index); + if(!directories[str]){ + directories[str]=[]; + directorylist.push(str); + } + directories[str].push(i.slice(index+1)); + } + if(audios.length||fonts.length||images.length){ + var str=''; + if(audios.length){ + str+=audios.length+'个音频文件'; + } + if(fonts.length){ + if(str.length) str+='、' + str+=fonts.length+'个字体文件'; + } + if(images.length){ + if(str.length) str+='、' + str+=images.length+'个图片文件'; + } + var filelist=audios.concat(fonts).concat(images); + if(filelist.length>200){ + str+=',导入时间可能较长'; + } + var assetLoaded=function(){ + promptnode.firstChild.innerHTML='导入成功。重新启动×'; + promptnode.firstChild.querySelectorAll('span')[0].onclick=game.reload; + promptnode.firstChild.querySelectorAll('span')[1].onclick=function(){ + promptnode.style.display='none'; + } + }; + if(confirm('本次将导入'+str+',是否继续?')){ + promptnode.firstChild.innerHTML='正在导入... 详细信息'; + promptnode.firstChild.querySelector('span.hrefnode').onclick=ui.click.consoleMenu; + if(lib.node&&lib.node.fs){ + var writeFile=function(){ + if(filelist.length){ + var str=filelist.shift(); + game.print(str.slice(str.lastIndexOf('/')+1)); + lib.node.fs.writeFile(__dirname+'/'+str,zip.files[str].asNodeBuffer(),null,writeFile); + } + else{ + assetLoaded(); + } + }; + game.ensureDirectory(directorylist,writeFile); + + } + else{ + var getDirectory=function(){ + if(directorylist.length){ + var dir=directorylist.shift(); + var filelist=directories[dir]; + window.resolveLocalFileSystemURL(lib.assetURL+dir,function(entry){ + var writeFile=function(){ + if(filelist.length){ + var filename=filelist.shift(); + game.print(filename); + entry.getFile(filename,{create:true},function(fileEntry){ + fileEntry.createWriter(function(fileWriter){ + fileWriter.onwriteend=writeFile; + fileWriter.onerror = function(e) { + game.print('Write failed: ' + e.toString()); + }; + fileWriter.write(zip.files[dir+'/'+filename].asArrayBuffer()); + }); }); - }); - } - else{ - getDirectory(); - } - }; - writeFile(); - }); - } - else{ - assetLoaded(); - } - }; - game.ensureDirectory(directorylist,getDirectory); + } + else{ + getDirectory(); + } + }; + writeFile(); + }); + } + else{ + assetLoaded(); + } + }; + game.ensureDirectory(directorylist,getDirectory); + } + } + else{ + promptnode.style.display='none'; } } else{ - promptnode.style.display='none'; + alert('没有检测到素材'); } } - else{ - alert('没有检测到素材'); + if(!window.JSZip){ + lib.init.js(lib.assetURL+'game','jszip',loadData); } - } - if(!window.JSZip){ - lib.init.js(lib.assetURL+'game','jszip',loadData); - } - else{ - loadData(); - } - }; - fileReader.readAsArrayBuffer(fileToLoad, "UTF-8"); - } - } - - var dashboard=ui.create.div(pageboard); - var clickDash=function(){ - ui.create.templayer(); - pageboard.hide(); - this.link.show(); - if(this.link.init){ - this.link.init(); - } - }; - var createDash=function(str1,str2,node){ - var dash=ui.create.div('.menubutton.large.dashboard'); - dashboard.appendChild(dash); - page.appendChild(node); - dash.link=node; - node.link=dash; - dash.listen(clickDash); - lib.setScroll(node); - ui.create.div('',str1,dash); - ui.create.div('',str2,dash); - }; - var createDash2=function(str1,str2,path,page){ - var dash=ui.create.div('.menubutton.large.dashboard.dashboard2'); - page.appendChild(dash); - dash.listen(function(){ - page.path=path; - enterDirectory(page,path); - }); - ui.create.div('',str1,dash); - ui.create.div('',str2,dash); - }; - var removeFile=function(selected,page){ - if(lib.node&&lib.node.fs){ - var unlink=function(){ - if(selected.length){ - lib.node.fs.unlink(__dirname+'/'+selected.shift().path,unlink); - } - else{ - enterDirectory(page,page.currentpath); - } + else{ + loadData(); + } + }; + fileReader.readAsArrayBuffer(fileToLoad, "UTF-8"); } - unlink(); } - else{ - window.resolveLocalFileSystemURL(lib.assetURL+page.currentpath,function(entry){ + + var dashboard=ui.create.div(pageboard); + var clickDash=function(){ + ui.create.templayer(); + pageboard.hide(); + this.link.show(); + if(this.link.init){ + this.link.init(); + } + }; + var createDash=function(str1,str2,node){ + var dash=ui.create.div('.menubutton.large.dashboard'); + dashboard.appendChild(dash); + page.appendChild(node); + dash.link=node; + node.link=dash; + dash.listen(clickDash); + lib.setScroll(node); + ui.create.div('',str1,dash); + ui.create.div('',str2,dash); + }; + var createDash2=function(str1,str2,path,page){ + var dash=ui.create.div('.menubutton.large.dashboard.dashboard2'); + page.appendChild(dash); + dash.listen(function(){ + page.path=path; + enterDirectory(page,path); + }); + ui.create.div('',str1,dash); + ui.create.div('',str2,dash); + }; + var removeFile=function(selected,page){ + if(lib.node&&lib.node.fs){ var unlink=function(){ if(selected.length){ - entry.getFile(selected.shift().filename,{create:false},function(fileEntry){ - fileEntry.remove(unlink); - }); + lib.node.fs.unlink(__dirname+'/'+selected.shift().path,unlink); } else{ enterDirectory(page,page.currentpath); } } unlink(); - }); - } - }; - var clickDirectory=function(){ - if(_status.dragged) return; - var page=this.parentNode.parentNode.parentNode; - if(page.deletebutton.classList.contains('active')){ - if(confirm('确认删除'+this.innerHTML+'文件夹?(此操作不可撤销)')){ - if(lib.node&&lib.node.fs){ - try{ - var removeDirectory=function(path,callback){ - lib.node.fs.readdir(__dirname+'/'+path,function(err,list){ - if(err){ - console.log(err); - return; - } - var removeFile=function(){ - if(list.length){ - var filename=list.shift(); - var url=__dirname+'/'+path+'/'+filename; - if(lib.node.fs.statSync(url).isDirectory()){ - removeDirectory(path+'/'+filename,removeFile); - } - else{ - lib.node.fs.unlink(url,removeFile); - } - } - else{ - lib.node.fs.rmdir(__dirname+'/'+path,callback); - } - } - removeFile(); + } + else{ + window.resolveLocalFileSystemURL(lib.assetURL+page.currentpath,function(entry){ + var unlink=function(){ + if(selected.length){ + entry.getFile(selected.shift().filename,{create:false},function(fileEntry){ + fileEntry.remove(unlink); }); - }; - removeDirectory(this.path,function(){ + } + else{ enterDirectory(page,page.currentpath); - }); + } } - catch(e){ - console.log(e); - } - } - else{ - window.resolveLocalFileSystemURL(lib.assetURL+this.path,function(entry){ - entry.removeRecursively(function(){ - enterDirectory(page,page.currentpath); - }); - }); - } - } - return; - } - enterDirectory(page,this.path); - }; - var clickFile=function(){ - if(_status.dragged) return; - var page=this.parentNode.parentNode.parentNode; - if(page.deletebutton.classList.contains('active')){ - if(confirm('确认删除'+this.innerHTML+'?(此操作不可撤销)')){ - removeFile([this],page); - } - return; - } - this.classList.toggle('thundertext'); - page.clicked=true; - if(this.ext=='jpg'||this.ext=='png'){ - if(this.classList.contains('thundertext')){ - if(!this.previewnode){ - this.previewnode=document.createElement('img'); - this.previewnode.src=lib.assetURL+this.path; - this.previewnode.width='60'; - this.previewnode.style.maxHeight='120px'; - this.parentNode.appendChild(this.previewnode); - } - } - else{ - if(this.previewnode){ - this.previewnode.remove(); - delete this.previewnode; - } - } - } - else if(this.ext=='mp3'||this.ext=='ogg'){ - if(this.classList.contains('thundertext')){ - if(!this.previewnode){ - this.previewnode=game.playAudio(this.path.slice(6)); - } - } - else{ - if(this.previewnode){ - this.previewnode.remove(); - delete this.previewnode; - } - } - } - }; - var clickFileList=function(){ - if(!this.parentNode) return; - if(this.parentNode.clicked){ - this.parentNode.clicked=false; - } - else{ - var selected=Array.from(this.querySelectorAll('span.thundertext')); - for(var i=0;ib) return 1; - if(a'+folders[i],filelist); - entry.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',clickDirectory); - entry.firstChild.path=parent+folders[i] - } - for(var i=0;i'+files[i],filelist); - entry.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',clickFile); - entry.firstChild.ext=files[i].slice(files[i].lastIndexOf('.')+1); - entry.firstChild.path=parent+files[i]; - entry.firstChild.filename=files[i]; } - }); + }; + var enterDirectory=function(page,path){ + page.innerHTML=''; + page.currentpath=path; + var backbutton=ui.create.div('.menubutton.round','返',page,function(){ + page.clicked=false; + clickFileList.call(filelist); + if(page.path==path){ + page.reset(); + } + else{ + if(path.indexOf('/')==-1){ + enterDirectory(page,''); + } + else{ + enterDirectory(page,path.slice(0,path.lastIndexOf('/'))); + } + } + }); + backbutton.style.zIndex=1; + backbutton.style.right='10px'; + backbutton.style.bottom='15px'; + + + var refresh=function(){ + enterDirectory(page,path); + }; + var addbutton=ui.create.div('.menubutton.round','添',page,function(){ + var pos1=this.getBoundingClientRect(); + var pos2=ui.window.getBoundingClientRect(); + openMenu(this.menu,{ + clientX:pos1.left+pos1.width+5-pos2.left, + clientY:pos1.top-pos2.top + }); + }); + addbutton.menu=ui.create.div('.menu'); + ui.create.div('','添加文件',addbutton.menu,function(){ + popupContainer.noclose=true; + }); + var createDir=function(str){ + if(lib.node&&lib.node.fs){ + lib.node.fs.mkdir(__dirname+'/'+path+'/'+str,refresh); + } + else{ + window.resolveLocalFileSystemURL(lib.assetURL+path,function(entry){ + entry.getDirectory(str,{create:true},refresh); + }); + } + }; + ui.create.div('','添加目录',addbutton.menu,function(){ + ui.create.templayer(); + game.prompt('输入目录名称',function(str){ + if(str){ + createDir(str); + } + }); + }); + var input=document.createElement('input'); + input.className='fileinput'; + input.type='file'; + input.onchange=function(){ + var fileToLoad=input.files[0]; + game.print(fileToLoad.name); + if(fileToLoad){ + var fileReader = new FileReader(); + fileReader.onload = function(e){ + game.writeFile(e.target.result,path,fileToLoad.name,refresh); + }; + fileReader.readAsArrayBuffer(fileToLoad, "UTF-8"); + } + }; + addbutton.menu.firstChild.appendChild(input); + addbutton.style.zIndex=1; + addbutton.style.right='10px'; + addbutton.style.bottom='80px'; + + var deletebutton=ui.create.div('.menubutton.round','删',page,function(){ + if(!this.parentNode) return; + if(!this.classList.contains('active')){ + var selected=Array.from(filelist.querySelectorAll('span.thundertext')); + if(selected.length){ + if(confirm('一共要删除'+selected.length+'个文件,此操作不可撤销,是否确定?')){ + removeFile(selected,page); + } + } + else{ + this.classList.add('active'); + } + } + else{ + this.classList.remove('active'); + } + }); + deletebutton.style.zIndex=1; + deletebutton.style.right='10px'; + deletebutton.style.bottom='145px'; + + page.backbutton=backbutton; + page.addbutton=addbutton; + page.deletebutton=deletebutton; + var filelist=ui.create.div(page); + filelist.classList.add('file-container'); + filelist.listen(clickFileList); + lib.setScroll(filelist); + game.getFileList(path,function(folders,files){ + var sort=function(a,b){ + if(a>b) return 1; + if(a'+folders[i],filelist); + entry.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',clickDirectory); + entry.firstChild.path=parent+folders[i] + } + for(var i=0;i'+files[i],filelist); + entry.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',clickFile); + entry.firstChild.ext=files[i].slice(files[i].lastIndexOf('.')+1); + entry.firstChild.path=parent+files[i]; + entry.firstChild.filename=files[i]; + } + }); + }; + var dash1=(function(){ + var page=ui.create.div('.hidden.menu-buttons'); + page.reset=function(){ + page.innerHTML=''; + var backbutton=ui.create.div('.menubutton.round','返',page,function(){ + ui.create.templayer(); + page.hide(); + pageboard.show(); + }); + backbutton.style.zIndex=1; + backbutton.style.right='10px'; + backbutton.style.bottom='15px'; + var placeholder=ui.create.div('.placeholder',page); + placeholder.style.position='relative'; + placeholder.style.display='block'; + placeholder.style.width='100%'; + placeholder.style.height='14px'; + createDash2('将','武将图片','image/character',page); + createDash2('肤','皮肤图片','image/skin',page); + createDash2('卡','卡牌图片','image/card',page); + createDash2('模','模式图片','image/mode',page); + createDash2('始','开始图片','image/splash',page); + createDash2('景','背景图片','image/background',page); + }; + page.reset(); + return page; + }()); + var dash2=(function(){ + var page=ui.create.div('.hidden.menu-buttons'); + page.reset=function(){ + page.innerHTML=''; + var backbutton=ui.create.div('.menubutton.round','返',page,function(){ + ui.create.templayer(); + page.hide(); + pageboard.show(); + }); + backbutton.style.zIndex=1; + backbutton.style.right='10px'; + backbutton.style.bottom='15px'; + var placeholder=ui.create.div('.placeholder',page); + placeholder.style.position='relative'; + placeholder.style.display='block'; + placeholder.style.width='100%'; + placeholder.style.height='14px'; + createDash2('技','技能配音','audio/skill',page); + createDash2('卡','男性卡牌','audio/card/male',page); + createDash2('牌','女性卡牌','audio/card/female',page); + createDash2('亡','阵亡配音','audio/die',page); + createDash2('效','游戏音效','audio/effect',page); + createDash2('景','背景音乐','audio/background',page); + }; + page.reset(); + return page; + }()); + var dash3=(function(){ + var page=ui.create.div('.hidden.menu-buttons'); + page.path='font'; + page.reset=function(){ + ui.create.templayer(); + page.hide(); + pageboard.show(); + }; + page.init=function(){ + enterDirectory(page,'font'); + }; + return page; + }()); + var dash4=(function(){ + var page=ui.create.div('.hidden.menu-buttons'); + page.path=''; + page.reset=function(){ + ui.create.templayer(); + page.hide(); + pageboard.show(); + }; + page.init=function(){ + enterDirectory(page,''); + }; + return page; + }()); + createDash('图','图片文件',dash1); + createDash('音','音频文件',dash2); + createDash('字','字体文件',dash3); + createDash('全','全部文件',dash4); }; - var dash1=(function(){ - var page=ui.create.div('.hidden.menu-buttons'); - page.reset=function(){ - page.innerHTML=''; - var backbutton=ui.create.div('.menubutton.round','返',page,function(){ - ui.create.templayer(); - page.hide(); - pageboard.show(); - }); - backbutton.style.zIndex=1; - backbutton.style.right='10px'; - backbutton.style.bottom='15px'; - var placeholder=ui.create.div('.placeholder',page); - placeholder.style.position='relative'; - placeholder.style.display='block'; - placeholder.style.width='100%'; - placeholder.style.height='14px'; - createDash2('将','武将图片','image/character',page); - createDash2('肤','皮肤图片','image/skin',page); - createDash2('卡','卡牌图片','image/card',page); - createDash2('模','模式图片','image/mode',page); - createDash2('始','开始图片','image/splash',page); - createDash2('景','背景图片','image/background',page); - }; - page.reset(); - return page; - }()); - var dash2=(function(){ - var page=ui.create.div('.hidden.menu-buttons'); - page.reset=function(){ - page.innerHTML=''; - var backbutton=ui.create.div('.menubutton.round','返',page,function(){ - ui.create.templayer(); - page.hide(); - pageboard.show(); - }); - backbutton.style.zIndex=1; - backbutton.style.right='10px'; - backbutton.style.bottom='15px'; - var placeholder=ui.create.div('.placeholder',page); - placeholder.style.position='relative'; - placeholder.style.display='block'; - placeholder.style.width='100%'; - placeholder.style.height='14px'; - createDash2('技','技能配音','audio/skill',page); - createDash2('卡','男性卡牌','audio/card/male',page); - createDash2('牌','女性卡牌','audio/card/female',page); - createDash2('亡','阵亡配音','audio/die',page); - createDash2('效','游戏音效','audio/effect',page); - createDash2('景','背景音乐','audio/background',page); - }; - page.reset(); - return page; - }()); - var dash3=(function(){ - var page=ui.create.div('.hidden.menu-buttons'); - page.path='font'; - page.reset=function(){ - ui.create.templayer(); - page.hide(); - pageboard.show(); - }; - page.init=function(){ - enterDirectory(page,'font'); - }; - return page; - }()); - var dash4=(function(){ - var page=ui.create.div('.hidden.menu-buttons'); - page.path=''; - page.reset=function(){ - ui.create.templayer(); - page.hide(); - pageboard.show(); - }; - page.init=function(){ - enterDirectory(page,''); - }; - return page; - }()); - createDash('图','图片文件',dash1); - createDash('音','音频文件',dash2); - createDash('字','字体文件',dash3); - createDash('全','全部文件',dash4); }()); createModeConfig('others',start.firstChild); @@ -40626,6 +40642,7 @@ active=start.firstChild.firstChild; active.classList.add('active'); } + if(!active.link) active._initLink(); rightPane.appendChild(active.link); }()); @@ -40644,7 +40661,11 @@ } this.classList.add('active'); updateActive(this); - rightPane.appendChild(this.link); + if(this.link) rightPane.appendChild(this.link); + else{ + this._initLink(); + rightPane.appendChild(this.link); + } }; updateActive=function(node){ if(!node){ @@ -40653,6 +40674,9 @@ return; } } + if (!node.link) { + node._initLink(); + } for(var i=0;i=5){ @@ -40721,228 +40744,250 @@ if(position2){ position.insertBefore(node,position2); } - node.link=page; - node.mode=mode; - page.node=node; - var list=[]; - var boolAI=true; - var alterableSkills=[]; - var alterableCharacters=[]; - var charactersToAlter=[]; - for(var i in info){ - if(info[i][4]&&info[i][4].contains('unseen')) continue; - if(connectMenu&&lib.connectBanned.contains(i)) continue; - list.push(i); - if(boolAI&&!lib.config.forbidai_user.contains(i)) boolAI=false; - for(var j=0;jb?1:-1; - } - return aa>bb?1:-1; - }); - var list2=list.slice(0); - var cfgnode=createConfig({ - name:'开启', - _name:mode, - init:lib.config.characters.contains(mode), - onclick:togglePack - }); - var cfgnodeAI=createConfig({ - name:'仅点将可用', - _name:mode, - init:boolAI, - intro:'将该武将包内的武将全部设置为仅点将可用', - onclick:function(bool){ - if(bool){ - for(var i=0;ib?1:-1; + } + return aa>bb?1:-1; + }); + var list2=list.slice(0); + var cfgnode=createConfig({ + name:'开启', + _name:mode, + init:lib.config.characters.contains(mode), + onclick:togglePack + }); + var cfgnodeAI=createConfig({ + name:'仅点将可用', + _name:mode, + init:boolAI, + intro:'将该武将包内的武将全部设置为仅点将可用', + onclick:function(bool){ + if(bool){ + for(var i=0;i该武将包不可被隐藏',page); } - } - } - page.classList.add('menu-buttons'); - page.classList.add('leftbutton'); - if(!connectMenu){ - if(lib.config.all.sgscharacters.contains(mode)){ - ui.create.div('.config.pointerspan','该武将包不可被隐藏',page); - } - else if(mode.indexOf('mode_')!=0){ - ui.create.div('.config.pointerspan','隐藏武将包',page,function(){ - if(this.firstChild.innerHTML=='隐藏武将包'){ - if(confirm('真的要隐藏“'+get.translation(mode+'_character_config')+'”武将包吗?\n建议使用“关闭”而不是“隐藏”功能,否则将会影响其他相关武将包的正常运行!')){ - this.firstChild.innerHTML='武将包将在重启后隐藏'; - lib.config.hiddenCharacterPack.add(mode); - if(!lib.config.prompt_hidepack){ - alert('隐藏的扩展包可通过选项-其它-重置隐藏内容恢复'); - game.saveConfig('prompt_hidepack',true); + else if(mode.indexOf('mode_')!=0){ + ui.create.div('.config.pointerspan','隐藏武将包',page,function(){ + if(this.firstChild.innerHTML=='隐藏武将包'){ + if(confirm('真的要隐藏“'+get.translation(mode+'_character_config')+'”武将包吗?\n建议使用“关闭”而不是“隐藏”功能,否则将会影响其他相关武将包的正常运行!')){ + this.firstChild.innerHTML='武将包将在重启后隐藏'; + lib.config.hiddenCharacterPack.add(mode); + if(!lib.config.prompt_hidepack){ + alert('隐藏的扩展包可通过选项-其它-重置隐藏内容恢复'); + game.saveConfig('prompt_hidepack',true); + } } } - } - else{ - this.firstChild.innerHTML='隐藏武将包'; - lib.config.hiddenCharacterPack.remove(mode); - } - game.saveConfig('hiddenCharacterPack',lib.config.hiddenCharacterPack); - }); + else{ + this.firstChild.innerHTML='隐藏武将包'; + lib.config.hiddenCharacterPack.remove(mode); + } + game.saveConfig('hiddenCharacterPack',lib.config.hiddenCharacterPack); + }); + } } - } + }; return node; }; if(lib.config.show_favourite_menu&&!connectMenu&&Array.isArray(lib.config.favouriteCharacter)){ @@ -41024,7 +41050,9 @@ lib.characterPack.mode_favourite[favname]=lib.character[favname]; } } - ui.favouriteCharacter=createModeConfig('mode_favourite',start.firstChild).link; + var favouriteCharacterNode=createModeConfig('mode_favourite',start.firstChild); + if(!favouriteCharacterNode.link) favouriteCharacterNode._initLink(); + ui.favouriteCharacter=favouriteCharacterNode.link; if(get.is.empty(lib.characterPack.mode_favourite)){ ui.favouriteCharacter.node.style.display='none'; } @@ -41071,6 +41099,7 @@ active.classList.add('active'); updateActive(active); } + if(!active.link) active._initLink(); rightPane.appendChild(active.link); if(!connectMenu){ @@ -41113,7 +41142,11 @@ if(this.mode=='cardpile'){ this.create(); } - rightPane.appendChild(this.link); + if(this.link) rightPane.appendChild(this.link); + else{ + this._initLink(); + rightPane.appendChild(this.link); + } }; updateActiveCard=function(node){ if(!node){ @@ -41122,6 +41155,7 @@ return; } } + if(!node.link) node._initLink(); for(var i=0;i=5){ node.classList.add('smallfont'); } - node.link=page; - node.mode=mode; - var list=[]; - for(var i=0;isort2){ - return 1; - } - else{ - return -1; - } - }); - var cfgnode=createConfig({ - name:'开启', - _name:mode, - init:lib.config.cards.contains(mode), - onclick:togglePack - }); - if(mode.indexOf('mode_')!=0){ - page.appendChild(cfgnode); - } - else{ - page.style.paddingTop='8px'; - } - var banCard=function(e){ - if(_status.clicked){ - _status.clicked=false; - return; - } - if(mode.indexOf('mode_')==0&&mode.indexOf('mode_extension_')!=0&&mode!='mode_banned'){ - return; - } - ui.click.touchpop(); - this._banning=connectMenu?'online':'offline'; - ui.click.intro.call(this,e); - _status.clicked=false; - delete this._banning; - }; - var updateBanned=function(){ - var list; - if(connectMenu){ - var mode=menux.pages[0].firstChild.querySelector('.active'); - if(mode&&mode.mode){ - list=lib.config['connect_'+mode.mode+'_bannedcards']; + if(lib.cardType[type]){ + return lib.cardType[type]; + } + switch(type){ + case 'basic':return 0; + case 'chess':return 1.5; + case 'trick':return 2; + case 'delay':return 3; + case 'equip':{ + switch(lib.card[card[2]].subtype){ + case 'equip1':return 4.1; + case 'equip2':return 4.2; + case 'equip3':return 4.3; + case 'equip4':return 4.4; + case 'equip5':return 4.5; + default:return 4; + } + } + case 'zhenfa':return 5; + default:return 6; } } - else{ - list=lib.config[get.mode()+'_bannedcards']; - } - if(list&&list.contains(this.link[2])){ - this.classList.add('banned'); - } - else{ - this.classList.remove('banned'); - } - }; - var buttons=ui.create.buttons(list,'vcard',page); - for(var i=0;i隐藏卡牌包',page,function(){ - if(this.firstChild.innerHTML=='隐藏卡牌包'){ - this.firstChild.innerHTML='卡牌包将在重启后隐藏'; - lib.config.hiddenCardPack.add(mode); - if(!lib.config.prompt_hidepack){ - alert('隐藏的扩展包可通过选项-其它-重置隐藏内容恢复'); - game.saveConfig('prompt_hidepack',true); - } + list.sort(function(a,b){ + var sort1=sortCard(a); + var sort2=sortCard(b); + if(sort1==sort2){ + return (b[2]sort2){ + return 1; } else{ - this.firstChild.innerHTML='隐藏卡牌包'; - lib.config.hiddenCardPack.remove(mode); - } - game.saveConfig('hiddenCardPack',lib.config.hiddenCardPack); - }); - } - if(mode.indexOf('mode_')!=0&&lib.cardPile[mode]){ - var cardpileNodes=[]; - var cardpileexpanded=false; - if(!lib.config.bannedpile[mode]){ - lib.config.bannedpile[mode]=[]; - } - if(!lib.config.addedpile[mode]){ - lib.config.addedpile[mode]=[]; - } - ui.create.div('.config.more.pile','编辑牌堆
>
',page,function(){ - if(cardpileexpanded){ - this.classList.remove('on'); - for(var k=0;k隐藏卡牌包',page,function(){ + if(this.firstChild.innerHTML=='隐藏卡牌包'){ + this.firstChild.innerHTML='卡牌包将在重启后隐藏'; + lib.config.hiddenCardPack.add(mode); + if(!lib.config.prompt_hidepack){ + alert('隐藏的扩展包可通过选项-其它-重置隐藏内容恢复'); + game.saveConfig('prompt_hidepack',true); + } + } + else{ + this.firstChild.innerHTML='隐藏卡牌包'; + lib.config.hiddenCardPack.remove(mode); + } + game.saveConfig('hiddenCardPack',lib.config.hiddenCardPack); }); - cfgnode.type='defaultcards'; + } + if(mode.indexOf('mode_')!=0&&lib.cardPile[mode]){ + var cardpileNodes=[]; + var cardpileexpanded=false; + if(!lib.config.bannedpile[mode]){ + lib.config.bannedpile[mode]=[]; + } + if(!lib.config.addedpile[mode]){ + lib.config.addedpile[mode]=[]; + } + ui.create.div('.config.more.pile','编辑牌堆
>
',page,function(){ + if(cardpileexpanded){ + this.classList.remove('on'); + for(var k=0;k=5){ node.classList.add('smallfont'); } - node.link=page; - node.mode=mode; - for(var i in lib.extensionMenu[mode]){ - if(i=='game') continue; - var cfg=copyObj(lib.extensionMenu[mode][i]); - var j; - if(mode.indexOf('extension_')==0){ - j=mode+'_'+i; - } - else{ - j=mode+'_'+i+'_playpackconfig'; - } - cfg._name=j; - if(!lib.config.hasOwnProperty(j)){ - game.saveConfig(j,cfg.init); - } - else{ - cfg.init=lib.config[j]; - } + node._initLink=function(){ + node.link=page; + node.mode=mode; + for(var i in lib.extensionMenu[mode]){ + if(i=='game') continue; + var cfg=copyObj(lib.extensionMenu[mode][i]); + var j; + if(mode.indexOf('extension_')==0){ + j=mode+'_'+i; + } + else{ + j=mode+'_'+i+'_playpackconfig'; + } + cfg._name=j; + if(!lib.config.hasOwnProperty(j)){ + game.saveConfig(j,cfg.init); + } + else{ + cfg.init=lib.config[j]; + } - if(i=='enable'){ - cfg.onclick=togglePack; + if(i=='enable'){ + cfg.onclick=togglePack; + } + else if(!lib.extensionMenu[mode][i].onclick){ + cfg.onclick=function(result){ + var cfg=this._link.config; + game.saveConfig(cfg._name,result); + }; + } + var cfgnode=createConfig(cfg); + if(cfg.onswitch){ + cfgnode.onswitch=cfg.onswitch; + } + page.appendChild(cfgnode); } - else if(!lib.extensionMenu[mode][i].onclick){ - cfg.onclick=function(result){ - var cfg=this._link.config; - game.saveConfig(cfg._name,result); - }; - } - var cfgnode=createConfig(cfg); - if(cfg.onswitch){ - cfgnode.onswitch=cfg.onswitch; - } - page.appendChild(cfgnode); - } + }; return node; }; for(var i in lib.extensionMenu){ @@ -41795,1997 +41838,1262 @@ if(lib.config.show_extensionmaker==false) return; var page=ui.create.div('#create-extension'); var node=ui.create.div('.menubutton.large','制作扩展',start.firstChild,clickMode); - node.link=page; - node.mode='create'; - var pageboard=ui.create.div(page); - var inputExtLine=ui.create.div(pageboard); - inputExtLine.style.transition='all 0s'; - inputExtLine.style.padding='10px'; - inputExtLine.style.height='22px'; - inputExtLine.style.lineHeight='22px'; - inputExtLine.style.whiteSpace='nowrap'; - inputExtLine.style.overflow='visible'; - var inputExtSpan=document.createElement('span'); - inputExtSpan.innerHTML='扩展名:'; - inputExtLine.appendChild(inputExtSpan); - var inputExtName=document.createElement('input'); - inputExtName.type='text'; - inputExtName.value='无名扩展'; - inputExtName.style.width='80px'; - inputExtName.style.textAlign='center'; - inputExtLine.appendChild(inputExtName); - - var buttonConfirmOnclick=function(){ - buttonConfirm.style.display='none'; - inputExtSpan.style.display='none'; - inputExtName.style.display='none'; - authorExtLine.style.display='none'; - introExtLine.style.display='none'; - forumExtLine.style.display='none'; - diskExtLine.style.display='none'; - versionExtLine.style.display='none'; - okExtLine.style.display='none'; + node._initLink=function(){ + node.link=page; + node.mode='create'; + var pageboard=ui.create.div(page); + var inputExtLine=ui.create.div(pageboard); + inputExtLine.style.transition='all 0s'; inputExtLine.style.padding='10px'; - buttonRename.style.display=''; - buttonSave.style.display=''; - buttonReset.style.display=''; - buttonExport.style.display=''; - inputExtSpan.innerHTML='扩展名称:'; - inputExtName.style.width='100px'; - inputExtName.style.textAlign=''; + inputExtLine.style.height='22px'; + inputExtLine.style.lineHeight='22px'; + inputExtLine.style.whiteSpace='nowrap'; + inputExtLine.style.overflow='visible'; + var inputExtSpan=document.createElement('span'); + inputExtSpan.innerHTML='扩展名:'; + inputExtLine.appendChild(inputExtSpan); + var inputExtName=document.createElement('input'); + inputExtName.type='text'; + inputExtName.value='无名扩展'; + inputExtName.style.width='80px'; + inputExtName.style.textAlign='center'; + inputExtLine.appendChild(inputExtName); - dashboard.style.display=''; - }; - var createExtLine=function(str,str2){ - var infoExtLine=ui.create.div(pageboard); - infoExtLine.style.display='none'; - infoExtLine.style.padding='0 10px 10px 10px'; - infoExtLine.style.height='22px'; - infoExtLine.style.lineHeight='22px'; - infoExtLine.style.whiteSpace='nowrap'; - infoExtLine.style.overflow='visible'; - if(typeof str=='boolean'){ - var inputConfirm=document.createElement('button'); - inputConfirm.innerHTML='确定'; - inputConfirm.onclick=buttonConfirmOnclick; - infoExtLine.appendChild(inputConfirm); - return infoExtLine; - } - var infoExtSpan=document.createElement('span'); - infoExtSpan.innerHTML=str+':'; - infoExtLine.appendChild(infoExtSpan); - var infoExtName=document.createElement('input'); - infoExtName.type='text'; - infoExtName.style.width='100px'; - infoExtName.value=str2||''; - infoExtLine.appendChild(infoExtName); - return infoExtLine; - }; - var authorExtLine=createExtLine('扩展作者',get.connectNickname()); - var introExtLine=createExtLine('扩展描述'); - var versionExtLine=createExtLine('扩展版本','1.0'); - var diskExtLine=createExtLine('网盘地址'); - var forumExtLine=createExtLine('讨论地址'); - var okExtLine=createExtLine(true); - - game.editExtension=function(name){ - page.currentExtension=name||'无名扩展'; - inputExtName.value=page.currentExtension; - if(name&&lib.extensionPack[name]){ - authorExtLine.querySelector('input').value=lib.extensionPack[name].author||''; - introExtLine.querySelector('input').value=lib.extensionPack[name].intro||''; - diskExtLine.querySelector('input').value=lib.extensionPack[name].diskURL||''; - forumExtLine.querySelector('input').value=lib.extensionPack[name].forumURL||''; - versionExtLine.querySelector('input').value=lib.extensionPack[name].version||''; - } - else{ - authorExtLine.querySelector('input').value=get.connectNickname()||''; - introExtLine.querySelector('input').value=''; - diskExtLine.querySelector('input').value=''; - forumExtLine.querySelector('input').value=''; - versionExtLine.querySelector('input').value='1.0'; - } - if(name){ - inputExtName.disabled=true; + var buttonConfirmOnclick=function(){ buttonConfirm.style.display='none'; inputExtSpan.style.display='none'; inputExtName.style.display='none'; + authorExtLine.style.display='none'; + introExtLine.style.display='none'; + forumExtLine.style.display='none'; + diskExtLine.style.display='none'; + versionExtLine.style.display='none'; + okExtLine.style.display='none'; + inputExtLine.style.padding='10px'; buttonRename.style.display=''; buttonSave.style.display=''; buttonReset.style.display=''; buttonExport.style.display=''; + inputExtSpan.innerHTML='扩展名称:'; + inputExtName.style.width='100px'; + inputExtName.style.textAlign=''; + + dashboard.style.display=''; + }; + var createExtLine=function(str,str2){ + var infoExtLine=ui.create.div(pageboard); + infoExtLine.style.display='none'; + infoExtLine.style.padding='0 10px 10px 10px'; + infoExtLine.style.height='22px'; + infoExtLine.style.lineHeight='22px'; + infoExtLine.style.whiteSpace='nowrap'; + infoExtLine.style.overflow='visible'; + if(typeof str=='boolean'){ + var inputConfirm=document.createElement('button'); + inputConfirm.innerHTML='确定'; + inputConfirm.onclick=buttonConfirmOnclick; + infoExtLine.appendChild(inputConfirm); + return infoExtLine; + } + var infoExtSpan=document.createElement('span'); + infoExtSpan.innerHTML=str+':'; + infoExtLine.appendChild(infoExtSpan); + var infoExtName=document.createElement('input'); + infoExtName.type='text'; + infoExtName.style.width='100px'; + infoExtName.value=str2||''; + infoExtLine.appendChild(infoExtName); + return infoExtLine; + }; + var authorExtLine=createExtLine('扩展作者',get.connectNickname()); + var introExtLine=createExtLine('扩展描述'); + var versionExtLine=createExtLine('扩展版本','1.0'); + var diskExtLine=createExtLine('网盘地址'); + var forumExtLine=createExtLine('讨论地址'); + var okExtLine=createExtLine(true); + + game.editExtension=function(name){ + page.currentExtension=name||'无名扩展'; + inputExtName.value=page.currentExtension; + if(name&&lib.extensionPack[name]){ + authorExtLine.querySelector('input').value=lib.extensionPack[name].author||''; + introExtLine.querySelector('input').value=lib.extensionPack[name].intro||''; + diskExtLine.querySelector('input').value=lib.extensionPack[name].diskURL||''; + forumExtLine.querySelector('input').value=lib.extensionPack[name].forumURL||''; + versionExtLine.querySelector('input').value=lib.extensionPack[name].version||''; + } + else{ + authorExtLine.querySelector('input').value=get.connectNickname()||''; + introExtLine.querySelector('input').value=''; + diskExtLine.querySelector('input').value=''; + forumExtLine.querySelector('input').value=''; + versionExtLine.querySelector('input').value='1.0'; + } + if(name){ + inputExtName.disabled=true; + buttonConfirm.style.display='none'; + inputExtSpan.style.display='none'; + inputExtName.style.display='none'; + buttonRename.style.display=''; + buttonSave.style.display=''; + buttonReset.style.display=''; + buttonExport.style.display=''; + } + else{ + inputExtName.disabled=false; + buttonConfirm.style.display=''; + inputExtSpan.innerHTML='扩展名:'; + inputExtName.style.width='80px'; + inputExtName.style.textAlign='center'; + inputExtSpan.style.display=''; + inputExtName.style.display=''; + buttonRename.style.display='none'; + buttonSave.style.display='none'; + buttonReset.style.display='none'; + buttonExport.style.display='none'; + } + + dashboard.style.display=''; + + exportExtLine.style.display='none'; + shareExtLine.style.display='none'; + authorExtLine.style.display='none'; + introExtLine.style.display='none'; + forumExtLine.style.display='none'; + diskExtLine.style.display='none'; + versionExtLine.style.display='none'; + okExtLine.style.display='none'; + inputExtLine.style.padding='10px'; + dash1.reset(name); + dash2.reset(name); + dash3.reset(name); + dash4.reset(name); + dash1.link.classList.remove('active'); + dash2.link.classList.remove('active'); + dash3.link.classList.remove('active'); + dash4.link.classList.remove('active'); + var active=node.parentNode.querySelector('.active'); + if(active===node){ + return; + } + active.classList.remove('active'); + active.link.remove(); + node.classList.add('active'); + rightPane.appendChild(node.link); } - else{ - inputExtName.disabled=false; - buttonConfirm.style.display=''; - inputExtSpan.innerHTML='扩展名:'; - inputExtName.style.width='80px'; - inputExtName.style.textAlign='center'; + var processExtension=function(exportext){ + if(page.currentExtension){ + if(page.currentExtension!=inputExtName.value&&!exportext){ + game.removeExtension(page.currentExtension); + } + } + inputExtName.disabled=true; + setTimeout(function(){ + var ext={}; + var config=null,help=null; + for(var i in dash4.content){ + try{ + if(i=='content'||i=='precontent'){ + eval('ext[i]='+dash4.content[i]); + if(typeof ext[i]!='function'){ + throw('err'); + } + else{ + ext[i]=ext[i].toString(); + } + } + else{ + eval(dash4.content[i]); + eval('ext[i]='+i); + if(ext[i]==null||typeof ext[i]!='object'){ + throw('err'); + } + else{ + ext[i]=JSON.stringify(ext[i]); + } + } + } + catch(e){ + console.log(e); + delete ext[i]; + } + } + page.currentExtension=inputExtName.value||'无名扩展'; + var str='{name:"'+page.currentExtension+'"'; + for(var i in ext){ + str+=','+i+':'+ext[i]; + } + dash2.content.pack.list=[]; + for(var i=0;i
返回',page,function(){ - ui.create.templayer(); - page.hide(); - pageboard.show(); - }); - page.content={ - pack:{ - character:{}, - translate:{} - }, - image:{} - }; - var newCharacter; - var toggle=ui.create.div('.config.more.on','创建武将
>
',page,function(){ - this.classList.toggle('on'); - if(this.classList.contains('on')){ - newCharacter.style.display=''; + var createButton=function(name,image){ + var button=ui.create.div('.button.character'); + button.link=name; + button.image=image; + button.style.backgroundImage='url('+image+')'; + button.style.backgroundSize='cover'; + button.listen(clickButton); + button.classList.add('noclick'); + button.nodename=ui.create.div(button,'.name',get.verticalStr(page.content.pack.translate[name])); + button.nodename.style.top='8px'; + page.insertBefore(button,page.childNodes[1]); } - else{ + page.reset=function(name){ + resetEditor(); + var buttons=page.querySelectorAll('.button.character'); + var list=[]; + for(var i=0;i
返回',page,function(){ + ui.create.templayer(); + page.hide(); + pageboard.show(); + }); + page.content={ + pack:{ + character:{}, + translate:{} + }, + image:{} + }; + var newCharacter; + var toggle=ui.create.div('.config.more.on','创建武将
>
',page,function(){ + this.classList.toggle('on'); + if(this.classList.contains('on')){ + newCharacter.style.display=''; + } + else{ + newCharacter.style.display='none'; + } + }); + var resetEditor=function(){ + currentButton=null; + toggle.classList.remove('on'); newCharacter.style.display='none'; + fakeme.classList.remove('inited'); + delete fakeme.image; + delete fakeme.image64; + fakeme.style.backgroundImage=''; + var inputs=newCharacter.querySelectorAll('input'); + for(var i=0;i',newCharacter).style.paddingTop='8px'; - ui.create.div('.indent','介绍:',newCharacter).style.paddingTop='8px'; - ui.create.div('.indent','体力:',newCharacter).style.paddingTop='8px'; - newCharacter.querySelector('input.new_name').onblur=updateButton; - var sexes=ui.create.selectlist([ - ['male','男'], - ['female','女'], - ['none','无'], - ],null,ui.create.div('.indent','性别:',newCharacter)); - var grouplist=[]; - for(var i=0;i主公BOSS仅点将可用
隐匿技
',newCharacter); - var addSkill=ui.create.div('.add_skill','添加技能
',newCharacter); - var list=[]; - for(var i in lib.character){ - if(lib.character[i][3].length){ - list.push([i,lib.translate[i]]); + ui.create.div('.indent','姓名:',newCharacter).style.paddingTop='8px'; + ui.create.div('.indent','介绍:',newCharacter).style.paddingTop='8px'; + ui.create.div('.indent','体力:',newCharacter).style.paddingTop='8px'; + newCharacter.querySelector('input.new_name').onblur=updateButton; + var sexes=ui.create.selectlist([ + ['male','男'], + ['female','女'], + ['none','无'], + ],null,ui.create.div('.indent','性别:',newCharacter)); + var grouplist=[]; + for(var i=0;i主公BOSS仅点将可用
隐匿技
',newCharacter); + var addSkill=ui.create.div('.add_skill','添加技能
',newCharacter); + var list=[]; + for(var i in lib.character){ + if(lib.character[i][3].length){ + list.push([i,lib.translate[i]]); + } } - } - list.sort(function(a,b){ - a=a[0];b=b[0]; - var aa=a,bb=b; - if(aa.indexOf('_')!=-1){ - aa=aa.slice(aa.indexOf('_')+1); + list.sort(function(a,b){ + a=a[0];b=b[0]; + var aa=a,bb=b; + if(aa.indexOf('_')!=-1){ + aa=aa.slice(aa.indexOf('_')+1); + } + if(bb.indexOf('_')!=-1){ + bb=bb.slice(bb.indexOf('_')+1); + } + if(aa!=bb){ + return aa>bb?1:-1; + } + return a>b?1:-1; + }); + var list2=[]; + var skills=lib.character[list[0][0]][3]; + for(var i=0;ibb?1:-1; - } - return a>b?1:-1; - }); - var list2=[]; - var skills=lib.character[list[0][0]][3]; - for(var i=0;i←返回',page,function(){ - ui.create.templayer(); - page.hide(); - pageboard.show(); - }); - page.content={ - pack:{ - card:{}, - translate:{}, - list:[] - }, - image:{} - }; - var newCard; - var toggle=ui.create.div('.config.more.on','创建卡牌
>
',page,function(){ - this.classList.toggle('on'); - if(this.classList.contains('on')){ - newCard.style.display=''; - } - else{ - newCard.style.display='none'; - } - }); - var resetEditor=function(){ - currentButton=null; - toggle.classList.remove('on'); - newCard.style.display='none'; - fakeme.classList.remove('inited'); - fakeme.classList.add('fullskin'); - delete fakeme.image; - delete fakeme.image64; - fakeme.style.backgroundImage=''; - fakeme.imagenode.style.backgroundImage=''; - var inputs=newCard.querySelectorAll('input'); - for(var i=0;i

景',fakeme); - - ui.create.div('.indent','名称:',newCard).style.paddingTop='8px'; - ui.create.div('.indent','描述:',newCard).style.paddingTop='6px'; - newCard.querySelector('input.new_name').onblur=updateButton; - var codeButton=document.createElement('button'); - newCard.appendChild(codeButton); - codeButton.innerHTML='编辑代码'; - codeButton.style.left='123px'; - codeButton.style.top='66px'; - codeButton.style.position='absolute'; - - var citeButton=document.createElement('button'); - newCard.appendChild(citeButton); - citeButton.innerHTML='引用代码'; - citeButton.style.left='123px'; - citeButton.style.top='90px'; - citeButton.style.position='absolute'; - citeButton.onclick=function(){ - codeButton.style.display='none'; - citeButton.style.display='none'; - selectname.style.display=''; - confirmcontainer.style.display=''; - } - - var list=[]; - for(var i in lib.card){ - if(lib.translate[i]){ - list.push([i,lib.translate[i]]); - } - } - list.sort(function(a,b){ - a=a[0];b=b[0]; - var aa=a,bb=b; - if(aa.indexOf('_')!=-1){ - aa=aa.slice(aa.indexOf('_')+1); - } - if(bb.indexOf('_')!=-1){ - bb=bb.slice(bb.indexOf('_')+1); - } - if(aa!=bb){ - return aa>bb?1:-1; - } - return a>b?1:-1; - }); - var selectname=ui.create.selectlist(list,list[0],newCard); - selectname.style.left='123px'; - selectname.style.top='66px'; - selectname.style.position='absolute'; - selectname.style.display='none'; - - var confirmcontainer=ui.create.div(newCard); - confirmcontainer.style.left='123px'; - confirmcontainer.style.top='90px'; - confirmcontainer.style.position='absolute'; - confirmcontainer.style.display='none'; - - var citeconfirm=document.createElement('button'); - citeconfirm.innerHTML='引用'; - confirmcontainer.appendChild(citeconfirm); - citeconfirm.onclick=function(){ - codeButton.style.display=''; - citeButton.style.display=''; - selectname.style.display='none'; - confirmcontainer.style.display='none'; - container.code='card='+get.stringify(lib.card[selectname.value]); - codeButton.onclick.call(codeButton); - if(lib.translate[selectname.value+'_info']){ - newCard.querySelector('input.new_description').value=lib.translate[selectname.value+'_info']; - } - } - - var citecancel=document.createElement('button'); - citecancel.innerHTML='取消'; - citecancel.style.marginLeft='3px'; - confirmcontainer.appendChild(citecancel); - citecancel.onclick=function(){ - codeButton.style.display=''; - citeButton.style.display=''; - selectname.style.display='none'; - confirmcontainer.style.display='none'; - } - - codeButton.onclick=function(){ - var node=container; - ui.window.classList.add('shortcutpaused'); - ui.window.classList.add('systempaused'); - window.saveNonameInput=saveInput; - if(node.aced){ - ui.window.appendChild(node); - node.editor.setValue(node.code,1); - } - else if(lib.device=='ios'){ - ui.window.appendChild(node); - if(!node.textarea){ - var textarea=document.createElement('textarea'); - editor.appendChild(textarea); - node.textarea=textarea; - lib.setScroll(textarea); - } - node.textarea.value=node.code; - } - else{ - var aceReady=function(){ - ui.window.appendChild(node); - var mirror = window.CodeMirror(editor, { - value:node.code, - mode:"javascript", - lineWrapping:!lib.config.touchscreen&&lib.config.mousewheel, - lineNumbers:true, - indentUnit:4, - autoCloseBrackets:true, - theme:'mdn-like' - }); - lib.setScroll(editor.querySelector('.CodeMirror-scroll')); - node.aced=true; - node.editor=mirror; - } - if(!window.CodeMirror){ - lib.init.js(lib.assetURL+'game','codemirror',aceReady); - lib.init.css(lib.assetURL+'layout/default','codemirror'); - } - else{ - aceReady(); - } - } - } - - var container=ui.create.div('.popup-container.editor'); - var editorpage=ui.create.div(container); - var discardConfig=ui.create.div('.editbutton','取消',editorpage,function(){ - ui.window.classList.remove('shortcutpaused'); - ui.window.classList.remove('systempaused'); - container.delete(null); - delete window.saveNonameInput; - }); - var saveInput=function(){ - var code; - if(container.editor){ - code=container.editor.getValue(); - } - else if(container.textarea){ - code=container.textarea.value; - } - try{ - var card=null; - eval(code); - if(card==null||typeof card!='object'){ - throw('err'); - } - } - catch(e){ - if(e=='err'){ - alert('代码格式有错误,请对比示例代码仔细检查'); - } - else{ - alert('代码语法有错误,请仔细检查('+e+')') - } - return; - } - dash2.link.classList.add('active'); - ui.window.classList.remove('shortcutpaused'); - ui.window.classList.remove('systempaused'); - container.delete(); - container.code=code; - delete window.saveNonameInput; - }; - var saveConfig=ui.create.div('.editbutton','保存',editorpage,saveInput); - var editor=ui.create.div(editorpage); - container.code='card={\n \n}\n\n\/*\n示例:\ncard={\n type:"basic",\n enable:true,\n filterTarget:true,\n content:function(){\n target.draw()\n },\n ai:{\n order:1,\n result:{\n target:1\n }\n }\n}\n此例的效果为目标摸一张牌\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; - - var editnode=ui.create.div('.menubutton.large.new_card.disabled','创建卡牌',newCard,function(){ - var name=page.querySelector('input.new_name').value; - if(!name){ - alert('请填写卡牌名\n提示:卡牌名格式为id+|+中文名,其中id必须惟一'); - return; - } - name=name.split('|'); - var translate=name[1]||name[0]; - var info=page.querySelector('input.new_description').value; - name=name[0]; - if(currentButton){ - if(currentButton.link!=name){ - if(lib.card[name]||page.content.pack.card[name]){ - alert('卡牌名与现有卡牌重复,请更改\n提示:卡牌名格式为id+|+中文名,其中id必须惟一'); - return; - } - var extname; - if(currentButton.classList.contains('fullskin')){ - extname='.png'; - } - else{ - extname='.jpg'; - } - page.content.image[name+extname]=page.content.image[currentButton.link+extname]; - delete page.content.image[currentButton.link+extname]; - delete page.content.pack.card[currentButton.link]; - delete page.content.pack.translate[currentButton.link]; - delete page.content.pack.translate[currentButton.link+'_info']; - currentButton.link=name; - } - } - else{ - if(lib.card[name]||page.content.pack.card[name]){ - alert('卡牌名与现有卡牌重复,请更改\n提示:卡牌名格式为id+|+中文名,其中id必须惟一'); + editnode.classList.remove('disabled'); + }; + var clickButton=function(){ + if(currentButton==this){ + resetEditor(); return; } - } - if(fakeme.image){ - if(fakeme.classList.contains('fullskin')){ - page.content.image[name+'.png']=fakeme.image; - delete page.content.image[name+'.jpg']; + resetEditor(); + currentButton=this; + toggle.classList.add('on'); + newCard.style.display=''; + fakeme.classList.add('inited'); + delete fakeme.image; + delete fakeme.image64; + if(this.classList.contains('fullskin')){ + fakeme.imagenode.style.backgroundImage=this.imagenode.style.backgroundImage; + fakeme.classList.add('fullskin'); } else{ - page.content.image[name+'.jpg']=fakeme.image; - delete page.content.image[name+'.png']; + fakeme.style.backgroundImage=this.style.backgroundImage; + fakeme.classList.remove('fullskin'); } - } - else if(!fakeme.classList.contains('inited')){ - alert('请选择一个卡牌背景'); - return; - } - page.content.pack.translate[name]=translate; - page.content.pack.translate[name+'_info']=info; - try{ - var card=null; - eval(container.code); - if(card==null||typeof card!='object'){ - throw('err'); - } - page.content.pack.card[name]=card; - } - catch(e){ - page.content.pack.card[name]={}; - } - if(fakeme.classList.contains('inited')){ - if(fakeme.classList.contains('fullskin')){ - page.content.pack.card[name].fullskin=true; - delete page.content.pack.card[name].fullimage; + if(page.content.pack.translate[this.link]!=this.link){ + newCard.querySelector('.new_name').value=this.link+'|'+page.content.pack.translate[this.link]; } else{ - page.content.pack.card[name].fullimage=true; - delete page.content.pack.card[name].fullskin; + newCard.querySelector('.new_name').value=this.link; } + newCard.querySelector('.new_description').value=page.content.pack.translate[this.link+'_info']; + var info=page.content.pack.card[this.link]; + container.code='card='+get.stringify(info); + + toggle.innerHTML='编辑卡牌
>
'; + editnode.innerHTML='编辑卡牌'; + editnode.classList.remove('disabled'); + delnode.innerHTML='删除'; + delnode.button=this; } - if(this.innerHTML=='创建卡牌'){ - createButton(name,fakeme.image64,fakeme.classList.contains('fullskin')); - } - else if(currentButton){ - if(fakeme.image64){ - if(fakeme.classList.contains('fullskin')){ - currentButton.style.color=''; - currentButton.style.textShadow=''; - currentButton.imagenode.style.backgroundImage='url('+fakeme.image64+')'; - currentButton.style.backgroundImage=''; - currentButton.style.backgroundSize=''; - currentButton.classList.add('fullskin'); + var createButton=function(name,image,fullskin){ + var button=ui.create.div('.button.card'); + button.link=name; + button.image=image; + button.imagenode=ui.create.div('.image',button); + if(image){ + if(fullskin){ + button.imagenode.style.backgroundImage='url('+image+')'; + button.style.backgroundImage=''; + button.style.backgroundSize=''; + button.classList.add('fullskin'); } else{ - currentButton.style.color='white'; - currentButton.style.textShadow='black 0 0 2px'; - currentButton.imagenode.style.backgroundImage=''; - currentButton.style.backgroundImage='url('+fakeme.image64+')'; - currentButton.style.backgroundSize='cover'; - currentButton.classList.remove('fullskin'); + button.style.color='white'; + button.style.textShadow='black 0 0 2px'; + button.imagenode.style.backgroundImage=''; + button.style.backgroundImage='url('+image+')'; + button.style.backgroundSize='cover'; } } - currentButton.nodename.innerHTML=get.verticalStr(translate); + button.listen(clickButton); + button.classList.add('noclick'); + button.nodename=ui.create.div(button,'.name',get.verticalStr(page.content.pack.translate[name])); + page.insertBefore(button,page.childNodes[1]); } - resetEditor(); - updatePile(); - dash2.link.classList.add('active'); - }); - var delnode=ui.create.div('.menubutton.large.new_card_delete','取消',editnode.parentNode,function(){ - if(this.innerHTML=='删除'){ - this.button.remove(); - var name=this.button.link; - delete dash2.content.pack.card[name]; - delete dash2.content.pack.translate[name]; - delete dash2.content.pack.translate[name+'_info']; - delete dash2.content.image[name]; - updatePile(); - dash2.link.classList.add('active'); - } - resetEditor(); - }); - - var editPile; - var toggle2=ui.create.div('.config.more','编辑牌堆
>
',page,function(){ - this.classList.toggle('on'); - if(this.classList.contains('on')){ - editPile.style.display=''; - } - else{ - editPile.style.display='none'; - } - }); - - editPile=ui.create.div('.edit_pile',page); - editPile.style.display='none'; - - - var cardpileadd=ui.create.div('.config.toggle.cardpilecfg.cardpilecfgadd',editPile); - var pile=ui.create.div(editPile); - page.pile=pile; - var cardpileaddname=document.createElement('select'); - var updatePile=function(){ - cardpileaddname.innerHTML=''; - var list=[]; - var list2=[]; - for(var i in page.content.pack.card){ - list.push([i,page.content.pack.translate[i]]); - list2.push(i); - } - if(list.length){ - toggle2.style.display=''; - if(toggle2.classList.contains('on')){ - editPile.style.display=''; - } - else{ - editPile.style.display='none'; + page.reset=function(name){ + resetEditor(); + var buttons=page.querySelectorAll('.button.card'); + var list=[]; + for(var i=0;i←返回',page,function(){ - ui.create.templayer(); - page.hide(); - if(page.fromchar){ - dash1.show(); - delete page.fromchar; - } - else{ - pageboard.show(); - } - }); - var currentButton=null; - var clickButton=function(){ - if(currentButton==this){ - resetEditor(); - return; - } - resetEditor(); - currentButton=this; - toggle.classList.add('on'); - newSkill.style.display=''; - if(page.content.pack.translate[this.link]!=this.link){ - newSkill.querySelector('.new_name').value=this.link+'|'+page.content.pack.translate[this.link]; - } - else{ - newSkill.querySelector('.new_name').value=this.link; - } - newSkill.querySelector('.new_description').value=page.content.pack.translate[this.link+'_info']; - var info=page.content.pack.skill[this.link]; - container.code='skill='+get.stringify(info); - - toggle.innerHTML='编辑技能
>
'; - editnode.innerHTML='编辑技能'; - editnode.classList.remove('disabled'); - delnode.button=this; - delnode.innerHTML='删除'; - } - var createButton=function(name){ - var button=ui.create.div('.menubutton'); - button.link=name; - button.innerHTML=page.content.pack.translate[name]; - button.listen(clickButton); - page.insertBefore(button,page.childNodes[1]); - } - var newSkill; - var toggle=ui.create.div('.config.more.on','创建技能
>
',page,function(){ - this.classList.toggle('on'); - if(this.classList.contains('on')){ - newSkill.style.display=''; - } - else{ - newSkill.style.display='none'; - } - }); - page.toggle=toggle; - var resetEditor=function(){ - currentButton=null; - toggle.classList.remove('on'); - newSkill.style.display='none'; - var inputs=newSkill.querySelectorAll('input'); - for(var i=0;i',newSkill); - var descnode=ui.create.div('.config','描述:',newSkill); - namenode.querySelector('input.new_name').onblur=updateButton; - var commandline=ui.create.div('.config',newSkill); - var editbutton=document.createElement('button'); - editbutton.innerHTML='编辑代码'; - commandline.appendChild(editbutton); - editbutton.onclick=function(){ - var node=container; - ui.window.classList.add('shortcutpaused'); - ui.window.classList.add('systempaused'); - window.saveNonameInput=saveInput; - if(node.aced){ - ui.window.appendChild(node); - node.editor.setValue(node.code,1); - } - else if(lib.device=='ios'){ - ui.window.appendChild(node); - if(!node.textarea){ - var textarea=document.createElement('textarea'); - editor.appendChild(textarea); - node.textarea=textarea; - lib.setScroll(textarea); - } - node.textarea.value=node.code; - } - else{ - var aceReady=function(){ - ui.window.appendChild(node); - var mirror = window.CodeMirror(editor, { - value:node.code, - mode:"javascript", - lineWrapping:!lib.config.touchscreen&&lib.config.mousewheel, - lineNumbers:true, - indentUnit:4, - autoCloseBrackets:true, - theme:'mdn-like' - }); - lib.setScroll(editor.querySelector('.CodeMirror-scroll')); - node.aced=true; - node.editor=mirror; - } - if(!window.ace){ - lib.init.js(lib.assetURL+'game','codemirror',aceReady); - lib.init.css(lib.assetURL+'layout/default','codemirror'); - } - else{ - aceReady(); - } - } - } - - var container=ui.create.div('.popup-container.editor'); - var editorpage=ui.create.div(container); - var discardConfig=ui.create.div('.editbutton','取消',editorpage,function(){ - ui.window.classList.remove('shortcutpaused'); - ui.window.classList.remove('systempaused'); - container.delete(null); - delete window.saveNonameInput; - }); - var saveInput=function(){ - var code; - if(container.editor){ - code=container.editor.getValue(); - } - else if(container.textarea){ - code=container.textarea.value; - } - try{ - var skill=null; - eval(code); - if(skill==null||typeof skill!='object'){ - throw('err'); - } - } - catch(e){ - if(e=='err'){ - alert('代码格式有错误,请对比示例代码仔细检查'); - } - else{ - alert('代码语法有错误,请仔细检查('+e+')') - } - return; - } - dash3.link.classList.add('active'); - ui.window.classList.remove('shortcutpaused'); - ui.window.classList.remove('systempaused'); - container.delete(); - container.code=code; - delete window.saveNonameInput; - }; - var saveConfig=ui.create.div('.editbutton','保存',editorpage,saveInput); - var editor=ui.create.div(editorpage); - container.code='skill={\n \n}\n\n\/*\n示例:\nskill={\n trigger:{player:"phaseJieshuBegin"},\n frequent:true,\n content:function(){\n player.draw()\n }\n}\n此例为闭月代码\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; - - var citebutton=document.createElement('button'); - citebutton.innerHTML='引用代码'; - commandline.appendChild(citebutton); - citebutton.onclick=function(){ - editbutton.style.display='none'; - citebutton.style.display='none'; - selectname.style.display=''; - skillopt.style.display=''; - addSkillButton.style.display=''; - cancelSkillButton.style.display=''; - } - - var list=[]; - for(var i in lib.character){ - if(lib.character[i][3].length){ - list.push([i,lib.translate[i]]); - } - } - list.sort(function(a,b){ - a=a[0];b=b[0]; - var aa=a,bb=b; - if(aa.indexOf('_')!=-1){ - aa=aa.slice(aa.indexOf('_')+1); - } - if(bb.indexOf('_')!=-1){ - bb=bb.slice(bb.indexOf('_')+1); - } - if(aa!=bb){ - return aa>bb?1:-1; - } - return a>b?1:-1; - }); - list.push(['others','其它']); - var list2=[]; - var skills=lib.character[list[0][0]][3]; - for(var i=0;ib?1:-1; - }); - selectname.onchange=function(){ - var skills; - skillopt.innerHTML=''; - if(this.value=='others'){ - skills=list3; - for(var i=0;i←返回',page,function(){ ui.create.templayer(); page.hide(); - dash1.show(); - delete page.fromchar; - setTimeout(resetEditor,600); - } - else{ - resetEditor(); - } - }); - - page.content={ - pack:{ - skill:{}, - translate:{} - }, - audio:{} - }; - return page; - }()); - var dash4=(function(){ - var page=ui.create.div('.hidden.menu-buttons'); - ui.create.div('.config.more.margin-bottom','
返回',page,function(){ - ui.create.templayer(); - page.hide(); - pageboard.show(); - }); - page.reset=function(name){ - page.content={}; - if(lib.extensionPack[name]){ - for(var i in dashes){ - dashes[i].node.code=''; + pageboard.show(); + }); + page.content={ + pack:{ + card:{}, + translate:{}, + list:[] + }, + image:{} + }; + var newCard; + var toggle=ui.create.div('.config.more.on','创建卡牌
>
',page,function(){ + this.classList.toggle('on'); + if(this.classList.contains('on')){ + newCard.style.display=''; } - for(var i in lib.extensionPack[name].code){ - switch(typeof lib.extensionPack[name].code[i]){ - case 'function':page.content[i]=lib.extensionPack[name].code[i].toString();break; - case 'object':page.content[i]=i+'='+get.stringify(lib.extensionPack[name].code[i]);break; + else{ + newCard.style.display='none'; + } + }); + var resetEditor=function(){ + currentButton=null; + toggle.classList.remove('on'); + newCard.style.display='none'; + fakeme.classList.remove('inited'); + fakeme.classList.add('fullskin'); + delete fakeme.image; + delete fakeme.image64; + fakeme.style.backgroundImage=''; + fakeme.imagenode.style.backgroundImage=''; + var inputs=newCard.querySelectorAll('input'); + for(var i=0;i

景',fakeme); + + ui.create.div('.indent','名称:',newCard).style.paddingTop='8px'; + ui.create.div('.indent','描述:',newCard).style.paddingTop='6px'; + newCard.querySelector('input.new_name').onblur=updateButton; + var codeButton=document.createElement('button'); + newCard.appendChild(codeButton); + codeButton.innerHTML='编辑代码'; + codeButton.style.left='123px'; + codeButton.style.top='66px'; + codeButton.style.position='absolute'; + + var citeButton=document.createElement('button'); + newCard.appendChild(citeButton); + citeButton.innerHTML='引用代码'; + citeButton.style.left='123px'; + citeButton.style.top='90px'; + citeButton.style.position='absolute'; + citeButton.onclick=function(){ + codeButton.style.display='none'; + citeButton.style.display='none'; + selectname.style.display=''; + confirmcontainer.style.display=''; + } + + var list=[]; + for(var i in lib.card){ + if(lib.translate[i]){ + list.push([i,lib.translate[i]]); + } + } + list.sort(function(a,b){ + a=a[0];b=b[0]; + var aa=a,bb=b; + if(aa.indexOf('_')!=-1){ + aa=aa.slice(aa.indexOf('_')+1); + } + if(bb.indexOf('_')!=-1){ + bb=bb.slice(bb.indexOf('_')+1); + } + if(aa!=bb){ + return aa>bb?1:-1; + } + return a>b?1:-1; + }); + var selectname=ui.create.selectlist(list,list[0],newCard); + selectname.style.left='123px'; + selectname.style.top='66px'; + selectname.style.position='absolute'; + selectname.style.display='none'; + + var confirmcontainer=ui.create.div(newCard); + confirmcontainer.style.left='123px'; + confirmcontainer.style.top='90px'; + confirmcontainer.style.position='absolute'; + confirmcontainer.style.display='none'; + + var citeconfirm=document.createElement('button'); + citeconfirm.innerHTML='引用'; + confirmcontainer.appendChild(citeconfirm); + citeconfirm.onclick=function(){ + codeButton.style.display=''; + citeButton.style.display=''; + selectname.style.display='none'; + confirmcontainer.style.display='none'; + container.code='card='+get.stringify(lib.card[selectname.value]); + codeButton.onclick.call(codeButton); + if(lib.translate[selectname.value+'_info']){ + newCard.querySelector('input.new_description').value=lib.translate[selectname.value+'_info']; + } + } + + var citecancel=document.createElement('button'); + citecancel.innerHTML='取消'; + citecancel.style.marginLeft='3px'; + confirmcontainer.appendChild(citecancel); + citecancel.onclick=function(){ + codeButton.style.display=''; + citeButton.style.display=''; + selectname.style.display='none'; + confirmcontainer.style.display='none'; + } + + codeButton.onclick=function(){ + var node=container; + ui.window.classList.add('shortcutpaused'); + ui.window.classList.add('systempaused'); + window.saveNonameInput=saveInput; + if(node.aced){ + ui.window.appendChild(node); + node.editor.setValue(node.code,1); + } + else if(lib.device=='ios'){ + ui.window.appendChild(node); + if(!node.textarea){ + var textarea=document.createElement('textarea'); + editor.appendChild(textarea); + node.textarea=textarea; + lib.setScroll(textarea); + } + node.textarea.value=node.code; + } + else{ + var aceReady=function(){ + ui.window.appendChild(node); + var mirror = window.CodeMirror(editor, { + value:node.code, + mode:"javascript", + lineWrapping:!lib.config.touchscreen&&lib.config.mousewheel, + lineNumbers:true, + indentUnit:4, + autoCloseBrackets:true, + theme:'mdn-like' + }); + lib.setScroll(editor.querySelector('.CodeMirror-scroll')); + node.aced=true; + node.editor=mirror; + } + if(!window.CodeMirror){ + lib.init.js(lib.assetURL+'game','codemirror',aceReady); + lib.init.css(lib.assetURL+'layout/default','codemirror'); + } + else{ + aceReady(); } } - for(var i in page.content){ - dashes[i].node.code=page.content[i]||''; - } } - else{ - dashes.content.node.code='function(config,pack){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之后、界面加载之前\n参数1扩展选项(见选项代码);参数2为扩展定义的武将、卡牌和技能等(可在此函数中修改)\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; - dashes.precontent.node.code='function(){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之前,且不受禁用扩展的限制\n除添加模式外请慎用\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; - dashes.config.node.code='config={\n \n}\n\n\/*\n示例:\nconfig={\n switcher_example:{\n name:"示例列表选项",\n init:"3",\n item:{"1":"一","2":"二","3":"三"}\n },\n toggle_example:{\n name:"示例开关选项",\n init:true\n }\n}\n此例中传入的主代码函数的默认参数为{switcher_example:"3",toggle_example:true}\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; - dashes.help.node.code='help={\n \n}\n\n\/*\n示例:\nhelp={\n "帮助条目":"
  • 列表1-条目1
  • 列表1-条目2
  1. 列表2-条目1
  2. 列表2-条目2"\n}\n帮助内容将显示在菜单-选项-帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; - } - }; - var dashes={}; - var createCode=function(str1,str2,sub,func,link,str){ - var dash=ui.create.div('.menubutton.large.dashboard'); - dashes[link]=dash; - sub.appendChild(dash); - dash.listen(func); - dash.link=link; - ui.create.div('',str1,dash); - ui.create.div('',str2,dash); + var container=ui.create.div('.popup-container.editor'); var editorpage=ui.create.div(container); var discardConfig=ui.create.div('.editbutton','取消',editorpage,function(){ @@ -43803,26 +43111,10 @@ code=container.textarea.value; } try{ - if(link=='content'||link=='precontent'){ - var func=null; - eval('func='+code); - if(typeof func!='function'){ - throw('err'); - } - } - else if(link=='config'){ - var config=null; - eval(code); - if(config==null||typeof config!='object'){ - throw('err'); - } - } - else if(link=='help'){ - var help=null; - eval(code); - if(help==null||typeof help!='object'){ - throw('err'); - } + var card=null; + eval(code); + if(card==null||typeof card!='object'){ + throw('err'); } } catch(e){ @@ -43834,381 +43126,1136 @@ } return; } - dash4.link.classList.add('active'); + dash2.link.classList.add('active'); ui.window.classList.remove('shortcutpaused'); ui.window.classList.remove('systempaused'); container.delete(); container.code=code; - page.content[link]=code; delete window.saveNonameInput; }; var saveConfig=ui.create.div('.editbutton','保存',editorpage,saveInput); var editor=ui.create.div(editorpage); - container.code=str; - dash.editor=editor; - dash.node=container; - dash.saveInput=saveInput; - page.content[link]=str; - }; - var clickCode=function(){ - var node=this.node; - ui.window.classList.add('shortcutpaused'); - ui.window.classList.add('systempaused'); - window.saveNonameInput=this.saveInput; - if(node.aced){ - ui.window.appendChild(node); - node.editor.setValue(node.code,1); - } - else if(lib.device=='ios'){ - ui.window.appendChild(node); - if(!node.textarea){ - var textarea=document.createElement('textarea'); - this.editor.appendChild(textarea); - node.textarea=textarea; - lib.setScroll(textarea); + container.code='card={\n \n}\n\n\/*\n示例:\ncard={\n type:"basic",\n enable:true,\n filterTarget:true,\n content:function(){\n target.draw()\n },\n ai:{\n order:1,\n result:{\n target:1\n }\n }\n}\n此例的效果为目标摸一张牌\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; + + var editnode=ui.create.div('.menubutton.large.new_card.disabled','创建卡牌',newCard,function(){ + var name=page.querySelector('input.new_name').value; + if(!name){ + alert('请填写卡牌名\n提示:卡牌名格式为id+|+中文名,其中id必须惟一'); + return; } - node.textarea.value=node.code; - } - else{ - var editor=this.editor; - var aceReady=function(){ - ui.window.appendChild(node); - var mirror = window.CodeMirror(editor, { - value:node.code, - mode:"javascript", - lineWrapping:!lib.config.touchscreen&&lib.config.mousewheel, - lineNumbers:true, - indentUnit:4, - autoCloseBrackets:true, - theme:'mdn-like' - }); - lib.setScroll(editor.querySelector('.CodeMirror-scroll')); - node.aced=true; - node.editor=mirror; - } - if(!window.ace){ - lib.init.js(lib.assetURL+'game','codemirror',aceReady); - lib.init.css(lib.assetURL+'layout/default','codemirror'); + name=name.split('|'); + var translate=name[1]||name[0]; + var info=page.querySelector('input.new_description').value; + name=name[0]; + if(currentButton){ + if(currentButton.link!=name){ + if(lib.card[name]||page.content.pack.card[name]){ + alert('卡牌名与现有卡牌重复,请更改\n提示:卡牌名格式为id+|+中文名,其中id必须惟一'); + return; + } + var extname; + if(currentButton.classList.contains('fullskin')){ + extname='.png'; + } + else{ + extname='.jpg'; + } + page.content.image[name+extname]=page.content.image[currentButton.link+extname]; + delete page.content.image[currentButton.link+extname]; + delete page.content.pack.card[currentButton.link]; + delete page.content.pack.translate[currentButton.link]; + delete page.content.pack.translate[currentButton.link+'_info']; + currentButton.link=name; + } } else{ - aceReady(); + if(lib.card[name]||page.content.pack.card[name]){ + alert('卡牌名与现有卡牌重复,请更改\n提示:卡牌名格式为id+|+中文名,其中id必须惟一'); + return; + } + } + if(fakeme.image){ + if(fakeme.classList.contains('fullskin')){ + page.content.image[name+'.png']=fakeme.image; + delete page.content.image[name+'.jpg']; + } + else{ + page.content.image[name+'.jpg']=fakeme.image; + delete page.content.image[name+'.png']; + } + } + else if(!fakeme.classList.contains('inited')){ + alert('请选择一个卡牌背景'); + return; + } + page.content.pack.translate[name]=translate; + page.content.pack.translate[name+'_info']=info; + try{ + var card=null; + eval(container.code); + if(card==null||typeof card!='object'){ + throw('err'); + } + page.content.pack.card[name]=card; + } + catch(e){ + page.content.pack.card[name]={}; + } + if(fakeme.classList.contains('inited')){ + if(fakeme.classList.contains('fullskin')){ + page.content.pack.card[name].fullskin=true; + delete page.content.pack.card[name].fullimage; + } + else{ + page.content.pack.card[name].fullimage=true; + delete page.content.pack.card[name].fullskin; + } + } + if(this.innerHTML=='创建卡牌'){ + createButton(name,fakeme.image64,fakeme.classList.contains('fullskin')); + } + else if(currentButton){ + if(fakeme.image64){ + if(fakeme.classList.contains('fullskin')){ + currentButton.style.color=''; + currentButton.style.textShadow=''; + currentButton.imagenode.style.backgroundImage='url('+fakeme.image64+')'; + currentButton.style.backgroundImage=''; + currentButton.style.backgroundSize=''; + currentButton.classList.add('fullskin'); + } + else{ + currentButton.style.color='white'; + currentButton.style.textShadow='black 0 0 2px'; + currentButton.imagenode.style.backgroundImage=''; + currentButton.style.backgroundImage='url('+fakeme.image64+')'; + currentButton.style.backgroundSize='cover'; + currentButton.classList.remove('fullskin'); + } + } + currentButton.nodename.innerHTML=get.verticalStr(translate); + } + resetEditor(); + updatePile(); + dash2.link.classList.add('active'); + }); + var delnode=ui.create.div('.menubutton.large.new_card_delete','取消',editnode.parentNode,function(){ + if(this.innerHTML=='删除'){ + this.button.remove(); + var name=this.button.link; + delete dash2.content.pack.card[name]; + delete dash2.content.pack.translate[name]; + delete dash2.content.pack.translate[name+'_info']; + delete dash2.content.image[name]; + updatePile(); + dash2.link.classList.add('active'); + } + resetEditor(); + }); + + var editPile; + var toggle2=ui.create.div('.config.more','编辑牌堆
    >
    ',page,function(){ + this.classList.toggle('on'); + if(this.classList.contains('on')){ + editPile.style.display=''; + } + else{ + editPile.style.display='none'; + } + }); + + editPile=ui.create.div('.edit_pile',page); + editPile.style.display='none'; + + + var cardpileadd=ui.create.div('.config.toggle.cardpilecfg.cardpilecfgadd',editPile); + var pile=ui.create.div(editPile); + page.pile=pile; + var cardpileaddname=document.createElement('select'); + var updatePile=function(){ + cardpileaddname.innerHTML=''; + var list=[]; + var list2=[]; + for(var i in page.content.pack.card){ + list.push([i,page.content.pack.translate[i]]); + list2.push(i); + } + if(list.length){ + toggle2.style.display=''; + if(toggle2.classList.contains('on')){ + editPile.style.display=''; + } + else{ + editPile.style.display='none'; + } + for(var i=0;i←返回',page,function(){ + ui.create.templayer(); + page.hide(); + if(page.fromchar){ + dash1.show(); + delete page.fromchar; + } + else{ + pageboard.show(); + } + }); + var currentButton=null; + var clickButton=function(){ + if(currentButton==this){ + resetEditor(); + return; + } + resetEditor(); + currentButton=this; + toggle.classList.add('on'); + newSkill.style.display=''; + if(page.content.pack.translate[this.link]!=this.link){ + newSkill.querySelector('.new_name').value=this.link+'|'+page.content.pack.translate[this.link]; + } + else{ + newSkill.querySelector('.new_name').value=this.link; + } + newSkill.querySelector('.new_description').value=page.content.pack.translate[this.link+'_info']; + var info=page.content.pack.skill[this.link]; + container.code='skill='+get.stringify(info); + + toggle.innerHTML='编辑技能
    >
    '; + editnode.innerHTML='编辑技能'; + editnode.classList.remove('disabled'); + delnode.button=this; + delnode.innerHTML='删除'; + } + var createButton=function(name){ + var button=ui.create.div('.menubutton'); + button.link=name; + button.innerHTML=page.content.pack.translate[name]; + button.listen(clickButton); + page.insertBefore(button,page.childNodes[1]); + } + var newSkill; + var toggle=ui.create.div('.config.more.on','创建技能
    >
    ',page,function(){ + this.classList.toggle('on'); + if(this.classList.contains('on')){ + newSkill.style.display=''; + } + else{ + newSkill.style.display='none'; + } + }); + page.toggle=toggle; + var resetEditor=function(){ + currentButton=null; + toggle.classList.remove('on'); + newSkill.style.display='none'; + var inputs=newSkill.querySelectorAll('input'); + for(var i=0;i
  3. 列表1-条目1
  4. 列表1-条目2
    1. 列表2-条目1
    2. 列表2-条目2"\n}\n帮助内容将显示在菜单-选项-帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'); - return page; - }()); - createDash('将','编辑武将',dash1); - createDash('卡','编辑卡牌',dash2); - createDash('技','编辑技能',dash3); - createDash('码','编辑代码',dash4); + newSkill=ui.create.div('.new_character.new_skill',page); + page.newSkill=newSkill; + var namenode=ui.create.div('.config','名称:',newSkill); + var descnode=ui.create.div('.config','描述:',newSkill); + namenode.querySelector('input.new_name').onblur=updateButton; + var commandline=ui.create.div('.config',newSkill); + var editbutton=document.createElement('button'); + editbutton.innerHTML='编辑代码'; + commandline.appendChild(editbutton); + editbutton.onclick=function(){ + var node=container; + ui.window.classList.add('shortcutpaused'); + ui.window.classList.add('systempaused'); + window.saveNonameInput=saveInput; + if(node.aced){ + ui.window.appendChild(node); + node.editor.setValue(node.code,1); + } + else if(lib.device=='ios'){ + ui.window.appendChild(node); + if(!node.textarea){ + var textarea=document.createElement('textarea'); + editor.appendChild(textarea); + node.textarea=textarea; + lib.setScroll(textarea); + } + node.textarea.value=node.code; + } + else{ + var aceReady=function(){ + ui.window.appendChild(node); + var mirror = window.CodeMirror(editor, { + value:node.code, + mode:"javascript", + lineWrapping:!lib.config.touchscreen&&lib.config.mousewheel, + lineNumbers:true, + indentUnit:4, + autoCloseBrackets:true, + theme:'mdn-like' + }); + lib.setScroll(editor.querySelector('.CodeMirror-scroll')); + node.aced=true; + node.editor=mirror; + } + if(!window.ace){ + lib.init.js(lib.assetURL+'game','codemirror',aceReady); + lib.init.css(lib.assetURL+'layout/default','codemirror'); + } + else{ + aceReady(); + } + } + } + + var container=ui.create.div('.popup-container.editor'); + var editorpage=ui.create.div(container); + var discardConfig=ui.create.div('.editbutton','取消',editorpage,function(){ + ui.window.classList.remove('shortcutpaused'); + ui.window.classList.remove('systempaused'); + container.delete(null); + delete window.saveNonameInput; + }); + var saveInput=function(){ + var code; + if(container.editor){ + code=container.editor.getValue(); + } + else if(container.textarea){ + code=container.textarea.value; + } + try{ + var skill=null; + eval(code); + if(skill==null||typeof skill!='object'){ + throw('err'); + } + } + catch(e){ + if(e=='err'){ + alert('代码格式有错误,请对比示例代码仔细检查'); + } + else{ + alert('代码语法有错误,请仔细检查('+e+')') + } + return; + } + dash3.link.classList.add('active'); + ui.window.classList.remove('shortcutpaused'); + ui.window.classList.remove('systempaused'); + container.delete(); + container.code=code; + delete window.saveNonameInput; + }; + var saveConfig=ui.create.div('.editbutton','保存',editorpage,saveInput); + var editor=ui.create.div(editorpage); + container.code='skill={\n \n}\n\n\/*\n示例:\nskill={\n trigger:{player:"phaseJieshuBegin"},\n frequent:true,\n content:function(){\n player.draw()\n }\n}\n此例为闭月代码\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; + + var citebutton=document.createElement('button'); + citebutton.innerHTML='引用代码'; + commandline.appendChild(citebutton); + citebutton.onclick=function(){ + editbutton.style.display='none'; + citebutton.style.display='none'; + selectname.style.display=''; + skillopt.style.display=''; + addSkillButton.style.display=''; + cancelSkillButton.style.display=''; + } + + var list=[]; + for(var i in lib.character){ + if(lib.character[i][3].length){ + list.push([i,lib.translate[i]]); + } + } + list.sort(function(a,b){ + a=a[0];b=b[0]; + var aa=a,bb=b; + if(aa.indexOf('_')!=-1){ + aa=aa.slice(aa.indexOf('_')+1); + } + if(bb.indexOf('_')!=-1){ + bb=bb.slice(bb.indexOf('_')+1); + } + if(aa!=bb){ + return aa>bb?1:-1; + } + return a>b?1:-1; + }); + list.push(['others','其它']); + var list2=[]; + var skills=lib.character[list[0][0]][3]; + for(var i=0;ib?1:-1; + }); + selectname.onchange=function(){ + var skills; + skillopt.innerHTML=''; + if(this.value=='others'){ + skills=list3; + for(var i=0;i←返回',page,function(){ + ui.create.templayer(); + page.hide(); + pageboard.show(); + }); + page.reset=function(name){ + page.content={}; + if(lib.extensionPack[name]){ + for(var i in dashes){ + dashes[i].node.code=''; + } + for(var i in lib.extensionPack[name].code){ + switch(typeof lib.extensionPack[name].code[i]){ + case 'function':page.content[i]=lib.extensionPack[name].code[i].toString();break; + case 'object':page.content[i]=i+'='+get.stringify(lib.extensionPack[name].code[i]);break; + } + } + for(var i in page.content){ + dashes[i].node.code=page.content[i]||''; + } + } + else{ + dashes.content.node.code='function(config,pack){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之后、界面加载之前\n参数1扩展选项(见选项代码);参数2为扩展定义的武将、卡牌和技能等(可在此函数中修改)\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; + dashes.precontent.node.code='function(){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之前,且不受禁用扩展的限制\n除添加模式外请慎用\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; + dashes.config.node.code='config={\n \n}\n\n\/*\n示例:\nconfig={\n switcher_example:{\n name:"示例列表选项",\n init:"3",\n item:{"1":"一","2":"二","3":"三"}\n },\n toggle_example:{\n name:"示例开关选项",\n init:true\n }\n}\n此例中传入的主代码函数的默认参数为{switcher_example:"3",toggle_example:true}\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; + dashes.help.node.code='help={\n \n}\n\n\/*\n示例:\nhelp={\n "帮助条目":"
      • 列表1-条目1
      • 列表1-条目2
      1. 列表2-条目1
      2. 列表2-条目2"\n}\n帮助内容将显示在菜单-选项-帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; + } + }; + var dashes={}; + var createCode=function(str1,str2,sub,func,link,str){ + var dash=ui.create.div('.menubutton.large.dashboard'); + dashes[link]=dash; + sub.appendChild(dash); + dash.listen(func); + dash.link=link; + ui.create.div('',str1,dash); + ui.create.div('',str2,dash); + var container=ui.create.div('.popup-container.editor'); + var editorpage=ui.create.div(container); + var discardConfig=ui.create.div('.editbutton','取消',editorpage,function(){ + ui.window.classList.remove('shortcutpaused'); + ui.window.classList.remove('systempaused'); + container.delete(null); + delete window.saveNonameInput; + }); + var saveInput=function(){ + var code; + if(container.editor){ + code=container.editor.getValue(); + } + else if(container.textarea){ + code=container.textarea.value; + } + try{ + if(link=='content'||link=='precontent'){ + var func=null; + eval('func='+code); + if(typeof func!='function'){ + throw('err'); + } + } + else if(link=='config'){ + var config=null; + eval(code); + if(config==null||typeof config!='object'){ + throw('err'); + } + } + else if(link=='help'){ + var help=null; + eval(code); + if(help==null||typeof help!='object'){ + throw('err'); + } + } + } + catch(e){ + if(e=='err'){ + alert('代码格式有错误,请对比示例代码仔细检查'); + } + else{ + alert('代码语法有错误,请仔细检查('+e+')') + } + return; + } + dash4.link.classList.add('active'); + ui.window.classList.remove('shortcutpaused'); + ui.window.classList.remove('systempaused'); + container.delete(); + container.code=code; + page.content[link]=code; + delete window.saveNonameInput; + }; + var saveConfig=ui.create.div('.editbutton','保存',editorpage,saveInput); + var editor=ui.create.div(editorpage); + container.code=str; + dash.editor=editor; + dash.node=container; + dash.saveInput=saveInput; + page.content[link]=str; + }; + var clickCode=function(){ + var node=this.node; + ui.window.classList.add('shortcutpaused'); + ui.window.classList.add('systempaused'); + window.saveNonameInput=this.saveInput; + if(node.aced){ + ui.window.appendChild(node); + node.editor.setValue(node.code,1); + } + else if(lib.device=='ios'){ + ui.window.appendChild(node); + if(!node.textarea){ + var textarea=document.createElement('textarea'); + this.editor.appendChild(textarea); + node.textarea=textarea; + lib.setScroll(textarea); + } + node.textarea.value=node.code; + } + else{ + var editor=this.editor; + var aceReady=function(){ + ui.window.appendChild(node); + var mirror = window.CodeMirror(editor, { + value:node.code, + mode:"javascript", + lineWrapping:!lib.config.touchscreen&&lib.config.mousewheel, + lineNumbers:true, + indentUnit:4, + autoCloseBrackets:true, + theme:'mdn-like' + }); + lib.setScroll(editor.querySelector('.CodeMirror-scroll')); + node.aced=true; + node.editor=mirror; + } + if(!window.ace){ + lib.init.js(lib.assetURL+'game','codemirror',aceReady); + lib.init.css(lib.assetURL+'layout/default','codemirror'); + } + else{ + aceReady(); + } + } + }; + page.content={} + createCode('主','主代码',page,clickCode,'content','function(config,pack){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之后、界面加载之前\n参数1扩展选项(见选项代码);参数2为扩展定义的武将、卡牌和技能等(可在此函数中修改)\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'); + createCode('启','启动代码',page,clickCode,'precontent','function(){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之前,且不受禁用扩展的限制\n除添加模式外请慎用\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'); + createCode('选','选项代码',page,clickCode,'config','config={\n \n}\n\n\/*\n示例:\nconfig={\n switcher_example:{\n name:"示例列表选项",\n init:"3",\n item:{"1":"一","2":"二","3":"三"}\n },\n toggle_example:{\n name:"示例开关选项",\n init:true\n }\n}\n此例中传入的主代码函数的默认参数为{switcher_example:"3",toggle_example:true}\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'); + createCode('帮','帮助代码',page,clickCode,'help','help={\n \n}\n\n\/*\n示例:\nhelp={\n "帮助条目":"
        • 列表1-条目1
        • 列表1-条目2
        1. 列表2-条目1
        2. 列表2-条目2"\n}\n帮助内容将显示在菜单-选项-帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'); + + return page; + }()); + createDash('将','编辑武将',dash1); + createDash('卡','编辑卡牌',dash2); + createDash('技','编辑技能',dash3); + createDash('码','编辑代码',dash4); + }; }()); (function(){ var page=ui.create.div(''); var node=ui.create.div('.menubutton.large','获取扩展',start.firstChild,clickMode); - node.link=page; - node.mode='get'; - page.listen(function(){ - if(!page.currenttimeout){ - var active=page.querySelector('.videonode.current'); - if(active){ + node._initLink=function(){ + node.link=page; + node.mode='get'; + page.listen(function(){ + if(!page.currenttimeout){ + var active=page.querySelector('.videonode.current'); + if(active){ + active.classList.remove('current'); + } + } + }); + var importextensionexpanded=false; + page.style.paddingBottom='10px'; + var importExtension; + var extensionnode=ui.create.div('.config.more','导入扩展
          >
          ',page,function(){ + if(importextensionexpanded){ + this.classList.remove('on'); + importExtension.style.display='none'; + } + else{ + this.classList.add('on'); + importExtension.style.display=''; + } + importextensionexpanded=!importextensionexpanded; + }); + importExtension=ui.create.div('.new_character.export.import',page); + importExtension.style.marginLeft='5px'; + importExtension.style.marginTop='5px'; + importExtension.style.marginBottom='5px'; + importExtension.style.display='none'; + importExtension.style.width='100%'; + importExtension.style.textAlign='left'; + ui.create.div('','',importExtension); + ui.create.div('.config','修改下载地址',page,function(){ + alert('您可以在“设置→通用→获取扩展地址”中,修改下载扩展时所采用的地址。') + }) + + var extensionURL; + var source=lib.config.extension_sources,index=lib.config.extension_source; + if(source&&source[index]) extensionURL=source[index]; + else extensionURL=lib.updateURL.replace(/noname/g,'noname-extension')+'/master/'; + + var reloadnode=ui.create.div('.config.toggle.pointerdiv','重新启动',page,game.reload); + reloadnode.style.display='none'; + var placeholder=ui.create.div('.config.toggle',page); + placeholder.style.height=0; + placeholder.style.marginTop='5px'; + + importExtension.firstChild.lastChild.onclick=function(){ + var fileToLoad=this.previousSibling.files[0]; + if(fileToLoad){ + var fileReader = new FileReader(); + fileReader.onload = function(fileLoadedEvent) + { + var finishLoad=function(){ + extensionnode.innerHTML='导入成功,3秒后将重启'; + setTimeout(function(){ + extensionnode.innerHTML='导入成功,2秒后将重启'; + setTimeout(function(){ + extensionnode.innerHTML='导入成功,1秒后将重启'; + setTimeout(game.reload,1000); + },1000); + },1000); + }; + var data = fileLoadedEvent.target.result; + if(game.importExtension(data,finishLoad)!==false){ + importExtension.style.display='none'; + } + }; + fileReader.readAsArrayBuffer(fileToLoad, "UTF-8"); + } + } + + var clickExtension=function(){ + var active=this.parentNode.querySelector('.videonode.current'); + if(active&&active!=this){ active.classList.remove('current'); } - } - }); - var importextensionexpanded=false; - page.style.paddingBottom='10px'; - var importExtension; - var extensionnode=ui.create.div('.config.more','导入扩展
          >
          ',page,function(){ - if(importextensionexpanded){ - this.classList.remove('on'); - importExtension.style.display='none'; - } - else{ - this.classList.add('on'); - importExtension.style.display=''; - } - importextensionexpanded=!importextensionexpanded; - }); - importExtension=ui.create.div('.new_character.export.import',page); - importExtension.style.marginLeft='5px'; - importExtension.style.marginTop='5px'; - importExtension.style.marginBottom='5px'; - importExtension.style.display='none'; - importExtension.style.width='100%'; - importExtension.style.textAlign='left'; - ui.create.div('','',importExtension); - ui.create.div('.config','修改下载地址',page,function(){ - alert('您可以在“设置→通用→获取扩展地址”中,修改下载扩展时所采用的地址。') - }) - - var extensionURL; - var source=lib.config.extension_sources,index=lib.config.extension_source; - if(source&&source[index]) extensionURL=source[index]; - else extensionURL=lib.updateURL.replace(/noname/g,'noname-extension')+'/master/'; - - var reloadnode=ui.create.div('.config.toggle.pointerdiv','重新启动',page,game.reload); - reloadnode.style.display='none'; - var placeholder=ui.create.div('.config.toggle',page); - placeholder.style.height=0; - placeholder.style.marginTop='5px'; - - importExtension.firstChild.lastChild.onclick=function(){ - var fileToLoad=this.previousSibling.files[0]; - if(fileToLoad){ - var fileReader = new FileReader(); - fileReader.onload = function(fileLoadedEvent) - { - var finishLoad=function(){ - extensionnode.innerHTML='导入成功,3秒后将重启'; - setTimeout(function(){ - extensionnode.innerHTML='导入成功,2秒后将重启'; - setTimeout(function(){ - extensionnode.innerHTML='导入成功,1秒后将重启'; - setTimeout(game.reload,1000); - },1000); - },1000); - }; - var data = fileLoadedEvent.target.result; - if(game.importExtension(data,finishLoad)!==false){ - importExtension.style.display='none'; - } - }; - fileReader.readAsArrayBuffer(fileToLoad, "UTF-8"); - } - } - - var clickExtension=function(){ - var active=this.parentNode.querySelector('.videonode.current'); - if(active&&active!=this){ - active.classList.remove('current'); - } - this.classList.add('current'); - clearTimeout(page.currenttimeout); - page.currenttimeout=setTimeout(function(){ - delete page.currenttimeout; - },200); - }; - var downloadExtension=function(e){ - if((this.innerHTML!='下载扩展'&&this.innerHTML!='更新扩展')||!window.JSZip) return; - this.classList.remove('update'); - if(e){ - e.stopPropagation(); - } - node.updated=true; - var that=this; - var list=[]; - var size=parseFloat(this.info.size)||0; - if(size){ - if(this.info.size.indexOf('MB')!=-1){ - size*=1024*1024; - } - else if(this.info.size.indexOf('KB')!=-1){ - size*=1024; - } - } - - this.innerHTML='正在下载
          正在下载
          '; - this.classList.add('nopointer'); - this.classList.add('button-downloading'); - var progress=ui.create.div('.button-progress',this); - ui.create.div(progress); - var url=extensionURL+this.info.name+'.zip'; - var onprogress=function(byte,total){ - if(total){ - size=total; - } - if(byte==-1){ - byte=size; - } - progress.firstChild.style.width=Math.round(100*byte/size)+'%'; + this.classList.add('current'); + clearTimeout(page.currenttimeout); + page.currenttimeout=setTimeout(function(){ + delete page.currenttimeout; + },200); }; - var files=this.info.files||[]; - for(var i=0;i('+list[i].size+')',node); + ui.create.div('.text',list[i].intro,node); + var download=ui.create.div('.menubutton.text.active','下载扩展',node.firstChild); + if(game.download){ + if(list[i].netdisk){ + var linknode=ui.create.div('.text',node); + ui.create.node('span.hrefnode','网盘链接',function(){ + game.open(this.link); + },linknode).link=list[i].netdisk; + if(list[i].forum){ + ui.create.node('span',linknode).style.marginRight='10px'; + ui.create.node('span.hrefnode','参与讨论',function(){ + game.open(this.link); + },linknode).link=list[i].forum; } } - reloadnode.style.display=''; - that.childNodes[0].innerHTML='安装成功'; - that.childNodes[1].innerHTML='安装成功'; - that.classList.remove('active'); - that.classList.remove('highlight'); - delete game.importedPack; - } - else{ - that.innerHTML='安装失败'; - that.classList.add('nopointer'); - } - _status.importingExtension=false; - },function(){ - that.innerHTML='下载失败'; - that.classList.add('nopointer'); - _status.importingExtension=false; - }); - },function(current){ - return 'extension/'+current.slice(extensionURL.length); - }); - }); - }; - - node.update=function(){ - if(this.updated) return; - if(!window.JSZip){ - lib.init.js(lib.assetURL+'game','jszip'); - } - var toremove=[]; - for(var i=0;i('+list[i].size+')',node); - ui.create.div('.text',list[i].intro,node); - var download=ui.create.div('.menubutton.text.active','下载扩展',node.firstChild); - if(game.download){ - if(list[i].netdisk){ - var linknode=ui.create.div('.text',node); - ui.create.node('span.hrefnode','网盘链接',function(){ - game.open(this.link); - },linknode).link=list[i].netdisk; - if(list[i].forum){ - ui.create.node('span',linknode).style.marginRight='10px'; + else if(list[i].forum){ + var linknode=ui.create.div('.text',node); ui.create.node('span.hrefnode','参与讨论',function(){ game.open(this.link); },linknode).link=list[i].forum; } - } - else if(list[i].forum){ - var linknode=ui.create.div('.text',node); - ui.create.node('span.hrefnode','参与讨论',function(){ - game.open(this.link); - },linknode).link=list[i].forum; - } - download.listen(downloadExtension); - if(lib.config.extensions.contains(list[i].name)){ - download.classList.remove('active'); - if(lib.extensionPack[list[i].name]&&lib.extensionPack[list[i].name].version==list[i].version){ - download.classList.add('transparent2'); + download.listen(downloadExtension); + if(lib.config.extensions.contains(list[i].name)){ download.classList.remove('active'); - download.innerHTML='已安装'; - } - else if(lib.config['extension_'+list[i].name+'_version']!=list[i].version){ - download.innerHTML='更新扩展'; - download.classList.add('highlight'); - download.classList.add('update'); - } - else{ - download.classList.add('transparent2'); - download.classList.remove('active'); - download.innerHTML='已安装'; + if(lib.extensionPack[list[i].name]&&lib.extensionPack[list[i].name].version==list[i].version){ + download.classList.add('transparent2'); + download.classList.remove('active'); + download.innerHTML='已安装'; + } + else if(lib.config['extension_'+list[i].name+'_version']!=list[i].version){ + download.innerHTML='更新扩展'; + download.classList.add('highlight'); + download.classList.add('update'); + } + else{ + download.classList.add('transparent2'); + download.classList.remove('active'); + download.innerHTML='已安装'; + } } + download.info=list[i]; } - download.info=list[i]; - } - else{ - if(list[i].forum){ - var linknode=ui.create.div('.text',node); - ui.create.node('span',linknode); - ui.create.node('span.hrefnode','参与讨论',function(){ + else{ + if(list[i].forum){ + var linknode=ui.create.div('.text',node); + ui.create.node('span',linknode); + ui.create.node('span.hrefnode','参与讨论',function(){ + game.open(this.link); + },linknode).link=list[i].forum; + } + download.listen(function(){ game.open(this.link); - },linknode).link=list[i].forum; + }); + download.link=list[i].netdisk; } - download.listen(function(){ - game.open(this.link); - }); - download.link=list[i].netdisk; } + }; + window.extension={}; + if(game.download){ + lib.init.req(extensionURL+'catalog.js',function(){ + try{ + eval(this.responseText); + // if(!window.noname_extension_list){ + // throw('err'); + // } + } + catch(e){ + delete window.extension; + loading.innerHTML='连接失败'; + return; + } + loaded(); + },function(){ + delete window.extension; + loading.innerHTML='连接失败'; + }); + } + else{ + lib.init.req(extensionURL.replace(/raw\.githubusercontent\.com/,'rawgit.com')+'catalog.js',function(){ + try{ + eval(this.responseText); + } + catch(e){ + delete window.extension; + loading.innerHTML='连接失败'; + return; + } + loaded(); + },function(){ + delete window.extension; + loading.innerHTML='连接失败'; + }); } }; - window.extension={}; - if(game.download){ - lib.init.req(extensionURL+'catalog.js',function(){ - try{ - eval(this.responseText); - // if(!window.noname_extension_list){ - // throw('err'); - // } - } - catch(e){ - delete window.extension; - loading.innerHTML='连接失败'; - return; - } - loaded(); - },function(){ - delete window.extension; - loading.innerHTML='连接失败'; - }); - } - else{ - lib.init.req(extensionURL.replace(/raw\.githubusercontent\.com/,'rawgit.com')+'catalog.js',function(){ - try{ - eval(this.responseText); - } - catch(e){ - delete window.extension; - loading.innerHTML='连接失败'; - return; - } - loaded(); - },function(){ - delete window.extension; - loading.innerHTML='连接失败'; - }); - } }; }()); var active=start.firstChild.querySelector('.active'); @@ -44216,6 +44263,7 @@ active=start.firstChild.firstChild; active.classList.add('active'); } + if(!active.link) active._initLink(); rightPane.appendChild(active.link); updateNodes(); }()); @@ -44256,7 +44304,11 @@ } active=this; this.classList.add('active'); - rightPane.appendChild(this.link); + if(this.link) rightPane.appendChild(this.link); + else{ + this._initLink(); + rightPane.appendChild(this.link); + } if(this.type=='cheat'){ cheatButton.style.display=''; } @@ -44287,6 +44339,7 @@ ui.click.menuTab('其它'); clickMode.call(ui.commandnode); }; + //更新菜单有本体函数赋值,就不要懒加载了 (function(){ var page=ui.create.div(''); var node=ui.create.div('.menubutton.large','更新',start.firstChild,clickMode); @@ -44982,653 +45035,659 @@ } }()); (function(){ - var norow2=function(){ - var node=currentrow1; - if(!node) return false; - return node.innerHTML=='横置'||node.innerHTML=='翻面'||node.innerHTML=='换人'||node.innerHTML=='复活'; - }; - var checkCheat=function(){ - if(norow2()){ - for(var i=0;i=0){ + logindex--; + if(logindex<0){ + text2.value=''; + } + else{ + text2.value=logs[logindex]; + } + } + else{ + text2.value=''; + } + } + else if(text2.value.indexOf('无天使')!=-1&&(text2.value.indexOf('无神佛')!=-1||text2.value.indexOf('无神')!=-1&&text2.value.indexOf('无佛')!=-1)){ + game.print('密码正确!欢迎来到死后世界战线!'); + _status.keyVerified=true; + text2.value=''; } else{ + if(!game.observe&&!game.online){ + try{ + var value=text2.value.trim(); + if(value.endsWith(";")) value=value.slice(0,-1).trim(); + var result=fun(reg,value,_status,lib,game,ui,get,ai); + game.print(result); + } + catch(e){ + game.print(e); + } + } text2.value=''; } } - else if(text2.value=='down'){ - if(logindex>=0){ - logindex--; - if(logindex<0){ - text2.value=''; - } - else{ - text2.value=logs[logindex]; + text2.addEventListener('keydown',function(e){ + if(e.keyCode==13){ + runCommand(); + } + else if(e.keyCode==38){ + if(logindex+1=0){ + logindex--; + if(logindex<0){ + text2.value=''; + } + else{ + text2.value=logs[logindex]; + } } } - text2.value=''; - } - } - text2.addEventListener('keydown',function(e){ - if(e.keyCode==13){ - runCommand(); - } - else if(e.keyCode==38){ - if(logindex+1=0){ - logindex--; - if(logindex<0){ - text2.value=''; - } - else{ - text2.value=logs[logindex]; - } - } - } - }); - page.appendChild(text2); - game.print=function(){ - var args=[].slice.call(arguments); - var printResult=args.map(arg=>{ - if(get.is.object(arg)||typeof arg=='function'){ - var argi=get.stringify(arg); - if(argi/*&&argi.length<5000*/){ - return argi.replace(/&/g, '&') + }); + page.appendChild(text2); + game.print=function(){ + var args=[].slice.call(arguments); + var printResult=args.map(arg=>{ + if(get.is.object(arg)||typeof arg=='function'){ + var argi=get.stringify(arg); + if(argi/*&&argi.length<5000*/){ + return argi.replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + else return arg.toString(); + }else{ + var str=String(arg); + if (!/<[a-zA-Z]+[^>]*?\/?>.*?(?=<\/[a-zA-Z]+[^>]*?>|$)/.exec(str)) return String(arg) + .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); + else return str; } - else return arg.toString(); - }else{ - var str=String(arg); - if (!/<[a-zA-Z]+[^>]*?\/?>.*?(?=<\/[a-zA-Z]+[^>]*?>|$)/.exec(str)) return String(arg) - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); - else return str; - } - }).join(' '); - pre.innerHTML+=printResult+'
          '; - text.scrollTop=text.scrollHeight; - } - if(_status.toprint){ - for(var i=0;i<_status.toprint.length;i++){ - game.print.apply(this,_status.toprint[i]); + }).join(' '); + pre.innerHTML+=printResult+'
          '; + text.scrollTop=text.scrollHeight; } - delete _status.toprint; - } - runButton.listen(runCommand); - clearButton.listen(function(){ - pre.innerHTML=''; - }); + if(_status.toprint){ + for(var i=0;i<_status.toprint.length;i++){ + game.print.apply(this,_status.toprint[i]); + } + delete _status.toprint; + } + runButton.listen(runCommand); + clearButton.listen(function(){ + pre.innerHTML=''; + }); + }; }()); (function(){ var page=ui.create.div(''); var node=ui.create.div('.menubutton.large','战绩',start.firstChild,clickMode); node.type='rec'; - node.link=page; - page.style.paddingBottom='10px'; - var reset=function(){ - if(this.innerHTML=='重置'){ - this.innerHTML='确定'; - var that=this; - setTimeout(function(){ - that.innerHTML='重置'; - },1000); + node._initLink=function(){ + node.link=page; + page.style.paddingBottom='10px'; + var reset=function(){ + if(this.innerHTML=='重置'){ + this.innerHTML='确定'; + var that=this; + setTimeout(function(){ + that.innerHTML='重置'; + },1000); + } + else{ + this.parentNode.previousSibling.remove(); + this.parentNode.remove(); + lib.config.gameRecord[this.parentNode.link]={data:{}}; + game.saveConfig('gameRecord',lib.config.gameRecord); + } } - else{ - this.parentNode.previousSibling.remove(); - this.parentNode.remove(); - lib.config.gameRecord[this.parentNode.link]={data:{}}; - game.saveConfig('gameRecord',lib.config.gameRecord); + for(var i=0;i重置',page); + item.style.height='auto'; + item.lastChild.addEventListener('click',reset); + item.lastChild.classList.add('pointerdiv'); + item.link=lib.config.all.mode[i]; + } } - } - for(var i=0;i重置',page); - item.style.height='auto'; - item.lastChild.addEventListener('click',reset); - item.lastChild.classList.add('pointerdiv'); - item.link=lib.config.all.mode[i]; - } - } + }; }()); (function(){ if(!window.indexedDB||window.nodb) return; var page=ui.create.div(''); var node=ui.create.div('.menubutton.large','录像',start.firstChild,clickMode); node.type='video'; - node.link=page; - - var store=lib.db.transaction(['video'],'readwrite').objectStore('video'); lib.videos=[]; - store.openCursor().onsuccess=function(e){ - var cursor=e.target.result; - if(cursor){ - lib.videos.push(cursor.value); - cursor.continue(); - } - else{ - lib.videos.sort(function(a,b){ - return parseInt(b.time)-parseInt(a.time); - }); - var clickcapt=function(){ - var current=this.parentNode.querySelector('.videonode.active'); - if(current&¤t!=this){ - current.classList.remove('active'); - } - if(this.classList.toggle('active')){ - playButton.show(); - deleteButton.show(); - saveButton.show(); - } - else{ - playButton.hide(); - deleteButton.hide(); - saveButton.hide(); - } - }; - var staritem=function(){ - this.parentNode.classList.toggle('starred'); - var store=lib.db.transaction(['video'],'readwrite').objectStore('video'); - if(this.parentNode.classList.contains('starred')){ - this.parentNode.link.starred=true; - } - else{ - this.parentNode.link.starred=false; - } - store.put(this.parentNode.link); + node._initLink=function(){ + node.link=page; + var store=lib.db.transaction(['video'],'readwrite').objectStore('video'); + store.openCursor().onsuccess=function(e){ + var cursor=e.target.result; + if(cursor){ + lib.videos.push(cursor.value); + cursor.continue(); } - var createNode=function(video,before){ - var node=ui.create.div('.videonode.menubutton.large',clickcapt); - node.link=video; - var nodename1=ui.create.div('.menubutton.videoavatar',node); - nodename1.setBackground(video.name1,'character'); - if(video.name2){ - var nodename2=ui.create.div('.menubutton.videoavatar2',node); - nodename2.setBackground(video.name2,'character'); - } - var date=new Date(video.time); - var str=date.getFullYear()+'.'+(date.getMonth()+1)+'.'+(date.getDate())+' '+ - date.getHours()+':'; - var minutes=date.getMinutes(); - if(minutes<10){ - str+='0'; - } - str+=minutes; - ui.create.div('.caption',video.name[0],node); - ui.create.div('.text',str+'
          '+video.name[1],node); - if(video.win){ - ui.create.div('.victory','胜',node); - } - - if(before){ - page.insertBefore(node,page.firstChild); - } - else{ - page.appendChild(node); - } - ui.create.div('.video_star','★',node,staritem); - if(video.starred){ - node.classList.add('starred'); - } - } - for(var i=0;i导入录像...',function(){ - this.nextSibling.classList.toggle('hidden'); - },page); - importVideoNode.style.marginLeft='12px'; - importVideoNode.style.marginTop='3px'; - var importVideo=ui.create.div('.config.hidden',page); - importVideo.style.whiteSpace='nowrap'; - importVideo.style.marginBottom='80px'; - importVideo.style.marginLeft='13px'; - importVideo.style.width='calc(100% - 30px)'; - importVideo.innerHTML=''+ - ''; - importVideo.lastChild.onclick=function(){ - var fileToLoad = importVideo.firstChild.files[0]; - var fileReader = new FileReader(); - fileReader.onload = function(fileLoadedEvent) - { - var data = fileLoadedEvent.target.result; - if(!data) return; - try{ - data=JSON.parse(lib.init.decode(data)); + else{ + lib.videos.sort(function(a,b){ + return parseInt(b.time)-parseInt(a.time); + }); + var clickcapt=function(){ + var current=this.parentNode.querySelector('.videonode.active'); + if(current&¤t!=this){ + current.classList.remove('active'); } - catch(e){ - console.log(e); - alert('导入失败'); - return; + if(this.classList.toggle('active')){ + playButton.show(); + deleteButton.show(); + saveButton.show(); } + else{ + playButton.hide(); + deleteButton.hide(); + saveButton.hide(); + } + }; + var staritem=function(){ + this.parentNode.classList.toggle('starred'); var store=lib.db.transaction(['video'],'readwrite').objectStore('video'); - var videos=lib.videos.slice(0); - for(var i=0;i=parseInt(lib.config.video)&&videos.length){ - var toremove=videos.pop(); - lib.videos.remove(toremove); - store.delete(toremove.time); - for(var i=0;i'+video.name[1],node); + if(video.win){ + ui.create.div('.victory','胜',node); + } + + if(before){ + page.insertBefore(node,page.firstChild); + } + else{ + page.appendChild(node); + } + ui.create.div('.video_star','★',node,staritem); + if(video.starred){ + node.classList.add('starred'); + } + } + for(var i=0;i导入录像...',function(){ + this.nextSibling.classList.toggle('hidden'); + },page); + importVideoNode.style.marginLeft='12px'; + importVideoNode.style.marginTop='3px'; + var importVideo=ui.create.div('.config.hidden',page); + importVideo.style.whiteSpace='nowrap'; + importVideo.style.marginBottom='80px'; + importVideo.style.marginLeft='13px'; + importVideo.style.width='calc(100% - 30px)'; + importVideo.innerHTML=''+ + ''; + importVideo.lastChild.onclick=function(){ + var fileToLoad = importVideo.firstChild.files[0]; + var fileReader = new FileReader(); + fileReader.onload = function(fileLoadedEvent) + { + var data = fileLoadedEvent.target.result; + if(!data) return; + try{ + data=JSON.parse(lib.init.decode(data)); + } + catch(e){ + console.log(e); + alert('导入失败'); return; } + var store=lib.db.transaction(['video'],'readwrite').objectStore('video'); + var videos=lib.videos.slice(0); + for(var i=0;i=parseInt(lib.config.video)&&videos.length){ + var toremove=videos.pop(); + lib.videos.remove(toremove); + store.delete(toremove.time); + for(var i=0;i