Simutrans-Squirrel-API OTRP v63_4
Loading...
Searching...
No Matches
gui Class Reference

Public Member Functions

array< gui_window_x > get_windows ()
array< gui_component_x > get_window_components (integer window_id)
void click (any_x x, any_x y, any_x shift, any_x ctrl)
void drag (any_x from_x, any_x from_y, any_x to_x, any_x to_y, any_x shift, any_x ctrl)

Static Public Member Functions

static void open_info_win ()
static void open_info_win_at (string tab)
static void open_info_win_client (string tab, integer player_nr)
static string add_message_at (string text, coord position)
static string add_message (player_x text, string)
static string add_message_at (player_x player, string text, coord position)
static void jump (any_x position)
static void close_all_windows ()
static void take_screenshot ()
static void export_minimap ()
static void export_minimap_with_mode (any_x mapmode)
static void set_zoom (any_x zoom)
static bool open_dialog_tool (integer tool_nr)

Detailed Description

Table with methods to access gui functions.

Definition at line 113 of file api_gui.cc.

Member Function Documentation

◆ click()

void gui::click ( any_x x,
any_x y,
any_x shift,
any_x ctrl )

Simulate a left mouse click at the given screen coordinates.

Parameters
xx coordinate on screen.
yy coordinate on screen.
shifttrue to click with shift pressed.
ctrltrue to click with ctrl pressed.

◆ close_all_windows()

void gui::close_all_windows ( )
static

Close all windows on the view.

◆ drag()

void gui::drag ( any_x from_x,
any_x from_y,
any_x to_x,
any_x to_y,
any_x shift,
any_x ctrl )

Simulate a left mouse drag from one screen coordinate to another.

Parameters
from_xstart x coordinate on screen.
from_ystart y coordinate on screen.
to_xend x coordinate on screen.
to_yend y coordinate on screen.
shifttrue to drag with shift pressed.
ctrltrue to drag with ctrl pressed.

◆ export_minimap()

void gui::export_minimap ( )
static

Render the entire minimap (the whole world, not just the current viewport) to a PNG file in the screenshot folder.

Returns
path to the exported file, or empty/null string on failure.

◆ export_minimap_with_mode()

void gui::export_minimap_with_mode ( any_x mapmode)
static

Render the entire minimap with the given map mode to a PNG file in the screenshot folder. The map mode of the map window is not changed.

Parameters
mapmodebit mask as string, or mode names joined by '|', e.g. "MAP_TOWN|MAP_LINES" (MAP_ prefix optional, case insensitive).
Returns
path to the exported file, or empty/null string on failure (also for an invalid mode).

◆ get_window_components()

array< gui_component_x > gui::get_window_components ( integer window_id)

Get snapshots of components in the given GUI window.

Components are returned as a tree. Each component has role, bounds, screen_bounds, visible, focusable, focused, children, and optional text fields.

Parameters
window_idid property of a window snapshot returned by gui::get_windows.
Returns
array of gui_component_x, or null if window_id is invalid.

◆ get_windows()

array< gui_window_x > gui::get_windows ( )

Get snapshots of currently open GUI windows.

Each entry contains id, z_order, top, title, has_title, bounds, and client_bounds. Pass the id to gui::get_window_components to inspect the components in that window.

◆ jump()

void gui::jump ( any_x position)
static

Jump view to given position. This function succeeds only when the pos is within the map.

Parameters
positionPosition of the view on the map to jump to.
Returns
true if succeeded.

◆ open_dialog_tool()

bool gui::open_dialog_tool ( integer tool_nr)
static

Opens a dialog tool for the active player.

Parameters
tool_nrdialog tool number, for example DIALOG_MINIMAP = 2
Returns
whether the dialog tool request was accepted

◆ open_info_win()

void gui::open_info_win ( )
static

Opens scenario info window and shows 'info' tab. In network mode, opens window on all clients and server.

Note
Only available in scenario mode.

◆ open_info_win_at()

void gui::open_info_win_at ( string tab)
static

Opens scenario info window with specific tab open. In network mode, opens window on all clients and server.

Parameters
tabpossible values are "info", "goal", "rules", "result", "about", "debug"
Note
Only available in scenario mode.

◆ open_info_win_client()

void gui::open_info_win_client ( string tab,
integer player_nr )
static

Opens scenario info window for certain clients (and the server), with specific tab open.

Parameters
tabpossible values are "info", "goal", "rules", "result", "about", "debug"
player_nropens scenario info window on all clients that have this player unlocked.
Note
Window is always opened on server.

◆ set_zoom()

void gui::set_zoom ( any_x zoom)
static

Set zoom factor.

Parameters
zoomZoom factor to set.

◆ take_screenshot()

void gui::take_screenshot ( )
static

Take a screen shot.


The documentation for this class was generated from the following file: