noname/mode/connect.js

142 lines
4.4 KiB
JavaScript
Raw Normal View History

2020-03-10 03:43:11 +00:00
'use strict';
game.import('mode',function(lib,game,ui,get,ai,_status){
return {
name:'connect',
start:function(){
var directstartmode=lib.config.directstartmode;
ui.create.menu(true);
event.textnode=ui.create.div('','输入联机地址');
var createNode=function(){
if(event.created) return;
if(directstartmode&&lib.node){
ui.exitroom=ui.create.system('退出房间',function(){
game.saveConfig('directstartmode');
game.reload();
},true);
game.switchMode(directstartmode);
return;
}
if(lib.node&&window.require){
ui.startServer=ui.create.system('启动服务器',function(e){
2023-05-02 11:26:19 +00:00
ui.click.shortcut(false);
2020-03-10 03:43:11 +00:00
e.stopPropagation();
ui.click.connectMenu();
},true);
}
event.created=true;
var node=ui.create.div('.shadowed');
node.style.width='400px';
node.style.height='30px';
node.style.lineHeight='30px';
node.style.fontFamily='xinwei';
node.style.fontSize='30px';
node.style.padding='10px';
node.style.left='calc(50% - 210px)';
node.style.top='calc(50% - 20px)';
node.style.whiteSpace='nowrap';
node.textContent=lib.config.last_ip||lib.hallURL;
2020-03-10 03:43:11 +00:00
node.contentEditable=true;
node.style.webkitUserSelect='text';
node.style.textAlign='center';
v1.9.122.3 (#146) * change lib.init.parsex, Enable 'step' to be used through nesting * Fixed an issue where nonstandard statement 'step 0' before standard statement 'step 0' would cause an error * zhangshiping; tw_madai bug fix * modify all the skills with incorrect "locked" tag * Change the game.exit function to restart the app for WKWebview users using ios. And added the macintosh field to the judgment of lib.device * various bug fix * Revert "various bug fix" This reverts commit ca7a363172a837af9244fca300d6a008cafc03ac. * various bug fix * some sudio * unlock zhenghun, fix sbdiaochan * add and adjust some audio, fix some bugs * add trigger "useSkill" and "logSkillBegin" * brand new wuxie * Update standard.js * update 武安国 * iriya! * Add character lushi; fix clansankuang * add 魏关羽/涛神,unlock 关宁/向朗/谋孙策/谋大乔/谋刘表,add related audio * fix: adjust the edit box style to fix the text overflow problem 🐛 * fix 修文 and some other small bugs * 伊莉雅·罗日杰斯特文斯卡娅 * Fix the issue of "game.getDB" and "game. deleteDB" reporting errors without "lib.db" * Some browsers do not support "autoplay", so "onconplay" listening has been added * sunwukong * more zooms * unlock 周善, modify 卢氏/卞喜/刘虞/黄祖/李采薇/张翼/笮融/孙寒华/TW董昭, fix some bug, add omitted audio * change the number of 如意金箍棒 to 9 instead of 5; fix 夏侯尚's bug; add audio for sunwukong & donghailongwang * Add the default accept value of '*/*' to the HTML selection file label * longwang * add&modify some audio * add 族王凌/界SP黄月英/界张松/武诸葛亮,fix 晖云's bug; resolve conflicts, bring 武诸葛 up to date, fix 龙王's bug * add 阮籍, add a skillTag in "jiu2" named jiuSustain for ruanji * add some audio, sort some characters in sp * sync 界SP黄月英 * add some character intros * make 谋弈 play audio correctly * revert some skills back to new ones * v1.9.122.3 * Update update.js --------- Co-authored-by: shijian <2954700422@qq.com> Co-authored-by: copcap <copcap@outlook.com> Co-authored-by: copcap <43802486+copcap@users.noreply.github.com> Co-authored-by: PBK-B <pbk-b@PBK6.cn>
2023-06-30 15:06:19 +00:00
node.style.overflow='hidden';
2020-03-10 03:43:11 +00:00
var connect=function(e){
const info=lib.config.reconnect_info;
if(info&&info[0]==node.textContent){
game.onlineID=info[1];
if(typeof (game.roomId=info[2])=='string') game.roomIdServer=true;
}
event.textnode.textContent='正在连接...';
2020-03-10 03:43:11 +00:00
clearTimeout(event.timeout);
if(e) e.preventDefault();
game.saveConfig('last_ip',node.textContent=node.textContent);
game.connect(node.textContent,function(success){
2020-03-10 03:43:11 +00:00
if(!success&&event.textnode){
alert('连接失败');
event.textnode.textContent='输入联机地址';
2020-03-10 03:43:11 +00:00
}
});
};
node.addEventListener('keydown',function(e){
if(e.keyCode==13){
connect(e);
}
});
ui.window.appendChild(node);
ui.ipnode=node;
var text=event.textnode;
text.style.width='400px';
text.style.height='30px';
text.style.lineHeight='30px';
text.style.fontFamily='xinwei';
text.style.fontSize='30px';
text.style.padding='10px';
text.style.left='calc(50% - 200px)';
text.style.top='calc(50% - 80px)';
text.style.textAlign='center';
ui.window.appendChild(text);
ui.iptext=text;
var button=ui.create.div('.menubutton.highlight.large.pointerdiv','连接',connect);
button.style.width='70px';
button.style.left='calc(50% - 35px)';
button.style.top='calc(50% + 60px)';
ui.window.appendChild(button);
ui.ipbutton=button;
ui.hall_button=ui.create.system('联机大厅',function(){
node.textContent=get.config('hall_ip')||lib.hallURL;
2020-03-10 03:43:11 +00:00
connect();
},true);
if(!get.config('hall_button')){
ui.hall_button.style.display='none';
}
ui.recentIP=ui.create.system('最近连接',null,true);
var clickLink=function(){
node.textContent=this.textContent;
2020-03-10 03:43:11 +00:00
connect();
};
lib.setPopped(ui.recentIP,function(){
if(!lib.config.recentIP.length) return;
var uiintro=ui.create.dialog('hidden');
uiintro.listen(function(e){
e.stopPropagation();
});
var list=ui.create.div('.caption');
for(var i=0;i<lib.config.recentIP.length;i++){
ui.create.div('.text.textlink',list,clickLink).textContent=get.trimip(lib.config.recentIP[i]);
2020-03-10 03:43:11 +00:00
}
uiintro.add(list);
var clear=uiintro.add('<div class="text center">清除</div>');
clear.style.paddingTop=0;
clear.style.paddingBottom='3px';
clear.listen(function(){
lib.config.recentIP.length=0;
game.saveConfig('recentIP',[]);
uiintro.delete();
});
return uiintro;
},220);
lib.init.onfree();
}
if(window.isNonameServer){
game.connect(window.isNonameServerIp||'localhost');
}
else{
createNode();
}
if(!game.onlineKey){
game.onlineKey=localStorage.getItem(lib.configprefix+'key');
if(!game.onlineKey){
game.onlineKey=get.id();
localStorage.setItem(lib.configprefix+'key',game.onlineKey);
}
}
_status.connectDenied=createNode;
setTimeout(lib.init.onfree,1000);
}
};
});