LeagueChangeNoticeView.cs 2.1 KB

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