protected override IEnumerable <Drawable> CreateDrawablesFor(string text, TextFlowContainer textFlowContainer) { var customizableContainer = (CustomizableTextContainer)textFlowContainer; var sprites = new List <Drawable>(); int index = 0; string str = text; while (index < str.Length) { Drawable?placeholderDrawable = null; int nextPlaceholderIndex = str.IndexOf(CustomizableTextContainer.UNESCAPED_LEFT, index, StringComparison.Ordinal); // make sure we skip ahead to the next [ as long as the current [ is escaped while (nextPlaceholderIndex != -1 && str.IndexOf(CustomizableTextContainer.ESCAPED_LEFT, nextPlaceholderIndex, StringComparison.Ordinal) == nextPlaceholderIndex) { nextPlaceholderIndex = str.IndexOf(CustomizableTextContainer.UNESCAPED_LEFT, nextPlaceholderIndex + 2, StringComparison.Ordinal); } string?strPiece = null; if (nextPlaceholderIndex != -1) { int placeholderEnd = str.IndexOf(CustomizableTextContainer.UNESCAPED_RIGHT, nextPlaceholderIndex, StringComparison.Ordinal); // make sure we skip ahead to the next ] as long as the current ] is escaped while (placeholderEnd != -1 && str.IndexOf(CustomizableTextContainer.ESCAPED_RIGHT, placeholderEnd, StringComparison.InvariantCulture) == placeholderEnd) { placeholderEnd = str.IndexOf(CustomizableTextContainer.UNESCAPED_RIGHT, placeholderEnd + 2, StringComparison.Ordinal); } if (placeholderEnd != -1) { strPiece = str[index..nextPlaceholderIndex];
protected virtual IEnumerable <Drawable> CreateDrawablesFor(string text, TextFlowContainer textFlowContainer) { bool first = true; var sprites = new List <Drawable>(); foreach (string l in text.Split('\n')) { if (!first) { Drawable?lastChild = sprites.LastOrDefault() ?? textFlowContainer.Children.LastOrDefault(); if (lastChild != null) { var newLine = new TextFlowContainer.NewLineContainer(newLineIsParagraph); sprites.Add(newLine); } } foreach (string word in SplitWords(l)) { if (string.IsNullOrEmpty(word)) { continue; } var textSprite = CreateSpriteText(textFlowContainer); textSprite.Text = word; sprites.Add(textSprite); } first = false; } return(sprites); }
protected virtual TSpriteText CreateSpriteText(TextFlowContainer textFlowContainer) { var spriteText = creationFunc.Invoke(); textFlowContainer.ApplyDefaultCreationParamters(spriteText); creationParameters?.Invoke(spriteText); return(spriteText); }
protected override IEnumerable <Drawable> CreateDrawablesFor(TextFlowContainer textFlowContainer) { string currentContent = textFlowContainer.Localisation?.GetLocalisedString(text) ?? text.ToString(); var drawables = new List <Drawable>(); // !newLineIsParagraph effectively means that we want to add just *one* paragraph, which means we need to make sure that any previous paragraphs // are terminated. Thus, we add a NewLineContainer that indicates the end of the paragraph before adding our current paragraph. if (!newLineIsParagraph) { var newLine = new TextNewLine(true); newLine.RecreateDrawablesFor(textFlowContainer); drawables.AddRange(newLine.Drawables); } drawables.AddRange(CreateDrawablesFor(currentContent, textFlowContainer)); return(drawables); }
public void RecreateDrawablesFor(TextFlowContainer textFlowContainer) { }
protected override IEnumerable <Drawable> CreateDrawablesFor(TextFlowContainer textFlowContainer) { var newLineContainer = new TextFlowContainer.NewLineContainer(indicatesNewParagraph); return(newLineContainer.Yield()); }
protected abstract IEnumerable <Drawable> CreateDrawablesFor(TextFlowContainer textFlowContainer);
public void RecreateDrawablesFor(TextFlowContainer textFlowContainer) { drawables.Clear(); drawables.AddRange(CreateDrawablesFor(textFlowContainer)); DrawablePartsRecreated?.Invoke(drawables); }