Skip to content

API reference Obsidian.API.Client.Razor

ScreenContext class

A Razor screen as its components see it, the cascading value the client gives them: take it with [CascadingParameter] public ScreenContext Screen { get; set; }. It's the screen's panel, like a ModScreen's, the menu it shows, and its translations.

public sealed class ScreenContext

In Obsidian.API.Client.

Remarks

Components that take it render again each time the client redraws the screen, every client tick, so they show the menu's data as last sent. Set the panel's properties as the component initializes; the client lays the screen out again after its first render.

Properties

Background

public GuiImage Background { get; set; }

The panel's background, drawn at its size under the components; null for none.

Height

public int Height { get; set; }

The panel's height, in the GUI's pixels, like ModScreen.Height; 166 unless set.

Inventory

public GuiPosition? Inventory { get; set; }

For a menu's screen, where the first slot of the player's inventory goes, like ModMenuScreen.Inventory; null to place them with SlotGrids, or not show them.

InventoryLabel

public GuiPosition? InventoryLabel { get; set; }

For a menu's screen, where the "Inventory" label goes, like ModMenuScreen.InventoryLabel.

IsOpen

public bool IsOpen { get; }

Whether the screen is open.

public IScreenMenu Menu { get; }

The menu the screen shows, for a menu type's screen (see IClientRegistry.RegisterMenuScreen); null for a mod's own screen.

Title

public GuiPosition Title { get; set; }

For a menu's screen, where the menu's title goes, like ModMenuScreen.Title.

Width

public int Width { get; set; }

The panel's width, in the GUI's pixels, like ModScreen.Width; 176 unless set.

Methods

Close()

public void Close();

Closes the screen if it's open; a menu's screen closes its menu too.

TextWidth(string)

public int TextWidth(string text);

How wide text is drawn, in the GUI's pixels.

Translate(string, object[])

public string Translate(string key, params object[] arguments);

Translates a translation key with the client's language, from vanilla's and the mods' lang files; the key itself if it has no translation.

On this page