主页面相关内容和快捷键修改
This commit is contained in:
74
Assets/Scripts/UI/Common/Panel/MessageBox.cs
Normal file
74
Assets/Scripts/UI/Common/Panel/MessageBox.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
// 本脚本只在不存在时会生成一次。已存在不会再次生成覆盖
|
||||
|
||||
using System;
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
using NBC;
|
||||
using UIPanel = NBC.UIPanel;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public partial class MessageBox : UIPanel
|
||||
{
|
||||
public override string UIPackName => "Common";
|
||||
public override string UIResName => "MessageBox";
|
||||
|
||||
private static string _confirmText;
|
||||
private static string _cancelText;
|
||||
private static string _title;
|
||||
private static string _content;
|
||||
private static Action<bool> _callback;
|
||||
private static int _style;
|
||||
|
||||
public static void Show(string msg, Action<bool> callback, string title = "", int style = 0,
|
||||
string confirm = "", string cancel = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
title = Lan.Get("TEXT_NOTE");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(confirm))
|
||||
{
|
||||
confirm = Lan.Get("TEXT_CONFIRM");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(cancel))
|
||||
{
|
||||
cancel = Lan.Get("TEXT_CANCEL");
|
||||
}
|
||||
|
||||
_confirmText = confirm;
|
||||
_cancelText = cancel;
|
||||
_callback = callback;
|
||||
_content = msg;
|
||||
_title = title;
|
||||
_style = style;
|
||||
UI.Inst.OpenUI<MessageBox>();
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.AutoAddClick(OnClick);
|
||||
ShowAnim = UIPanelAnimation.GetCenterScaleBig(this);
|
||||
HideAnim = UIPanelAnimation.GetCenterScaleBig(this, true);
|
||||
IsModal = true;
|
||||
IsDontBack = true;
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
TextTitle.text = _title;
|
||||
BtnConfirm.title = _confirmText;
|
||||
BtnCancel.title = _cancelText;
|
||||
TextContent.text = _content;
|
||||
MessageStyle.selectedIndex = _style;
|
||||
}
|
||||
|
||||
private void OnClick(GComponent btn)
|
||||
{
|
||||
_callback?.Invoke(btn == BtnConfirm);
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user