diff --git a/game/game.js b/game/game.js index 9b9ff81ab..1d998855a 100644 --- a/game/game.js +++ b/game/game.js @@ -45180,7 +45180,25 @@ dash2.content.pack.list.push(dash2.pile.childNodes[i].link); } str+=',package:'+get.stringify({ - character:dash1.content.pack, + //替换die audio,加上扩展名 + character:(pack=>{ + var character=pack.character; + for (var key in character){ + var info=character[key]; + if(Array.isArray(info[4])){ + var tag=info[4].find(tag=>/^die:.+$/.test(tag)); + if(tag){ + info[4].remove(tag); + if(typeof game.readFile=='function'){ + info[4].push('die:ext:'+page.currentExtension+'/audio/die/'+tag.slice(tag.lastIndexOf('/')+1)); + }else{ + info[4].push('die:db:extension-'+page.currentExtension+':audio/die/'+tag.slice(tag.lastIndexOf('/')+1)); + } + } + } + } + return pack; + })(dash1.content.pack), card:dash2.content.pack, skill:dash3.content.pack, intro:introExtLine.querySelector('input').value||'', @@ -45189,10 +45207,13 @@ forumURL:forumExtLine.querySelector('input').value||'', version:versionExtLine.querySelector('input').value||'', }); - var files={character:[],card:[],skill:[]}; + var files={character:[],card:[],skill:[],audio:[]}; for(var i in dash1.content.image){ files.character.push(i); } + for(var i in dash1.content.audio){ + files.audio.push('audio/die/'+i); + } for(var i in dash2.content.image){ files.card.push(i); } @@ -45205,6 +45226,9 @@ for(var i in dash1.content.image){ extension[i]=dash1.content.image[i]; } + for(var i in dash1.content.audio){ + extension['audio/die/'+i]=dash1.content.audio[i]; + } for(var i in dash2.content.image){ extension[i]=dash2.content.image[i]; } @@ -45431,7 +45455,7 @@ } editnode.classList.remove('disabled'); }; - var clickButton=function(){ + var clickButton=lib.gnc.of(function*(){ if(currentButton==this){ resetEditor(); return; @@ -45465,6 +45489,31 @@ if(info[4][i].startsWith('des:')){ newCharacter.querySelector('.new_des').value=info[4][i].slice(4); } + if(info[4][i].startsWith('die:')){ + var dieaudionode=newCharacter.querySelector('.die_audio'); + dieaudionode.file={ + name:info[4][i].slice(info[4][i].lastIndexOf('/')+1) + }; + yield new Promise(resolve=>{ + if(typeof game.readFile=='function'){ + game.readFile(info[4][i].slice(4).replace('ext:','extension/'),arraybuffer=>{ + dieaudionode.arrayBuffer=arraybuffer; + resolve(); + },()=>{ + console.warn(`未找到${info[4][i].slice(4).replace('ext:','extension/')}阵亡配音`); + resolve(); + }); + }else{ + game.getDB('image',info[4][i].slice(7)).then(octetStream=>{ + dieaudionode.arrayBuffer=octetStream; + resolve(); + },()=>{ + console.warn(`未找到${info[4][i].slice(4)}阵亡配音`); + resolve(); + }); + } + }); + } } } @@ -45482,7 +45531,7 @@ editnode.classList.remove('disabled'); delnode.innerHTML='删除'; delnode.button=this; - } + }); var createButton=function(name,image){ var button=ui.create.div('.button.character'); button.link=name; @@ -45566,7 +45615,8 @@ character:{}, translate:{} }, - image:{} + image:{}, + audio:{} }; toggle.classList.add('on'); newCharacter.style.display=''; @@ -45582,7 +45632,8 @@ character:{}, translate:{} }, - image:{} + image:{}, + audio:{} }; var newCharacter; var toggle=ui.create.div('.config.more.on','创建武将
>
',page,function(){ @@ -45652,18 +45703,65 @@ ui.create.div('.indent','姓名:',newCharacter).style.paddingTop='8px'; 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','无'], + ['double','双性'], + ['none','无'] ],null,ui.create.div('.indent','性别:',newCharacter)); - var grouplist=[]; - for(var i=0;i[lib.group[i],get.translation(lib.group[i])]); var groups=ui.create.selectlist(grouplist,null,ui.create.div('.indent','势力:',newCharacter)); + var dieaudio=ui.create.div('.die_audio',newCharacter,{textAlign:'left'}); + var dieaudiolabel=ui.create.node('label','阵亡配音:',dieaudio); + var dieaudioUpload=dieaudio.appendChild(document.createElement('input')); + dieaudioUpload.type='file'; + dieaudioUpload.accept='audio/*'; + dieaudioUpload.style.width='calc(100% - 100px)'; + dieaudioUpload.onchange=function(){ + var fileToLoad=dieaudioUpload.files[0]; + if(fileToLoad){ + console.log(fileToLoad); + var fileReader=new FileReader(); + fileReader.onload=function(fileLoadedEvent){ + var data=fileLoadedEvent.target.result; + var blob=new Blob([data]); + dieaudio.file=fileToLoad; + dieaudio.arrayBuffer=data; + dieaudio.blob=blob; + var new_name=newCharacter.querySelector('input.new_name'); + dieaudioUpload.style.display='none'; + dieaudiopreview.style.display= + dieaudiocancel.style.display=''; + dieaudiotag.src=window.URL.createObjectURL(blob); + }; + fileReader.readAsArrayBuffer(fileToLoad); + } + }; + var dieaudiotag=ui.create.node('audio',dieaudio); + var dieaudiopreview=ui.create.node('button',dieaudio,()=>{ + if(dieaudiotag.error){ + alert('您使用的客户端不支持预览此音频!') + } else dieaudiotag.play(); + }); + dieaudiopreview.innerHTML='播放'; + dieaudiopreview.style.display='none'; + var dieaudiocancel=ui.create.node('button',dieaudio,()=>{ + dieaudiopreview.style.display='none'; + dieaudiocancel.style.display='none'; + if(dieaudio.blob){ + window.URL.revokeObjectURL(dieaudio.blob); + dieaudiotag.src=null; + delete dieaudio.file; + delete dieaudio.arrayBuffer; + delete dieaudio.blob; + } + dieaudioUpload.value=''; + dieaudioUpload.style.display=''; + }); + dieaudiocancel.innerHTML='取消'; + dieaudiocancel.style.display='none'; var options=ui.create.div('.add_skill.options','主公BOSS仅点将可用
隐匿技
',newCharacter); var addSkill=ui.create.div('.add_skill','添加技能
',newCharacter); var list=[]; @@ -45728,8 +45826,10 @@ } addSkillButton.onclick=function(){ for(var i=0;i.new_character>.die_audio { + position: absolute; + left: 12px; + top: 160px; + height: 45px; + width: calc(100% - 12px); +} + +.menu-buttons>.new_character>.die_audio>input { + width: calc(100% - 100px); +} + +.menu-buttons>.new_character>.die_audio>button { + margin-right: 12px; +} + .menu-buttons>.new_character>.add_skill { position: absolute; left: 12px; - top: 205px; + top: 250px; text-align: left; line-height: 20px; white-space: nowrap; } .menu-buttons>.new_character>.add_skill.options { - top: 160px; + top: 205px; } .menu-buttons>.new_character>.add_skill.options>span { @@ -1859,7 +1875,7 @@ input.fileinput::-webkit-file-upload-button { } #create-extension>.menu-buttons>.new_character>.skill_list { - top: 245px; + top: 290px; } #create-extension>.menu-buttons>.new_character>.skill_list>div:first-child {