|
@@ -1,6 +1,10 @@
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
using FairyGUI;
|
|
|
using Sirenix.Utilities;
|
|
|
+using System;
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
using UnityEngine;
|
|
|
|
|
|
namespace ET.Client
|
|
@@ -8,6 +12,9 @@ namespace ET.Client
|
|
|
[Event(SceneType.Client)]
|
|
|
public class AppStartInitFinish_CreateLoginUI : AEvent<EventType.AppStartInitFinish>
|
|
|
{
|
|
|
+ private string mIP;
|
|
|
+ private int mPort;
|
|
|
+
|
|
|
protected override async ETTask Run(Scene scene, EventType.AppStartInitFinish args)
|
|
|
{
|
|
|
Log.Debug("to load login ui.");
|
|
@@ -19,27 +26,95 @@ namespace ET.Client
|
|
|
UIPackage.RemovePackage("CheckForResUpdate");
|
|
|
}
|
|
|
|
|
|
+ private void InitServerList(GComboBox list)
|
|
|
+ {
|
|
|
+ var saveip = GameSetting.Instance.GetString(GameSetting.Sets.Server_str);
|
|
|
+
|
|
|
+ int select = -1;
|
|
|
+ List<string> servers = new();
|
|
|
+ foreach (var info in ServerInfo.ServerList)
|
|
|
+ {
|
|
|
+ servers.Add(info.ShowName);
|
|
|
+
|
|
|
+ if (select < 0 && !saveip.IsNullOrWhitespace())
|
|
|
+ {
|
|
|
+ if (saveip == info.HostStr)
|
|
|
+ {
|
|
|
+ select = servers.Count - 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(select < 0 && !saveip.IsNullOrWhitespace())
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var ipendpoint = NetworkHelper.ToIPEndPoint(saveip);
|
|
|
+
|
|
|
+ servers.Add($"Custom[{saveip}]");
|
|
|
+ ServerInfo.ServerList.Append(new ServerInfo()
|
|
|
+ {
|
|
|
+ ShowName = $"Custom[{saveip}]",
|
|
|
+ Ip = ipendpoint.Address.ToString(),
|
|
|
+ Port = ipendpoint.Port,
|
|
|
+ }) ;
|
|
|
+ select = servers.Count - 1;
|
|
|
+ }
|
|
|
+ catch(Exception)
|
|
|
+ {
|
|
|
+ Log.Error($"error save ip: {saveip}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(select < 0)
|
|
|
+ {
|
|
|
+ select = 0;
|
|
|
+ }
|
|
|
+ var cur = ServerInfo.ServerList[select];
|
|
|
+ mIP = cur.Ip;
|
|
|
+ mPort = cur.Port;
|
|
|
+
|
|
|
+ list.items = servers.ToArray();
|
|
|
+ list.selectedIndex = select;
|
|
|
+ list.onChanged.Set(() =>
|
|
|
+ {
|
|
|
+ var info = ServerInfo.ServerList[list.selectedIndex];
|
|
|
+ GameSetting.Instance.SetString(GameSetting.Sets.Server_str, info.HostStr);
|
|
|
+
|
|
|
+ mIP = info.Ip;
|
|
|
+ mPort = info.Port;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void InitResolutionList(GComboBox list)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void InitLogin(Scene scene, GComponent view)
|
|
|
{
|
|
|
- var account = view.GetChild("input_name");
|
|
|
- var password = view.GetChild("input_password");
|
|
|
- var btn = view.GetChild("Btn_Login");
|
|
|
+ var comp = view.GetChild("comp_login") as GComponent;
|
|
|
+ var listSvr = view.GetChild("listServer").asComboBox;
|
|
|
+ var listResolution = comp.GetChild("listResolution").asComboBox;
|
|
|
+ InitServerList(listSvr);
|
|
|
+ InitResolutionList(listResolution);
|
|
|
+
|
|
|
+ var inputID = comp.GetChild("txtID");
|
|
|
+ var btn = comp.GetChild("btn_go");
|
|
|
btn.onClick.Add(async () =>
|
|
|
{
|
|
|
- var imgtips = view.GetChild("img_tips");
|
|
|
- var tips = view.GetChild("txt_tips");
|
|
|
+ var imgtips = comp.GetChild("img_tips");
|
|
|
+ var tips = comp.GetChild("txt_tips");
|
|
|
tips.visible = false;
|
|
|
imgtips.visible = false;
|
|
|
- if (account.text.IsNullOrWhitespace() || password.text.IsNullOrWhitespace())
|
|
|
+ /*if (account.text.IsNullOrWhitespace() || password.text.IsNullOrWhitespace())
|
|
|
{
|
|
|
tips.visible = true;
|
|
|
tips.text = "用户名或密码为空";
|
|
|
return;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
imgtips.visible = true;
|
|
|
btn.enabled = false;
|
|
|
- var ret = await LoginHelper.Login(scene, account.text, password.text);
|
|
|
+ var ret = await LoginHelper.Login(scene, mIP, mPort, "111", "111");
|
|
|
if (ret != ErrorCode.ERR_Success)
|
|
|
{
|
|
|
imgtips.visible = false;
|
|
@@ -55,7 +130,8 @@ namespace ET.Client
|
|
|
{
|
|
|
tips.text = "连接服务器过程中出现了问题\n" +
|
|
|
"如重试后还是不行,请与客服联系" +
|
|
|
- "\n[color=#FFCCCC][b]QQ: 400888666[/b][/color] 微信:[color=#FFCCCC][b]大老板[/color][/b]";
|
|
|
+ "\n[color=#FF0000]QQ: 2910280670[/color]" +
|
|
|
+ "\n微信:[color=#FF0000]lvlh117[/color]";
|
|
|
}
|
|
|
}
|
|
|
});
|