Пример #1
0
        public override void OnClickSendButton()
        {
            if (_inputChat.text == "")
            {
                return;
            }

            ChatDataItem chatDataItem = new ChatDataItem
            {
                sendUserId    = GlobalUser.GetInstance().UserId,
                receiveUserId = _groupItem.groupId,
                date          = System.DateTime.Now.Ticks,
                chatType      = ChatDataItem.ChatType.TEXT,
                chatBody      = _inputChat.text,
                targetType    = ChatDataItem.TargetType.GROUP,
            };

            GlobalChat.GetInstance().SendChatReq(chatDataItem);

            AddBubbleFrame(chatDataItem);

            UpdateChatBubbleGrid();

            _inputChat.text = "";
        }
        public void OnClickBeginChatButton()
        {
            StateManager.GetInstance().ClearStatesExceptBottom(true);
            ChatLog chatLog = GlobalChat.GetInstance().GetChatLog(_userItem.userId);

            StateManager.GetInstance().PushState <ChatPanel>(EUIType.ChatPanel, chatLog);
        }
Пример #3
0
        private void SetIsSend(Transform parent)
        {
            if (_chatDataItem.sendUserId != GlobalUser.GetInstance().UserId)
            {
                return;
            }

            GameObject buttonReSend = parent.Find("ReSendButton").gameObject;
            GameObject labelSending = parent.Find("SendingLabel").gameObject;

            buttonReSend.SetActive(false);
            labelSending.SetActive(false);
            if (!_chatDataItem.isSend)
            {
                if (GlobalChat.GetInstance().IsChatDataItemSending(_chatDataItem))
                {
                    labelSending.SetActive(true);
                }
                else
                {
                    buttonReSend.SetActive(true);
                    buttonReSend.GetComponent <Button>().onClick.AddListener(OnClickReSendButton);
                }
            }
        }
Пример #4
0
        public void OnClickEnterGroupChat()
        {
            ChatLog chatLog = GlobalChat.GetInstance().GetChatLog(_groupItem.groupId);

            StateManager.GetInstance().ClearStatesExceptBottom();
            StateManager.GetInstance().PushState <GroupChatPanel>(EUIType.GroupChatPanel, chatLog);
        }
Пример #5
0
        public override void OnShow(object param = null)
        {
            base.OnShow(param);
            _mainMenuNaviBar.GetCurPanel().Show();

            _imageUnReadChat.gameObject.SetActive(GlobalChat.GetInstance().IsAnyUnReadChat());
            MessageDispatcher.GetInstance().RegisterMessageHandler((uint)EUIMessage.UPDATE_CHAT_LIST, OnUpdateChatList);
            
        }
Пример #6
0
        public virtual void Show(ChatLog chatLog)
        {
            _chatLog = chatLog;

            // Set UserItem //

            UserItem userItem = GlobalContacts.GetInstance().GetUserItemById(chatLog.chatID);

            if (userItem != null && chatLog.targetType == ChatDataItem.TargetType.INDIVIDUAL)
            {
                if (_imageHead)
                {
                    UIManager.GetInstance().SetImage(_imageHead, EAtlasName.Head, "00" + userItem.headIndex);
                }

                if (_labelUserName)
                {
                    _labelUserName.text = userItem.userName;
                }
            }


            // Set ChatItem //
            if (_labelLastChat)
            {
                _labelLastChat.text = "";
                ChatDataItem lastChat = GlobalChat.GetInstance().GetLastChat(chatLog.chatID);
                if (lastChat != null)
                {
                    if (lastChat.chatType == ChatDataItem.ChatType.TEXT)
                    {
                        _labelLastChat.text = lastChat.chatBody;
                    }
                    else if (lastChat.chatType == ChatDataItem.ChatType.IMAGE)
                    {
                        _labelLastChat.text = "[表情]";
                    }
                }
            }

            if (_labelDate)
            {
                _labelDate.text = DateFormatTool.GetChatFrameTimeStr(_chatLog.date);
            }

            if (_imageUnRead)
            {
                int num = GlobalChat.GetInstance().GetUnReadNum(_chatLog.chatID);
                num = (num > 99) ? 99 : num;
                _imageUnRead.gameObject.SetActive(num != 0);
                _labelUnReadNum.text = num.ToString();
            }
        }
Пример #7
0
        public void OnChangeGroupRsp(uint iMessageType, object kParam)
        {
            NetworkMessageParam param = kParam as NetworkMessageParam;
            ChangeGroupReq      req   = param.req as ChangeGroupReq;
            ChangeGroupRsp      rsp   = param.rsp as ChangeGroupRsp;

            if (rsp.resultCode == ChangeGroupRsp.ResultCode.SUCCESS &&
                req.changeType == ChangeGroupReq.ChangeType.DELETE)
            {
                _groupDict.Remove(req.groupId);
                GlobalChat.GetInstance().RemoveChatLog(req.groupId);
                StateManager.GetInstance().ClearStatesExceptBottom(true);
            }
        }
Пример #8
0
        public void OnClearAll(string[] args)
        {
            PlayerPrefs.DeleteKey(GlobalVars.PREF_USER_ID);
            PlayerPrefs.DeleteKey(GlobalVars.PREF_USER_PASSWORD);

            GlobalChat.GetInstance().ClearLogDict();
            GlobalContacts.GetInstance().ClearFriendDict();
            GlobalGroup.GetInstance().ClearGroupDict();

            DirectoryInfo dirInfo = new DirectoryInfo(Application.persistentDataPath);

            foreach (var item in dirInfo.GetDirectories())
            {
                item.Delete(true);
            }
        }
Пример #9
0
        public override void OnClickSendEmotionButton(int index)
        {
            ChatDataItem chatDataItem = new ChatDataItem
            {
                sendUserId    = GlobalUser.GetInstance().UserId,
                receiveUserId = _groupItem.groupId,
                date          = System.DateTime.Now.Ticks,
                chatType      = ChatDataItem.ChatType.IMAGE,
                chatBody      = index.ToString(),
                targetType    = ChatDataItem.TargetType.GROUP,
            };

            GlobalChat.GetInstance().SendChatReq(chatDataItem);

            AddBubbleFrame(chatDataItem);

            UpdateChatBubbleGrid();
        }
Пример #10
0
        private void RefreshChatLog(bool refreshAll = false)
        {
            if (refreshAll)
            {
                foreach (ChatBubbleFrame chatBubble in _chatBubbleList)
                {
                    GameObject.Destroy(chatBubble.gameObject);
                }

                _chatBubbleList.Clear();
            }

            for (int i = _chatBubbleList.Count; i < _chatLog.itemList.Count; i++)
            {
                AddBubbleFrame(_chatLog.itemList[i]);
            }

            UpdateChatBubbleGrid();

            GlobalChat.GetInstance().MarkForRead(_chatLog.chatID);
        }
Пример #11
0
        public void RefreshChatFrames()
        {
            _chatGrid.GetComponent <RectTransform>().sizeDelta = new Vector2(GlobalVars.DEFAULT_SCREEN_WIDTH, CHAT_FRAME_HEIGHT * GlobalChat.GetInstance().Count);
            _scrollChatList.verticalNormalizedPosition         = 1.0f;

            int i = 0;

            GlobalChat.GetInstance().SortChatLog();
            foreach (ChatLog chatLog in GlobalChat.GetInstance())
            {
                if (GlobalChat.GetInstance().GetLastChat(chatLog.chatID) == null)
                {
                    continue;
                }

                if (i >= _chatFrameList.Count)
                {
                    GameObject go = AddChatFrame(chatLog);
                    _chatFrameList.Add(go.GetComponent <ChatFrame>());
                }
                else
                {
                    ResetChtFrame(i, chatLog);
                }

                _chatFrameList[i].Show(chatLog);
                i++;
            }

            if (_chatFrameList.Count > GlobalChat.GetInstance().Count)
            {
                for (i = GlobalChat.GetInstance().Count; i < _chatFrameList.Count; i++)
                {
                    GameObject.Destroy(_chatFrameList[i].gameObject);
                }
                _chatFrameList = _chatFrameList.GetRange(0, GlobalChat.GetInstance().Count);
            }
        }
Пример #12
0
 public void OnUpdateChatList(uint iMessageType, object kParam)
 {
     _imageUnReadChat.gameObject.SetActive(GlobalChat.GetInstance().IsAnyUnReadChat());
 }
Пример #13
0
        public void OnClickReSendButton()
        {
            GlobalChat.GetInstance().SendChatReq(_chatDataItem);

            Show(_chatDataItem);
        }
Пример #14
0
 public void OnConfirmDeleteChatLog()
 {
     GlobalChat.GetInstance().RemoveChatLog(_chatLog.chatID);
     Destroy(gameObject);
     Log4U.LogDebug("chat count", GlobalChat.GetInstance().Count);
 }