API reference Obsidian.API.Client.Screens
ModScreen class
A mod's screen, built in code from widgets like a NeoForge mod's Screen: a panel of ModScreen.Width by ModScreen.Height pixels centred on the darkened game, with an optional ModScreen.Background and the widgets the mod adds in ModScreen.Init. Open one with IClientScreens.Open; a screen for a menu type is a ModMenuScreen.
public abstract class ModScreen : WidgetGroup
In Obsidian.API.Client.
Remarks
The client calls the screen's methods, and raises its widgets' events, on the game's thread, inside a call into the mod: if one throws, it's logged and the screen closes. Widgets are drawn as they are each frame, so the screen changes them whenever it likes, typically in ModScreen.Tick and in their events.
Escape closes the screen and goes back to what was shown before, as does ModScreen.Close. When the mod unloads, its open screens close.
Constructors
protected ModScreen();Properties
Background
public GuiImage Background { get; set; }The panel's background, drawn at its size under the widgets; null for none.
Height
public int Height { get; set; }The panel's height, in the GUI's pixels, like vanilla's container screens' imageHeight.
IsOpen
public bool IsOpen { get; }Whether the screen is open: from just before ModScreen.Init until ModScreen.Removed.
Width
public int Width { get; set; }The panel's width, in the GUI's pixels, like vanilla's container screens' imageWidth.
Methods
Close()
public void Close();Closes the screen if it's open; a menu's screen closes its menu too.
Init()
protected internal virtual void Init();Builds the screen as it opens, like vanilla's init: add its widgets here. The client removes the widgets before calling it, so widgets added earlier, like in the constructor, don't show.
Removed()
protected internal virtual void Removed();Runs as the screen closes, like vanilla's removed.
TextWidth(string)
protected int TextWidth(string text);How wide text is drawn, in the GUI's pixels, to place labels by it.
Tick()
protected internal virtual void Tick();Runs every client tick, 20 times a second, while the screen is open, like vanilla's tick: update the widgets from what changed, like a menu's data slots.
Translate(string, object[])
protected 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.