158 lines
3.6 KiB
C#
158 lines
3.6 KiB
C#
// ***********************************************************************
|
|
// Assembly : Unity
|
|
// Author : Kimch
|
|
// Created :
|
|
//
|
|
// Last Modified By : Kimch
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "MessageBox" company=""></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
namespace G.UI
|
|
{
|
|
public partial class MessageBox : KUIWindow
|
|
{
|
|
#region Static
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="title"></param>
|
|
/// <param name="content"></param>
|
|
public static void ShowMessage(string title, string content)
|
|
{
|
|
ShowMessage(title, content, OnEmptyCallback, null);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="title"></param>
|
|
/// <param name="content"></param>
|
|
/// <param name="onConfirm"></param>
|
|
public static void ShowMessage(string title, string content, System.Action onConfirm)
|
|
{
|
|
ShowMessage(title, content, onConfirm, null);
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="title"></param>
|
|
/// <param name="content"></param>
|
|
/// <param name="onConfirm"></param>
|
|
/// <param name="onCancel"></param>
|
|
public static void ShowMessage(string title, string content, System.Action onConfirm, System.Action onCancel)
|
|
{
|
|
DefaultData.title = title;
|
|
DefaultData.content = content;
|
|
DefaultData.onConfirm = onConfirm;
|
|
DefaultData.onCancel = onCancel;
|
|
DefaultData.onClose = OnEmptyCallback;
|
|
|
|
DefaultData.confirmText = "确定";
|
|
DefaultData.cancelText = "取消";
|
|
|
|
OpenWindow<MessageBox>(DefaultData);
|
|
}
|
|
|
|
public static void ShowMessage(string title, string content, string confirmText, string cancelText, System.Action onConfirm, System.Action onCancel)
|
|
{
|
|
DefaultData.title = title;
|
|
DefaultData.content = content;
|
|
DefaultData.onConfirm = onConfirm;
|
|
DefaultData.onCancel = onCancel;
|
|
DefaultData.onClose = OnEmptyCallback;
|
|
|
|
DefaultData.confirmText = confirmText;
|
|
DefaultData.cancelText = cancelText;
|
|
|
|
OpenWindow<MessageBox>(DefaultData);
|
|
}
|
|
|
|
public static void ShowMessageWithoutButton(string title, string content)
|
|
{
|
|
DefaultData.title = title;
|
|
DefaultData.content = content;
|
|
DefaultData.onConfirm = null;
|
|
DefaultData.onCancel = null;
|
|
DefaultData.onClose = null;
|
|
|
|
DefaultData.confirmText = "";
|
|
DefaultData.cancelText = "";
|
|
OpenWindow<MessageBox>(DefaultData);
|
|
}
|
|
|
|
private static void OnEmptyCallback()
|
|
{
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public MessageBox()
|
|
: base(UILayer.kPopup, UIMode.kNone)
|
|
{
|
|
uiPath = "ui_common/ui_w_message.prefab";
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Action
|
|
|
|
private void OnConfirmClick()
|
|
{
|
|
CloseWindow(this);
|
|
if (_messageData.onConfirm != null)
|
|
{
|
|
F.Events.EventInvoker.Invoke(_messageData.onConfirm);
|
|
}
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
private void OnCancelClick()
|
|
{
|
|
CloseWindow(this);
|
|
if (_messageData.onCancel != null)
|
|
{
|
|
F.Events.EventInvoker.Invoke(_messageData.onCancel);
|
|
}
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
private void OnCloseClick()
|
|
{
|
|
CloseWindow(this);
|
|
if (_messageData.onClose != null)
|
|
{
|
|
F.Events.EventInvoker.Invoke(_messageData.onClose);
|
|
}
|
|
SoundProxy.PlayFxAsync(GlobalDefine.BUTTON_CLICK_SOUND);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Unity
|
|
|
|
// Use this for initialization
|
|
public override void Awake()
|
|
{
|
|
InitModel();
|
|
InitView();
|
|
}
|
|
|
|
public override void OnEnable()
|
|
{
|
|
RefreshModel();
|
|
RefreshView();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|