Class TranslationFormattingUtility
- Namespace
- Uncreated.Warfare.Translations.Util
- Assembly
- Uncreated.Warfare.dll
public static class TranslationFormattingUtility
- Inheritance
-
TranslationFormattingUtility
- Inherited Members
Methods
AppendColorized(StringBuilder, ReadOnlySpan<char>, string, bool, bool)
Adds the correct color tags around text for TMPro or Unity rich text and appends it to a StringBuilder.
public static StringBuilder AppendColorized(this StringBuilder stringBuilder, ReadOnlySpan<char> text, string hexColor, bool imgui = false, bool end = true)
Parameters
stringBuilderStringBuildertextReadOnlySpan<char>hexColorstringimguiboolUse Unity rich text instead of TMPro.
endbool
Returns
AppendColorized(StringBuilder, ReadOnlySpan<char>, Color32, bool, bool)
Adds the correct color tags around text for TMPro or Unity rich text and appends it to a StringBuilder.
public static StringBuilder AppendColorized(this StringBuilder stringBuilder, ReadOnlySpan<char> text, Color32 color, bool imgui = false, bool end = true)
Parameters
stringBuilderStringBuildertextReadOnlySpan<char>colorColor32imguiboolUse Unity rich text instead of TMPro.
endbool
Returns
Colorize(ReadOnlySpan<char>, string, bool)
Adds the correct color tags around text for TMPro or Unity rich text.
public static string Colorize(ReadOnlySpan<char> text, string hexColor, bool imgui = false)
Parameters
textReadOnlySpan<char>hexColorstringimguiboolUse Unity rich text instead of TMPro.
Returns
Colorize(ReadOnlySpan<char>, Color32, bool)
Adds the correct color tags around text for TMPro or Unity rich text.
public static string Colorize(ReadOnlySpan<char> text, Color32 color, bool imgui = false)
Parameters
textReadOnlySpan<char>colorColor32imguiboolUse Unity rich text instead of TMPro.
Returns
Colorize(ReadOnlySpan<char>, Color32, TranslationOptions, StackColorFormatType)
Adds the correct color tags around text based on which flags are enabled in options.
public static string Colorize(ReadOnlySpan<char> text, Color32 color, TranslationOptions options, StackColorFormatType terminalColoring)
Parameters
textReadOnlySpan<char>colorColor32optionsTranslationOptionsterminalColoringStackColorFormatType
Returns
Colorize(string, string, bool)
Adds the correct color tags around text for TMPro or Unity rich text.
public static string Colorize(string text, string hexColor, bool imgui = false)
Parameters
Returns
Colorize(string, Color32, bool)
Adds the correct color tags around text for TMPro or Unity rich text.
public static string Colorize(string text, Color32 color, bool imgui = false)
Parameters
Returns
Colorize(string, Color32, TranslationOptions, StackColorFormatType)
Adds the correct color tags around text based on which flags are enabled in options.
public static string Colorize(string text, Color32 color, TranslationOptions options, StackColorFormatType terminalColoring)
Parameters
textstringcolorColor32optionsTranslationOptionsterminalColoringStackColorFormatType
Returns
CreateIMGUIString(ReadOnlySpan<char>)
Converts a translation that was written with TMPro tags for convenience to IMGUI (Unity) rich text.
public static string CreateIMGUIString(ReadOnlySpan<char> original)
Parameters
originalReadOnlySpan<char>
Returns
ExtractColor(ReadOnlySpan<char>, out int, out int)
Isolates the color tag that surrounds the entire message, if any. Also returns span arguments to be able to reconstruct that.
public static Color32? ExtractColor(ReadOnlySpan<char> text, out int innerStartIndex, out int innerLength)
Parameters
textReadOnlySpan<char>innerStartIndexintinnerLengthint
Returns
- Color32?
FormatString(ReadOnlySpan<char>, ReadOnlySpan<char>, ReadOnlySpan<int>)
Less error-prone Format(string, params object[]) using spans. Only works with strings and doesn't take the format into account.
public static string FormatString(ReadOnlySpan<char> format, ReadOnlySpan<char> strings, ReadOnlySpan<int> indices)
Parameters
formatReadOnlySpan<char>stringsReadOnlySpan<char>indicesReadOnlySpan<int>The first index is assumed to be zero, this is a list of all the following indices.