Commit 8417d3d7 authored by hex's avatar hex

add servers

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