Esempio n. 1
0
    private ChatInfo ToSystemChatInfo(uint OPDesThisid, string speakText, string speakName, uint job, string voicefileid = "", uint voiceLength = 0, uint timestamp = 0)
    {
        speakText = speakText.Trim();
        TimeSpan ts = System.DateTime.Now - new System.DateTime(1970, 1, 1, 0, 0, 0);

        timestamp = (uint)System.Convert.ToInt32(ts.TotalSeconds);
        var title = string.Format(
            "<color value=\"{0}\">{1} </color>",
            string.Format("#{0:X8}", (uint)ConstDefine.GetChatColor(CHATTYPE.CHAT_NINE)),
            Head);
        var      richText = "";// FormatAddCharHead(Head, speakName, speakText);
        var      chat     = speakText;
        ChatInfo info     = new ChatInfo()
        {
            IsMe        = Client.ClientGlobal.Instance().IsMainPlayer(OPDesThisid),
            Id          = OPDesThisid,
            Title       = title,
            Content     = FormatContent(chat),
            RichText    = richText,
            Channel     = ChannelType,
            Name        = speakName,
            job         = (int)job,
            voiceFileid = voicefileid,
            voiceLegth  = voiceLength,
            Timestamp   = timestamp != 0 ? timestamp : UserData.ServerTime.ToUnixTime(),
        };

        return(info);
    }
Esempio n. 2
0
    public string FormatCharTitle(string channelHead, string name, string time, string srcText, uint uid = 0)
    {
        try
        {
            //          if (srcText.FirstOrDefault() == '<')
            //          {
            //              return RichXmlHelper.RemoveP(RichXmlHelper.RichXmlAdapt(srcText));
            //          }
            // 普通文本转换成富文本
            var color       = string.Format("#{0:X8}", (uint)ConstDefine.GetChatColor(ChannelType));
            var yellow      = GXColor.Yellow;
            var colorYellow = string.Format("#{0:X8}", (uint)yellow);
            var gray        = GXColor.Gray;
            var colorGray   = string.Format("#{0:X8}", (uint)gray);

            string text = "";

            if (ChannelType == CHATTYPE.CHAT_SYS)
            {
                text = RichXmlHelper.RichXmlAdapt(string.Format(
                                                      "<color value=\"{0}\">{1} </color>",
                                                      string.Format("#{0:X8}", (uint)ConstDefine.GetChatColor(CHATTYPE.CHAT_NINE)),
                                                      channelHead,
                                                      new XText(srcText).ToString())); // xml escape
            }
            else
            {
                text = RichXmlHelper.RichXmlAdapt(string.Format(
                                                      //"<color value=\"{0}\">{1}</color>{2}",
                                                      "{0} {1}",
                                                      //color,
                                                      channelHead,
                                                      ChatDataManager.GetPlayerHrefString(name, uid, Cmd.GXColor.Yellow),
                                                      new XText(srcText).ToString())); // xml escape
            }

            //Debug.Log(text);
            return(text);
        }
        catch (Exception e)
        {
            Debug.LogError(string.Format("e.Message:{0},e.StackTrace:{1}", e.Message, e.StackTrace));
        }
        return(String.Empty);
    }
Esempio n. 3
0
    public string FormatPrivateAddCharHead(string channelHead, string extentedString, string srcText, string voicefileid = "")
    {
        //  Log.LogGroup("ZDY", "enter :FormatPrivateAddCharHead");
        if (srcText.FirstOrDefault() == '<')
        {
            return(RichXmlHelper.RemoveP(RichXmlHelper.RichXmlAdapt(srcText)));
        }

        //Log.LogGroup("ZDY", "普通文本转换成富文本:" + srcText + " " + srcText.Length);
        // 普通文本转换成富文本
        var color = string.Format("#{0:X8}", (uint)ConstDefine.GetChatColor(GameCmd.CHATTYPE.CHAT_PRIVATE));

        string xtext = new XText(srcText).ToString();

        return(RichXmlHelper.RichXmlAdapt(string.Format("<color value=\"{0}\">{1}{2}:{3}</color>",
                                                        color,
                                                        channelHead,
                                                        extentedString,
                                                        xtext))); // xml escape
    }
Esempio n. 4
0
    public string FormatAddCharHead(string channelHead, string extentedString, string srcText)
    {
        if (srcText.FirstOrDefault() == '<')
        {
            return(RichXmlHelper.RemoveP(RichXmlHelper.RichXmlAdapt(srcText)));
        }
        // 普通文本转换成富文本
        var color = string.Format("#{0:X8}", (uint)ConstDefine.GetChatColor(ChannelType));

        // Debug.Log("FormatAddCharHead:" + srcText + " " + srcText.Length);

        string xtext = new XText(srcText).ToString();

        //Debug.Log("FormatAddCharHeadxtext:" + xtext);

        return(RichXmlHelper.RichXmlAdapt(string.Format("<color value=\"{0}\">{1}{2}:{3}</color>",
                                                        color,
                                                        channelHead,
                                                        extentedString,
                                                        xtext))); // xml escape
    }