| | |
| | | using DG.Tweening;
|
| | | namespace Snxxz.UI
|
| | | {
|
| | | [XLua.Hotfix]
|
| | | public class MessageWin : Window
|
| | | {
|
| | | private static MessageWin _inst = null;
|
| | | public static MessageWin Inst
|
| | | {
|
| | | get
|
| | | {
|
| | | if (_inst == null)
|
| | | {
|
| | | _inst = WindowCenter.Instance.Get<MessageWin>();
|
| | | }
|
| | |
|
| | | return _inst;
|
| | | }
|
| | | }
|
| | |
|
| | | [SerializeField] RectTransform m_ContianerFixedTip0;
|
| | | [SerializeField] RichText m_FixedTip0;
|
| | |
|
| | | [SerializeField] List<RectTransform> m_ContianerFixedTips;
|
| | | [SerializeField] List<RichText> m_FixedTips;
|
| | | List<bool> m_FixedTipDisplays = new List<bool>();
|
| | |
|
| | | #region GM
|
| | | [SerializeField] GameObject gmPanel;
|
| | | [SerializeField] ScrollerController gmCtrl;
|
| | | [SerializeField] Toggle gmToggle;
|
| | | [SerializeField] Toggle gmUpdateToggle;
|
| | | [SerializeField] Button gmClose;
|
| | | #endregion
|
| | |
|
| | | public void ShowFixedTip(string tip, ArrayList infoList = null)
|
| | | {
|
| | | transform.SetAsLastSibling();
|
| | | m_FixedTip0.SetExtenalData(infoList);
|
| | | m_FixedTip0.text = tip;
|
| | | if (!m_ContianerFixedTip0.gameObject.activeInHierarchy)
|
| | | {
|
| | | m_ContianerFixedTip0.gameObject.SetActive(true);
|
| | | }
|
| | | m_ContianerFixedTip0.DoWaitRestart();
|
| | | }
|
| | |
|
| | | public void ShowFixedTips(string tip, ArrayList infoList = null)
|
| | | {
|
| | | transform.SetAsLastSibling();
|
| | | var _index = m_FixedTipDisplays.FindIndex((x) =>
|
| | | {
|
| | | return !x;
|
| | | });
|
| | | _index = _index == -1 ? 0 : _index;
|
| | | m_FixedTips[_index].SetExtenalData(infoList);
|
| | | m_FixedTips[_index].text = tip;
|
| | | m_FixedTipDisplays[_index] = true;
|
| | | if (!m_ContianerFixedTips[_index].gameObject.activeInHierarchy)
|
| | | {
|
| | | m_ContianerFixedTips[_index].gameObject.SetActive(true);
|
| | | }
|
| | | m_ContianerFixedTips[_index].DoWaitRestart();
|
| | | }
|
| | |
|
| | | private void OnHideFixedTip(Component com)
|
| | | {
|
| | | com.DoWaitStop();
|
| | | com.gameObject.SetActive(false);
|
| | |
|
| | | var _index = m_ContianerFixedTips.FindIndex((x) =>
|
| | | {
|
| | | return x.Equals(com);
|
| | | });
|
| | | if (_index != -1)
|
| | | {
|
| | | m_FixedTipDisplays[_index] = false;
|
| | | }
|
| | | }
|
| | | [SerializeField] RectTransform m_ContainerNormalHint;
|
| | | [SerializeField] RichText m_NormalHint;
|
| | |
|
| | | [SerializeField] RectTransform m_ContainerServerTip;
|
| | | [SerializeField] ScaleTween m_ServerTipScaleTween;
|
| | |
| | | [SerializeField] RichText m_ServerTip;
|
| | | [SerializeField, Header("全服广播停留时间")] float m_ServerTipKeepTime = 1.5f;
|
| | |
|
| | | private bool serverTipPrepared = true;
|
| | | public void ShowServerTip()
|
| | | [SerializeField] RectTransform m_ContainerGM;
|
| | | [SerializeField] ScrollerController m_ScrollControl;
|
| | | [SerializeField] Toggle m_AutoPopToggle;
|
| | | [SerializeField] Toggle m_AutoRefreshToggle;
|
| | | [SerializeField] Button m_GMClose;
|
| | |
|
| | | bool m_ServerTipPrepared = true;
|
| | |
|
| | | protected override void BindController()
|
| | | {
|
| | | if (!serverTipPrepared)
|
| | | }
|
| | |
|
| | | protected override void AddListeners()
|
| | | {
|
| | | m_ContainerNormalHint.OnWaitCompelete(OnHintDisplayComplete);
|
| | | m_ScrollControl.OnRefreshCell += OnRefreshGmCell;
|
| | | m_ScrollControl.lockType = EnhanceLockType.LockVerticalBottom;
|
| | | m_GMClose.onClick.AddListener(OnGMClose);
|
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | m_ServerTipPrepared = true;
|
| | |
|
| | | #if UNITY_EDITOR
|
| | | m_ContainerGM.gameObject.SetActive(VersionConfig.Get().debugVersion);
|
| | | #else
|
| | | m_ContainerGM.gameObject.SetActive(false);
|
| | | #endif
|
| | | ServerTipDetails.normalHintRefresh += CheckNormalHint;
|
| | | ServerTipDetails.serverHintRefresh += CheckServerHint;
|
| | | ServerTipDetails.gmMessageRefresh += DisplayGM;
|
| | | ServerTipDetails.gmOpenEvent += GmOpenEvent;
|
| | | CheckNormalHint();
|
| | | CheckServerHint();
|
| | | DisplayGM(string.Empty);
|
| | |
|
| | | if (ServerTipDetails.requireOpenGM)
|
| | | {
|
| | | if (hasOnFrom)
|
| | | {
|
| | | OnGMOpen();
|
| | | }
|
| | | ServerTipDetails.requireOpenGM = false;
|
| | | }
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | ServerTipDetails.normalHintRefresh -= CheckNormalHint;
|
| | | ServerTipDetails.serverHintRefresh -= CheckServerHint;
|
| | | ServerTipDetails.gmMessageRefresh -= DisplayGM;
|
| | | ServerTipDetails.gmOpenEvent -= GmOpenEvent;
|
| | | }
|
| | |
|
| | | protected override void OnAfterClose()
|
| | | {
|
| | | }
|
| | |
|
| | | private void GmOpenEvent()
|
| | | {
|
| | | if (ServerTipDetails.requireOpenGM)
|
| | | {
|
| | | if (hasOnFrom)
|
| | | {
|
| | | OnGMOpen();
|
| | | }
|
| | | ServerTipDetails.requireOpenGM = false;
|
| | | }
|
| | | }
|
| | |
|
| | | void CheckNormalHint()
|
| | | {
|
| | | var hint = ServerTipDetails.RequireNormalHint();
|
| | | if (hint != null)
|
| | | {
|
| | | DisplayNormalHint(hint);
|
| | | }
|
| | | }
|
| | |
|
| | | void DisplayNormalHint(SystemHintData hint)
|
| | | {
|
| | | transform.SetAsLastSibling();
|
| | | m_NormalHint.SetExtenalData(hint.extentionData);
|
| | | m_NormalHint.text = hint.message;
|
| | | if (!m_ContainerNormalHint.gameObject.activeInHierarchy)
|
| | | {
|
| | | m_ContainerNormalHint.gameObject.SetActive(true);
|
| | | }
|
| | | m_ContainerNormalHint.DoWaitRestart();
|
| | | }
|
| | |
|
| | | private void OnHintDisplayComplete(Component com)
|
| | | {
|
| | | com.DoWaitStop();
|
| | | com.gameObject.SetActive(false);
|
| | | }
|
| | |
|
| | | void CheckServerHint()
|
| | | {
|
| | | if (!m_ServerTipPrepared)
|
| | | {
|
| | | return;
|
| | | }
|
| | | transform.SetAsLastSibling();
|
| | | var _hint = ServerTipDetails.RequireServerTip();
|
| | | if (_hint != null)
|
| | | var hint = ServerTipDetails.RequireServerTip();
|
| | | if (hint != null && gameObject.activeInHierarchy)
|
| | | {
|
| | | serverTipPrepared = false;
|
| | | if (!m_ServerTipScaleTween.gameObject.activeSelf)
|
| | | {
|
| | | m_ServerTipScaleTween.gameObject.SetActive(true);
|
| | | }
|
| | | m_ServerTipScaleTween.SetStartState();
|
| | | m_ServerTipPositionTween.SetStartState();
|
| | | m_ContainerServerTip.gameObject.SetActive(true);
|
| | | m_ServerTip.SetExtenalData(_hint.extentionData);
|
| | | m_ServerTip.text = _hint.message;
|
| | | m_ServerTipScaleTween.Play();
|
| | | TimeMgr.Instance.Register(m_ServerTip, ServerTipStartHide, m_ServerTipKeepTime + m_ServerTipScaleTween.duration);
|
| | | DisplayServerHint(hint);
|
| | | }
|
| | | else
|
| | | {
|
| | | DisableServerTip();
|
| | | }
|
| | | }
|
| | |
|
| | | public void DisplayServerHint(SystemHintData hint)
|
| | | {
|
| | | transform.SetAsLastSibling();
|
| | | m_ServerTipPrepared = false;
|
| | | if (!m_ServerTipScaleTween.gameObject.activeSelf)
|
| | | {
|
| | | m_ServerTipScaleTween.gameObject.SetActive(true);
|
| | | }
|
| | | m_ServerTipScaleTween.SetStartState();
|
| | | m_ServerTipPositionTween.SetStartState();
|
| | | m_ContainerServerTip.gameObject.SetActive(true);
|
| | | m_ServerTip.SetExtenalData(hint.extentionData);
|
| | | m_ServerTip.text = hint.message;
|
| | | m_ServerTipScaleTween.Play();
|
| | | TimeMgr.Instance.Register(m_ServerTip, ServerTipStartHide, m_ServerTipKeepTime + m_ServerTipScaleTween.duration);
|
| | | }
|
| | |
|
| | | private void ServerTipStartHide(Component comp)
|
| | | {
|
| | | m_ServerTipPositionTween.Play();
|
| | |
| | |
|
| | | private void ServerTipTweenComplete(Component comp)
|
| | | {
|
| | | serverTipPrepared = true;
|
| | | m_ServerTipPrepared = true;
|
| | | DisableServerTip();
|
| | | ShowServerTip();
|
| | | CheckServerHint();
|
| | | }
|
| | |
|
| | | private void DisableServerTip()
|
| | |
| | |
|
| | |
|
| | | #region GM
|
| | | private const int MAX_GM = 300;
|
| | | private List<string> gmList = new List<string>();
|
| | | public readonly Regex autoPopRegex = new Regex("参数错误|执行GM命令错误|^###");
|
| | | public void RevGMMsg(string msg)
|
| | | readonly Regex autoPopRegex = new Regex("参数错误|执行GM命令错误|^###");
|
| | | void DisplayGM(string latest)
|
| | | {
|
| | | if (gmList.Count >= MAX_GM)
|
| | | if (!string.IsNullOrEmpty(latest))
|
| | | {
|
| | | gmList.RemoveAt(0);
|
| | | if (m_AutoPopToggle.isOn && hasOnFrom)
|
| | | {
|
| | | RectTransform rt = m_ContainerGM;
|
| | | Vector3 pos = new Vector3(hasOnFrom ? -rt.sizeDelta.x / 2 : rt.sizeDelta.x / 2, 0, 0);
|
| | | rt.DOLocalMove(pos, 1.0f);
|
| | | hasOnFrom = !hasOnFrom;
|
| | | m_GMClose.gameObject.SetActive(!hasOnFrom);
|
| | | }
|
| | | }
|
| | | msg.Replace("###", string.Empty);
|
| | | gmList.Add(msg);
|
| | | if (gmToggle.isOn && hasOnFrom)
|
| | | if (m_ScrollControl.GetNumberOfCells(m_ScrollControl.m_Scorller) >= 300)
|
| | | {
|
| | | RectTransform rt = gmPanel.transform as RectTransform;
|
| | | Vector3 pos = new Vector3(hasOnFrom ? -rt.sizeDelta.x / 2 : rt.sizeDelta.x / 2, 0, 0);
|
| | | rt.DOLocalMove(pos, 1.0f);
|
| | | hasOnFrom = !hasOnFrom;
|
| | | gmClose.gameObject.SetActive(!hasOnFrom);
|
| | | }
|
| | | if (gmCtrl.GetNumberOfCells(gmCtrl.m_Scorller) >= MAX_GM)
|
| | | {
|
| | | gmCtrl.m_Scorller.RefreshActiveCellViews();
|
| | | m_ScrollControl.m_Scorller.RefreshActiveCellViews();
|
| | | return;
|
| | | }
|
| | | gmCtrl.Refresh();
|
| | | for (int i = 0; i < gmList.Count; i++)
|
| | | m_ScrollControl.Refresh();
|
| | | for (int i = 0; i < ServerTipDetails.gmMessages.Count; i++)
|
| | | {
|
| | | gmCtrl.AddCell(ScrollerDataType.Normal, i);
|
| | | m_ScrollControl.AddCell(ScrollerDataType.Normal, i);
|
| | | }
|
| | | gmCtrl.Restart();
|
| | | if (autoPopRegex.IsMatch(msg))
|
| | | m_ScrollControl.Restart();
|
| | | if (autoPopRegex.IsMatch(latest))
|
| | | {
|
| | | if (hasOnFrom)
|
| | | {
|
| | |
| | |
|
| | | private void OnRefreshGmCell(ScrollerDataType type, CellView cell)
|
| | | {
|
| | | if (cell.index < gmList.Count)
|
| | | if (cell.index < ServerTipDetails.gmMessages.Count)
|
| | | {
|
| | | Text text = cell.transform.Find("Text").GetComponent<Text>();
|
| | | text.text = gmList[cell.index];
|
| | | text.text = ServerTipDetails.gmMessages[cell.index];
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | if (!hasOnFrom)
|
| | | {
|
| | | RectTransform rt = gmPanel.transform as RectTransform;
|
| | | RectTransform rt = m_ContainerGM;
|
| | | Vector3 pos = new Vector3(hasOnFrom ? -rt.sizeDelta.x / 2 : rt.sizeDelta.x / 2, 0, 0);
|
| | | rt.DOLocalMove(pos, 1.0f);
|
| | | hasOnFrom = !hasOnFrom;
|
| | | gmClose.gameObject.SetActive(!hasOnFrom);
|
| | | m_GMClose.gameObject.SetActive(!hasOnFrom);
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | private void OnDisable()
|
| | | {
|
| | | m_ContianerFixedTip0.gameObject.SetActive(false);
|
| | | for (int i = 0; i < m_ContianerFixedTips.Count; i++)
|
| | | {
|
| | | m_ContianerFixedTips[i].gameObject.SetActive(false);
|
| | | }
|
| | | m_ContainerNormalHint.gameObject.SetActive(false);
|
| | | DisableServerTip();
|
| | | StopAllCoroutines();
|
| | | }
|
| | |
| | | private bool hasOnFrom = true;
|
| | | public void OnGMOpen()
|
| | | {
|
| | | RectTransform rt = gmPanel.transform as RectTransform;
|
| | | RectTransform rt = m_ContainerGM;
|
| | | Vector3 pos = new Vector3(hasOnFrom ? -rt.sizeDelta.x / 2 : rt.sizeDelta.x / 2, 0, 0);
|
| | | rt.DOLocalMove(pos, 1.0f);
|
| | | hasOnFrom = !hasOnFrom;
|
| | | gmClose.gameObject.SetActive(!hasOnFrom);
|
| | | }
|
| | |
|
| | | protected override void BindController()
|
| | | {
|
| | | }
|
| | | protected override void AddListeners()
|
| | | {
|
| | | m_ContianerFixedTip0.OnWaitCompelete(OnHideFixedTip);
|
| | | for (int i = 0; i < m_ContianerFixedTips.Count; i++)
|
| | | {
|
| | | m_ContianerFixedTips[i].OnWaitCompelete(OnHideFixedTip);
|
| | | m_FixedTipDisplays.Add(false);
|
| | | }
|
| | | gmCtrl.OnRefreshCell += OnRefreshGmCell;
|
| | | gmCtrl.lockType = EnhanceLockType.LockVerticalBottom;
|
| | | gmClose.onClick.AddListener(OnGMClose);
|
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | #if UNITY_EDITOR
|
| | | gmPanel.SetActive(VersionConfig.Get().debugVersion);
|
| | | #else
|
| | | gmPanel.SetActive(false);
|
| | | #endif
|
| | | serverTipPrepared = true;
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | }
|
| | |
|
| | | protected override void OnAfterClose()
|
| | | {
|
| | | _inst = null;
|
| | | m_GMClose.gameObject.SetActive(!hasOnFrom);
|
| | | }
|
| | | }
|
| | | }
|