Пример #1
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);
    }