Documentation

Controls plugin dependency

The Controls dependency has functions for common UI controls for use across plugins. Originally developed for the plugin manager, and now available for everyone to use for a consistent style.

Demo window

In the plugin settings for Controls you can enable the demo window to see all available controls in a single window.

Getting started

To get started with the Controls plugin, add a dependency to it in your info.toml:

[script]
dependencies = [ "Controls" ]

Tags

Tags are small colored boxes with some text in it, usually to signal to the user that some content has some status.

Controls::Tag

Adds a tag with an optional color at the current cursor position to the UI. The default color is dark.

Parameters:

  • const string &in text The text within the tag.
  • const vec4 &in color = Controls::COLOR_DEFAULT The color of the tag.

Instead of passing colors to color, you can also use one of the following functions:

  • Controls::TagPrimary
  • Controls::TagInfo
  • Controls::TagLink
  • Controls::TagSuccess
  • Controls::TagWarning
  • Controls::TagDanger

Controls::DrawTag

Draws a tag to the screen at a given position. This does not count as a UI control.

Parameters:

  • const vec2 &in pos or const vec4 &in rect The position to draw the tag at. If a vec2 is passed rather than a vec4, the width and height will be calculated by measuring the text.
  • const string &in text The text within the tag.
  • const vec4 &in color = COLOR_DEFAULT The color of the tag.

Returns: vec4 rectangle at which the tag is drawn at.

Frames

Frames are colored containers for larger portions of text and optional content. This could be used as a warning, error, or informational indicator, for example.

Controls::Frame

Adds a frame with a line of text and an optional color to the UI.

Parameters

  • const string &in text The line of text to display.
  • bool requireInput = false Whether to allow the child to receive input from the user. If this is false, then UI::WindowFlags::NoInputs will be passed to the child control.
  • const vec4 &in color = COLOR_DEFAULT The color of the frame.

Instead of passing colors to color, you can also use one of the following functions:

  • Controls::FramePrimary
  • Controls::FrameInfo
  • Controls::FrameLink
  • Controls::FrameSuccess
  • Controls::FrameWarning
  • Controls::FrameDanger

Controls::BeginFrame

Begins a frame with an optional color. Can be used instead of Controls::Frame if you wanted to add more than just a line of text. Remember to call Controls::EndFrame to end the frame.

Parameters:

  • const string &in text The name of the child control and the first line of text.
  • bool requireInput = false Whether to allow the child to receive input from the user. If this is false, then UI::WindowFlags::NoInputs will be passed to the child control.
  • const vec4 &in color = COLOR_DEFAULT The color of the frame.

Instead of passing colors to color, you can also use one of the following functions:

  • Controls::BeginFramePrimary
  • Controls::BeginFrameInfo
  • Controls::BeginFrameLink
  • Controls::BeginFrameSuccess
  • Controls::BeginFrameWarning
  • Controls::BeginFrameDanger

Controls::EndFrame

Ends a previously begun frame using Controls::BeginFrame or any of the colored versions.


Page updated 4 months ago by Miss(Trusted developer)