From 68acdb8d3f3f34b9f2d87db078b6bab8ae3fefb2 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期一, 05 十一月 2018 16:24:44 +0800
Subject: [PATCH] 4398 【1.2】聊天气泡框

---
 Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs.meta |   12 +
 System/Chat/ChatExtentWin.cs                                                                         |   73 +++++++-
 Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs      |   18 ++
 System/Chat/ChatBubbleCell.cs.meta                                                                   |   12 +
 Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs                                                  |    9 
 Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs.meta       |   12 +
 System/Chat/ChatBubbleCell.cs                                                                        |   38 ++++
 Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs.meta                 |   12 +
 Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs            |   24 +++
 Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs                      |   17 ++
 System/Chat/ChatBubbleSelectBehaviour.cs.meta                                                        |   12 +
 Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta                                             |    2 
 System/Chat/ChatBubbleModel.cs                                                                       |   92 +++++++++--
 System/Chat/ChatBubbleSelectBehaviour.cs                                                             |  117 ++++++++++++++
 Core/GameEngine/DataToCtl/PackageRegedit.cs                                                          |    1 
 15 files changed, 416 insertions(+), 35 deletions(-)

diff --git a/Core/GameEngine/DataToCtl/PackageRegedit.cs b/Core/GameEngine/DataToCtl/PackageRegedit.cs
index 39eb2bf..ef84b84 100644
--- a/Core/GameEngine/DataToCtl/PackageRegedit.cs
+++ b/Core/GameEngine/DataToCtl/PackageRegedit.cs
@@ -11,6 +11,7 @@
     public static void Init()
     {
         // 鐧昏鐩稿簲鐨勬暟鎹綋鍙婂搴旂殑鏁版嵁杞�昏緫绫�
+		Register(typeof(HA717_tagMCChatBubbleBoxState), typeof(DTCA717_tagMCChatBubbleBoxState));
 		Register(typeof(HB913_tagGCEnterTeamFBFailReason), typeof(DTCB913_tagGCEnterTeamFBFailReason));
 		Register(typeof(H0311_tagDeleteSkill), typeof(DTC0311_tagDeleteSkill));
 		Register(typeof(HB106_tagMCNotifyPlayerMove), typeof(DTCB106_tagMCNotifyPlayerMove));
diff --git a/Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs b/Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs
index 3123cd1..58bf0d8 100644
--- a/Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs
+++ b/Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs
@@ -1,6 +1,6 @@
 锘�//--------------------------------------------------------
 //    [Author]:			绗簩涓栫晫
-//    [  Date ]:		   Friday, November 02, 2018
+//    [  Date ]:		   Monday, November 05, 2018
 //--------------------------------------------------------
 
 using UnityEngine;
@@ -18,7 +18,8 @@
 		public string leftBubbleIcon { get ; private set; } 
 		public string rightBubbleIcon { get ; private set; } 
 		public int[] leftOffset;
-		public int[] rightOffset;
+		public int[] rightOffset;
+		public string Icon { get ; private set; } 
 
 		public override string getKey()
         {
@@ -52,7 +53,9 @@
 				for (int i=0;i<rightOffsetStringArray.Length;i++)
 				{
 					 int.TryParse(rightOffsetStringArray[i],out rightOffset[i]);
-				}
+				}
+			
+				Icon = rawContents[8].Trim();
             }
             catch (Exception ex)
             {
diff --git a/Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta b/Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta
index 5516250..54390e1 100644
--- a/Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta
+++ b/Core/GameEngine/Model/Config/ChatBubbleBoxConfig.cs.meta
@@ -1,6 +1,6 @@
 fileFormatVersion: 2
 guid: d3368c32387593943aae6e197d7cb78f
-timeCreated: 1541148738
+timeCreated: 1541405725
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2
diff --git a/Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs b/Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs
new file mode 100644
index 0000000..1f13e87
--- /dev/null
+++ b/Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs
@@ -0,0 +1,18 @@
+using UnityEngine;
+using System.Collections;
+
+// A2 30 设置聊天气泡框 #tagCMSetChatBubbleBox

+

+public class CA230_tagCMSetChatBubbleBox : GameNetPackBasic {

+    public byte BubbleBoxType;    //气泡框类型

+

+    public CA230_tagCMSetChatBubbleBox () {

+        combineCmd = (ushort)0x03FE;

+        _cmd = (ushort)0xA230;

+    }

+

+    public override void WriteToBytes () {

+        WriteBytes (BubbleBoxType, NetDataType.BYTE);

+    }

+

+}

diff --git a/Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs.meta b/Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs.meta
new file mode 100644
index 0000000..975baf7
--- /dev/null
+++ b/Core/NetworkPackage/ClientPack/ClientToMapServer/CA2_Interaction/CA230_tagCMSetChatBubbleBox.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 2bd82e50dd886f640bb5c2c2a95029ae
+timeCreated: 1541388926
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs b/Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs
new file mode 100644
index 0000000..2aa2d8e
--- /dev/null
+++ b/Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs
@@ -0,0 +1,24 @@
+锘�//--------------------------------------------------------
+//    [Author]:           绗簩涓栫晫
+//    [  Date ]:           Monday, November 05, 2018
+//--------------------------------------------------------
+
+using Snxxz.UI;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+public class DTCA717_tagMCChatBubbleBoxState : DtcBasic {
+
+    public override void Done(GameNetPackBasic vNetPack)
+    {
+        base.Done(vNetPack);
+        var package = vNetPack as HA717_tagMCChatBubbleBoxState;
+        var model = ModelCenter.Instance.GetModel<ChatBubbleModel>();
+    }
+
+}
+
+
+
+
diff --git a/Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs.meta b/Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs.meta
new file mode 100644
index 0000000..2a670e1
--- /dev/null
+++ b/Core/NetworkPackage/DTCFile/ServerPack/HA7_Interaction/DTCA717_tagMCChatBubbleBoxState.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 9b9fa6bf002bc674f827dd8e5bf995be
+timeCreated: 1541388295
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs b/Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs
new file mode 100644
index 0000000..e79b1b3
--- /dev/null
+++ b/Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs
@@ -0,0 +1,17 @@
+using UnityEngine;
+using System.Collections;
+
+// A7 17 聊天气泡框状态 #tagMCChatBubbleBoxState

+

+public class HA717_tagMCChatBubbleBoxState : GameNetPackBasic {

+    public uint BoxState;    // 按二进制位存储代表是否已开启,暂支持31位,以后有需要再加

+

+    public HA717_tagMCChatBubbleBoxState () {

+        _cmd = (ushort)0xA717;

+    }

+

+    public override void ReadFromBytes (byte[] vBytes) {

+        TransBytes (out BoxState, vBytes, NetDataType.DWORD);

+    }

+

+}

diff --git a/Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs.meta b/Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs.meta
new file mode 100644
index 0000000..c42a0aa
--- /dev/null
+++ b/Core/NetworkPackage/ServerPack/HA7_Interaction/HA717_tagMCChatBubbleBoxState.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 75af16c19e35946488560bae099c3ceb
+timeCreated: 1541388257
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/System/Chat/ChatBubbleCell.cs b/System/Chat/ChatBubbleCell.cs
new file mode 100644
index 0000000..c4245da
--- /dev/null
+++ b/System/Chat/ChatBubbleCell.cs
@@ -0,0 +1,38 @@
+锘縰sing System.Collections;
+using System.Collections.Generic;
+using TableConfig;
+using UnityEngine;
+namespace Snxxz.UI
+{
+    public class ChatBubbleCell : CellView
+    {
+        [SerializeField] ChatBubbleSelectBehaviour[] m_ChatBubbles;
+        [SerializeField] int m_LineCount = 7;
+
+        public int lineCount { get { return m_LineCount; } }
+
+        ChatBubbleModel model
+        {
+            get { return ModelCenter.Instance.GetModel<ChatBubbleModel>(); }
+        }
+
+        public void Display(int line)
+        {
+            var configs = Config.Instance.GetAllValues<ChatBubbleBoxConfig>();
+            for (int i = 0; i < lineCount; i++)
+            {
+                var index = line * 7 + i;
+                if (index < configs.Count)
+                {
+                    m_ChatBubbles[i].gameObject.SetActive(true);
+                    m_ChatBubbles[i].Display(configs[i].ID);
+                }
+                else
+                {
+                    m_ChatBubbles[i].gameObject.SetActive(false);
+                }
+            }
+        }
+    }
+}
+
diff --git a/System/Chat/ChatBubbleCell.cs.meta b/System/Chat/ChatBubbleCell.cs.meta
new file mode 100644
index 0000000..65e11a5
--- /dev/null
+++ b/System/Chat/ChatBubbleCell.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 335becbcd490c4a48b88be31b662fc32
+timeCreated: 1541403023
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/System/Chat/ChatBubbleModel.cs b/System/Chat/ChatBubbleModel.cs
index e3598af..dc7a2ff 100644
--- a/System/Chat/ChatBubbleModel.cs
+++ b/System/Chat/ChatBubbleModel.cs
@@ -1,12 +1,17 @@
-锘縰sing System.Collections;
+锘縰sing System;
+using System.Collections;
 using System.Collections.Generic;
 using TableConfig;
 using UnityEngine;
 namespace Snxxz.UI
 {
-    public class ChatBubbleModel : Model
+    public class ChatBubbleModel : Model, IBeforePlayerDataInitialize
     {
         public Dictionary<int, ChatBubble> chatBubbles = new Dictionary<int, ChatBubble>();
+
+        public event Action chatBubbleStateRefresh;
+
+        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
         public override void Init()
         {
             ParseConfig();
@@ -14,6 +19,11 @@
 
         public override void UnInit()
         {
+        }
+
+        public void OnBeforePlayerDataInitialize()
+        {
+            bubbleState = 0;
         }
 
         void ParseConfig()
@@ -28,11 +38,6 @@
                 }
                 var bubble = new ChatBubble();
                 bubble.id = config.ID;
-                bubble.name = config.Name;
-                bubble.requireLevel = config.NeedLV;
-                bubble.requireVipLevel = config.NeedVIPLVGift;
-                bubble.leftBubbleIcon = config.leftBubbleIcon;
-                bubble.rightBubbleIcon = config.rightBubbleIcon;
                 bubble.leftPadding = new RectOffset()
                 {
                     left = config.leftOffset.Length > 0 ? config.leftOffset[0] : 0,
@@ -56,37 +61,88 @@
             return chatBubbles.TryGetValue(id, out bubble);
         }
 
+        public bool IsBubbleGot(int id, out int reason)
+        {
+            ChatBubble bubble;
+            reason = 0;
+            if (TryGetBubble(id, out bubble))
+            {
+                var config = Config.Instance.Get<ChatBubbleBoxConfig>(id);
+                if (config.NeedLV != 0)
+                {
+                    reason = 1;
+                    return PlayerDatas.Instance.baseData.LV >= config.NeedLV;
+                }
+                if (config.NeedVIPLVGift != 0)
+                {
+                    reason = 2;
+                    var gift = vipModel.GetVipGift(config.NeedVIPLVGift);
+                    return gift != null && gift.hasBuy;
+                }
+                try
+                {
+                    reason = 3;
+                    return MathUtility.GetBitValue(bubbleState, (ushort)id);
+                }
+                catch (ArgumentOutOfRangeException)
+                {
+                    DebugEx.LogError("鐩墠涓嶆敮鎸乮d瓒呰繃31鐨勮亰澶╂锛�" + id);
+                }
+            }
+            return false;
+        }
+
+        #region 鏈嶅姟绔暟鎹�
+        public uint bubbleState { get; private set; }
+        public void UpdateBubbleState(HA717_tagMCChatBubbleBoxState package)
+        {
+            bubbleState = package.BoxState;
+            if (chatBubbleStateRefresh != null)
+            {
+                chatBubbleStateRefresh();
+            }
+        }
+
+        public void SendUseBubble(int id)
+        {
+            var reason = 0;
+            if (!IsBubbleGot(id, out reason))
+            {
+                return;
+            }
+            CA230_tagCMSetChatBubbleBox pak = new CA230_tagCMSetChatBubbleBox();
+            pak.BubbleBoxType = (byte)id;
+            GameNetSystem.Instance.SendInfo(pak);
+        }
+        #endregion
+
         public struct ChatBubble
         {
             public int id;
-            public string name;
-            public int requireLevel;
-            public int requireVipLevel;
-            public string leftBubbleIcon;
-            public string rightBubbleIcon;
             public RectOffset leftPadding;
             public RectOffset rifhtPadding;
 
             public string GetBubbleIcon(bool left, ref bool isFlip)
             {
+                var config = Config.Instance.Get<ChatBubbleBoxConfig>(id);
                 isFlip = false;
                 if (left)
                 {
-                    if (string.IsNullOrEmpty(leftBubbleIcon))
+                    if (string.IsNullOrEmpty(config.leftBubbleIcon))
                     {
                         isFlip = true;
-                        return rightBubbleIcon;
+                        return config.rightBubbleIcon;
                     }
-                    return leftBubbleIcon;
+                    return config.leftBubbleIcon;
                 }
                 else
                 {
-                    if (string.IsNullOrEmpty(rightBubbleIcon))
+                    if (string.IsNullOrEmpty(config.rightBubbleIcon))
                     {
                         isFlip = true;
-                        return leftBubbleIcon;
+                        return config.leftBubbleIcon;
                     }
-                    return rightBubbleIcon;
+                    return config.rightBubbleIcon;
                 }
             }
         }
diff --git a/System/Chat/ChatBubbleSelectBehaviour.cs b/System/Chat/ChatBubbleSelectBehaviour.cs
new file mode 100644
index 0000000..7bf0d25
--- /dev/null
+++ b/System/Chat/ChatBubbleSelectBehaviour.cs
@@ -0,0 +1,117 @@
+锘縰sing System;
+using System.Collections;
+using System.Collections.Generic;
+using TableConfig;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace Snxxz.UI
+{
+    public class ChatBubbleSelectBehaviour : MonoBehaviour
+    {
+        [SerializeField] Button m_Func;
+        [SerializeField] Image m_Icon;
+        [SerializeField] Image m_Using;
+        [SerializeField] Text m_BubbleName;
+        [SerializeField] RectTransform m_ContainerUnGet;
+        [SerializeField] Text m_Condition;
+
+        private int bubbleId = 0;
+
+        ChatBubbleModel model
+        {
+            get { return ModelCenter.Instance.GetModel<ChatBubbleModel>(); }
+        }
+
+        VipModel vipModel
+        {
+            get { return ModelCenter.Instance.GetModel<VipModel>(); }
+        }
+
+        private void Awake()
+        {
+            m_Func.onClick.AddListener(OnFunc);
+        }
+
+        private void OnEnable()
+        {
+            PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
+            vipModel.OnVipGiftEvent += OnVipGiftEvent;
+        }
+
+        private void OnDisable()
+        {
+            PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerDataRefreshInfoEvent;
+            vipModel.OnVipGiftEvent -= OnVipGiftEvent;
+        }
+
+        private void PlayerDataRefreshInfoEvent(PlayerDataRefresh refreshType)
+        {
+            if (refreshType == PlayerDataRefresh.ExAttr10)
+            {
+                DisplaySelect();
+            }
+            else if (refreshType == PlayerDataRefresh.LV)
+            {
+                DisplayState();
+            }
+        }
+
+        private void OnVipGiftEvent()
+        {
+            DisplayState();
+        }
+
+        public void Display(int id)
+        {
+            ChatBubbleModel.ChatBubble bubble;
+            if (model.TryGetBubble(id, out bubble))
+            {
+                bubbleId = id;
+                var config = Config.Instance.Get<ChatBubbleBoxConfig>(bubbleId);
+                m_BubbleName.text = config.Name;
+                m_Icon.SetSprite(config.Icon);
+                DisplayState();
+                DisplaySelect();
+            }
+        }
+
+        void DisplaySelect()
+        {
+            m_Using.gameObject.SetActive(PlayerDatas.Instance.baseData.bubbleId == bubbleId);
+        }
+
+        void DisplayState()
+        {
+            ChatBubbleModel.ChatBubble bubble;
+            if (model.TryGetBubble(bubbleId, out bubble))
+            {
+                var reason = 0;
+                var got = model.IsBubbleGot(bubbleId, out reason);
+                m_ContainerUnGet.gameObject.SetActive(reason != 0 && !got);
+                var config = Config.Instance.Get<ChatBubbleBoxConfig>(bubbleId);
+                if (!got)
+                {
+                    switch (reason)
+                    {
+                        case 1:
+                            m_Condition.text = Language.Get("", config.NeedLV);
+                            break;
+                        case 2:
+                            m_Condition.text = Language.Get("", config.NeedVIPLVGift);
+                            break;
+                        default:
+                            m_Condition.text = string.Empty;
+                            break;
+                    }
+                }
+            }
+        }
+
+        private void OnFunc()
+        {
+
+        }
+    }
+}
+
diff --git a/System/Chat/ChatBubbleSelectBehaviour.cs.meta b/System/Chat/ChatBubbleSelectBehaviour.cs.meta
new file mode 100644
index 0000000..978194f
--- /dev/null
+++ b/System/Chat/ChatBubbleSelectBehaviour.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: f81808b2bd0f09e41b846324c1fedcf6
+timeCreated: 1541387386
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/System/Chat/ChatExtentWin.cs b/System/Chat/ChatExtentWin.cs
index 0f50bb4..00e6d43 100644
--- a/System/Chat/ChatExtentWin.cs
+++ b/System/Chat/ChatExtentWin.cs
@@ -11,7 +11,8 @@
 using UnityEngine;
 using UnityEngine.UI;
 
-namespace Snxxz.UI {
+namespace Snxxz.UI
+{
 
     public class ChatExtentWin : Window
     {
@@ -23,13 +24,19 @@
         [SerializeField] ScrollerController m_BagControl;
         [SerializeField] RectTransform m_ContainerFace;
         [SerializeField] ScrollerController m_FaceControl;
+        [SerializeField] RectTransform m_ContainerChatBubble;
+        [SerializeField] ScrollerController m_ChatBubbleController;
 
-        [SerializeField] Button m_FaceBtn;
-        [SerializeField] Button m_QuickChatBtn;
-        [SerializeField] Button m_BagBtn;
+        [SerializeField] Button m_Face;
+        [SerializeField] Button m_QuickChat;
+        [SerializeField] Button m_Bag;
+        [SerializeField] Button m_ChatBubble;
         [SerializeField] Text m_FaceBtnTxt;
         [SerializeField] Text m_QuickChatBtnTxt;
         [SerializeField] Text m_BagBtnTxt;
+        [SerializeField] Text m_ChatBubbleBtnTxt;
+
+        [SerializeField] ChatBubbleCell m_ChatBubbleCell;
 
         ChatCenter m_ChatCenter;
         ChatCenter chatCenter
@@ -60,18 +67,20 @@
             for (int i = 0; i < m_QuickChatBtns.Count; i++)
             {
                 int _index = i;
-                m_QuickChatBtns[i].onClick.AddListener(()=> 
+                m_QuickChatBtns[i].onClick.AddListener(() =>
                 {
                     OnQuickChat(_index);
                 });
             }
 
-            m_FaceBtn.onClick.AddListener(OnFaceBtn);
-            m_BagBtn.onClick.AddListener(OnBagBtn);
-            m_QuickChatBtn.onClick.AddListener(OnQuickChat);
+            m_Face.onClick.AddListener(OnFaceBtn);
+            m_Bag.onClick.AddListener(OnBagBtn);
+            m_QuickChat.onClick.AddListener(OnQuickChat);
+            m_ChatBubble.onClick.AddListener(OnChatBubble);
 
             m_FaceControl.OnRefreshCell += OnRefreshFaceCell;
             m_BagControl.OnRefreshCell += OnRefreshBagCell;
+            m_ChatBubbleController.OnRefreshCell += OnRefreshBubbleCell;
         }
 
         private void OnRefreshBagCell(ScrollerDataType type, CellView cell)
@@ -202,6 +211,14 @@
             RecentlyChatChangeEvent();
         }
 
+        private void OnChatBubble()
+        {
+            presentSelect = 3;
+            UpdateButtonState();
+
+            RefreshChatBubble();
+        }
+
         private void OnQuickChat(int _index)
         {
             if (_index < chatCenter.recentlyChats.Count)
@@ -251,7 +268,7 @@
             }
         }
 
-        private bool GetCutOffValue(Text _text,string _value,int _line,out string _display)
+        private bool GetCutOffValue(Text _text, string _value, int _line, out string _display)
         {
             _display = string.Empty;
             if (_text.preferredWidth >= _text.rectTransform.rect.width * _line)
@@ -271,7 +288,7 @@
                         break;
                     }
                 }
-                _display= _value.Substring(0, Mathf.Max(0, _index - 5));
+                _display = _value.Substring(0, Mathf.Max(0, _index - 5));
                 return true;
             }
             return false;
@@ -322,19 +339,49 @@
             m_BagControl.Restart();
         }
 
+        private void RefreshChatBubble()
+        {
+            if (m_ChatBubbleController.GetNumberOfCells(m_ChatBubbleController.m_Scorller) == 0)
+            {
+                m_ChatBubbleController.Refresh();
+                var configs = Config.Instance.GetAllValues<ChatBubbleBoxConfig>();
+                var lineCount = m_ChatBubbleCell.lineCount == 0 ? 7 : m_ChatBubbleCell.lineCount;
+                var line = Mathf.CeilToInt((float)configs.Count / lineCount);
+                for (int i = 0; i < line; i++)
+                {
+                    m_ChatBubbleController.AddCell(ScrollerDataType.Header, i);
+                }
+                m_ChatBubbleController.Restart();
+            }
+            else
+            {
+                m_ChatBubbleController.JumpIndex(0);
+                m_ChatBubbleController.m_Scorller.RefreshActiveCellViews();
+            }
+        }
+
+        private void OnRefreshBubbleCell(ScrollerDataType type, CellView cell)
+        {
+            var chatBubbleCell = cell as ChatBubbleCell;
+            chatBubbleCell.Display(cell.index);
+        }
+
         void UpdateButtonState()
         {
             m_ContainerFace.gameObject.SetActive(presentSelect == 0);
             m_ContainerBag.gameObject.SetActive(presentSelect == 2);
             m_ContainerQuickChat.gameObject.SetActive(presentSelect == 1);
+            m_ContainerChatBubble.gameObject.SetActive(presentSelect == 3);
 
-            m_BagBtn.image.SetSprite(presentSelect == 2 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
-            m_FaceBtn.image.SetSprite(presentSelect == 0 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
-            m_QuickChatBtn.image.SetSprite(presentSelect == 1 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
+            m_Bag.image.SetSprite(presentSelect == 2 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
+            m_Face.image.SetSprite(presentSelect == 0 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
+            m_QuickChat.image.SetSprite(presentSelect == 1 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
+            m_ChatBubble.image.SetSprite(presentSelect == 3 ? "Chat_SelectBtn" : "Chat_UnSelectBtn");
 
             m_QuickChatBtnTxt.color = presentSelect == 1 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
             m_BagBtnTxt.color = presentSelect == 2 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
             m_FaceBtnTxt.color = presentSelect == 0 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
+            m_ChatBubbleBtnTxt.color = presentSelect == 3 ? UIHelper.s_LightYellow : UIHelper.GetUIColor(TextColType.NavyBrown);
         }
     }
 

--
Gitblit v1.8.0