StartsWith() public méthode

public StartsWith ( StringPart s ) : bool
s StringPart
Résultat bool
Exemple #1
0
        private static TagType ParseTag(StringPart text, ref Vector2 position, ref int lineSpacing, ref int lineIndex)
        {
            var type = TagType.None;

            if (text.Equals("\n"))
            {
                NewLine(ref position, ref lineSpacing, ref lineIndex);
                type = TagType.NewLine;
            }
            else if (text.StartsWith("f:") && fonts != null)
            {
                var        fontName = text.Substring(2);
                SpriteFont font;
                if (fonts.TryParse(fontName, out font))
                {
                    PushFont(font);
                    type = TagType.FontStart;
                }
            }
            else if (text.Equals("/f"))
            {
                PopFont();
                type = TagType.FontEnd;
            }
            else if (text.StartsWith("c:"))
            {
                var   colourName = text.Substring(2);
                Color colour;
                if (ColourParser.TryParse(colourName, out colour))
                {
                    PushColour(colour);
                    type = TagType.ColourStart;
                }
            }
            else if (text.Equals("/c"))
            {
                PopColour();
                type = TagType.ColourEnd;
            }

            return(type);
        }
Exemple #2
0
        private static void RecordFontChanges(StringBuilder input)
        {
            fontChanges.Clear();

            int tagStart = 0;
            int tagEnd   = 0;

            while ((tagStart = IndexOf(input, "[", tagEnd)) != -1 &&
                   (tagEnd = IndexOf(input, "]", tagStart)) != -1)
            {
                var tag = new StringPart(input, tagStart + 1, tagEnd - tagStart - 1);

                var fontChanged = false;
                if (tag.StartsWith("f:") && fonts != null)
                {
                    var        fontName = tag.Substring(2);
                    SpriteFont font;
                    if (fonts.TryParse(fontName, out font))
                    {
                        PushFont(font);
                        fontChanged = true;
                    }
                }
                else if (tag.Equals("/f"))
                {
                    PopFont();
                    fontChanged = true;
                }

                if (fontChanged)
                {
                    fontChanges.Add(new FontChange()
                    {
                        Font = CurrentFont(), Index = tagStart
                    });
                }
            }
        }
Exemple #3
0
        private static void RecordFontChanges(StringBuilder input)
        {
            fontChanges.Clear();

            int tagStart = 0;
            int tagEnd = 0;
            while ((tagStart = IndexOf(input, "[", tagEnd)) != -1
                && (tagEnd = IndexOf(input, "]", tagStart)) != -1)
            {
                var tag = new StringPart(input, tagStart + 1, tagEnd - tagStart - 1);

                var fontChanged = false;
                if (tag.StartsWith("f:") && fonts != null)
                {
                    var fontName = tag.Substring(2);
                    SpriteFont font;
                    if (fonts.TryParse(fontName, out font))
                    {
                        PushFont(font);
                        fontChanged = true;
                    }
                }
                else if (tag.Equals("/f"))
                {
                    PopFont();
                    fontChanged = true;
                }

                if (fontChanged)
                    fontChanges.Add(new FontChange() { Font = CurrentFont(), Index = tagStart });
            }
        }
Exemple #4
0
        private static TagType ParseTag(StringPart text, ref Vector2 position, ref int lineSpacing, ref int lineIndex)
        {
            var type = TagType.None;

            if (text.Equals("\n"))
            {
                NewLine(ref position, ref lineSpacing, ref lineIndex);
                type = TagType.NewLine;
            }
            else if (text.StartsWith("f:") && fonts != null)
            {
                var fontName = text.Substring(2);
                SpriteFont font;
                if (fonts.TryParse(fontName, out font))
                {
                    PushFont(font);
                    type = TagType.FontStart;
                }
            }
            else if (text.Equals("/f"))
            {
                PopFont();
                type = TagType.FontEnd;
            }
            else if (text.StartsWith("c:"))
            {
                var colourName = text.Substring(2);
                Color colour;
                if (ColourParser.TryParse(colourName, out colour))
                {
                    PushColour(colour);
                    type = TagType.ColourStart;
                }
            }
            else if (text.Equals("/c"))
            {
                PopColour();
                type = TagType.ColourEnd;
            }

            return type;
        }