123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- using UnityEngine;
- using FairyGUI;
- using UI.Notice;
- namespace GFGGame
- {
- public class NoticeView : BaseWindow
- {
- private UI_NoticeUI _ui;
- public override void Dispose()
- {
- base.Dispose();
- }
- protected override void Init()
- {
- base.Init();
- packageName = UI_NoticeUI.PACKAGE_NAME;
- _ui = UI_NoticeUI.Create();
- this.viewCom = _ui.target;
- this.viewCom.Center();
- this.modal = true;
- viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui.m_listActivity.itemRenderer = ListActivityItemRender;
- _ui.m_listActivity.onClick.Add(OnListActivityClick);
- _ui.m_listNotice.itemRenderer = ListNoticeItemRender;
- _ui.m_c1.onChanged.Add(OnCtrlChange);
- EventAgent.AddEventListener(ConstMessage.NOTICE_SYSTOM_ADD, OnCtrlChange);
- EventAgent.AddEventListener(ConstMessage.NOTICE_SYSTOM_REMOVE, OnCtrlChange);
- }
- protected override void OnShown()
- {
- base.OnShown();
- _ui.m_c1.selectedIndex = 1;
- _ui.m_listActivity.visible = true;
- _ui.m_listNotice.visible = true;
- OnCtrlChange();
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- private void OnCtrlChange()
- {
- if (_ui.m_c1.selectedIndex == 0)
- {
- _ui.m_listActivity.numItems = 0;
- _ui.m_txtTips.visible = _ui.m_listActivity.numItems == 0;
- }
- else if (_ui.m_c1.selectedIndex == 1)
- {
- _ui.m_listNotice.numItems = NoticeDataManager.Instance.NoticeInfos.Count;
- _ui.m_txtTips.visible = _ui.m_listNotice.numItems == 0;
- }
- }
- private void ListActivityItemRender(int index, GObject obj)
- {
- UI_ListActivityItem item = UI_ListActivityItem.Proxy(obj);
- item.m_loaShow.url = ResPathUtil.GetActivityPath("");
- item.target.data = index;
- }
- private void OnListActivityClick(EventContext context)
- {
- // _ui.m_listActivity.visible = false;
- // _ui.m_listNotice.visible = false;
- // int noticeId = (int)(context.data as GObject).data;
- // ViewManager.Show<NoticeActivityShowView>(null, new object[] { typeof(NoticeView).Name, this.viewData });
- }
- private void ListNoticeItemRender(int index, GObject obj)
- {
- NoticeInfo noticeInfo = NoticeDataManager.Instance.NoticeInfos[index];
- UI_ListNoticeItem item = UI_ListNoticeItem.Proxy(obj);
- item.m_txtTitle.text = noticeInfo.title;
- item.m_txtTime.text = TimeUtil.FormattingTime(noticeInfo.time);
- // item.m_imgTips.visible = !noticeInfo.readStatus;
- RedDotController.Instance.SetComRedDot(item.target, !noticeInfo.readStatus, "gg_gg_hdhdgth", -13, 12);
- if (item.m_btnGo.data == null)
- {
- item.m_btnGo.onClick.Add(OnListNoticeBtnGoClick);
- }
- item.m_btnGo.data = noticeInfo;
- }
- private async void OnListNoticeBtnGoClick(EventContext context)
- {
- _ui.m_listActivity.visible = false;
- _ui.m_listNotice.visible = false;
- NoticeInfo noticeInfo = (context.sender as GObject).data as NoticeInfo;
- if (noticeInfo.content == "")
- {
- bool result = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId);
- if (result)
- {
- ViewManager.Show<NoticeSystemShowView>(NoticeDataManager.Instance.GetNoticeInfoById(noticeInfo.noticeId), new object[] { typeof(NoticeView).Name, this.viewData });
- }
- }
- else
- {
- ViewManager.Show<NoticeSystemShowView>(noticeInfo, new object[] { typeof(NoticeView).Name, this.viewData });
- }
- }
- }
- }
|