OpenTTD GameScript API: GSWindow Class Reference

OpenTTD GameScript API 14.0-beta2

Public Types | Static Public Member Functions
GSWindow Class Reference

Class that handles window interaction. More...

Inheritance diagram for GSWindow:

## Public Types
enum | WindowNumberEnum { WN_GAME_OPTIONS_AI, WN_GAME_OPTIONS_GS, WN_GAME_OPTIONS_ABOUT, WN_GAME_OPTIONS_NEWGRF_STATE, WN_GAME_OPTIONS_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_SETTINGS, WN_QUERY_STRING, WN_QUERY_STRING_SIGN, WN_CONFIRM_POPUP_QUERY, WN_CONFIRM_POPUP_QUERY_BOOTSTRAP, WN_NETWORK_WINDOW_GAME, WN_NETWORK_WINDOW_CONTENT_LIST, WN_NETWORK_WINDOW_START, WN_NETWORK_STATUS_WINDOW_JOIN, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD }
| Window numbers. More...
enum | WindowClass { WC_NONE, WC_MAIN_WINDOW, WC_MAIN_TOOLBAR, WC_STATUS_BAR, WC_BUILD_TOOLBAR, WC_SCEN_BUILD_TOOLBAR, WC_BUILD_TREES, WC_TRANSPARENCY_TOOLBAR, WC_BUILD_SIGNAL, WC_SMALLMAP, WC_ERRMSG, WC_TOOLTIPS, WC_QUERY_STRING, WC_CONFIRM_POPUP_QUERY, WC_GOAL_QUESTION, WC_SAVELOAD, WC_LAND_INFO, WC_DROPDOWN_MENU, WC_OSK, WC_SET_DATE, WC_SCRIPT_SETTINGS, WC_GRF_PARAMETERS, WC_TEXTFILE, WC_TOWN_AUTHORITY, WC_VEHICLE_DETAILS, WC_VEHICLE_REFIT, WC_VEHICLE_ORDERS, WC_REPLACE_VEHICLE, WC_VEHICLE_TIMETABLE, WC_COMPANY_COLOUR, WC_COMPANY_MANAGER_FACE, WC_SELECT_STATION, WC_NEWS_WINDOW, WC_TOWN_DIRECTORY, WC_SUBSIDIES_LIST, WC_INDUSTRY_DIRECTORY, WC_MESSAGE_HISTORY, WC_SIGN_LIST, WC_SCRIPT_LIST, WC_GOALS_LIST, WC_STORY_BOOK, WC_STATION_LIST, WC_TRAINS_LIST, WC_ROADVEH_LIST, WC_SHIPS_LIST, WC_AIRCRAFT_LIST, WC_TOWN_VIEW, WC_VEHICLE_VIEW, WC_STATION_VIEW, WC_VEHICLE_DEPOT, WC_WAYPOINT_VIEW, WC_INDUSTRY_VIEW, WC_COMPANY, WC_BUILD_OBJECT, WC_BUILD_VEHICLE, WC_BUILD_BRIDGE, WC_BUILD_STATION, WC_BUS_STATION, WC_TRUCK_STATION, WC_BUILD_DEPOT, WC_BUILD_WAYPOINT, WC_FOUND_TOWN, WC_BUILD_INDUSTRY, WC_SELECT_GAME, WC_SCEN_LAND_GEN, WC_GENERATE_LANDSCAPE, WC_MODAL_PROGRESS, WC_NETWORK_WINDOW, WC_CLIENT_LIST, WC_NETWORK_STATUS_WINDOW, WC_NETWORK_ASK_RELAY, WC_NETWORK_ASK_SURVEY, WC_SEND_NETWORK_MSG, WC_COMPANY_PASSWORD_WINDOW, WC_INDUSTRY_CARGOES, WC_GRAPH_LEGEND, WC_FINANCES, WC_INCOME_GRAPH, WC_OPERATING_PROFIT, WC_DELIVERED_CARGO, WC_PERFORMANCE_HISTORY, WC_COMPANY_VALUE, WC_COMPANY_LEAGUE, WC_PAYMENT_RATES, WC_PERFORMANCE_DETAIL, WC_COMPANY_INFRASTRUCTURE, WC_BUY_COMPANY, WC_ENGINE_PREVIEW, WC_MUSIC_WINDOW, WC_MUSIC_TRACK_SELECTION, WC_GAME_OPTIONS, WC_CUSTOM_CURRENCY, WC_CHEATS, WC_EXTRA_VIEWPORT, WC_CONSOLE, WC_BOOTSTRAP, WC_HIGHSCORE, WC_ENDSCREEN, WC_SCRIPT_DEBUG, WC_NEWGRF_INSPECT, WC_SPRITE_ALIGNER, WC_LINKGRAPH_LEGEND, WC_SAVE_PRESET, WC_FRAMERATE_DISPLAY, WC_FRAMETIME_GRAPH, WC_SCREENSHOT, numbers, WC_INVALID }
| Window classes. More...
enum | TextColour { TC_BLUE, TC_SILVER, TC_GOLD, TC_RED, TC_PURPLE, TC_LIGHT_BROWN, TC_ORANGE, TC_GREEN, TC_YELLOW, TC_DARK_GREEN, TC_CREAM, TC_BROWN, TC_WHITE, TC_LIGHT_BLUE, TC_GREY, TC_DARK_BLUE, TC_BLACK, TC_INVALID }
| The colours in the game which you can use for text and highlights. More...
enum | NumberType { NUMBER_ALL }
| Special number values. More...
enum | WidgetType { WIDGET_ALL }
| Special widget values. More...

## Static Public Member Functions
static void | Close (WindowClass window, SQInteger number)
| Close a window. More...
static bool | IsOpen (WindowClass window, SQInteger number)
| Check if a window is open. More...
static void | Highlight (WindowClass window, SQInteger number, SQInteger widget, TextColour colour)
| Highlight a widget in a window. More...

## Detailed Description

Class that handles window interaction.

A Window in OpenTTD has two important values. The WindowClass, and a Window number. The first indicates roughly which window it is. WC_TOWN_VIEW for example, is the view of a town. The Window number is a bit more complex, as it depends mostly on the WindowClass. For example for WC_TOWN_VIEW it is the TownID. In general a good rule of thumb is: either the number is always 0, or the ID of the object in question. In the comment at the widget enum, it is mentioned how the number is used.

Note, that the detailed window layout is very version specific. Enum values might be added, changed or removed in future versions without notice in the changelog, and there won't be any means of compatibility.

## Member Enumeration Documentation

## ◆ NumberType

enum GSWindow::NumberType

Special number values.

Enumerator
NUMBER_ALL | Value to select all windows of a class.

## ◆ TextColour

enum GSWindow::TextColour

The colours in the game which you can use for text and highlights.

Enumerator
TC_BLUE | Blue colour.
TC_SILVER | Silver colour.
TC_GOLD | Gold colour.
TC_RED | Red colour.
TC_PURPLE | Purple colour.
TC_LIGHT_BROWN | Light brown colour.
TC_ORANGE | Orange colour.
TC_GREEN | Green colour.
TC_YELLOW | Yellow colour.
TC_DARK_GREEN | Dark green colour.
TC_CREAM | Cream colour.
TC_BROWN | Brown colour.
TC_WHITE | White colour.
TC_LIGHT_BLUE | Light blue colour.
TC_GREY | Grey colour.
TC_DARK_BLUE | Dark blue colour.
TC_BLACK | Black colour.
TC_INVALID | Invalid colour.

## ◆ WidgetType

enum GSWindow::WidgetType

Special widget values.

Enumerator
WIDGET_ALL | Value to select all widgets of a window.

## ◆ WindowClass

enum GSWindow::WindowClass

Window classes.

Enumerator
WC_NONE | No window, redirects to WC_MAIN_WINDOW.
WC_MAIN_WINDOW | Main window; Window numbers: 0 = #MainWidgets
WC_MAIN_TOOLBAR | Main toolbar (the long bar at the top); Window numbers: 0 = #ToolbarNormalWidgets 0 = #ToolbarEditorWidgets
WC_STATUS_BAR | Statusbar (at the bottom of your screen); Window numbers: 0 = #StatusbarWidgets
WC_BUILD_TOOLBAR | Build toolbar; Window numbers: #TRANSPORT_RAIL = #RailToolbarWidgets #TRANSPORT_AIR = #AirportToolbarWidgets #TRANSPORT_WATER = #DockToolbarWidgets #TRANSPORT_ROAD = #RoadToolbarWidgets
WC_SCEN_BUILD_TOOLBAR | Scenario build toolbar; Window numbers: #TRANSPORT_WATER = #DockToolbarWidgets #TRANSPORT_ROAD = #RoadToolbarWidgets
WC_BUILD_TREES | Build trees toolbar; Window numbers: 0 = #BuildTreesWidgets
WC_TRANSPARENCY_TOOLBAR | Transparency toolbar; Window numbers: 0 = #TransparencyToolbarWidgets
WC_BUILD_SIGNAL | Build signal toolbar; Window numbers: #TRANSPORT_RAIL = #BuildSignalWidgets
WC_SMALLMAP | Small map; Window numbers: 0 = #SmallMapWidgets
WC_ERRMSG | Error message; Window numbers: 0 = #ErrorMessageWidgets
WC_TOOLTIPS | Tooltip window; Window numbers: 0 = #ToolTipsWidgets
WC_QUERY_STRING | Query string window; Window numbers: WN_QUERY_STRING = #QueryStringWidgets WN_QUERY_STRING_SIGN = #QueryEditSignWidgets
WC_CONFIRM_POPUP_QUERY | Popup with confirm question; Window numbers: WN_CONFIRM_POPUP_QUERY = #QueryWidgets WN_CONFIRM_POPUP_QUERY_BOOTSTRAP = #BootstrapAskForDownloadWidgets
WC_GOAL_QUESTION | Popup with a set of buttons, designed to ask the user a question from a GameGS. Window numbers: uniqueid = #GoalQuestionWidgets
WC_SAVELOAD | Saveload window; Window numbers: 0 = #SaveLoadWidgets
WC_LAND_INFO | Land info window; Window numbers: 0 = #LandInfoWidgets
WC_DROPDOWN_MENU | Drop down menu; Window numbers: 0 = #DropdownMenuWidgets
WC_OSK | On Screen Keyboard; Window numbers: 0 = #OnScreenKeyboardWidgets
WC_SET_DATE | Set date; Window numbers: #VehicleID = #SetDateWidgets
WC_SCRIPT_SETTINGS | GS settings; Window numbers: 0 = #GSSettingsWidgets
WC_GRF_PARAMETERS | NewGRF parameters; Window numbers: 0 = #NewGRFParametersWidgets
WC_TEXTFILE | textfile; Window numbers: 0 = #TextfileWidgets
WC_TOWN_AUTHORITY | Town authority; Window numbers: #TownID = #TownAuthorityWidgets
WC_VEHICLE_DETAILS | Vehicle details; Window numbers: #VehicleID = #VehicleDetailsWidgets
WC_VEHICLE_REFIT | Vehicle refit; Window numbers: #VehicleID = #VehicleRefitWidgets
WC_VEHICLE_ORDERS | Vehicle orders; Window numbers: #VehicleID = #OrderWidgets
WC_REPLACE_VEHICLE | Replace vehicle window; Window numbers: #VehicleType = #ReplaceVehicleWidgets
WC_VEHICLE_TIMETABLE | Vehicle timetable; Window numbers: #VehicleID = #VehicleTimetableWidgets
WC_COMPANY_COLOUR | Company colour selection; Window numbers: #CompanyID = #SelectCompanyLiveryWidgets
WC_COMPANY_MANAGER_FACE | Alter company face window; Window numbers: #CompanyID = #SelectCompanyManagerFaceWidgets
WC_SELECT_STATION | Select station (when joining stations); Window numbers: 0 = #JoinStationWidgets
WC_NEWS_WINDOW | News window; Window numbers: 0 = #NewsWidgets
WC_TOWN_DIRECTORY | Town directory; Window numbers: 0 = #TownDirectoryWidgets
WC_SUBSIDIES_LIST | Subsidies list; Window numbers: 0 = #SubsidyListWidgets
WC_INDUSTRY_DIRECTORY | Industry directory; Window numbers: 0 = #IndustryDirectoryWidgets
WC_MESSAGE_HISTORY | News history list; Window numbers: 0 = #MessageHistoryWidgets
WC_SIGN_LIST | Sign list; Window numbers: 0 = #SignListWidgets
WC_SCRIPT_LIST | GSs list; Window numbers: 0 = #GSListWidgets
WC_GOALS_LIST | Goals list; Window numbers: 0 ; #GoalListWidgets
WC_STORY_BOOK | Story book; Window numbers: CompanyID = #StoryBookWidgets
WC_STATION_LIST | Station list; Window numbers: #CompanyID = #StationListWidgets
WC_TRAINS_LIST | Trains list; Window numbers: Packed value = #GroupListWidgets / #VehicleListWidgets
WC_ROADVEH_LIST | Road vehicle list; Window numbers: Packed value = #GroupListWidgets / #VehicleListWidgets
WC_SHIPS_LIST | Ships list; Window numbers: Packed value = #GroupListWidgets / #VehicleListWidgets
WC_AIRCRAFT_LIST | Aircraft list; Window numbers: Packed value = #GroupListWidgets / #VehicleListWidgets
WC_TOWN_VIEW | Town view; Window numbers: #TownID = #TownViewWidgets
WC_VEHICLE_VIEW | Vehicle view; Window numbers: #VehicleID = #VehicleViewWidgets
WC_STATION_VIEW | Station view; Window numbers: #StationID = #StationViewWidgets
WC_VEHICLE_DEPOT | Depot view; Window numbers: #TileIndex = #DepotWidgets
WC_WAYPOINT_VIEW | Waypoint view; Window numbers: #WaypointID = #WaypointWidgets
WC_INDUSTRY_VIEW | Industry view; Window numbers: #IndustryID = #IndustryViewWidgets
WC_COMPANY | Company view; Window numbers: #CompanyID = #CompanyWidgets
WC_BUILD_OBJECT | Build object; Window numbers: 0 = #BuildObjectWidgets
WC_BUILD_VEHICLE | Build vehicle; Window numbers: #VehicleType = #BuildVehicleWidgets #TileIndex = #BuildVehicleWidgets
WC_BUILD_BRIDGE | Build bridge; Window numbers: #TransportType = #BuildBridgeSelectionWidgets
WC_BUILD_STATION | Build station; Window numbers: #TRANSPORT_AIR = #AirportPickerWidgets #TRANSPORT_WATER = #DockToolbarWidgets #TRANSPORT_RAIL = #BuildRailStationWidgets
WC_BUS_STATION | Build bus station; Window numbers: #TRANSPORT_ROAD = #BuildRoadStationWidgets
WC_TRUCK_STATION | Build truck station; Window numbers: #TRANSPORT_ROAD = #BuildRoadStationWidgets
WC_BUILD_DEPOT | Build depot; Window numbers: #TRANSPORT_WATER = #BuildDockDepotWidgets #TRANSPORT_RAIL = #BuildRailDepotWidgets #TRANSPORT_ROAD = #BuildRoadDepotWidgets
WC_BUILD_WAYPOINT | Build waypoint; Window numbers: #TRANSPORT_RAIL = #BuildRailWaypointWidgets
WC_FOUND_TOWN | Found a town; Window numbers: 0 = #TownFoundingWidgets
WC_BUILD_INDUSTRY | Build industry; Window numbers: 0 = #DynamicPlaceIndustriesWidgets
WC_SELECT_GAME | Select game window; Window numbers: 0 = #SelectGameIntroWidgets
WC_SCEN_LAND_GEN | Landscape generation (in Scenario Editor); Window numbers: 0 = #TerraformToolbarWidgets 0 = #EditorTerraformToolbarWidgets
WC_GENERATE_LANDSCAPE | Generate landscape (newgame); Window numbers: GLWM_SCENARIO = #CreateScenarioWidgets #GenerateLandscapeWindowMode = #GenerateLandscapeWidgets
WC_MODAL_PROGRESS | Progress report of landscape generation; Window numbers: 0 = #GenerationProgressWidgets 1 = #ScanProgressWidgets
WC_NETWORK_WINDOW | Network window; Window numbers: WN_NETWORK_WINDOW_GAME = #NetworkGameWidgets WN_NETWORK_WINDOW_CONTENT_LIST = #NetworkContentListWidgets WN_NETWORK_WINDOW_START = #NetworkStartServerWidgets
WC_CLIENT_LIST | Client list; Window numbers: 0 = #ClientListWidgets
WC_NETWORK_STATUS_WINDOW | Network status window; Window numbers: WN_NETWORK_STATUS_WINDOW_JOIN = #NetworkJoinStatusWidgets WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD = #NetworkContentDownloadStatusWidgets
WC_NETWORK_ASK_RELAY | Network ask relay window; Window numbers: 0 - #NetworkAskRelayWidgets
WC_NETWORK_ASK_SURVEY | Network ask survey window; Window numbers: 0 - #NetworkAskSurveyWidgets
WC_SEND_NETWORK_MSG | Chatbox; Window numbers: #DestType = #NetWorkChatWidgets
WC_COMPANY_PASSWORD_WINDOW | Company password query; Window numbers: 0 = #NetworkCompanyPasswordWidgets
WC_INDUSTRY_CARGOES | Industry cargoes chain; Window numbers: 0 = #IndustryCargoesWidgets
WC_GRAPH_LEGEND | Legend for graphs; Window numbers: 0 = #GraphLegendWidgets
WC_FINANCES | Finances of a company; Window numbers: #CompanyID = #CompanyWidgets
WC_INCOME_GRAPH | Income graph; Window numbers: 0 = #CompanyValueWidgets
WC_OPERATING_PROFIT | Operating profit graph; Window numbers: 0 = #CompanyValueWidgets
WC_DELIVERED_CARGO | Delivered cargo graph; Window numbers: 0 = #CompanyValueWidgets
WC_PERFORMANCE_HISTORY | Performance history graph; Window numbers: 0 = #PerformanceHistoryGraphWidgets
WC_COMPANY_VALUE | Company value graph; Window numbers: 0 = #CompanyValueWidgets
WC_COMPANY_LEAGUE | Company league window; Window numbers: 0 = #CompanyLeagueWidgets
WC_PAYMENT_RATES | Payment rates graph; Window numbers: 0 = #CargoPaymentRatesWidgets
WC_PERFORMANCE_DETAIL | Performance detail window; Window numbers: 0 = #PerformanceRatingDetailsWidgets
WC_COMPANY_INFRASTRUCTURE | Company infrastructure overview; Window numbers: #CompanyID = #CompanyInfrastructureWidgets
WC_BUY_COMPANY | Buyout company (merger); Window numbers: #CompanyID = #BuyCompanyWidgets
WC_ENGINE_PREVIEW | Engine preview window; Window numbers: #EngineID = #EnginePreviewWidgets
WC_MUSIC_WINDOW | Music window; Window numbers: 0 = #MusicWidgets
WC_MUSIC_TRACK_SELECTION | Music track selection; Window numbers: 0 = MusicTrackSelectionWidgets
WC_GAME_OPTIONS | Game options window; Window numbers: WN_GAME_OPTIONS_AI = #AIConfigWidgets WN_GAME_OPTIONS_GS = #GSConfigWidgets WN_GAME_OPTIONS_ABOUT = #AboutWidgets WN_GAME_OPTIONS_NEWGRF_STATE = #NewGRFStateWidgets WN_GAME_OPTIONS_GAME_OPTIONS = #GameOptionsWidgets WN_GAME_OPTIONS_GAME_SETTINGS = #GameSettingsWidgets
WC_CUSTOM_CURRENCY | Custom currency; Window numbers: 0 = #CustomCurrencyWidgets
WC_CHEATS | Cheat window; Window numbers: 0 = #CheatWidgets
WC_EXTRA_VIEWPORT | Extra viewport; Window numbers: Ascending value = #ExtraViewportWidgets
WC_CONSOLE | Console; Window numbers: 0 = #ConsoleWidgets
WC_BOOTSTRAP | Bootstrap; Window numbers: 0 = #BootstrapBackgroundWidgets
WC_HIGHSCORE | Highscore; Window numbers: 0 = #HighscoreWidgets
WC_ENDSCREEN | Endscreen; Window numbers: 0 = #HighscoreWidgets
WC_SCRIPT_DEBUG | GS debug window; Window numbers: Ascending value = #GSDebugWidgets
WC_NEWGRF_INSPECT | NewGRF inspect (debug); Window numbers: Packed value = #NewGRFInspectWidgets
WC_SPRITE_ALIGNER | Sprite aligner (debug); Window numbers: 0 = #SpriteAlignerWidgets
WC_LINKGRAPH_LEGEND | Linkgraph legend; Window numbers: 0 = #LinkGraphWidgets
WC_SAVE_PRESET | Save preset; Window numbers: 0 = #SavePresetWidgets
WC_FRAMERATE_DISPLAY | Framerate display; Window numbers: 0 = #FramerateDisplayWidgets
WC_FRAMETIME_GRAPH | Frame time graph; Window numbers: 0 = #FrametimeGraphWindowWidgets
WC_SCREENSHOT | Screenshot window; Window numbers: 0 = #ScreenshotWidgets
WC_INVALID | Invalid window.

## ◆ WindowNumberEnum

enum GSWindow::WindowNumberEnum

Window numbers.

Enumerator
WN_GAME_OPTIONS_AI | AI settings.
WN_GAME_OPTIONS_GS | GS settings.
WN_GAME_OPTIONS_ABOUT | About window.
WN_GAME_OPTIONS_NEWGRF_STATE | NewGRF settings.
WN_GAME_OPTIONS_GAME_OPTIONS | Game options.
WN_GAME_OPTIONS_GAME_SETTINGS | Game settings.
WN_QUERY_STRING | Query string.
WN_QUERY_STRING_SIGN | Query string for signs.
WN_CONFIRM_POPUP_QUERY | Query popup confirm.
WN_CONFIRM_POPUP_QUERY_BOOTSTRAP | Query popup confirm for bootstrap.
WN_NETWORK_WINDOW_GAME | Network game window.
WN_NETWORK_WINDOW_CONTENT_LIST | Network content list.
WN_NETWORK_WINDOW_START | Network start server.
WN_NETWORK_STATUS_WINDOW_JOIN | Network join status.
WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD | Network content download status.

## Member Function Documentation

## ◆ Close()

static void GSWindow::Close | ( | WindowClass | window,
|  | SQInteger | number
| ) |  |
| static

Close a window.

Parameters

  window | The class of the window to close.
  number | The number of the window to close, or NUMBER_ALL to close all of this class. The value will be clamped to 0 .. MAX(int32_t) when value is not NUMBER_ALL.

Precondition
  !GSGame::IsMultiplayer().

## ◆ Highlight()

static void GSWindow::Highlight | ( | WindowClass | window,
|  | SQInteger | number,
|  | SQInteger | widget,
|  | TextColour | colour
| ) |  |
| static

Highlight a widget in a window.

Parameters

  window | The class of the window to highlight a widget in.
  number | The number of the window to highlight a widget in. The value will be clamped to 0 .. MAX(int32_t) when value is not NUMBER_ALL.
  widget | The widget in the window to highlight, or WIDGET_ALL (in combination with TC_INVALID) to disable all widget highlighting on this window. The value will be clamped to 0 .. MAX(uint8_t) when value is not WIDGET_ALL.
  colour | The colour of the highlight, or TC_INVALID for disabling.

Precondition
  !GSGame::IsMultiplayer().
  number != NUMBER_ALL.
  colour < TC_END || (widget == WIDGET_ALL && colour == TC_INVALID).
  IsOpen(window, number).

## ◆ IsOpen()

static bool GSWindow::IsOpen | ( | WindowClass | window,
|  | SQInteger | number
| ) |  |
| static

Check if a window is open.

Parameters

  window | The class of the window to check for.
  number | The number of the window to check for, or NUMBER_ALL to check for any in the class. The value will be clamped to 0 .. MAX(int32_t) when value is not NUMBER_ALL.

Precondition
  !GSGame::IsMultiplayer().

Returns
  True if the window is open.