zhaoyang 3 years ago
parent
commit
9fe8f22d0c

File diff suppressed because it is too large
+ 0 - 3
FGUIProject/assets/Mail/components/ComContent.xml


+ 4 - 4
FGUIProject/assets/Mail/components/ListItem.xml

@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="utf-8"?>
 <component size="874,152">
-  <controller name="c1" pages="0,,1,,2,,3," selected="3"/>
+  <controller name="c1" pages="0,,1,,2,,3," selected="0"/>
   <displayList>
     <image id="n7_ehs9" name="bg" src="ehs94" fileName="images/yx_dik_1.png" xy="0,0"/>
-    <loader id="n4_ehs9" name="loaIcon" xy="35,32" size="84,84" url="ui://y44a413eehs90" autoSize="true">
+    <loader id="n4_ehs9" name="loaIcon" xy="35,32" size="84,84" url="ui://y44a413eehs95" autoSize="true">
       <gearIcon controller="c1" pages="1,2,3" values="ui://y44a413eehs96|ui://y44a413eehs97|ui://y44a413eehs90" default="ui://y44a413eehs95"/>
     </loader>
-    <text id="n5_ehs9" name="txtDiscribe" xy="184,18" size="423,52" fontSize="38" color="#9b7853" autoSize="none" text="周日奖励周日奖励周报...."/>
-    <text id="n6_ehs9" name="txtTime" xy="184,95" size="189,39" fontSize="28" color="#c19f7b" text="剩余时间:5天"/>
+    <text id="n5_ehs9" name="txtTitle" xy="184,18" size="423,52" fontSize="38" color="#9b7853" autoSize="none" autoClearText="true" text="周日奖励周日奖励周报...."/>
+    <text id="n6_ehs9" name="txtTime" xy="184,95" size="189,39" fontSize="28" color="#c19f7b" autoClearText="true" text="剩余时间:5天"/>
     <component id="n8_ehs9" name="btnLook" src="ehs9e" fileName="components/Button1.xml" xy="669,41"/>
   </displayList>
 </component>

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Constant/ConstMessage.cs

@@ -9,6 +9,7 @@ namespace GFGGame
 
         public const string SUIT_BOX_STATUS_CHANGED = "SUIT_BOX_STATUS_CHANGED";
         public const string CJ_FINISH = "CJ_FINISH";
+        public const string MAIL_REFRESH = "MAIL_REFRESH";
         public const string MAIL_CHANGE = "MAIL_CHANGE";
         public const string DRESS_FILTER = "DRESS_FILTER";
         public const string DRESS_SEARCH = "DRESS_SEARCH";

File diff suppressed because it is too large
+ 7 - 8
GameClient/Assets/Game/HotUpdate/Data/MailDataManager.cs


+ 2 - 8
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Mail/UI_ComContent.cs

@@ -7,9 +7,7 @@ namespace UI.Mail
     public partial class UI_ComContent
     {
         public GComponent target;
-        public GTextField m_txtTo;
-        public GTextField m_txtContent;
-        public GTextField m_txtFrom;
+        public GRichTextField m_txtContent;
         public const string URL = "ui://y44a413eehs9g";
         public const string PACKAGE_NAME = "Mail";
         public const string RES_NAME = "ComContent";
@@ -57,15 +55,11 @@ namespace UI.Mail
 
         private void Init(GComponent comp)
         {
-            m_txtTo = (GTextField)comp.GetChild("txtTo");
-            m_txtContent = (GTextField)comp.GetChild("txtContent");
-            m_txtFrom = (GTextField)comp.GetChild("txtFrom");
+            m_txtContent = (GRichTextField)comp.GetChild("txtContent");
         }
         public void Dispose(bool disposeTarget = false)
         {
-            m_txtTo = null;
             m_txtContent = null;
-            m_txtFrom = null;
             if(disposeTarget && target != null)
             {
                 target.RemoveFromParent();

+ 3 - 3
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Mail/UI_ListItem.cs

@@ -10,7 +10,7 @@ namespace UI.Mail
         public Controller m_c1;
         public GImage m_bg;
         public GLoader m_loaIcon;
-        public GTextField m_txtDiscribe;
+        public GTextField m_txtTitle;
         public GTextField m_txtTime;
         public GButton m_btnLook;
         public const string URL = "ui://y44a413eehs9d";
@@ -63,7 +63,7 @@ namespace UI.Mail
             m_c1 = comp.GetController("c1");
             m_bg = (GImage)comp.GetChild("bg");
             m_loaIcon = (GLoader)comp.GetChild("loaIcon");
-            m_txtDiscribe = (GTextField)comp.GetChild("txtDiscribe");
+            m_txtTitle = (GTextField)comp.GetChild("txtTitle");
             m_txtTime = (GTextField)comp.GetChild("txtTime");
             m_btnLook = (GButton)comp.GetChild("btnLook");
         }
@@ -72,7 +72,7 @@ namespace UI.Mail
             m_c1 = null;
             m_bg = null;
             m_loaIcon = null;
-            m_txtDiscribe = null;
+            m_txtTitle = null;
             m_txtTime = null;
             m_btnLook = null;
             if(disposeTarget && target != null)

+ 159 - 0
GameClient/Assets/Game/HotUpdate/ServerProxy/MailSProxy.cs

@@ -0,0 +1,159 @@
+using System.Collections.Generic;
+using ET;
+using GFGGame;
+
+namespace ET
+{
+
+    public class NoticeMailCountChanged : AMHandler<G2C_MailCountChanged>
+    {
+        protected override async ETTask Run(Session session, G2C_MailCountChanged message)
+        {
+            MailDataManager.Instance.TotolCount = message.TotolCount;
+            MailDataManager.Instance.UnreadCount = message.UnreadCount;
+            await ETTask.CompletedTask;
+        }
+    }
+
+}
+namespace GFGGame
+{
+    public static class MailSProxy
+    {
+        public static async ETTask<bool> ReqMailCount()
+        {
+            G2C_GetMailCount response = null;
+            response = (G2C_GetMailCount)await MessageHelper.SendToServer(new C2G_GetMailCount());
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    MailDataManager.Instance.TotolCount = response.TotolCount;
+                    MailDataManager.Instance.UnreadCount = response.UnreadCount;
+
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public static async ETTask<bool> ReqMailList(int index, int count, bool sort)
+        {
+            G2C_GetMailList response = null;
+            response = (G2C_GetMailList)await MessageHelper.SendToServer(new C2G_GetMailList() { StartIndex = index, Count = count, NeedSort = sort });
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    List<MailInfo> mailInfos = new List<MailInfo>();
+                    for (int i = 0; i < response.mailList.Count; i++)
+                    {
+                        MailInfo mailInfo = new MailInfo();
+                        mailInfo.mailId = response.mailList[i].MailId;
+                        mailInfo.title = response.mailList[i].Tile;
+                        mailInfo.timeSec = response.mailList[i].TimeSec;
+                        mailInfo.state = response.mailList[i].Status;
+                        mailInfo.hasItem = response.mailList[i].HasItem;
+                        mailInfos.Add(mailInfo);
+                    }
+                    MailDataManager.Instance.UpdateMailInfoList(mailInfos);
+
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public static async ETTask<bool> ReqMailContent(int mailId)
+        {
+            G2C_GetMailData response = null;
+            response = (G2C_GetMailData)await MessageHelper.SendToServer(new C2G_GetMailData() { MailId = mailId });
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    MailDataManager.Instance.UnreadCount = response.UnreadCount;
+
+                    int state = response.Status;
+                    string content = response.MailDetail.Content;
+                    List<ItemData> itemDatas = ItemUtil.CreateItemDataList(response.MailDetail.ItemList);
+                    MailDataManager.Instance.UpdateMailContent(response.MailId, state, content, itemDatas);
+                    return true;
+                }
+            }
+            return false;
+        }
+        public static async ETTask<bool> ReqMailReward(int mailId)
+        {
+            G2C_GetMailItems response = null;
+            response = (G2C_GetMailItems)await MessageHelper.SendToServer(new C2G_GetMailItems() { MailId = mailId });
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    MailDataManager.Instance.UpdateMailContent(response.MailId, response.Status);
+                    List<ItemData> itemDatas = MailDataManager.Instance.GetMailInfoById(response.MailId).rewards;
+                    BonusController.TryShowBonusList(itemDatas);
+
+                    EventAgent.DispatchEvent(ConstMessage.MAIL_REFRESH);
+                    return true;
+                }
+            }
+            return false;
+        }
+        public static async ETTask<bool> ReqDeleteMail(int mailId)
+        {
+            G2C_DeleteMail response = null;
+            response = (G2C_DeleteMail)await MessageHelper.SendToServer(new C2G_DeleteMail() { MailId = mailId });
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    MailDataManager.Instance.TotolCount = response.TotolCount;
+                    EventAgent.DispatchEvent(ConstMessage.MAIL_CHANGE);
+
+                    return true;
+                }
+            }
+            return false;
+        }
+        public static async ETTask<bool> ReqAllMailRewards()
+        {
+            G2C_GetAllMailItems response = null;
+            response = (G2C_GetAllMailItems)await MessageHelper.SendToServer(new C2G_GetAllMailItems());
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    List<ItemData> itemDatas = ItemUtil.CreateItemDataList(response.ItemList);
+                    BonusController.TryShowBonusList(itemDatas);
+                    EventAgent.DispatchEvent(ConstMessage.MAIL_REFRESH);
+
+                    return true;
+                }
+            }
+            return false;
+        }
+        public static async ETTask<bool> ReqDeleteAllMails()
+        {
+            G2C_DeleteAllMails response = null;
+            response = (G2C_DeleteAllMails)await MessageHelper.SendToServer(new C2G_DeleteAllMails());
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    if (response.DeleteCount > 0)
+                    {
+                        MailDataManager.Instance.TotolCount = MailDataManager.Instance.TotolCount - response.DeleteCount;
+                        EventAgent.DispatchEvent(ConstMessage.MAIL_CHANGE);
+
+                    }
+
+                    return true;
+                }
+            }
+            return false;
+        }
+
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/ServerProxy/MailSProxy.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 72b993d6e7590a14f83979b48e23b9f3
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
GameClient/Assets/Game/HotUpdate/ServerProxy/MessageHelper.cs

@@ -5,7 +5,7 @@ namespace GFGGame
 {
     public static class MessageHelper
     {
-        public static async ETTask<IResponse> SendToServer(IActorLocationRequest request, bool showError = true)
+        public static async ETTask<IResponse> SendToServer(IRequest request, bool showError = true)
         {
             IResponse response = null;
             Session session = GameGlobal.zoneScene.GetComponent<SessionComponent>().Session;
@@ -21,7 +21,7 @@ namespace GFGGame
                 }
                 return response;
             }
-            catch(Exception e)
+            catch (Exception e)
             {
                 Log.Error(e.ToString());
                 return null;

+ 30 - 31
GameClient/Assets/Game/HotUpdate/Views/Mail/MailContentView.cs

@@ -9,8 +9,8 @@ namespace GFGGame
     {
 
         private UI_MailContentUI _ui;
-        private int _index;
-
+        private int _childIndex;
+        private MailInfo mailInfo;
         public override void Dispose()
         {
             base.Dispose();
@@ -26,8 +26,6 @@ namespace GFGGame
             viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
 
             _ui.m_listReward.itemRenderer = RenderListRewardItem;
-            // _ui.m_listReward.onClickItem.Add(OnClickListRewardItem);
-
             _ui.m_btnGet.onClick.Add(OnClickBtnGet);
             _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
 
@@ -35,58 +33,59 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
-            EventAgent.AddEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
+            // EventAgent.AddEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
 
-            _index = (int)this.viewData;
-            MailDataManager.Instance.ChangeMailReadState(_index);
-            MailData data = MailDataManager.Instance.mailListData[_index];
-            _ui.m_c1.selectedIndex = data.rewards.Count == 0 ? 0 : 1;
-            _ui.m_txtTitle.text = data.title;
+            _childIndex = (int)this.viewData;
+            mailInfo = MailDataManager.Instance.mailInfos[_childIndex];
+            _ui.m_c1.selectedIndex = mailInfo.rewards.Count == 0 ? 0 : 1;
+            _ui.m_txtTitle.text = mailInfo.title;
             _ui.m_ComContent.target.scrollPane.ScrollTop();
-            _ui.m_ComContent.m_txtTo.text = data.toName;
-            _ui.m_ComContent.m_txtFrom.text = data.fromName;
-            _ui.m_ComContent.m_txtContent.text = data.content;
+            _ui.m_ComContent.m_txtContent.text = mailInfo.content;
 
             UpdateNormal();
         }
         private void UpdateNormal()
         {
-            MailData data = MailDataManager.Instance.mailListData[_index];
-
-            _ui.m_btnGet.visible = data.rewards.Count > 0 && data.isGet == 0 ? true : false;
+            _ui.m_btnGet.visible = (ConstMailStatus)mailInfo.state == ConstMailStatus.ReadedButNotGet ? true : false;
             _ui.m_btnDelete.visible = _ui.m_btnGet.visible == true ? false : true;
-
-            _ui.m_listReward.numItems = data.rewards.Count;
+            _ui.m_listReward.numItems = mailInfo.rewards.Count;
         }
 
         private void RenderListRewardItem(int index, GObject obj)
         {
-            MailData data = MailDataManager.Instance.mailListData[_index];
-            ItemData reward = data.rewards[index];
+            ItemData reward = mailInfo.rewards[index];
             if (obj.data == null)
             {
                 obj.data = new ItemView(obj as GComponent);
             }
             (obj.data as ItemView).SetData(reward);
-            (obj.data as ItemView).ImgGotVisible = data.isGet == 1 ? true : false;
+            (obj.data as ItemView).ImgGotVisible = (ConstMailStatus)mailInfo.state == ConstMailStatus.ReadedAndGot ? true : false;
         }
 
-        private void OnClickBtnGet()
+        private async void OnClickBtnGet()
         {
-            MailDataManager.Instance.GetRewards(_index);
+            bool result = await MailSProxy.ReqMailReward(mailInfo.mailId);
+            if (result)
+            {
+                mailInfo = MailDataManager.Instance.GetMailInfoById(mailInfo.mailId);
+                UpdateNormal();
+            }
         }
 
-        private void OnClickBtnDelete()
+        private async void OnClickBtnDelete()
         {
-            MailDataManager.Instance.DeleteMail(_index);
-            this.Hide();
+            bool result = await MailSProxy.ReqDeleteMail(mailInfo.mailId);
+            if (result)
+            {
+                this.Hide();
+            }
         }
 
-        protected override void OnHide()
-        {
-            base.OnHide();
-            EventAgent.RemoveEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
+        // protected override void OnHide()
+        // {
+        //     base.OnHide();
+        //     // EventAgent.RemoveEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
 
-        }
+        // }
     }
 }

+ 76 - 26
GameClient/Assets/Game/HotUpdate/Views/Mail/MailView.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using UnityEngine;
 using UI.Mail;
 using FairyGUI;
+using ET;
 
 namespace GFGGame
 {
@@ -12,7 +13,11 @@ namespace GFGGame
         private UI_MailUI _ui;
         private MailDataManager mailDataMgr;
         private const int _maxMailCount = 300;
+        private const int _retainDay = 30;//邮件保存时间
+        private const int _showCount = 5;//列表展示数量
+        private int _firstChildIndex = 0;//列表显示内容得一个项的显示对象索引
 
+        public bool _canShowContent = false;//获取内容数据返回前不可查看
         public override void Dispose()
         {
             base.Dispose();
@@ -29,12 +34,19 @@ namespace GFGGame
             viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
 
             _ui.m_list.itemRenderer = RenderListItem;
+            _ui.m_list.scrollPane.onScrollEnd.Add(OnListScrollEnd);
+            _ui.m_list.scrollPane.onScroll.Add(OnListScroll);
             _ui.m_list.SetVirtual();
 
             _ui.m_btnGet.onClick.Add(OnClickBtnGet);
             _ui.m_btnDelete.onClick.Add(OnClickBtnDelete);
+            EventAgent.AddEventListener(ConstMessage.MAIL_REFRESH, () =>
+            {
+                _ui.m_list.RefreshVirtualList();
+            });
+
+            EventAgent.AddEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
 
-            MailDataManager.Instance.GMSetList(20);
             mailDataMgr = MailDataManager.Instance;
         }
 
@@ -42,58 +54,96 @@ namespace GFGGame
         {
             base.OnShown();
 
-            EventAgent.AddEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
-
+            _firstChildIndex = 0;
             UpdateNormal();
-
         }
         private void UpdateNormal()
         {
-            int count = mailDataMgr.mailListData.Count;
-            _ui.m_list.numItems = count;
-            _ui.m_txtTips.visible = count == 0 ? true : false;
-            _ui.m_txtCount.text = string.Format("当前邮件:{0}/{1}", StringUtil.GetColorText(count.ToString(), count >= _maxMailCount ? "#B19977" : "#E27D78"), _maxMailCount);
+            _ui.m_list.numItems = mailDataMgr.TotolCount;
+            _ui.m_txtTips.visible = mailDataMgr.TotolCount == 0 ? true : false;
+            _ui.m_txtCount.text = string.Format("当前邮件:{0}/{1}", StringUtil.GetColorText(mailDataMgr.TotolCount.ToString(), mailDataMgr.TotolCount >= _maxMailCount ? "#B19977" : "#E27D78"), _maxMailCount);
             _ui.m_txtMaxCount.text = string.Format("最高可储存{0}封邮箱,请及时查看", _maxMailCount);
+            RefreshMailInfo(0, true);
         }
 
         private void RenderListItem(int index, GObject obj)
         {
+            int childIndex = _ui.m_list.ItemIndexToChildIndex(index);
             UI_ListItem item = UI_ListItem.Proxy(obj);
-            MailData data = mailDataMgr.mailListData[index];
+            if (mailDataMgr.mailInfos.Count == 0) return;
+            MailInfo data = mailDataMgr.mailInfos[childIndex];
             item.m_c1.selectedIndex = mailDataMgr.GetMailState(data);
-            item.m_txtDiscribe.text = string.Format("{0}...", data.content.Length > 10 ? data.content.Substring(0, 10) : data.content);
-            item.m_txtTime.text = string.Format("剩余时间:{0}天", data.remainingTime);
-            item.m_btnLook.onClick.Clear();
-            item.m_btnLook.onClick.Add(OnClickBtnLook);
-            item.m_btnLook.data = index;
+            item.m_txtTitle.text = data.title;// string.Format("{0}...", data.content.Length > 10 ? data.content.Substring(0, 10) : data.content);
+            string str = TimeUtil.FormattingTime(TimeHelper.ServerNowSecs, ((int)data.timeSec + _retainDay * TimeUtil.SECOND_PER_DAY));
+            item.m_txtTime.text = string.Format("剩余时间:{0}", str);
+            if (item.target.data == null)
+            {
+                item.m_btnLook.onClick.Add(OnClickBtnLook);
+            }
+            item.target.data = index;
+
+        }
+        private async void OnClickBtnLook(EventContext context)
+        {
+            if (!_canShowContent) return;
+            int index = (int)(context.data as GObject).data;
+            int childIndex = (int)_ui.m_list.ItemIndexToChildIndex(index);
+            bool result = await MailSProxy.ReqMailContent(mailDataMgr.mailInfos[childIndex].mailId);
+            if (result)
+            {
+                ViewManager.Show<MailContentView>(childIndex);
+            }
+        }
 
+
+        private void OnListScroll()
+        {
+            _canShowContent = false;
         }
-        private void OnClickBtnLook(EventContext context)
+        private void OnListScrollEnd()
         {
-            GButton btn = context.sender as GButton;
-            int data = (int)btn.data;
-            ViewManager.Show<MailContentView>(data);
+            _firstChildIndex = (int)_ui.m_list.GetChildAt(0).data;
+            RefreshMailInfo(_firstChildIndex, false);
         }
-        private void OnClickBtnGet()
+
+        private async void RefreshMailInfo(int index, bool needSort)
         {
-            mailDataMgr.GetAllRewards();
-            _ui.m_list.scrollPane.ScrollTop();
+            bool result = await MailSProxy.ReqMailList(index, _showCount, needSort);
+            if (result)
+            {
+                _ui.m_list.RefreshVirtualList();
+                _canShowContent = true;
+            }
+        }
+
+        private async void OnClickBtnGet()
+        {
+            bool result = await MailSProxy.ReqAllMailRewards();
+            if (result)
+            {
+                RefreshMailInfo(_firstChildIndex, false);
+            }
         }
 
         private void OnClickBtnDelete()
         {
             Alert.Show("是否删除所有已读文件?").SetLeftButton(true).SetRightButton(true, "确认", (object data) =>
             {
-                mailDataMgr.DeleteAllMail();
-                _ui.m_list.scrollPane.ScrollTop();
+                SendDeleteAll();
             });
-
+        }
+        private async void SendDeleteAll()
+        {
+            bool result = await MailSProxy.ReqDeleteAllMails();
+            if (result)
+            {
+                _ui.m_list.ScrollToView(0);
+                RefreshMailInfo(0, true);
+            }
         }
         protected override void OnHide()
         {
             base.OnHide();
-            EventAgent.RemoveEventListener(ConstMessage.MAIL_CHANGE, UpdateNormal);
-
         }
     }
 }

BIN
GameClient/Assets/ResIn/UI/Mail/Mail_atlas0!a.png


BIN
GameClient/Assets/ResIn/UI/Mail/Mail_atlas0.png


BIN
GameClient/Assets/ResIn/UI/Mail/Mail_fui.bytes


Some files were not shown because too many files changed in this diff