NoticeView.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.Notice;
  4. namespace GFGGame
  5. {
  6. public class NoticeView : BaseWindow
  7. {
  8. private UI_NoticeUI _ui;
  9. public override void Dispose()
  10. {
  11. base.Dispose();
  12. }
  13. protected override void Init()
  14. {
  15. base.Init();
  16. packageName = UI_NoticeUI.PACKAGE_NAME;
  17. _ui = UI_NoticeUI.Create();
  18. this.viewCom = _ui.target;
  19. this.viewCom.Center();
  20. this.modal = true;
  21. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. _ui.m_listActivity.itemRenderer = ListActivityItemRender;
  27. _ui.m_listActivity.onClick.Add(OnListActivityClick);
  28. _ui.m_listNotice.itemRenderer = ListNoticeItemRender;
  29. _ui.m_c1.onChanged.Add(OnCtrlChange);
  30. EventAgent.AddEventListener(ConstMessage.NOTICE_SYSTOM_ADD, OnCtrlChange);
  31. EventAgent.AddEventListener(ConstMessage.NOTICE_SYSTOM_REMOVE, OnCtrlChange);
  32. }
  33. protected override void OnShown()
  34. {
  35. base.OnShown();
  36. _ui.m_c1.selectedIndex = 1;
  37. _ui.m_listActivity.visible = true;
  38. _ui.m_listNotice.visible = true;
  39. OnCtrlChange();
  40. }
  41. protected override void OnHide()
  42. {
  43. base.OnHide();
  44. }
  45. private void OnCtrlChange()
  46. {
  47. if (_ui.m_c1.selectedIndex == 0)
  48. {
  49. _ui.m_listActivity.numItems = 0;
  50. _ui.m_txtTips.visible = _ui.m_listActivity.numItems == 0;
  51. }
  52. else if (_ui.m_c1.selectedIndex == 1)
  53. {
  54. _ui.m_listNotice.numItems = NoticeDataManager.Instance.NoticeInfos.Count;
  55. _ui.m_txtTips.visible = _ui.m_listNotice.numItems == 0;
  56. }
  57. }
  58. private void ListActivityItemRender(int index, GObject obj)
  59. {
  60. UI_ListActivityItem item = UI_ListActivityItem.Proxy(obj);
  61. item.m_loaShow.url = ResPathUtil.GetActivityPath("");
  62. item.target.data = index;
  63. }
  64. private void OnListActivityClick(EventContext context)
  65. {
  66. // _ui.m_listActivity.visible = false;
  67. // _ui.m_listNotice.visible = false;
  68. // int noticeId = (int)(context.data as GObject).data;
  69. // ViewManager.Show<NoticeActivityShowView>(null, new object[] { typeof(NoticeView).Name, this.viewData });
  70. }
  71. private void ListNoticeItemRender(int index, GObject obj)
  72. {
  73. NoticeInfo noticeInfo = NoticeDataManager.Instance.NoticeInfos[index];
  74. UI_ListNoticeItem item = UI_ListNoticeItem.Proxy(obj);
  75. item.m_txtTitle.text = noticeInfo.title;
  76. item.m_txtTime.text = TimeUtil.FormattingTime(noticeInfo.time);
  77. // item.m_imgTips.visible = !noticeInfo.readStatus;
  78. RedDotController.Instance.SetComRedDot(item.target, !noticeInfo.readStatus, "gg_gg_hdhdgth", -13, 12);
  79. if (item.m_btnGo.data == null)
  80. {
  81. item.m_btnGo.onClick.Add(OnListNoticeBtnGoClick);
  82. }
  83. item.m_btnGo.data = noticeInfo;
  84. }
  85. private async void OnListNoticeBtnGoClick(EventContext context)
  86. {
  87. _ui.m_listActivity.visible = false;
  88. _ui.m_listNotice.visible = false;
  89. NoticeInfo noticeInfo = (context.sender as GObject).data as NoticeInfo;
  90. if (noticeInfo.content == "")
  91. {
  92. bool result = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId);
  93. if (result)
  94. {
  95. ViewManager.Show<NoticeSystemShowView>(NoticeDataManager.Instance.GetNoticeInfoById(noticeInfo.noticeId), new object[] { typeof(NoticeView).Name, this.viewData });
  96. }
  97. }
  98. else
  99. {
  100. ViewManager.Show<NoticeSystemShowView>(noticeInfo, new object[] { typeof(NoticeView).Name, this.viewData });
  101. }
  102. }
  103. }
  104. }