LeagueChangeNoticeView.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System.Text.RegularExpressions;
  2. using ET;
  3. using FairyGUI;
  4. using UI.League;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. //修改联盟公告
  9. public class LeagueChangeNoticeView : BaseWindow
  10. {
  11. private UI_LeagueChangeNoticeUI _ui;
  12. public override void Dispose()
  13. {
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. _ui = null;
  18. }
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_LeagueChangeNoticeUI.PACKAGE_NAME;
  25. _ui = UI_LeagueChangeNoticeUI.Create();
  26. this.viewCom = _ui.target;
  27. this.viewCom.Center();
  28. this.modal = true;
  29. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  30. _ui.m_btnSave.onClick.Add(OnBtnSaveClick);
  31. _ui.m_txtContent.onFocusOut.Add(OnFocuseOut);
  32. }
  33. protected override void AddEventListener()
  34. {
  35. base.AddEventListener();
  36. }
  37. protected override void OnShown()
  38. {
  39. base.OnShown();
  40. }
  41. protected override void OnHide()
  42. {
  43. base.OnHide();
  44. }
  45. protected override void RemoveEventListener()
  46. {
  47. base.RemoveEventListener();
  48. }
  49. private void OnFocuseOut()
  50. {
  51. _ui.m_txtCount.SetVar("value", _ui.m_txtContent.text.Length.ToString());
  52. _ui.m_txtCount.SetVar("maxValue", "50");
  53. }
  54. private async void OnBtnSaveClick()
  55. {
  56. if (!Regex.IsMatch(_ui.m_txtContent.text, @"^[\u4e00-\u9fa5_0-9]+$"))
  57. {
  58. PromptController.Instance.ShowFloatTextPrompt("雅集公告仅允许汉字、数字、下划线");
  59. return;
  60. }
  61. bool result = await LeagueSproxy.ReqChangeLeagueNotice(_ui.m_txtContent.text);
  62. if (result)
  63. {
  64. Hide();
  65. }
  66. }
  67. }
  68. }