Exemple #1
0
        public static string ToTerraria(string text)
        {
            string str = text;
            Dictionary <ElementType, Func <object, Formatter.Tag> > elementTypes = new Dictionary <ElementType, Func <object, Formatter.Tag> >();

            elementTypes[ElementType.Color] = (object c) => new Formatter.Tag(string.Concat("[c/", Formatter.RGBAtoRGB(c), ":"), "]");
            return(Formatter.ToTreeFormat(str, elementTypes));
        }
Exemple #2
0
        public static string ToUnity(string text)
        {
            string str = text;
            Dictionary <ElementType, Func <object, Formatter.Tag> > elementTypes = new Dictionary <ElementType, Func <object, Formatter.Tag> >();

            elementTypes[ElementType.Bold]   = (object _) => new Formatter.Tag("<b>", "</b>");
            elementTypes[ElementType.Italic] = (object _) => new Formatter.Tag("<i>", "</i>");
            elementTypes[ElementType.Color]  = (object c) => new Formatter.Tag(string.Format("<color=#{0}>", c), "</color>");
            elementTypes[ElementType.Size]   = (object s) => new Formatter.Tag(string.Format("<size={0}>", s), "</size>");
            return(Formatter.ToTreeFormat(str, elementTypes));
        }
Exemple #3
0
        private static string ToTreeFormat(List <Element> tree, Dictionary <ElementType, Func <object, Formatter.Tag> > translations)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (Element element in tree)
            {
                if (element.Type != ElementType.String)
                {
                    Formatter.Tag tag = Formatter.Translation(element, translations);
                    stringBuilder.Append(tag.Open);
                    stringBuilder.Append(Formatter.ToTreeFormat(element.Body, translations));
                    stringBuilder.Append(tag.Close);
                }
                else
                {
                    stringBuilder.Append(element.Val);
                }
            }
            return(stringBuilder.ToString());
        }
Exemple #4
0
 private static string ToTreeFormat(string text, Dictionary <ElementType, Func <object, Formatter.Tag> > translations)
 {
     return(Formatter.ToTreeFormat(Formatter.Parse(text), translations));
 }
Exemple #5
0
 public static string ToPlaintext(string text)
 {
     return(Formatter.ToTreeFormat(text, new Dictionary <ElementType, Func <object, Formatter.Tag> >()));
 }