UI#

class UI#

Adds windows of buttons, text fields and other widgets to the game’s UI.

Note

The windows are removed when the client that added them disconnects. For messages on the screen, see KSA.ShowMessage.

static Window AddWindow (IConnection connection, string title, bool visible = true)#

Add a window, with no widgets.

Parameters:
  • title – The text in the title bar.

  • visible – Whether the window is visible.

Game Scenes:

All

static void Clear (IConnection connection, bool clientOnly = false)#

Remove the windows.

Parameters:
  • clientOnly – Whether to remove only the windows added by the calling client.

Game Scenes:

All

class Window#

A window, holding widgets one per line. Created using UI.AddWindow.

Note

The window fits its widgets until its size is set. Closing the window makes it invisible. The window is hidden with the game’s UI.

string Title { get; set; }#

The text in the title bar.

Game Scenes:

All

Tuple<float, float> Position { get; set; }#

The position of the top left corner of the window, from the top left corner of the game window, in pixels.

Game Scenes:

All

Tuple<float, float> Size { get; set; }#

The width and height of the window, in pixels.

Game Scenes:

All

Note

Throws an exception if the width or height is not positive.

bool Visible { get; set; }#

Whether the widget is visible.

Game Scenes:

All

bool Enabled { get; set; }#

Whether the widget responds to input. A disabled widget is drawn dimmed.

Game Scenes:

All

Label AddLabel (string content, bool visible = true)#

Add a label.

Parameters:
  • content – The text of the label.

  • visible – Whether the label is visible.

Game Scenes:

All

Button AddButton (string content, bool visible = true)#

Add a button.

Parameters:
  • content – The text on the button.

  • visible – Whether the button is visible.

Game Scenes:

All

InputField AddInputField (string label = "", bool visible = true)#

Add a text input field, empty.

Parameters:
  • label – The text shown next to the field.

  • visible – Whether the field is visible.

Game Scenes:

All

Slider AddSlider (string label = "", float minimum = 0.0f, float maximum = 1.0f, bool visible = true)#

Add a slider, at its minimum value.

Parameters:
  • label – The text shown next to the slider.

  • minimum – The minimum value.

  • maximum – The maximum value.

  • visible – Whether the slider is visible.

Game Scenes:

All

Note

Throws an exception if the minimum is not less than the maximum.

Toggle AddToggle (string content, bool visible = true)#

Add a toggle, unchecked.

Parameters:
  • content – The text shown next to the toggle.

  • visible – Whether the toggle is visible.

Game Scenes:

All

Dropdown AddDropdown (IList<string> options, string label = "", bool visible = true)#

Add a dropdown, with no option selected.

Parameters:
  • options – The options to choose from.

  • label – The text shown next to the dropdown.

  • visible – Whether the dropdown is visible.

Game Scenes:

All

Separator AddSeparator (bool visible = true)#

Add a horizontal line.

Parameters:
  • visible – Whether the line is visible.

Game Scenes:

All

Row AddRow (bool visible = true)#

Add a row, which lays out its widgets from left to right.

Parameters:
  • visible – Whether the row is visible.

Game Scenes:

All

void Remove ()#

Remove the widget.

Game Scenes:

All

class Row#

A row of widgets, laid out from left to right. Added to a window or a row.

bool Visible { get; set; }#

Whether the widget is visible.

Game Scenes:

All

bool Enabled { get; set; }#

Whether the widget responds to input. A disabled widget is drawn dimmed.

Game Scenes:

All

Label AddLabel (string content, bool visible = true)#

Add a label.

Parameters:
  • content – The text of the label.

  • visible – Whether the label is visible.

Game Scenes:

All

Button AddButton (string content, bool visible = true)#

Add a button.

Parameters:
  • content – The text on the button.

  • visible – Whether the button is visible.

Game Scenes:

All

InputField AddInputField (string label = "", bool visible = true)#

Add a text input field, empty.

Parameters:
  • label – The text shown next to the field.

  • visible – Whether the field is visible.

Game Scenes:

All

Slider AddSlider (string label = "", float minimum = 0.0f, float maximum = 1.0f, bool visible = true)#

Add a slider, at its minimum value.

Parameters:
  • label – The text shown next to the slider.

  • minimum – The minimum value.

  • maximum – The maximum value.

  • visible – Whether the slider is visible.

Game Scenes:

All

Note

Throws an exception if the minimum is not less than the maximum.

Toggle AddToggle (string content, bool visible = true)#

Add a toggle, unchecked.

Parameters:
  • content – The text shown next to the toggle.

  • visible – Whether the toggle is visible.

Game Scenes:

All

Dropdown AddDropdown (IList<string> options, string label = "", bool visible = true)#

Add a dropdown, with no option selected.

Parameters:
  • options – The options to choose from.

  • label – The text shown next to the dropdown.

  • visible – Whether the dropdown is visible.

Game Scenes:

All

Separator AddSeparator (bool visible = true)#

Add a horizontal line.

Parameters:
  • visible – Whether the line is visible.

Game Scenes:

All

Row AddRow (bool visible = true)#

Add a row, which lays out its widgets from left to right.

Parameters:
  • visible – Whether the row is visible.

Game Scenes:

All

void Remove ()#

Remove the widget.

Game Scenes:

All

class Label#

A line of text. Added to a window or a row.

string Content { get; set; }#

The text of the label.

Game Scenes:

All

bool Visible { get; set; }#

Whether the widget is visible.

Game Scenes:

All

bool Enabled { get; set; }#

Whether the widget responds to input. A disabled widget is drawn dimmed.

Game Scenes:

All

void Remove ()#

Remove the widget.

Game Scenes:

All

class Button#

A button. Added to a window or a row.

string Content { get; set; }#

The text on the button.

Game Scenes:

All

bool Clicked { get; set; }#

Whether the button has been clicked.

Game Scenes:

All

Note

A click sets this to true, and it stays true until set to false.

bool Visible { get; set; }#

Whether the widget is visible.

Game Scenes:

All

bool Enabled { get; set; }#

Whether the widget responds to input. A disabled widget is drawn dimmed.

Game Scenes:

All

void Remove ()#

Remove the widget.

Game Scenes:

All

class InputField#

A single line text input field. Added to a window or a row.

Note

While the field is being edited, the game clears the rotation and translation inputs of the controlled vehicle each frame.

string Label { get; set; }#

The text shown next to the field.

Game Scenes:

All

string Value { get; set; }#

The text in the field.

Game Scenes:

All

bool Changed { get; set; }#

Whether the text has been edited.

Game Scenes:

All

Note

An edit sets this to true, and it stays true until set to false. Setting InputField.Value leaves it unchanged.

bool Visible { get; set; }#

Whether the widget is visible.

Game Scenes:

All

bool Enabled { get; set; }#

Whether the widget responds to input. A disabled widget is drawn dimmed.

Game Scenes:

All

void Remove ()#

Remove the widget.

Game Scenes:

All

class Slider#

A horizontal slider. Added to a window or a row.

string Label { get; set; }#

The text shown next to the slider.

Game Scenes:

All

float Value { get; set; }#

The value of the slider, clamped to its range.

Game Scenes:

All

float Minimum { get; set; }#

The minimum value.

Game Scenes:

All

Note

Throws an exception if set to a value not less than the maximum.

float Maximum { get; set; }#

The maximum value.

Game Scenes:

All

Note

Throws an exception if set to a value not greater than the minimum.

bool Changed { get; set; }#

Whether the value has been changed by dragging the slider.

Game Scenes:

All

Note

A change sets this to true, and it stays true until set to false. Setting Slider.Value leaves it unchanged.

bool Visible { get; set; }#

Whether the widget is visible.

Game Scenes:

All

bool Enabled { get; set; }#

Whether the widget responds to input. A disabled widget is drawn dimmed.

Game Scenes:

All

void Remove ()#

Remove the widget.

Game Scenes:

All

class Toggle#

A check box with a label. Added to a window or a row.

string Content { get; set; }#

The text shown next to the toggle.

Game Scenes:

All

bool Checked { get; set; }#

Whether the toggle is checked.

Game Scenes:

All

bool Changed { get; set; }#

Whether the toggle has been clicked.

Game Scenes:

All

Note

A click sets this to true, and it stays true until set to false. Setting Toggle.Checked leaves it unchanged.

bool Visible { get; set; }#

Whether the widget is visible.

Game Scenes:

All

bool Enabled { get; set; }#

Whether the widget responds to input. A disabled widget is drawn dimmed.

Game Scenes:

All

void Remove ()#

Remove the widget.

Game Scenes:

All

class Dropdown#

A dropdown list of options. Added to a window or a row.

string Label { get; set; }#

The text shown next to the dropdown.

Game Scenes:

All

IList<string> Options { get; set; }#

The options to choose from.

Game Scenes:

All

Note

Setting the options clears the selection if the selected index is no longer in the list.

int SelectedIndex { get; set; }#

The index of the selected option, or -1 for none.

Game Scenes:

All

Note

Throws an exception if the index is out of range.

bool Changed { get; set; }#

Whether an option has been chosen from the list.

Game Scenes:

All

Note

A choice sets this to true, and it stays true until set to false. Setting Dropdown.SelectedIndex leaves it unchanged.

bool Visible { get; set; }#

Whether the widget is visible.

Game Scenes:

All

bool Enabled { get; set; }#

Whether the widget responds to input. A disabled widget is drawn dimmed.

Game Scenes:

All

void Remove ()#

Remove the widget.

Game Scenes:

All

class Separator#

A horizontal line between widgets. Added to a window or a row.

bool Visible { get; set; }#

Whether the widget is visible.

Game Scenes:

All

bool Enabled { get; set; }#

Whether the widget responds to input. A disabled widget is drawn dimmed.

Game Scenes:

All

void Remove ()#

Remove the widget.

Game Scenes:

All