LeagueChangeNoticeView.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_btnClose.onClick.Add(Hide);
  31. _ui.m_btnSave.onClick.Add(OnBtnSaveClick);
  32. _ui.m_txtContent.onFocusOut.Add(UpdateView);
  33. }
  34. protected override void AddEventListener()
  35. {
  36. base.AddEventListener();
  37. }
  38. protected override void OnShown()
  39. {
  40. base.OnShown();
  41. _ui.m_txtContent.text = LeagueDataManager.Instance.LeagueData.Notice;
  42. UpdateView();
  43. }
  44. protected override void OnHide()
  45. {
  46. base.OnHide();
  47. }
  48. protected override void RemoveEventListener()
  49. {
  50. base.RemoveEventListener();
  51. }
  52. private void UpdateView()
  53. {
  54. _ui.m_txtCount.SetVar("value", _ui.m_txtContent.text.Length.ToString()).FlushVars();
  55. _ui.m_txtCount.SetVar("maxValue", "50").FlushVars();
  56. }
  57. private async void OnBtnSaveClick()
  58. {
  59. // if (!Regex.IsMatch(_ui.m_txtContent.text, @"^[\u4e00-\u9fa5_0-9]+$"))
  60. // {
  61. // PromptController.Instance.ShowFloatTextPrompt("雅集公告仅允许汉字、数字、下划线");
  62. // return;
  63. // }
  64. bool result = await LeagueSproxy.ReqChangeLeagueNotice(_ui.m_txtContent.text);
  65. if (result)
  66. {
  67. Hide();
  68. }
  69. }
  70. }
  71. }