Table of Contents

Class TimbnPluginUI

Namespace
Timbn.GraveyardKeeperTwo.Core.Framework
Assembly
Timbn.GraveyardKeeperTwo.Core.dll

Puts a plugin's own things on screen (windows, hints and its own GUI) and fades the screen through black with code the plugin can call off, all taken down again when the plugin unloads. See TimbnUI to read the game's windows. Reach it through the plugin's UI property.

public sealed class TimbnPluginUI
Inheritance
TimbnPluginUI
Inherited Members

Methods

AddObjectAction(TimbnObjectAction)

Adds something the player can do beside an object in the world that the game gives no interaction for. See TimbnObjectAction. The hint, the walk and the held controls are taken down when the handle is disposed, the plugin unloads or the player returns to the main menu.

public IDisposable AddObjectAction(TimbnObjectAction action)

Parameters

action TimbnObjectAction

What to do and where.

Returns

IDisposable

A handle that removes the action when disposed. You don't need to keep it.

Examples

UI.AddObjectAction(new TimbnObjectAction("common_box_08", new Vector3(-104.36f, 0f, -338.20f), "my_mod_pet"));

CreateBubble()

Makes an icon bubble the plugin can show over any spot in the world, such as what a customer wants. It is hidden when the plugin unloads and on the way to the main menu, and can be shown again afterwards. Dispose one the plugin is done with, such as one made per customer, so the plugin forgets it.

public TimbnBubble CreateBubble()

Returns

TimbnBubble

The bubble, hidden until its Show is called.

Examples

_wants = UI.CreateBubble();
_wants.Show(customer.Position + Vector3.up * 2f, "i_cup_beer");

CreateDebugWindow(string, Action, ConfigEntry<KeyboardShortcut>?)

Makes an IMGUI window for a debug or cheat menu. Core draws the box, a title line that names the key to close it, and a "load a save" note, so you only draw what goes inside. The window is taken down when the plugin unloads. Set its Area and the other properties on the returned window.

public TimbnGuiWindow CreateDebugWindow(string title, Action draw, ConfigEntry<KeyboardShortcut>? toggle = null)

Parameters

title string

The window's title, drawn on its first line with the key that closes it.

draw Action

Draws the contents with GUILayout calls. It runs only while the window is visible.

toggle ConfigEntry<KeyboardShortcut>

The key that opens and closes the window, or null to set IsVisible from code.

Returns

TimbnGuiWindow

The window.

Examples

var menu = UI.CreateDebugWindow("Timbn Cheats", DrawCheats, PluginConfig.ToggleMenu);

CreateHint()

Makes a "press a key to do something" hint the plugin can show over any spot in the world. It is hidden when the plugin unloads and on the way to the main menu, and can be shown again afterwards. Dispose one the plugin is done with, such as one made per visitor, so the plugin forgets it.

public TimbnInteractionHint CreateHint()

Returns

TimbnInteractionHint

The hint, hidden until its Show is called.

DrawGui(Action)

Draws Unity IMGUI every GUI pass, on the main menu and in game, while the plugin is enabled. Use it in place of an OnGUI method, for a debug window or an overlay. If the handler throws, the error is logged once and the handler is stopped.

public IDisposable DrawGui(Action draw)

Parameters

draw Action

The IMGUI code to run.

Returns

IDisposable

A handle that stops drawing when disposed. You don't need to keep it.

Examples

UI.DrawGui(() =>
{
    if (_menuOpen)
        GUILayout.Label($"Day {TimbnClock.Day}, {TimbnClock.TimeText}");
});

FadeThrough(Action)

Fades the screen to black, runs your code while it is black, and fades back in, the way the game hides a change such as the player sitting down or a teleport. The code can be called off before the screen goes black, such as when the player changes their mind during the fade. When the game has no fade to show, or one is already showing, the code runs straight away.

public IDisposable FadeThrough(Action whileBlack)

Parameters

whileBlack Action

The code to run once the screen is black.

Returns

IDisposable

A handle that calls the code off when disposed. It is also called off when the plugin unloads and on the way to the main menu.

Examples

_fade?.Dispose();
_fade = UI.FadeThrough(SitDown);

OpenStorage(IDictionary<string, int>, string, int, params string[])

Opens the game's chest window on a storage only the plugin knows about, such as a keg, with the player's inventory beside it so they move items in and out the usual way. The storage is a list of item ids and counts the plugin keeps, usually in its save data, and every move the player makes is written back into it at once.

public IDisposable OpenStorage(IDictionary<string, int> contents, string titleKey, int slots, params string[] itemIds)

Parameters

contents IDictionary<string, int>

The items in the storage, item id to count. It is changed as the player moves items.

titleKey string

A text key added with Text.Add, shown over the storage, such as "Keg".

slots int

How many slots the storage has. Items that do not fit stay in the contents but are not shown.

itemIds string[]

The only items the player may put in. Leave it out to take anything.

Returns

IDisposable

A handle that closes the window when disposed, if it is still open. It is also closed when the plugin unloads and on the way to the main menu. You don't need to keep it.

Examples

UI.OpenStorage(Data.Current.Keg, "my_mod_keg", 10, "beer");