# gui.h File Reference

GUI functions that shouldn't be here. More...

`#include "vehicle_type.h"`
`#include "gfx_type.h"`
`#include "economy_type.h"`
`#include "tile_type.h"`
`#include "strings_type.h"`
`#include "transport_type.h"`

Go to the source code of this file.

## Enumerations
enum | WarningLevel { WL_INFO, WL_WARNING, WL_ERROR, WL_CRITICAL }
| Message severity/type. More...
## Functions
void | HandleOnEditText (const char *str)
void | InitializeGUI ()
void | ShowGameOptions ()
| Open the game options window.
void | ShowGameDifficulty ()
| Open the game-difficulty window.
void | ShowGameSettings ()
| Open advanced settings window.
void | DrawArrowButtons (int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
| Draw [<][>] boxes.
void | ShowOrdersWindow (const Vehicle *v)
Window * | ShowBuildDocksToolbar ()
| Open the build water toolbar window.
Window * | ShowBuildDocksScenToolbar ()
| Open the build water toolbar window for the scenario editor.
Window * | ShowBuildAirToolbar ()
| Open the build airport toolbar window.
void | ShowGenerateLandscape ()
void | ShowHeightmapLoad ()
void | ShowLandInfo (TileIndex tile)
| Show land information window.
void | ShowAboutWindow ()
void | ShowBuildTreesToolbar ()
void | ShowTownDirectory ()
void | ShowIndustryDirectory ()
void | ShowSubsidiesList ()
void | ShowEstimatedCostOrIncome (Money cost, int x, int y)
| Display estimated costs.
void | ShowErrorMessage (StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0)
| Display an error message in a window.
void | ShowExtraViewPortWindow (TileIndex tile=INVALID_TILE)
| Show a new Extra Viewport window.
void | ShowExtraViewPortWindowForTileUnderCursor ()
| Show a new Extra Viewport window.
void | ShowBuildBridgeWindow (TileIndex start, TileIndex end, TransportType transport_type, byte bridge_type)
| Prepare the data for the build a bridge window.
void | ShowBuildIndustryWindow ()
void | ShowFoundTownWindow ()
void | ShowMusicWindow ()

## Detailed Description

GUI functions that shouldn't be here.

Definition in file gui.h.

## Enumeration Type Documentation

enum WarningLevel

Message severity/type.

Enumerator:

  WL_INFO | Used for DoCommand-like (and some nonfatal AI GUI) errors/information.
  WL_WARNING | Other information.
  WL_ERROR | Errors (eg. saving/loading failed).
  WL_CRITICAL | Critical errors, the MessageBox is shown in all cases.

Definition at line 59 of file gui.h.

## Function Documentation

void DrawArrowButtons | ( | int | x,
|  | int | y,
|  | Colours | button_colour,
|  | byte | state,
|  | bool | clickable_left,
|  | bool | clickable_right |
| ) |  |  |

Draw [<][>] boxes.

Parameters:

  | x | the x position to draw
  | y | the y position to draw
  | button_colour | the colour of the button
  | state | 0 = none clicked, 1 = first clicked, 2 = second clicked
  | clickable_left | is the left button clickable?
  | clickable_right | is the right button clickable?

Definition at line 1765 of file settings_gui.cpp.

References _colour_gradient, _current_text_dir, DrawFrameRect(), DrawSprite(), FILLRECT_CHECKER, FR_LOWERED, GfxFillRect(), TD_RTL, WD_IMGBTN_LEFT, and WD_IMGBTN_TOP.

Referenced by IndustryViewWindow::DrawInfo(), SettingEntry::DrawSetting(), NewGRFParametersWindow::DrawWidget(), CheatWindow::DrawWidget(), and AISettingsWindow::DrawWidget().

Window* ShowBuildAirToolbar | ( |  | ) |

Open the build airport toolbar window.

If the terraform toolbar is linked to the toolbar, that window is also opened.

Returns:
  newly opened airport toolbar, or NULL if the toolbar could not be opened.

Definition at line 188 of file airport_gui.cpp.

References _local_company, DeleteWindowByClass(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and TRANSPORT_AIR.

Referenced by MainToolbarWindow::OnKeyPress().

void ShowBuildBridgeWindow | ( | TileIndex | start,
|  | TileIndex | end,
|  | TransportType | transport_type,
|  | byte | road_rail_type |
| ) |  |  |

Prepare the data for the build a bridge window.

If we can't build a bridge under the given conditions show an error message.

Parameters:

  | start | The start tile of the bridge
  | end | The end tile of the bridge
  | transport_type | The transport type
  | road_rail_type | The road/rail type

Definition at line 378 of file bridge_gui.cpp.

References _build_bridge_desc, _ctrl_pressed, _last_railbridge_type, _last_roadbridge_type, SmallVector< T, S >::Append(), CalcBridgeLenCostFactor(), CcBuildBridge(), CheckBridgeAvailability(), CMD_BUILD_BRIDGE, CMD_MSG, CommandFlagsToDCFlags(), DC_QUERY_COST, DeleteWindowByClass(), DoCommand(), DoCommandP(), CommandCost::Failed(), GetCommandFlags(), CommandCost::GetCost(), CommandCost::GetErrorMessage(), GetTunnelBridgeLength(), INVALID_STRING_ID, SmallVector< T, S >::Length(), MAX_BRIDGES, BridgeSpec::price, RailBuildCost(), ShowErrorMessage(), CommandCost::Succeeded(), TILE_SIZE, TileX(), TileY(), TRANSPORT_RAIL, TRANSPORT_ROAD, and WL_INFO.

Referenced by BuildRoadToolbarWindow::OnPlaceMouseUp(), and BuildRailToolbarWindow::OnPlaceMouseUp().

Window* ShowBuildDocksScenToolbar | ( |  | ) |

Open the build water toolbar window for the scenario editor.

Returns:
  newly opened water toolbar, or NULL if the toolbar could not be opened.

Definition at line 395 of file dock_gui.cpp.

References _build_docks_scen_toolbar_desc, and TRANSPORT_WATER.

Window* ShowBuildDocksToolbar | ( |  | ) |

Open the build water toolbar window.

If the terraform toolbar is linked to the toolbar, that window is also opened.

Returns:
  newly opened water toolbar, or NULL if the toolbar could not be opened.

Definition at line 345 of file dock_gui.cpp.

References _local_company, DeleteWindowByClass(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), and TRANSPORT_WATER.

Referenced by MainToolbarWindow::OnKeyPress().

void ShowErrorMessage | ( | StringID | summary_msg,
|  | StringID | detailed_msg,
|  | WarningLevel | wl,
|  | int | x,
|  | int | y |
| ) |  |  |

Display an error message in a window.

Parameters:

  | summary_msg | General error message showed in first line. Must be valid.
  | detailed_msg | Detailed error message showed in second line. Can be INVALID_STRING_ID.
  | wl | Message severity.
  | x | World X position (TileVirtX) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.
  | y | World Y position (TileVirtY) of the error location. Set both x and y to 0 to just center the message when there is no related error tile.

Definition at line 737 of file misc_gui.cpp.

References _settings_client, CC_WARNING, DeleteWindowById(), DRAW_STRING_BUFFER, GUISettings::errmsg_duration, ClientSettings::gui, IConsoleError(), IConsolePrint(), INVALID_STRING_ID, lastof, seprintf(), WL_CRITICAL, WL_INFO, and WL_WARNING.

Referenced by ClientNetworkContentSocketHandler::AfterDownload(), ClientNetworkContentSocketHandler::BeforeDownload(), CcBuildIndustry(), ChangeDynamicEngines(), ClientNetworkGameSocketHandler::CheckConnection(), CheckForMissingGlyphsInLoadedLanguagePack(), CheckForMissingSprites(), CheckTrainsLengths(), AIInstance::Died(), DoAutosave(), DoCommandP(), IndustryProductionCallback(), MakeScreenshot(), FoundTownWindow::OnClick(), TownViewWindow::OnClick(), GameDifficultyWindow::OnClick(), GameOptionsWindow::OnClick(), NewGRFWindow::OnClick(), SelectGameWindow::OnClick(), BuildIndustryWindow::OnClick(), SaveLoadWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), AIConfigWindow::OnClick(), NetworkContentListWindow::OnConnect(), BuildIndustryWindow::OnPlaceObject(), SelectCompanyManagerFaceWindow::OnQueryTextFinished(), SaveLoadWindow::OnTimeout(), ReadHeightmapBMP(), ReadHeightmapPNG(), SaveFileError(), SaveOrLoad(), ShowAIDebugWindow(), ShowBuildBridgeWindow(), ShowEstimatedCostOrIncome(), ShowNetworkContentListWindow(), ShowNewGRFError(), ShowNewGrfVehicleError(), and WarnCorruptSprite().

void ShowEstimatedCostOrIncome | ( | Money | cost,
|  | int | x,
|  | int | y |
| ) |  |  |

Display estimated costs.

Parameters:

  | cost | Estimated cost (or income if negative).
  | x | X position of the notification window.
  | y | Y position of the notification window.

Definition at line 771 of file misc_gui.cpp.

References INVALID_STRING_ID, SetDParam(), ShowErrorMessage(), and WL_INFO.

Referenced by DoCommandP().

void ShowExtraViewPortWindow | ( | TileIndex | tile | ) |

Show a new Extra Viewport window.

Parameters:

  | tile | Tile to center the view on. INVALID_TILE means to use the center of main viewport.

Definition at line 175 of file viewport_gui.cpp.

References FindWindowById().

Referenced by WaypointWindow::OnClick(), TownDirectoryWindow::OnClick(), TownViewWindow::OnClick(), StationViewWindow::OnClick(), CompanyStationsWindow::OnClick(), NewsWindow::OnClick(), IndustryDirectoryWindow::OnClick(), IndustryViewWindow::OnClick(), DepotWindow::OnClick(), CompanyWindow::OnClick(), and ShowExtraViewPortWindowForTileUnderCursor().

void ShowExtraViewPortWindowForTileUnderCursor | ( |  | ) |

Show a new Extra Viewport window.

Center it on the tile under the cursor, if the cursor is inside a viewport. If that fails, center it on main viewport center.

Definition at line 190 of file viewport_gui.cpp.

References INVALID_TILE, and ShowExtraViewPortWindow().

Referenced by ScenarioEditorToolbarWindow::OnKeyPress(), and MainToolbarWindow::OnKeyPress().

void ShowGameDifficulty | ( |  | ) |

Open the game-difficulty window.

Definition at line 841 of file settings_gui.cpp.

References _game_difficulty_desc, and DeleteWindowById().

Referenced by SelectGameWindow::OnClick().

void ShowGameOptions | ( |  | ) |

Open the game options window.

Definition at line 558 of file settings_gui.cpp.

References DeleteWindowById().

Referenced by SelectGameWindow::OnClick(), ScenarioEditorToolbarWindow::OnKeyPress(), and MainToolbarWindow::OnKeyPress().

void ShowGameSettings | ( |  | ) |

Open advanced settings window.

Definition at line 1749 of file settings_gui.cpp.

References DeleteWindowById().

Referenced by SelectGameWindow::OnClick().

void ShowLandInfo | ( | TileIndex | tile | ) |

Show land information window.

Parameters:

  | tile | The tile to show information about.

Definition at line 355 of file misc_gui.cpp.

References DeleteWindowById().

Referenced by ScenarioEditorToolbarWindow::OnPlaceObject(), and MainToolbarWindow::OnPlaceObject().