Skip to content

Host

The plugin host itself: its version, a clock, and opening web pages.

Version

string Host::Version()

The host's version, for example "0.6.0". To require a minimum version, set min_host in info.toml instead: older hosts then refuse to install or run the plugin.

Example
// Shown in an about panel
aboutText.text = "running on plugin host " + Host::Version();

Time

double Host::Time()

Seconds of real time since the plugin host started, which is when the game started. It keeps counting through pauses and loading screens. Use the difference between two readings to time things.

Example
// Do something at most once every 5 seconds
if (Host::Time() - lastSave > 5.0)
{
    Save();
    lastSave = Host::Time();
}

MapNumber

int Host::MapNumber()

A number that goes up each time a map loads (the menu, a track, the editor). Compare two readings to tell that the map changed, even to another copy of the same track. Requires host 0.14.0.

Example
int map = Host::MapNumber();
// later
if (Host::MapNumber() != map)
    Log::Info("a new map is loaded");

WindowMaximized

bool Host::WindowMaximized()

Whether the game's window is maximized. Requires host 0.15.0.

Example
if (!Host::WindowMaximized())
    Log::Info("windowed, not maximized");

WindowFitsScreen

bool Host::WindowFitsScreen()

Whether the game's window fits the usable part of its screen (the taskbar left out). A fullscreen or borderless window always does. A bordered window reopened at the size it had maximized doesn't: its title bar and borders push it past the screen. Requires host 0.15.0.

Example
if (!Host::WindowFitsScreen())
    Host::MaximizeWindow();

MaximizeWindow

bool Host::MaximizeWindow()

Maximizes the game's window (a bordered one; fullscreen and borderless are left alone), as double-clicking its title bar does. True if it's maximized now. Requires host 0.15.0.

Example
Host::MaximizeWindow();

MaximizeAtStart

void Host::MaximizeAtStart(int mode)

Asks the host to maximize the game's window at the next starts, as soon as the window appears, seconds before any plugin runs: 0 off, 1 when it doesn't fit the screen, 2 always. Kept until changed, and only while the plugin is installed and not turned off. Requires host 0.15.1.

Example
Host::MaximizeAtStart(AlwaysMaximize ? 2 : 1);

OpenUrl

void Host::OpenUrl(const string &in)

Opens a page in the player's web browser. Only https://github.com/ addresses are allowed. Anything else is refused and logged.

Example
// A "source" button that opens the plugin's repo
if (sourceButton.Clicked())
    Host::OpenUrl("https://github.com/AnythingGoes-ballest/ballest-grind-timer-plugin");