pref: format @/mode.

This commit is contained in:
Rintim 2024-04-16 02:46:41 +08:00
parent 230b6a9088
commit 6a82aecbe0
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
12 changed files with 63286 additions and 51507 deletions

15065
mode/boss.js

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,182 +1,208 @@
'use strict'; "use strict";
game.import('mode',function(lib,game,ui,get,ai,_status){ game.import("mode", function (lib, game, ui, get, ai, _status) {
return { return {
name:'connect', name: "connect",
start:function(){ start: function () {
var directstartmode=lib.config.directstartmode; var directstartmode = lib.config.directstartmode;
ui.create.menu(true); ui.create.menu(true);
event.textnode=ui.create.div('','输入联机地址'); event.textnode = ui.create.div("", "输入联机地址");
var createNode=function(){ var createNode = function () {
if(event.created) return; if (event.created) return;
if(directstartmode&&lib.node){ if (directstartmode && lib.node) {
ui.exitroom=ui.create.system('退出房间',function(){ ui.exitroom = ui.create.system(
game.saveConfig('directstartmode'); "退出房间",
game.reload(); function () {
},true); game.saveConfig("directstartmode");
game.switchMode(directstartmode); game.reload();
return; },
} true
if(lib.node&&window.require){ );
ui.startServer=ui.create.system('启动服务器',function(e){ game.switchMode(directstartmode);
ui.click.shortcut(false); return;
e.stopPropagation(); }
ui.click.connectMenu(); if (lib.node && window.require) {
},true); ui.startServer = ui.create.system(
} "启动服务器",
function (e) {
event.created=true; ui.click.shortcut(false);
var node=ui.create.div('.shadowed'); e.stopPropagation();
node.style.width='400px'; ui.click.connectMenu();
node.style.height='30px'; },
node.style.lineHeight='30px'; true
node.style.fontFamily='xinwei'; );
node.style.fontSize='30px'; }
node.style.padding='10px';
node.style.left='calc(50% - 210px)'; event.created = true;
node.style.top='calc(50% - 20px)'; var node = ui.create.div(".shadowed");
node.style.whiteSpace='nowrap'; node.style.width = "400px";
node.textContent=lib.config.last_ip||lib.hallURL; node.style.height = "30px";
node.contentEditable=true; node.style.lineHeight = "30px";
node.style.webkitUserSelect='text'; node.style.fontFamily = "xinwei";
node.style.textAlign='center'; node.style.fontSize = "30px";
node.style.overflow='hidden'; node.style.padding = "10px";
node.style.left = "calc(50% - 210px)";
var connect=function(e){ node.style.top = "calc(50% - 20px)";
event.textnode.textContent='正在连接...'; node.style.whiteSpace = "nowrap";
clearTimeout(event.timeout); node.textContent = lib.config.last_ip || lib.hallURL;
if(e) e.preventDefault(); node.contentEditable = true;
game.saveConfig('last_ip',node.textContent); node.style.webkitUserSelect = "text";
game.connect(node.textContent,function(success){ node.style.textAlign = "center";
if(success){ node.style.overflow = "hidden";
var info=lib.config.reconnect_info;
if(info&&info[0]==_status.ip){ var connect = function (e) {
game.onlineID=info[1]; event.textnode.textContent = "正在连接...";
if(typeof (game.roomId=info[2])=='string') game.roomIdServer=true; clearTimeout(event.timeout);
} if (e) e.preventDefault();
return; game.saveConfig("last_ip", node.textContent);
} game.connect(node.textContent, function (success) {
if(event.textnode){ if (success) {
alert('连接失败'); var info = lib.config.reconnect_info;
event.textnode.textContent='输入联机地址'; if (info && info[0] == _status.ip) {
} game.onlineID = info[1];
}); if (typeof (game.roomId = info[2]) == "string") game.roomIdServer = true;
}; }
node.addEventListener('keydown',function(e){ return;
if(e.keyCode==13){ }
connect(e); if (event.textnode) {
} alert("连接失败");
}); event.textnode.textContent = "输入联机地址";
ui.window.appendChild(node); }
ui.ipnode=node; });
};
var text=event.textnode; node.addEventListener("keydown", function (e) {
text.style.width='400px'; if (e.keyCode == 13) {
text.style.height='30px'; connect(e);
text.style.lineHeight='30px'; }
text.style.fontFamily='xinwei'; });
text.style.fontSize='30px'; ui.window.appendChild(node);
text.style.padding='10px'; ui.ipnode = node;
text.style.left='calc(50% - 200px)';
text.style.top='calc(50% - 80px)'; var text = event.textnode;
text.style.textAlign='center'; text.style.width = "400px";
ui.window.appendChild(text); text.style.height = "30px";
ui.iptext=text; text.style.lineHeight = "30px";
text.style.fontFamily = "xinwei";
var button=ui.create.div('.menubutton.highlight.large.pointerdiv','连接',connect); text.style.fontSize = "30px";
button.style.width='70px'; text.style.padding = "10px";
button.style.left='calc(50% - 35px)'; text.style.left = "calc(50% - 200px)";
button.style.top='calc(50% + 60px)'; text.style.top = "calc(50% - 80px)";
ui.window.appendChild(button); text.style.textAlign = "center";
ui.ipbutton=button; ui.window.appendChild(text);
ui.iptext = text;
ui.hall_button=ui.create.system('联机大厅',function(){
node.textContent=get.config('hall_ip')||lib.hallURL; var button = ui.create.div(".menubutton.highlight.large.pointerdiv", "连接", connect);
connect(); button.style.width = "70px";
},true); button.style.left = "calc(50% - 35px)";
if(!get.config('hall_button')){ button.style.top = "calc(50% + 60px)";
ui.hall_button.style.display='none'; ui.window.appendChild(button);
} ui.ipbutton = button;
ui.recentIP=ui.create.system('最近连接',null,true);
var clickLink=function(){ ui.hall_button = ui.create.system(
node.textContent=this.textContent; "联机大厅",
connect(); function () {
}; node.textContent = get.config("hall_ip") || lib.hallURL;
lib.setPopped(ui.recentIP,function(){ connect();
if(!lib.config.recentIP.length) return; },
var uiintro=ui.create.dialog('hidden'); true
uiintro.listen(function(e){ );
e.stopPropagation(); if (!get.config("hall_button")) {
}); ui.hall_button.style.display = "none";
var list=ui.create.div('.caption'); }
for(var i=0;i<lib.config.recentIP.length;i++){ ui.recentIP = ui.create.system("最近连接", null, true);
ui.create.div('.text.textlink',list,clickLink).textContent=get.trimip(lib.config.recentIP[i]); var clickLink = function () {
} node.textContent = this.textContent;
uiintro.add(list); connect();
var clear=uiintro.add('<div class="text center">清除</div>'); };
clear.style.paddingTop=0; lib.setPopped(
clear.style.paddingBottom='3px'; ui.recentIP,
clear.listen(function(){ function () {
lib.config.recentIP.length=0; if (!lib.config.recentIP.length) return;
game.saveConfig('recentIP',[]); var uiintro = ui.create.dialog("hidden");
uiintro.delete(); uiintro.listen(function (e) {
}); e.stopPropagation();
return uiintro; });
},220); var list = ui.create.div(".caption");
if (get.config('read_clipboard','connect')){ for (var i = 0; i < lib.config.recentIP.length; i++) {
var ced=false; ui.create.div(".text.textlink", list, clickLink).textContent = get.trimip(
var read=text=>{ lib.config.recentIP[i]
try{ );
var text2=text.split('\n')[2]; }
var ip=text2.slice(5); uiintro.add(list);
if(ip.length>0&&text2.startsWith("联机地址:")&&(ced||confirm('是否根据剪贴板的邀请链接以进入联机地址和房间?'))){ var clear = uiintro.add('<div class="text center">清除</div>');
node.innerHTML=ip; clear.style.paddingTop = 0;
event.textnode.innerHTML='正在连接...'; clear.style.paddingBottom = "3px";
clearTimeout(event.timeout); clear.listen(function () {
game.saveConfig('last_ip',node.innerHTML); lib.config.recentIP.length = 0;
game.connect(node.innerHTML,function(success){ game.saveConfig("recentIP", []);
if(!success&&event.textnode){ uiintro.delete();
alert('邀请链接解析失败'); });
event.textnode.innerHTML='输入联机地址'; return uiintro;
} },
if (success) _status.read_clipboard_text=text; 220
}); );
} if (get.config("read_clipboard", "connect")) {
}catch(e){console.log(e);} var ced = false;
} var read = (text) => {
window.focus(); try {
if (navigator.clipboard&&lib.node){ var text2 = text.split("\n")[2];
navigator.clipboard.readText().then(read).catch(_=>{}); var ip = text2.slice(5);
}else{ if (
var input=ui.create.node('textarea',ui.window,{opacity:'0'}); ip.length > 0 &&
input.select(); text2.startsWith("联机地址:") &&
var result=document.execCommand('paste'); (ced || confirm("是否根据剪贴板的邀请链接以进入联机地址和房间?"))
input.blur(); ) {
ui.window.removeChild(input); node.innerHTML = ip;
if(result||input.value.length>0) read(input.value); event.textnode.innerHTML = "正在连接...";
else if(confirm('是否输入邀请链接以进入联机地址和房间?')){ clearTimeout(event.timeout);
ced=true; game.saveConfig("last_ip", node.innerHTML);
var text=prompt('请输入邀请链接'); game.connect(node.innerHTML, function (success) {
if(typeof text=='string'&&text.length>0) read(text); if (!success && event.textnode) {
} alert("邀请链接解析失败");
} event.textnode.innerHTML = "输入联机地址";
} }
lib.init.onfree(); if (success) _status.read_clipboard_text = text;
} });
if(window.isNonameServer){ }
game.connect(window.isNonameServerIp||'localhost'); } catch (e) {
} console.log(e);
else{ }
createNode(); };
} window.focus();
if(!game.onlineKey){ if (navigator.clipboard && lib.node) {
game.onlineKey=localStorage.getItem(lib.configprefix+'key'); navigator.clipboard
if(!game.onlineKey){ .readText()
game.onlineKey=get.id(); .then(read)
localStorage.setItem(lib.configprefix+'key',game.onlineKey); .catch((_) => {});
} } else {
} var input = ui.create.node("textarea", ui.window, { opacity: "0" });
_status.connectDenied=createNode; input.select();
setTimeout(lib.init.onfree,1000); var result = document.execCommand("paste");
} input.blur();
}; ui.window.removeChild(input);
}); if (result || input.value.length > 0) read(input.value);
else if (confirm("是否输入邀请链接以进入联机地址和房间?")) {
ced = true;
var text = prompt("请输入邀请链接");
if (typeof text == "string" && text.length > 0) read(text);
}
}
}
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);
},
};
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,8 @@
'use strict'; "use strict";
game.import('mode',function(lib,game,ui,get,ai,_status){ game.import("mode", function (lib, game, ui, get, ai, _status) {
return { return {
name:'realtime', name: "realtime",
start:function(){ start: function () {},
}, game: {},
game:{ };
} });
};
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff