Commit 8417d3d7 authored by hex's avatar hex

add servers

parent 645bee95
Pipeline #38467 failed
......@@ -53,13 +53,16 @@ public class SelectServer : WindowServantSP
set_version("0x" + String.Format("{0:X}", Config.ClientVersion));
//方便免修改 [selectServerWithRoomlist.prefab]
serversList.items.Add("[OCG]EXP");
serversList.items.Add("[OCG]MYGO");
serversList.items.Add("[OCG]MYGO 2");
serversList.items.Add("[OCG]EXP");
serversList.items.Add("[OCG]233 1");
serversList.items.Add("[OCG]233 2");
serversList.items.Add("[OCG]233 约战");
serversList.items.Add("[OCG]23333 Pre");
serversList.items.Add("[OCG]Koishi");
serversList.items.Add("决斗编年史");
serversList.items.Add("2Pick轮抽");
if (
Application.systemLanguage == SystemLanguage.Chinese
|| Application.systemLanguage == SystemLanguage.ChineseSimplified
......@@ -81,31 +84,31 @@ public class SelectServer : WindowServantSP
string server = serversList.value;
switch (server)
{
case "[OCG]EXP":
case "[OCG]MYGO":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "exp.baldlee.top";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "23333";
Config.Set("serversPicker", "[OCG]EXP");
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "mygo.superpre.pro";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "888";
Config.Set("serversPicker", "[OCG]MYGO");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[OCG]MYGO":
case "[OCG]EXP":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "mygo.superpre.pro";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "888";
Config.Set("serversPicker", "[OCG]MYGO");
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "exp.baldlee.top";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "23333";
Config.Set("serversPicker", "[OCG]EXP");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[OCG]Koishi":
case "[OCG]MYGO 2":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "7210";
Config.Set("serversPicker", "[OCG]Koishi");
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "mygo.superpre.pro";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "888";
Config.Set("serversPicker", "[OCG]MYGO 2");
inputIP_.enabled = false;
inputPort_.enabled = true;
......@@ -151,6 +154,36 @@ public class SelectServer : WindowServantSP
inputPort_.enabled = true;
break;
}
case "决斗编年史":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "duels.link";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "2333";
Config.Set("serversPicker", "决斗编年史");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "2Pick轮抽":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "2pick.moecube.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "765";
Config.Set("serversPicker", "2Pick轮抽");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
case "[OCG]Koishi":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.momobako.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "7210";
Config.Set("serversPicker", "[OCG]Koishi");
inputIP_.enabled = false;
inputPort_.enabled = true;
break;
}
default:
{
if (
......@@ -183,50 +216,31 @@ public class SelectServer : WindowServantSP
private void readString(string str)
{
/*
str = str.Substring(1, str.Length - 1);
string version = "", remain = "";
string[] splited;
splited = str.Split(")");
try
{
version = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(":");
string ip = "";
try
{
ip = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(" ");
string psw = "", port = "";
try
{
port = splited[0];
psw = splited[1];
}
catch (Exception)
{
}
if (EditIpAndPort)
{
inputIP.value = ip;
inputPort.value = port;
}
inputPsw.value = psw;
*/
//确保密码为空时,退出后密码依旧保持为空
str = str.Substring(5, str.Length - 5);
inputPsw.value = str;
//inputVersion.value = version;
if (str.StartsWith("psw: ")) // 特征:旧格式以 "psw: " 开头
{
// 按旧格式 "psw: xxx" 解析
string password = str.Substring(5); // 从第5个字符开始取,即密码部分
inputPsw.value = password;
}
else
{
// 新格式: IP:Port|密码
string[] parts = str.Split('|');
string ipPortPart = parts[0];
string passwordPart = (parts.Length > 1) ? parts[1] : "";
string[] ipPort = ipPortPart.Split(':');
string ip = ipPort[0];
string port = (ipPort.Length > 1) ? ipPort[1] : "";
// --- 填充到UI输入框 ---
// 只有当服务器选择为“[自定义]”时才填充IP和端口
if (serversList.value == "[自定义]" || serversList.value == "[Custom]")
{
inputIP.value = ip;
inputPort.value = port;
}
inputPsw.value = passwordPart;
}
}
void onClearPsw()
......@@ -269,17 +283,17 @@ public class SelectServer : WindowServantSP
File.Create("config/passwords.conf").Close();
}
string txtString = File.ReadAllText("config/passwords.conf");
string[] lines = txtString.Replace("\r", "").Split("\n");
for (int i = 0; i < lines.Length; i++)
string[] lines = txtString
.Replace("\r", "")
.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); // 过滤空行
foreach (string line in lines)
{
if (i == 0)
{
if (first)
{
readString(lines[i]);
}
}
list.AddItem(lines[i]);
list.AddItem(line);
}
if (first && lines.Length > 0)
{
// 初始加载时,读取第一个历史记录来填充UI
readString(lines[0]);
}
}
......@@ -351,12 +365,13 @@ public class SelectServer : WindowServantSP
{
if (name != "")
{
//string fantasty = "(" + versionString + ")" + ipString + ":" + portString + " " + pswString;
string fantasty = "psw: " + pswString;
// 旧格式: string fantasty = "psw: " + pswString;
// 新格式: IP:Port|密码
string fantasty = string.Format("{0}:{1}|{2}", ipString, portString, pswString);
list.items.Remove(fantasty);
list.items.Insert(0, fantasty);
list.value = fantasty;
if (list.items.Count > 5)
if (list.items.Count > 6)
{
list.items.RemoveAt(list.items.Count - 1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment