using Cysharp.Threading.Tasks;
using Framework;
using Gameplay;
using Gameplay.Net;
using NLDPB;
using PhxhSDK;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using Button = UnityEngine.UI.Button;
using Image = UnityEngine.UI.Image;
using Toggle = UnityEngine.UI.Toggle;
#if SDK_TAPTAP
using TapSDK.Login;
#elif SDK_BILIBILI
using PhxhSDK.AOT.Bilibili;
#endif
public class UI_StartGameInterfaceController : UIWindow
{
enum LoginType
{
Account,
PhoneCode,
TapTap,
Bilibili,
#if UNITY_IOS
Apple,
#endif
}
#region UI_obj
//UI GameObj
///Auto Gen Start///
public Image Image_Bg;
public Image Image_BgDark;
public Button Button_StartGame;
public Image Image_LoginBg;
public Button Button_AccountLogin_1;
//public Image Image_YellowLine_Account_1;
public Button Button_VerifyCodeLogin_1;
//public Image Image_YellowLine_VerifyCode_1;
//public TMP_InputField InputField_Account;
public Image Image_AccountIcon;
//public TMP_InputField InputField_Password;
public Image Image_PasswordIcon;
//public Toggle Toggle_RememberPassword;
public TMP_Text Text_RememberPassword;
public Toggle Toggle_Agreement_1;
//public TMP_Text Text_Agreement_1;
public Button Button_UnLogin_1;
public Button Button_Login_1;
//public TMP_InputField InputField_PhoneNumber;
public Image Image_PhoneIcon;
//public TMP_InputField InputField_VerifyCode;
public Image Image_VerifyCodeIcon;
public Button Button_GetVerifyCode;
public Button Button_GetVerifyCodeCooling;
public Toggle Toggle_Agreement_2;
public TMP_Text Text_Agreement_2;
public Button Button_UnLogin_2;
public Button Button_Login_2;
public Image Image_UpdateBg;
public Button Button_Confirm;
public Button Button_Cancle;
public Image Image_BottomLine;
public Button Button_UserCenter;
public Button Button_Notice;
public TMP_Text Text_UID;
public TMP_Text Text_Version;
public Image Image_DarkSide;
public Button AppleBtn;
///
/// TapTap登录按钮
///
private Button buttonTapTap;
///
/// Bilibili登录按钮
///
private Button buttonBilibili;
///Auto Gen End///
#endregion
#region UI_Class
class LoginWindow : UIGameObjectWrapper
{
public GameObject Root;
public GameObject VerifyCodeLoginPanel;
public Toggle Toggle_Agreement;
public TMP_InputField InputField_PhoneNumber;
public TMP_InputField InputField_VerifyCode;
public Button Button_GetVerifyCode;
public Button Button_GetVerifyCodeCooling;
public TMP_Text Text_Agreement;
public bool isTimer;
public Button Button_Login;
public LoginWindow(GameObject root,
UnityAction PhoneNumberEdit,
UnityAction CodeEdit,
UnityAction AgreementAccept,
UnityAction PhoneCodeLogin,
UnityAction SendPhoneRequest) : base(root)
{
}
public virtual void SetLoginType(LoginType loginType)
{
}
public virtual void CheckLoginButton(LoginType loginType, bool isToggled)
{
if (InputField_PhoneNumber.text.Length > 0 && InputField_VerifyCode.text.Length > 0 && isToggled)
{
Button_Login.gameObject.SetActive(true);
}
else
{
Button_Login.gameObject.SetActive(false);
}
}
public void CheckPhoneCodeButton()
{
if (InputField_PhoneNumber.text.Length == 11)
{
Button_GetVerifyCode.interactable = true;
}
else
{
Button_GetVerifyCode.interactable = false;
}
}
public async UniTask CoolingTimer()
{
int duration = 60;
isTimer = true;
Button_GetVerifyCode.gameObject.SetActive(false);
Button_GetVerifyCodeCooling.gameObject.SetActive(true);
while (duration > 0)
{
if (!isTimer)
{
duration = 0;
return;
}
Button_GetVerifyCodeCooling.GetComponentInChildren().text = duration + "s";
await UniTask.WaitForSeconds(1);
duration--;
}
Button_GetVerifyCode.gameObject.SetActive(true);
Button_GetVerifyCodeCooling.gameObject.SetActive(false);
}
protected void SetLinkText(Toggle agreement, TMP_Text text)
{
LinkText linkText = text.GetComponent();
if (linkText == null)
{
DebugUtil.Log("LinkText is null");
}
else
{
string url1= "https://kedrgame.com/user_agreement.txt";
string url2 = "https://kedrgame.com/privacy_agreement.txt";
string url3 = "https://kedrgame.com/children_privacy_agreement.txt";
string content = string.Format(CommonUtils.GetLocalizeText("uilogin_AgreementText"), url1, url2, url3);
//string.Format("我已详细阅读并同意《许可服务协议》 " +
//"《隐私政策》" +
//"和《儿童信息及隐私保护政策》",
//url1, url2, url3);
linkText.SetText(content);
}
linkText.SetOtherAreaClicked(() => agreement.isOn = !agreement.isOn);
}
}
///
/// 包含账户登录界面
///
class DebugLoginWindow : LoginWindow
{
public Button Button_AccountLogin;
public Button Button_VerifyCodeLogin;
public GameObject AccountLoginPanel;
public TMP_Dropdown ServerSelecter;
public Image Image_YellowLine_Account_1;
public Image Image_YellowLine_VerifyCode_1;
public Toggle Toggle_RememberPassword;
public TMP_InputField InputField_Account;
public TMP_InputField InputField_Password;
public TMP_Text Text_Agreement_Account;
public Button Button_Login_Account;
public Toggle Toggle_Agreement_Account;
public DebugLoginWindow(GameObject root, UnityAction PhoneNumberEdit, UnityAction CodeEdit, UnityAction AgreementAccept, UnityAction PhoneCodeLogin, UnityAction SendPhoneRequest)
: base(root, PhoneNumberEdit, CodeEdit, AgreementAccept, PhoneCodeLogin, SendPhoneRequest)
{
AccountLoginPanel = root.transform.Find("Image_LoginBg/LoginPanel/AccountLogin").gameObject;
VerifyCodeLoginPanel = root.transform.Find("Image_LoginBg/LoginPanel/VerifyCodeLogin").gameObject;
ServerSelecter = root.transform.Find("Image_LoginBg/ALDropdown").GetComponent();
Button_AccountLogin = GetComponent