289 lines
9.3 KiB
C#
289 lines
9.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Events;
|
|
namespace GameLogic {
|
|
/// <summary>
|
|
/// 更新提示框
|
|
/// </summary>
|
|
public class UpdateMsgBox : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 左边的按钮
|
|
/// </summary>
|
|
[SerializeField]
|
|
Button buttonL;
|
|
/// <summary>
|
|
/// 左边按钮文字
|
|
/// </summary>
|
|
[SerializeField]
|
|
Text buttonLText;
|
|
/// <summary>
|
|
/// 右边按钮
|
|
/// </summary>
|
|
[SerializeField]
|
|
Button buttonR;
|
|
/// <summary>
|
|
/// 右边按钮文字
|
|
/// </summary>
|
|
[SerializeField]
|
|
Text buttonRText;
|
|
/// <summary>
|
|
/// 右边按钮
|
|
/// </summary>
|
|
[SerializeField]
|
|
Button buttonC;
|
|
/// <summary>
|
|
/// 右边按钮文字
|
|
/// </summary>
|
|
[SerializeField]
|
|
Text buttonCText;
|
|
/// <summary>
|
|
/// 消息
|
|
/// </summary>
|
|
[SerializeField]
|
|
Text msg;
|
|
/// <summary>
|
|
/// 消息
|
|
/// </summary>
|
|
[SerializeField]
|
|
GameObject proto;
|
|
/// <summary>
|
|
/// 消息
|
|
/// </summary>
|
|
[SerializeField]
|
|
GameObject grant;
|
|
/// <summary>
|
|
/// title
|
|
/// </summary>
|
|
[SerializeField]
|
|
Text title;
|
|
/// <summary>
|
|
/// 点击回调
|
|
/// </summary>
|
|
UnityAction<int> action;
|
|
/// <summary>
|
|
/// 隐私协议按钮
|
|
/// </summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 左边按钮点击
|
|
/// </summary>
|
|
private void LClickHandler()
|
|
{
|
|
CallBack(0);
|
|
}
|
|
/// <summary>
|
|
/// 右边按钮点击
|
|
/// </summary>
|
|
private void RClickHandler()
|
|
{
|
|
CallBack(1);
|
|
}
|
|
/// <summary>
|
|
/// 右边按钮点击
|
|
/// </summary>
|
|
private void CClickHandler()
|
|
{
|
|
CallBack(2);
|
|
}
|
|
/// <summary>
|
|
/// 用户隐私协议按钮点击事件
|
|
/// </summary>
|
|
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);
|
|
}
|
|
/// <summary>
|
|
/// 用户隐私协议按钮点击事件
|
|
/// </summary>
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 回调
|
|
/// </summary>
|
|
/// <param name="i"></param>
|
|
private void CallBack(int i)
|
|
{
|
|
this.gameObject.SetActive(false);
|
|
if (action != null)
|
|
{
|
|
action(i);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示提示框,有两个按钮
|
|
/// </summary>
|
|
/// <param name="strL"></param>
|
|
/// <param name="strR"></param>
|
|
/// <param name="msg"></param>
|
|
public void Show(string strL, string strR, string msg, UnityAction<int> 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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示对话框,只有一个按钮
|
|
/// </summary>
|
|
/// <param name="strc"></param>
|
|
/// <param name="msg"></param>
|
|
/// <param name="action"></param>
|
|
public void Show(string strc, string msg, UnityAction<int> 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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 显示对话框,没有按钮
|
|
/// </summary>
|
|
/// <param name="strc"></param>
|
|
/// <param name="msg"></param>
|
|
/// <param name="action"></param>
|
|
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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 显示用户隐私协议
|
|
/// </summary>
|
|
/// <param name="strL"></param>
|
|
/// <param name="strR"></param>
|
|
/// <param name="msg"></param>
|
|
public void ShowProto(string strL, string strR, string msg, UnityAction<int> 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>().text = msg;
|
|
}
|
|
/// <summary>
|
|
/// 显示权限申请
|
|
/// </summary>
|
|
/// <param name="strL"></param>
|
|
/// <param name="strR"></param>
|
|
/// <param name="msg"></param>
|
|
public void ShowGrant(string strC, string msg, UnityAction<int> 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>().text = msg;
|
|
}
|
|
|
|
}
|
|
|
|
}
|