Scripting API

Scripting API

UiDocumentFiles

Class in Abyss.Core, from Abyss.Core.

A UI document's file: .ui, in the format scenes and prefabs are written in, its elements the entities in it and their components Bevy's own UI's — Node, Text, Button — and, beside them, the name of the class the build makes of it.

public static class UiDocumentFiles

Remarks

A document is shown by a UI Document component; see GameUi. Its class's name is kept in the file rather than worked out from the file's name, so code written against it keeps working as the file is renamed; a file renamed while its class is still the one its old name gave takes its new name's (UiDocumentFiles.ClassOnRename).

Methods

Is

public static bool Is(string path)

Whether a path names a UI document, by its extension.

Parameters

  • path

ClassFor

public static string ClassFor(string path)

The class a document at path is named for: its file's name made an identifier word by word and starting in capitals — main menu.ui is MainMenu.

Parameters

  • path

ClassOnRename

public static string ClassOnRename(string from, string to, string? current)

The class a document renamed from from to to is named for: its new name's, where it still has the one its old name gave it, and otherwise its own, which somebody chose.

Parameters

  • from: Its path before.
  • to: Its path after.
  • current: The class it names now.

New

public static string New(string path)

What a new document at path says: a screen-filling column, its title and a Play button in the middle of it, its class named for the file, and its look its own.

Parameters

  • path

New

public static string New(string path, string? sheet)

What a new document at path says, styled by the sheet at sheet: its elements and their layout the same as UiDocumentFiles.New's, each given a class — screen, title, button, button-label — and their look in the sheet StyleSheetFiles.Starter writes, which the document names.

Parameters

  • path: Where the document is under the asset root.
  • sheet: Where its sheet is under the asset root; null for a document whose look is its own.

ClassIn

public static string? ClassIn(string text)

The class text, a document, names; null where it names none, or is no document.

Parameters

  • text

WithClass

public static string? WithClass(string text, string name)

text, a document, with its class named name: null where it is named so already, or is no document.

Parameters

  • text
  • name

SheetsIn

public static IReadOnlyList<UiSheetReference> SheetsIn(string text)

The stylesheets text, a document, is styled by, in order, as its top element names them: each by its path under the asset root and its identity, where it was known. None for a document that names none, or is no document.

Parameters

  • text

WithSheets

public static string? WithSheets(string text, IReadOnlyList<UiSheetReference> sheets)

text, a document, styled by sheets in that order, as its top element names them; by none, the list is null. Null where it is so already, or is no document.

Parameters

  • text
  • sheets

ElementsIn

public static IReadOnlyList<UiElementClasses> ElementsIn(string text)

Each element of text, a document, in its order: its name, how deep it is under the top, and its classes, apart by spaces. None for no document.

Parameters

  • text

WithClasses

public static string? WithClasses(string text, int index, string classes)

text, a document, its element at index given the classes classes, apart by spaces; none, it holds no classes at all. Null where it has them already, or is no such element.

Parameters

  • text
  • index
  • classes
public static IReadOnlyList<UiElementNavigation> NavigationIn(string text)

The elements of text, a document, that can have focus — its buttons, toggles, sliders and text fields — in its order: each with whether it is ticked to have focus first and, for each direction, the name of the element that direction goes to from it, empty where the guess from where elements are drawn decides.

Parameters

  • text

WithFocusFirst

public static string? WithFocusFirst(string text, int index, bool first)

text, a document, its element at index ticked to have focus first, every other let go of, as a document has one first element; or, where first is false, not ticked. Null where nothing changes, or is no such element.

Parameters

  • text
  • index
  • first

WithDirection

public static string? WithDirection(string text, int index, UiDirection direction, string to)

text, a document, direction from its element at index going to the element named to; empty, to where the guess from where elements are drawn takes it. Null where it goes there already, or is no such element.

Parameters

  • text
  • index
  • direction
  • to

CodeOf

public static UiDocumentCode CodeOf(SceneDocument document, string path)

What the build writes of document's class, the document at path: its name, each named element's member in the document's order, and the handlers the game's half can implement — each control's, then OnShown(), OnHidden() and OnCancel() — as the source generator writes them, by the same rules.

Parameters

  • document
  • path

IsClassName

public static bool IsClassName(string name)

Whether name can name a document's class: an identifier as written, and no keyword.

Parameters

  • name

Constants

Extension

public const string Extension = ".ui"

The extension a UI document has.