Skip to content

FormatAttribute

namespace Griff.Scenes;
public sealed class FormatAttribute : FieldEditorAttribute

Marks a string property as text with holes the game fills in as it shows it, e.g. a counter’s “Score: {0}” or a save slot’s “{date} {time}”: the Inspector has a button for each hole, says what each is, and shows how it reads now. A hole can carry a number format after a colon (“{0:000}”). A hole it doesn’t have is flagged.

public IReadOnlyList<ValueTuple<string, string>> Holes { get; }

The holes, each with what it is: (“{0}”, “the count”).

public string? Preview { get; init; }

A method of the component taking the text (a string, or null) and giving how it reads with what the component holds now, e.g. a counter’s “Score: 12”; null when there’s none.

public bool Replaced { get; init; }

The holes are put in by replacing them (a choice’s {0}), rather than as a .NET format string, so a brace on its own is fine.

public override string Describe()
public override string? Problem(Component component, object? value)
public string? ReadsAs(Component component, string? format)

How component’s text reads with format as its value now; null when it can’t say.