Scripting API

Scripting API

UiSettings

Class in Abyss.Core, from Abyss.Core.

A game's interface as a whole: settings/ui.json beside the game's assets, which Project Settings' UI page lays out — the theme every document is styled by, and the screen its documents are laid out for.

public sealed class UiSettings

Remarks

The theme is a stylesheet (StyleSheetFiles) beneath each document's own: colors and fonts said once for the whole game, which a document's sheets say otherwise where they say as much. Named by its path and its identity, so it is found where it has moved.

The reference resolution is the screen a document is laid out for, scaled from there to the one it is drawn on: matching its width at UiSettings.MatchHeight zero, its height at one. A game's code can say otherwise as it plays (World.SetUiReference).

A game with no ui.json has no theme and is laid out for 1920 by 1080, matching the height.

Properties

Theme

public string? Theme { get; set; }

The theme's path under the asset root; null for none.

ThemeId

public AssetGuid ThemeId { get; set; }

The theme's identity, which finds it where it has moved; AssetGuid.None where it is not known.

ReferenceWidth

public float ReferenceWidth { get; set; }

How wide a screen the interface is laid out for, in pixels.

ReferenceHeight

public float ReferenceHeight { get; set; }

How high a screen the interface is laid out for, in pixels.

MatchHeight

public float MatchHeight { get; set; }

How far towards matching the height it is scaled: zero matches the width, one the height.

Scaled

public bool Scaled { get; set; }

Whether it is scaled with the screen at all; off, it is drawn at the window's own scale.

Methods

FileIn

public static string FileIn(string game)

Where a game keeps it: settings/ui.json in its folder.

Parameters

  • game

Read

public static UiSettings Read(string game)

A game's settings; the defaults for one with no ui.json.

Parameters

  • game

Exceptions

  • FormatException: The file is not settings this build reads, saying why.
  • IOException: The file is there and cannot be read.

Parse

public static UiSettings Parse(string json)

Settings from their text.

Parameters

  • json

Exceptions

  • FormatException: It is not settings this build reads, saying why.

ThemeJson

public string ThemeJson()

The theme as the engine is told it: {"css":"ui/theme.css","guid":"..."}, or null for none.

ToJson

public string ToJson()

The settings as their file holds them.

Write

public void Write(string game)

Writes the settings into a game's folder.

Parameters

  • game

Copy

public UiSettings Copy()

A copy, to change without changing this.

Constants

FileName

public const string FileName = "ui.json"

The file, under the game's settings folder.

PathName

public const string PathName = "settings/ui.json"

What it is called in a game's folder and in its pack: settings/ui.json.

CurrentVersion

public const int CurrentVersion = 1

The version of the file this build writes, and the newest it reads.