Table of Contents

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

stringBuilder StringBuilder
text ReadOnlySpan<char>
hexColor string
imgui bool

Use Unity rich text instead of TMPro.

end bool

Returns

StringBuilder

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

stringBuilder StringBuilder
text ReadOnlySpan<char>
color Color32
imgui bool

Use Unity rich text instead of TMPro.

end bool

Returns

StringBuilder

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

text ReadOnlySpan<char>
hexColor string
imgui bool

Use Unity rich text instead of TMPro.

Returns

string

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

text ReadOnlySpan<char>
color Color32
imgui bool

Use Unity rich text instead of TMPro.

Returns

string

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

text ReadOnlySpan<char>
color Color32
options TranslationOptions
terminalColoring StackColorFormatType

Returns

string

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

text string
hexColor string
imgui bool

Use Unity rich text instead of TMPro.

Returns

string

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

text string
color Color32
imgui bool

Use Unity rich text instead of TMPro.

Returns

string

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

text string
color Color32
options TranslationOptions
terminalColoring StackColorFormatType

Returns

string

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

original ReadOnlySpan<char>

Returns

string

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

text ReadOnlySpan<char>
innerStartIndex int
innerLength int

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

format ReadOnlySpan<char>
strings ReadOnlySpan<char>
indices ReadOnlySpan<int>

The first index is assumed to be zero, this is a list of all the following indices.

Returns

string