summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/XLoginView.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-01-25 14:28:30 +0800
committerchai <chaifix@163.com>2021-01-25 14:28:30 +0800
commit6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch)
tree7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/UI/XLoginView.cs
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/UI/XLoginView.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/UI/XLoginView.cs525
1 files changed, 525 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/UI/XLoginView.cs b/Client/Assets/Scripts/XMainClient/UI/XLoginView.cs
new file mode 100644
index 00000000..7df45921
--- /dev/null
+++ b/Client/Assets/Scripts/XMainClient/UI/XLoginView.cs
@@ -0,0 +1,525 @@
+using System;
+using System.Collections.Generic;
+using MiniJSON;
+using UILib;
+using UnityEngine;
+using XMainClient.UI.UICommon;
+using XUpdater;
+using XUtliPoolLib;
+
+namespace XMainClient.UI
+{
+ internal class XLoginView : DlgBase<XLoginView, LoginWindowBehaviour>
+ {
+ public override string fileName
+ {
+ get
+ {
+ return "SelectChar/LoginDlg";
+ }
+ }
+
+ public override int layer
+ {
+ get
+ {
+ return 1;
+ }
+ }
+
+ private XLoginDocument _doc = null;
+
+ protected override void Init()
+ {
+ this._doc = XSingleton<XLoginDocument>.singleton;
+ this._doc.View = this;
+ }
+
+ protected override void OnShow()
+ {
+ base.OnShow();
+ this.SetVersion("v" + XSingleton<XUpdater.XUpdater>.singleton.Version);
+ base.uiBehaviour.m_Login.SetVisible(!this._doc.IsPublish());
+ base.uiBehaviour.m_Account.SetVisible(!this._doc.IsPublish());
+ base.uiBehaviour.m_Password.SetVisible(!this._doc.IsPublish());
+ int num = 4;
+ float num2 = 0f;
+ float y = base.uiBehaviour.m_GuestLogin.gameObject.transform.localPosition.y;
+ bool flag = (int)Application.platform == 8;
+ if (flag)
+ {
+ num |= 1;
+ num2 -= (float)(base.uiBehaviour.m_GuestLogin.spriteWidth / 2 + 10);
+ }
+ bool flag2 = XSingleton<XUpdater.XUpdater>.singleton.XPlatform.CheckWeChatInstalled() || (int)Application.platform != 8;
+ if (flag2)
+ {
+ num |= 2;
+ num2 -= (float)(base.uiBehaviour.m_GuestLogin.spriteWidth / 2 + 10);
+ }
+ bool flag3 = (num & 1) > 0;
+ if (flag3)
+ {
+ base.uiBehaviour.m_GuestLogin.gameObject.transform.localPosition = new Vector3(num2, y);
+ num2 += (float)(base.uiBehaviour.m_GuestLogin.spriteWidth + 10);
+ }
+ else
+ {
+ base.uiBehaviour.m_GuestLogin.SetVisible(false);
+ }
+ bool flag4 = (num & 2) > 0;
+ if (flag4)
+ {
+ base.uiBehaviour.m_WXLogin.gameObject.transform.localPosition = new Vector3(num2, y);
+ num2 += (float)(base.uiBehaviour.m_WXLogin.spriteWidth + 10);
+ }
+ else
+ {
+ base.uiBehaviour.m_WXLogin.SetVisible(false);
+ }
+ bool flag5 = (num & 4) > 0;
+ if (flag5)
+ {
+ base.uiBehaviour.m_QQLogin.gameObject.transform.localPosition = new Vector3(num2, y);
+ num2 += (float)(base.uiBehaviour.m_QQLogin.spriteWidth + 10);
+ }
+ else
+ {
+ base.uiBehaviour.m_QQLogin.SetVisible(false);
+ }
+ }
+
+ public override void RegisterEvent()
+ {
+ base.uiBehaviour.m_Login.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnAccountInfoEnterClick));
+ base.uiBehaviour.m_QQLogin.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnQQLoginButtonClick));
+ base.uiBehaviour.m_WXLogin.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnWXLoginButtonClick));
+ base.uiBehaviour.m_GuestLogin.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnGuestButtonClick));
+ base.uiBehaviour.m_Notice.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnNoticeClicked));
+ base.uiBehaviour.m_CG.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCGClicked));
+ base.uiBehaviour.m_CustomerService.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCustomerServiceClicked));
+ base.uiBehaviour.m_EnterToSelectChar.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnEnterToSelectCharClicked));
+ base.uiBehaviour.m_ReturnToLogin.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnReturnToLoginClicked));
+ base.uiBehaviour.m_ServerListButton.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnSelectServerClick));
+ base.uiBehaviour.m_CloseServerList.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnServerListCloseClicked));
+ base.uiBehaviour.m_LeaveQueue.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnLeaveQueueClicked));
+ base.uiBehaviour.m_FriendWrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.FriendWrapContentUpdated));
+ }
+
+ public void RefreshAccount()
+ {
+ base.uiBehaviour.m_Account.SetText(this._doc.Account ?? "");
+ base.uiBehaviour.m_Password.SetText(this._doc.Password ?? "");
+ }
+
+ private bool OnAccountInfoEnterClick(IXUIButton button)
+ {
+ bool flag = this._doc.CheckLoginBlockTime();
+ if (flag)
+ {
+ string text = base.uiBehaviour.m_Account.GetText();
+ string text2 = base.uiBehaviour.m_Password.GetText();
+ this._doc.Authorization(XAuthorizationChannel.XAuthorization_Internal, true, false, text, text2);
+ }
+ else
+ {
+ XSingleton<UiUtility>.singleton.ShowLoginTip(XStringDefineProxy.GetString("LOGIN_TOO_FREQUENT"));
+ }
+ return true;
+ }
+
+ private bool OnQQLoginButtonClick(IXUIButton go)
+ {
+ bool flag = this._doc.CheckLoginBlockTime();
+ if (flag)
+ {
+ this._doc.Authorization(XAuthorizationChannel.XAuthorization_QQ, true, false, null, null);
+ }
+ else
+ {
+ XSingleton<UiUtility>.singleton.ShowLoginTip(XStringDefineProxy.GetString("LOGIN_TOO_FREQUENT"));
+ }
+ return true;
+ }
+
+ private bool OnWXLoginButtonClick(IXUIButton go)
+ {
+ bool flag = this._doc.CheckLoginBlockTime();
+ if (flag)
+ {
+ this._doc.Authorization(XAuthorizationChannel.XAuthorization_WeChat, true, false, null, null);
+ }
+ else
+ {
+ XSingleton<UiUtility>.singleton.ShowLoginTip(XStringDefineProxy.GetString("LOGIN_TOO_FREQUENT"));
+ }
+ return true;
+ }
+
+ private bool OnGuestButtonClick(IXUIButton go)
+ {
+ bool flag = this._doc.CheckLoginBlockTime();
+ if (flag)
+ {
+ this._doc.Authorization(XAuthorizationChannel.XAuthorization_Guest, true, false, null, null);
+ }
+ else
+ {
+ XSingleton<UiUtility>.singleton.ShowLoginTip(XStringDefineProxy.GetString("LOGIN_TOO_FREQUENT"));
+ }
+ return true;
+ }
+
+ private bool OnNoticeClicked(IXUIButton go)
+ {
+ XSingleton<UiUtility>.singleton.ShowAfterLoginAnnouncement(this._doc.Announcement);
+ return true;
+ }
+
+ private bool OnCGClicked(IXUIButton button)
+ {
+ XSingleton<XTimerMgr>.singleton.SetTimer(0.1f, new XTimerMgr.ElapsedEventHandler(XSingleton<XUpdater.XUpdater>.singleton.PlayCG), null);
+ return true;
+ }
+
+ private bool OnCustomerServiceClicked(IXUIButton go)
+ {
+ Dictionary<string, string> dictionary = new Dictionary<string, string>();
+ RuntimePlatform platform = Application.platform;
+ if ((int)platform != 8)
+ {
+ if ((int)platform != 11)
+ {
+ XSingleton<XDebug>.singleton.AddGreenLog("CustomerService-Login", null, null, null, null, null);
+ }
+ else
+ {
+ dictionary["url"] = XSingleton<XGlobalConfig>.singleton.GetValue("CustomerServiceLoginAndroid");
+ dictionary["screendir"] = "SENSOR";
+ XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary));
+ }
+ }
+ else
+ {
+ dictionary["url"] = XSingleton<XGlobalConfig>.singleton.GetValue("CustomerServiceLoginApple");
+ dictionary["screendir"] = "SENSOR";
+ XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary));
+ }
+ return true;
+ }
+
+ private bool OnEnterToSelectCharClicked(IXUIButton go)
+ {
+ bool flag = string.IsNullOrEmpty(XSingleton<XClientNetwork>.singleton.XLoginToken);
+ if (flag)
+ {
+ XSingleton<XLoginDocument>.singleton.AutoAuthorization(false);
+ }
+ else
+ {
+ XSingleton<XLoginDocument>.singleton.Login();
+ }
+ return true;
+ }
+
+ private bool OnReturnToLoginClicked(IXUIButton go)
+ {
+ this._doc.AuthorizationSignOut();
+ return true;
+ }
+
+ private void OnServerListCloseClicked(IXUISprite sp)
+ {
+ base.uiBehaviour.m_ServerList.gameObject.SetActive(false);
+ }
+
+ private bool OnLeaveQueueClicked(IXUIButton button)
+ {
+ base.uiBehaviour.m_QueueFrame.SetActive(false);
+ this._doc.CancelQueue();
+ return true;
+ }
+
+ public void TweenAlpha(bool bForward)
+ {
+ base.uiBehaviour.m_Tween.PlayTween(bForward, -1f);
+ }
+
+ public void SetVersion(string version)
+ {
+ bool flag = XSingleton<XUpdater.XUpdater>.singleton.XPlatform.IsTestMode();
+ if (flag)
+ {
+ base.uiBehaviour.m_Version.SetText(version + "Test");
+ }
+ else
+ {
+ base.uiBehaviour.m_Version.SetText(version);
+ }
+ }
+
+ public void ShowLogin()
+ {
+ base.uiBehaviour.m_normalFrame.SetActive(true);
+ base.uiBehaviour.m_ServerListFrame.SetActive(false);
+ base.uiBehaviour.m_QueueFrame.SetActive(false);
+ this.RefreshAccount();
+ }
+
+ public void ShowSelectServer()
+ {
+ base.uiBehaviour.m_normalFrame.SetActive(false);
+ base.uiBehaviour.m_ServerListFrame.SetActive(true);
+ base.uiBehaviour.m_ServerList.gameObject.SetActive(false);
+ base.uiBehaviour.m_QueueFrame.SetActive(false);
+ }
+
+ public void ShowQueue()
+ {
+ base.uiBehaviour.m_normalFrame.SetActive(false);
+ base.uiBehaviour.m_ServerListFrame.SetActive(false);
+ base.uiBehaviour.m_QueueFrame.SetActive(true);
+ base.uiBehaviour.m_QueueTip.SetText("");
+ }
+
+ public void RefreshQueueState()
+ {
+ bool flag = !base.uiBehaviour.m_QueueFrame.activeSelf;
+ if (!flag)
+ {
+ base.uiBehaviour.m_QueueTip.SetText(string.Format(XSingleton<UiUtility>.singleton.ReplaceReturn(XStringDefineProxy.GetString("WAIT_FOR_SERVER_QUEUE")), XSingleton<XClientNetwork>.singleton.Server, this._doc.RoleCountInQueue, XSingleton<UiUtility>.singleton.TimeAccFormatString((int)this._doc.LeftTimeInQueue, 3, 0)));
+ }
+ }
+
+ public void OnShowServerList()
+ {
+ base.uiBehaviour.m_ServerPool.ReturnAll(false);
+ base.uiBehaviour.m_ServerList.gameObject.SetActive(true);
+ this.SetupAreaServerList();
+ }
+
+ private void OnSelectServerClick(IXUISprite sp)
+ {
+ this.OnShowServerList();
+ }
+
+ public void SetCurrentServer()
+ {
+ base.uiBehaviour.m_CurrentServer.SetText(XSingleton<XClientNetwork>.singleton.Server);
+ }
+
+ private void SetupAreaServerList()
+ {
+ base.uiBehaviour.m_AreaPool.ReturnAll(false);
+ Vector3 localPosition = base.uiBehaviour.m_AreaPool._tpl.transform.localPosition;
+ int tplHeight = base.uiBehaviour.m_AreaPool.TplHeight;
+ IXUICheckBox ixuicheckBox = null;
+ string @string = XSingleton<XStringTable>.singleton.GetString("BACK_SERVERS");
+ bool flag = XSingleton<XLoginDocument>.singleton.BackFlowServerList.Count > 0;
+ for (int i = 0; i < this._doc.ZoneList.Count; i++)
+ {
+ GameObject gameObject = base.uiBehaviour.m_AreaPool.FetchGameObject(false);
+ gameObject.name = "Area" + i;
+ gameObject.transform.localPosition = localPosition + new Vector3(0f, (float)(-(float)i * tplHeight));
+ IXUILabel ixuilabel = gameObject.GetComponent("XUILabel") as IXUILabel;
+ IXUILabel ixuilabel2 = gameObject.transform.Find("Selected/Label").GetComponent("XUILabel") as IXUILabel;
+ ixuilabel2.SetText(this._doc.ZoneList[i]);
+ ixuilabel.SetText(this._doc.ZoneList[i]);
+ ixuilabel.RegisterLabelClickEventHandler(new LabelClickEventHandler(this.OnAreaClicked));
+ string a = this._doc.ZoneList[i];
+ bool flag2 = flag && a == @string;
+ if (flag2)
+ {
+ flag = true;
+ this.ShowAreaServers(this._doc.ZoneList[i]);
+ ixuicheckBox = (gameObject.GetComponent("XUICheckBox") as IXUICheckBox);
+ }
+ bool flag3 = i == 2 && !flag;
+ if (flag3)
+ {
+ this.ShowAreaServers(this._doc.ZoneList[i]);
+ ixuicheckBox = (gameObject.GetComponent("XUICheckBox") as IXUICheckBox);
+ }
+ }
+ bool flag4 = ixuicheckBox != null;
+ if (flag4)
+ {
+ ixuicheckBox.bChecked = true;
+ }
+ }
+
+ private void ShowAreaServers(string zone)
+ {
+ bool flag = zone == XStringDefineProxy.GetString("FRIENDS_SERVERS");
+ if (flag)
+ {
+ base.uiBehaviour.m_FriendFrame.gameObject.SetActive(true);
+ base.uiBehaviour.m_ServerFrame.gameObject.SetActive(false);
+ base.uiBehaviour.m_FriendWrapContent.SetContentCount(this._doc.FriendOpenid.Count, true);
+ base.uiBehaviour.m_FriendScrollView.ResetPosition();
+ }
+ else
+ {
+ base.uiBehaviour.m_FriendFrame.gameObject.SetActive(false);
+ base.uiBehaviour.m_ServerFrame.gameObject.SetActive(true);
+ base.uiBehaviour.m_FriendWrapContent.SetContentCount(0, true);
+ }
+ base.uiBehaviour.m_ServerPool.ReturnAll(false);
+ Vector3 localPosition = base.uiBehaviour.m_ServerPool._tpl.transform.localPosition;
+ int tplHeight = base.uiBehaviour.m_ServerPool.TplHeight;
+ int tplWidth = base.uiBehaviour.m_ServerPool.TplWidth;
+ List<int> list = this._doc.ServerCategory[zone];
+ int num = 0;
+ for (int i = list.Count - 1; i >= 0; i--)
+ {
+ ServerInfo serverData = this._doc.GetServerData(list[i]);
+ bool flag2 = serverData == null;
+ if (!flag2)
+ {
+ bool flag3 = !XSingleton<XGame>.singleton.IsGMAccount;
+ if (flag3)
+ {
+ bool flag4 = serverData.StateTxt == 6;
+ if (flag4)
+ {
+ goto IL_2EF;
+ }
+ }
+ Transform transform = base.uiBehaviour.m_ServerPool.FetchGameObject(true).transform;
+ transform.name = "Server" + list[i];
+ int num2 = num / 2;
+ int num3 = num % 2;
+ num++;
+ transform.localPosition = localPosition + new Vector3((float)(num3 * tplWidth), (float)(-(float)num2 * tplHeight));
+ IXUISprite ixuisprite = transform.GetComponent("XUISprite") as IXUISprite;
+ IXUILabel ixuilabel = transform.Find("Bg/Name").GetComponent("XUILabel") as IXUILabel;
+ ixuisprite.ID = (ulong)((long)list[i]);
+ ixuilabel.SetText(serverData.ServerName);
+ ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnServerClicked));
+ IXUISprite ixuisprite2 = transform.Find("Bg/Status").GetComponent("XUISprite") as IXUISprite;
+ ixuisprite2.SetSprite(this._ServerStateString((ServerStateEnum)serverData.State));
+ this._SetServerStateLabel(transform.gameObject, serverData.StateTxt);
+ IXUILabel ixuilabel2 = transform.Find("Bg/Level").GetComponent("XUILabel") as IXUILabel;
+ ixuilabel2.Alpha = ((serverData.Level == 0u) ? 0f : 1f);
+ ixuilabel2.SetText(string.Format("Lv.{0}", serverData.Level));
+ }
+ IL_2EF:;
+ }
+ base.uiBehaviour.m_ServerScrollView.ResetPosition();
+ }
+
+ private void FriendWrapContentUpdated(Transform t, int index)
+ {
+ bool flag = index < 0 || index >= this._doc.FriendOpenid.Count;
+ if (flag)
+ {
+ t.gameObject.SetActive(false);
+ }
+ else
+ {
+ FriendServerInfo friendServerInfo = null;
+ bool flag2 = !this._doc.FriendServerDic.TryGetValue(this._doc.FriendOpenid[index], out friendServerInfo);
+ if (!flag2)
+ {
+ ServerInfo serverData = this._doc.GetServerData(this._doc.FriendServerDic[this._doc.FriendOpenid[index]].info.serverid);
+ bool flag3 = serverData == null;
+ if (!flag3)
+ {
+ IXUISprite ixuisprite = t.GetComponent("XUISprite") as IXUISprite;
+ IXUILabel ixuilabel = t.Find("Bg/Name").GetComponent("XUILabel") as IXUILabel;
+ ixuisprite.ID = (ulong)((long)friendServerInfo.info.serverid);
+ ixuilabel.SetText(serverData.ServerName);
+ ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnServerClicked));
+ IXUISprite ixuisprite2 = t.Find("Bg/Status").GetComponent("XUISprite") as IXUISprite;
+ ixuisprite2.SetSprite(this._ServerStateString((ServerStateEnum)serverData.State));
+ this._SetServerStateLabel(t.gameObject, serverData.StateTxt);
+ IXUILabel ixuilabel2 = t.Find("Bg/Level").GetComponent("XUILabel") as IXUILabel;
+ ixuilabel2.Alpha = ((friendServerInfo.info.level == 0) ? 0f : 1f);
+ ixuilabel2.SetText(string.Format("Lv.{0}", friendServerInfo.info.level));
+ IXUILabel ixuilabel3 = t.Find("Bg/GameName").GetComponent("XUILabel") as IXUILabel;
+ ixuilabel3.SetText(friendServerInfo.info.rolename);
+ IXUILabel ixuilabel4 = t.Find("Bg/IMName").GetComponent("XUILabel") as IXUILabel;
+ ixuilabel4.SetText(friendServerInfo.account);
+ IXUITexture ixuitexture = t.Find("Bg/Icon").GetComponent("XUITexture") as IXUITexture;
+ ixuitexture.SetVisible(true);
+ ixuitexture.SetTexturePath("");
+ XSingleton<XUICacheImage>.singleton.Load(friendServerInfo.icon, ixuitexture, base.uiBehaviour);
+ }
+ }
+ }
+ }
+
+ private void OnAreaClicked(IXUILabel sp)
+ {
+ this.ShowAreaServers(sp.GetText());
+ }
+
+ private void OnServerClicked(IXUISprite sp)
+ {
+ base.uiBehaviour.m_ServerList.gameObject.SetActive(false);
+ this._doc.OnServerChanged((int)sp.ID);
+ }
+
+ private Color _ServerStateColor(ServerStateEnum state)
+ {
+ Color result;
+ switch (state)
+ {
+ case ServerStateEnum.TIMEOUT:
+ result = new Color(1f, 1f, 1f, 1f);
+ break;
+ case ServerStateEnum.EMPTY:
+ result = new Color(0.1254902f, 0.8784314f, 0.160784319f, 1f);
+ break;
+ case ServerStateEnum.NORMAL:
+ result = new Color(0.996078432f, 0.7254902f, 0f, 1f);
+ break;
+ case ServerStateEnum.FULL:
+ result = new Color(0.8784314f, 0.286274523f, 0.1254902f, 1f);
+ break;
+ default:
+ result = new Color(1f, 1f, 1f, 1f);
+ break;
+ }
+ return result;
+ }
+
+ private string _ServerStateString(ServerStateEnum state)
+ {
+ string result;
+ switch (state)
+ {
+ case ServerStateEnum.TIMEOUT:
+ result = "fwq_0";
+ break;
+ case ServerStateEnum.EMPTY:
+ result = "fwq_1";
+ break;
+ case ServerStateEnum.NORMAL:
+ result = "fwq_2";
+ break;
+ case ServerStateEnum.FULL:
+ result = "fwq_3";
+ break;
+ default:
+ result = "fwq_0";
+ break;
+ }
+ return result;
+ }
+
+ private void _SetServerStateLabel(GameObject go, int state)
+ {
+ int num = XFastEnumIntEqualityComparer<ServerFlagEnum>.ToInt(ServerFlagEnum.MAX);
+ for (int i = 0; i < num; i++)
+ {
+ Transform transform = go.transform.Find(string.Format("Bg/State{0}", i));
+ bool flag = transform != null;
+ if (flag)
+ {
+ transform.gameObject.SetActive(state == i);
+ }
+ }
+ }
+ }
+}