Table of Contents

Class FormattingUtility

Namespace
Uncreated.Warfare.Util
Assembly
Uncreated.Warfare.dll
public static class FormattingUtility
Inheritance
FormattingUtility
Inherited Members

Properties

TimeRegex

public static Regex TimeRegex { get; }

Property Value

Regex

Methods

ParseTimespan(string)

Parses a timespan string in the form '3d 4hr 21min etc'. Can also be 'perm[anent]'.

public static TimeSpan ParseTimespan(string input)

Parameters

input string

Returns

TimeSpan

Total amount of time. InfiniteTimeSpan is returned if input is permanent.

RemoveRichText(string, int, int, RemoveRichTextOptions)

Remove rich text, including TextMeshPro and normal Unity tags.

[Pure]
public static string RemoveRichText(string str, int index = 0, int length = -1, RemoveRichTextOptions options = RemoveRichTextOptions.All)

Parameters

str string
index int
length int
options RemoveRichTextOptions

Tags to check for and remove.

Returns

string

Exceptions

ArgumentOutOfRangeException

ReplaceNewLineSubstrings(string?)

Replaces newline constants like '/n', '\n', '<br>', etc with the actual newline character.

public static string? ReplaceNewLineSubstrings(string? str)

Parameters

str string

Returns

string

ToArgb(Color)

Convert a UnityEngine.Color to ARGB data.

public static int ToArgb(Color color)

Parameters

color Color

Returns

int

ToArgb(Color32)

Convert a UnityEngine.Color32 to ARGB data.

public static int ToArgb(Color32 color)

Parameters

color Color32

Returns

int

ToCountdownString(int, bool)

Format a minute/second timer.

public static string ToCountdownString(int seconds, bool withHours)

Parameters

seconds int
withHours bool

Returns

string

Remarks

[HH:]MM:SS

ToCountdownString(TimeSpan, bool)

Format a minute/second timer.

public static string ToCountdownString(TimeSpan span, bool withHours)

Parameters

span TimeSpan
withHours bool

Returns

string

Remarks

[HH:]MM:SS

ToTimeString(TimeSpan, int, bool)

Converts a timespan to a string in the form '3d 4hr 21min etc'. Will be 'perm[anent]' if timeSpan is InfiniteTimeSpan (or any negative TimeSpan).

public static string ToTimeString(TimeSpan timeSpan, int figures = -1, bool space = false)

Parameters

timeSpan TimeSpan
figures int
space bool

Returns

string

TryParseAny(string, IFormatProvider, Type, out object?)

Parse any common type.

public static bool TryParseAny(string input, IFormatProvider provider, Type type, out object? value)

Parameters

input string
provider IFormatProvider
type Type
value object

Returns

bool