using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Events; namespace GameLogic { /// /// 更新提示框 /// public class UpdateMsgBox : MonoBehaviour { /// /// 左边的按钮 /// [SerializeField] Button buttonL; /// /// 左边按钮文字 /// [SerializeField] Text buttonLText; /// /// 右边按钮 /// [SerializeField] Button buttonR; /// /// 右边按钮文字 /// [SerializeField] Text buttonRText; /// /// 右边按钮 /// [SerializeField] Button buttonC; /// /// 右边按钮文字 /// [SerializeField] Text buttonCText; /// /// 消息 /// [SerializeField] Text msg; /// /// 消息 /// [SerializeField] GameObject proto; /// /// 消息 /// [SerializeField] GameObject grant; /// /// title /// [SerializeField] Text title; /// /// 点击回调 /// UnityAction action; /// /// 隐私协议按钮 /// [SerializeField] Button[] protoButton; [SerializeField] Button[] privateButton; protected void Awake() { buttonL.onClick.AddListener(LClickHandler); buttonR.onClick.AddListener(RClickHandler); buttonC.onClick.AddListener(CClickHandler); foreach(Button b in protoButton) { b.onClick.AddListener(ProtoClickHandler); } foreach (Button b in privateButton) { b.onClick.AddListener(PrivateClickHandler); } title.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.TIPS); } private void ClosePanel() { CallBack(-1); } /// /// 左边按钮点击 /// private void LClickHandler() { CallBack(0); } /// /// 右边按钮点击 /// private void RClickHandler() { CallBack(1); } /// /// 右边按钮点击 /// private void CClickHandler() { CallBack(2); } /// /// 用户隐私协议按钮点击事件 /// private void ProtoClickHandler() { string UserChannel = ConfigManager.Instance.GetSettingValue("USER_CHANNEL"); string Channel = VersionManager.Instance.GetVersionInfo("channel"); string serverUrl = VersionManager.Instance.GetVersionInfo("serverUrl"); string ChannelID = UserChannel != null ? UserChannel : Channel; string url = serverUrl + "jl_loginserver/getAgreement?gamePack=" + ChannelID; NetworkManager.Instance.SendGetHttp(url, null, (string json) => { Hashtable info = MiniJSON.jsonDecode(json) as Hashtable; Hashtable parms = info["parms"] as Hashtable; string instructions = parms["instructions"] as string; if (ConfigManager.Instance.IsSettingActive("INNER_WEB_CONTROL")) { SDK.SDKManager.Instance.OpenWeb(instructions); } else { Application.OpenURL(url); } }, null, null); } /// /// 用户隐私协议按钮点击事件 /// private void PrivateClickHandler() { string UserChannel = ConfigManager.Instance.GetSettingValue("USER_CHANNEL"); string Channel = VersionManager.Instance.GetVersionInfo("channel"); string serverUrl = VersionManager.Instance.GetVersionInfo("serverUrl"); string ChannelID = UserChannel != null ? UserChannel : Channel; string url = serverUrl + "jl_loginserver/getAgreement?gamePack=" + ChannelID; NetworkManager.Instance.SendGetHttp(url, null, (string json) => { Hashtable info = MiniJSON.jsonDecode(json) as Hashtable; Hashtable parms = info["parms"] as Hashtable; string privacy = parms["privacy"] as string; if (ConfigManager.Instance.IsSettingActive("INNER_WEB_CONTROL")) { SDK.SDKManager.Instance.OpenWeb(privacy); } else { Application.OpenURL(url); } }, null, null); } /// /// 回调 /// /// private void CallBack(int i) { this.gameObject.SetActive(false); if (action != null) { action(i); } } /// /// 显示提示框,有两个按钮 /// /// /// /// public void Show(string strL, string strR, string msg, UnityAction action) { this.gameObject.SetActive(true); this.msg.gameObject.SetActive(true); this.proto.gameObject.SetActive(false); this.grant.gameObject.SetActive(false); this.buttonL.gameObject.SetActive(true); this.buttonR.gameObject.SetActive(true); this.buttonC.gameObject.SetActive(false); this.buttonLText.text = strL; this.buttonRText.text = strR; this.msg.text = msg; this.action = action; } /// /// 显示对话框,只有一个按钮 /// /// /// /// public void Show(string strc, string msg, UnityAction action) { this.gameObject.SetActive(true); this.msg.gameObject.SetActive(true); this.proto.gameObject.SetActive(false); this.grant.gameObject.SetActive(false); this.buttonL.gameObject.SetActive(false); this.buttonR.gameObject.SetActive(false); this.buttonC.gameObject.SetActive(true); this.buttonCText.text = strc; this.msg.text = msg; this.action = action; } /// /// 显示对话框,没有按钮 /// /// /// /// public void Show(string msg) { this.gameObject.SetActive(true); this.msg.gameObject.SetActive(true); this.proto.gameObject.SetActive(false); this.grant.gameObject.SetActive(false); this.buttonL.gameObject.SetActive(false); this.buttonR.gameObject.SetActive(false); this.buttonC.gameObject.SetActive(false); this.msg.text = msg; } /// /// 显示用户隐私协议 /// /// /// /// public void ShowProto(string strL, string strR, string msg, UnityAction action) { this.gameObject.SetActive(true); this.msg.gameObject.SetActive(false); this.proto.gameObject.SetActive(true); this.grant.gameObject.SetActive(false); this.buttonL.gameObject.SetActive(true); this.buttonR.gameObject.SetActive(true); this.buttonC.gameObject.SetActive(false); this.buttonLText.text = strL; this.buttonRText.text = strR; this.action = action; //设置显示内容 this.proto.GetComponent().text = msg; } /// /// 显示权限申请 /// /// /// /// public void ShowGrant(string strC, string msg, UnityAction action) { this.gameObject.SetActive(true); this.msg.gameObject.SetActive(false); this.proto.gameObject.SetActive(false); this.grant.gameObject.SetActive(true); this.buttonL.gameObject.SetActive(false); this.buttonR.gameObject.SetActive(false); this.buttonC.gameObject.SetActive(true); this.buttonCText.text = strC; this.action = action; //设置显示内容 this.grant.transform.Find("Scroll View/Viewport/Text").GetComponent().text = msg; } } }