예제 #1
0
 public QueueData(ChatCode code, string msgFrom, string msgTo, object msg)
 {
     this.code    = code;
     this.msgFrom = msgFrom;
     this.msgTo   = msgTo;
     this.msg     = msg;
 }
        public bool UpdateChat()
        {
            ChatLogResult readResult = Reader.GetChatLog(_previousArrayIndex, _previousOffset);

            _previousArrayIndex = readResult.PreviousArrayIndex;
            _previousOffset     = readResult.PreviousOffset;
            if (readResult.ChatLogItems.Count > 0)
            {
                foreach (var item in readResult.ChatLogItems)
                {
                    ChatCode code = (ChatCode)int.Parse(item.Code, System.Globalization.NumberStyles.HexNumber);
                    //ProcessChatMsg(readResult.ChatLogItems[i]);
                    if ((int)code < 0x9F) // Skips battle log
                    {
                        if (code == ChatCode.GilReceive || code == ChatCode.Gather || code == ChatCode.FieldAttack || code == ChatCode.EmoteCustom)
                        {
                            continue;
                        }
                        ChatQueue.q.Add(item);
                    }
                }
                return(true);
            }
            return(false);
        }
예제 #3
0
        public PopupContentFactory AppendChatCode(ChatCode code)
        {
            StackPanel panel = new StackPanel();

            panel.Orientation = Orientation.Horizontal;

            TextBlock text = new TextBlock();

            text.Foreground = Brushes.Black;
            text.Inlines.Add(string.Format("Chat code: {0}", code.ToString()));
            text.VerticalAlignment = VerticalAlignment.Center;
            panel.Children.Add(text);

            Button copy = new Button();

            copy.Template = ResourceUtility.LoadControlTemplate("/ImageButtonTemplate.xaml");
            copy.Content  = COPY_ICON;
            copy.Width    = 18;
            copy.Height   = 18;
            copy.Margin   = new Thickness(2, 1, 0, 1);
            copy.Click   += (s, e) => Clipboard.SetText(code.ToString());
            copy.ToolTip  = "Copy to clipboard";

            panel.Children.Add(copy);

            Content.Children.Add(panel);

            return(this);
        }
예제 #4
0
        public void OnReceive(ClientPeer client, SocketMsg msg)
        {
            ChatCode code = (ChatCode)msg.SubCode;

            switch (code)
            {
            case ChatCode.Default:
                ChatRequest(client, msg);
                break;

            default:
                break;
            }
        }
예제 #5
0
    public override void OnResponse(string data)
    {
        string[] strs     = data.Split('-');
        ChatCode chatCode = (ChatCode)int.Parse(strs[0]);

        switch (chatCode)
        {
        case ChatCode.Player:
            chatPanel.PlayerChatOnMain(strs[1], strs[2]);
            break;

        case ChatCode.System:
            chatPanel.SystemChatOnMain(strs[1]);
            break;
        }
    }
예제 #6
0
        public PointOfInterestPushpin(PointOfInterest poi)
            : base()
        {
            if (IMAGES.ContainsKey(poi.TypeEnum))
            {
                Image = IMAGES[poi.TypeEnum];
            }

            if (!string.IsNullOrWhiteSpace(poi.Name))
            {
                ToolTip = poi.Name;

                PopupContent = new PopupContentFactory()
                               .AppendWikiLink(poi.Name)
                               .AppendChatCode(ChatCode.CreateMapLink((uint)poi.PoiId))
                               .Content;
            }
        }
예제 #7
0
        private void UpdateChatbox(object state)
        {
            if (ChatQueue.q.Any())
            {// Should q be locked?
                var chat = ChatQueue.q.Take();
                int.TryParse(chat.Code, System.Globalization.NumberStyles.HexNumber, null, out var intCode);
                ChatCode code = (ChatCode)intCode;
                if (code <= ChatCode.CWLinkShell8)
                {// For now, CWLinkShell8(0x6B) is upper bound of chat related code.
                    if (ironworksSettings.Chat.ChannelVisibility.TryGetValue(code, out bool show))
                    {
                        if (show)
                        {
                            string      line        = chat.Line;
                            ChatLogItem decodedChat = chat.Bytes.DecodeAutoTranslate();
                            Log.Debug("Chat: {@Chat}", decodedChat);

                            if (code == ChatCode.Recruitment || code == ChatCode.System || code == ChatCode.Error ||
                                code == ChatCode.Notice || code == ChatCode.Emote || code == ChatCode.MarketSold)
                            {
                                if (!ContainsNativeLanguage(decodedChat.Line))
                                {
                                    var translated = ironworksContext.TranslateChat(decodedChat.Line, ironworksSettings.Chat.ChannelLanguage[code]);

                                    Application.Current.Dispatcher.Invoke(() =>
                                    {
                                        TranslatedChatBox.Text +=
#if DEBUG
                                            $"[{decodedChat.Code}]{translated}{Environment.NewLine}";
#else
                                            $"{translated}{Environment.NewLine}";
#endif
                                    });
                                }
                            }
                            else
                            {
                                var author   = decodedChat.Line.RemoveAfter(":");
                                var sentence = decodedChat.Line.RemoveBefore(":");
                                if (!ContainsNativeLanguage(decodedChat.Line))
                                {
                                    var translated = ironworksContext.TranslateChat(sentence, ironworksSettings.Chat.ChannelLanguage[code]);

                                    Application.Current.Dispatcher.Invoke(() =>
                                    {
                                        TranslatedChatBox.Text +=
#if DEBUG
                                            $"[{decodedChat.Code}]{author}:{translated}{Environment.NewLine}";
#else
                                            $"{author}:{translated}{Environment.NewLine}";
#endif
                                    });
                                }
                            }
                        }
                    }
                    else
                    {
                        Log.Information("Unexpected {@Code} when translating {@Message}", intCode, chat.Line);
                        //Application.Current.Dispatcher.Invoke(() =>
                        //{
                        //    TranslatedChatBox.Text +=
                        //$"[모르는 채널-제보요망][{chat.Code}]{chat.Line}{Environment.NewLine}";
                        //});
                    }
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        TranslatedChatBox.Text +=
#if DEBUG
                            $"[???][{chat.Code}]{chat.Line}{Environment.NewLine}";
#else
                            $"[???]{chat.Line}{Environment.NewLine}";
#endif
                    });
                }
                Application.Current.Dispatcher.Invoke(() =>
                {
                    TranslatedChatBox.ScrollToEnd();
                    //TranslatedChatBox.ScrollToVerticalOffset(double.MaxValue);
                });
            }
        }
예제 #8
0
 public Channel(ChatCode code)
 {
     Code          = code;
     Show          = true;
     MajorLanguage = ClientLanguage.Japanese;
 }
예제 #9
0
 public QueueData(ChatCode code, object msg)
 {
     this.code = code;
     this.msg  = msg;
 }
예제 #10
0
 public QueueData(ChatCode code, string msgFrom)
 {
     this.code    = code;
     this.msgFrom = msgFrom;
 }
예제 #11
0
 public QueueData(object serverMsg)
 {
     this.code = ChatCode.Sys;
     this.msg  = serverMsg;
 }