OpenTTD Source: src/gfx_func.h File Reference

OpenTTD Source 15.0-RC2

Functions | Variables
gfx_func.h File Reference

Functions related to the gfx engine. More...

`#include "gfx_type.h"`
`#include "strings_type.h"`
`#include "string_type.h"`

Go to the source code of this file.

## Functions
void | GameLoop ()
void | CreateConsole ()
void | HandleToolbarHotkey (int hotkey)
| Handle Toolbar hotkey events - can come from a source like the MacBook Touch Bar.
void | HandleKeypress (uint keycode, char32_t key)
| Handle keyboard input.
void | HandleTextInput (std::string_view str, bool marked=false, std::optional< size_t > caret=std::nullopt, std::optional< size_t > insert_location=std::nullopt, std::optional< size_t > replacement_end=std::nullopt)
| Handle text input.
void | HandleCtrlChanged ()
| State of CONTROL key has changed.
void | HandleMouseEvents ()
| Handle a mouse event from the video driver.
void | UpdateWindows ()
| Update the continuously changing contents of the windows, such as the viewports.
void | ChangeGameSpeed (bool enable_fast_forward)
void | DrawMouseCursor ()
void | ScreenSizeChanged ()
void | GameSizeChanged ()
| Size of the application screen changed.
void | UpdateGUIZoom ()
| Resolve GUI zoom level, if auto-suggestion is requested.
bool | AdjustGUIZoom (bool automatic)
| Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
void | UndrawMouseCursor ()
void | RedrawScreenRect (int left, int top, int right, int bottom)
| Repaints a specific rectangle of the screen.
void | GfxScroll (int left, int top, int width, int height, int xo, int yo)
Dimension | GetSpriteSize (SpriteID sprid, Point *offset=nullptr, ZoomLevel zoom=_gui_zoom)
| Get the size of a sprite.
Dimension | GetScaledSpriteSize (SpriteID sprid)
| Scale sprite size for GUI.
void | DrawSpriteViewport (SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub=nullptr)
| Draw a sprite in a viewport.
void | DrawSprite (SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub=nullptr, ZoomLevel zoom=_gui_zoom)
| Draw a sprite, not in a viewport.
void | DrawSpriteIgnorePadding (SpriteID img, PaletteID pal, const Rect &r, StringAlignment align)
std::unique_ptr< uint32_t[]> | DrawSpriteToRgbaBuffer (SpriteID spriteId, ZoomLevel zoom=_gui_zoom)
| Draws a sprite to a new RGBA buffer (see Colour union) instead of drawing to the screen.
int | DrawString (int left, int right, int top, std::string_view str, TextColour colour=TC_FROMSTRING, StringAlignment align=SA_LEFT, bool underline=false, FontSize fontsize=FS_NORMAL)
| Draw string, possibly truncated to make it fit in its allocated space.
int | DrawString (int left, int right, int top, StringID str, TextColour colour=TC_FROMSTRING, StringAlignment align=SA_LEFT, bool underline=false, FontSize fontsize=FS_NORMAL)
| Draw string, possibly truncated to make it fit in its allocated space.
int | DrawStringMultiLine (int left, int right, int top, int bottom, std::string_view str, TextColour colour=TC_FROMSTRING, StringAlignment align=(SA_TOP|SA_LEFT), bool underline=false, FontSize fontsize=FS_NORMAL)
| Draw string, possibly over multiple lines.
int | DrawStringMultiLine (int left, int right, int top, int bottom, StringID str, TextColour colour=TC_FROMSTRING, StringAlignment align=(SA_TOP|SA_LEFT), bool underline=false, FontSize fontsize=FS_NORMAL)
| Draw string, possibly over multiple lines.
bool | DrawStringMultiLineWithClipping (int left, int right, int top, int bottom, std::string_view str, TextColour colour=TC_FROMSTRING, StringAlignment align=(SA_TOP|SA_LEFT), bool underline=false, FontSize fontsize=FS_NORMAL)
| Draw a multiline string, possibly over multiple lines, if the region is within the current display clipping area.
void | DrawCharCentered (char32_t c, const Rect &r, TextColour colour)
| Draw single character horizontally centered around (x,y)
void | GfxFillRect (int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode=FILLRECT_OPAQUE)
| Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
void | GfxFillPolygon (std::span< const Point > shape, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode=FILLRECT_OPAQUE)
| Fill a polygon with colour.
void | GfxDrawLine (int left, int top, int right, int bottom, PixelColour colour, int width=1, int dash=0)
void | DrawBox (int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3)
| Draws the projection of a parallelepiped.
void | DrawRectOutline (const Rect &r, PixelColour colour, int width=1, int dash=0)
| Draw the outline of a Rect.
int | DrawString (const Rect &r, std::string_view str, TextColour colour=TC_FROMSTRING, StringAlignment align=SA_LEFT, bool underline=false, FontSize fontsize=FS_NORMAL)
int | DrawString (const Rect &r, StringID str, TextColour colour=TC_FROMSTRING, StringAlignment align=SA_LEFT, bool underline=false, FontSize fontsize=FS_NORMAL)
int | DrawStringMultiLine (const Rect &r, std::string_view str, TextColour colour=TC_FROMSTRING, StringAlignment align=(SA_TOP|SA_LEFT), bool underline=false, FontSize fontsize=FS_NORMAL)
int | DrawStringMultiLine (const Rect &r, StringID str, TextColour colour=TC_FROMSTRING, StringAlignment align=(SA_TOP|SA_LEFT), bool underline=false, FontSize fontsize=FS_NORMAL)
bool | DrawStringMultiLineWithClipping (const Rect &r, std::string_view str, TextColour colour=TC_FROMSTRING, StringAlignment align=(SA_TOP|SA_LEFT), bool underline=false, FontSize fontsize=FS_NORMAL)
void | GfxFillRect (const Rect &r, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode=FILLRECT_OPAQUE)
Dimension | GetStringBoundingBox (std::string_view str, FontSize start_fontsize=FS_NORMAL)
| Return the string dimension in pixels.
Dimension | GetStringBoundingBox (StringID strid, FontSize start_fontsize=FS_NORMAL)
| Get bounding box of a string.
uint | GetStringListWidth (std::span< const StringID > list, FontSize fontsize=FS_NORMAL)
| Get maximum width of a list of strings.
Dimension | GetStringListBoundingBox (std::span< const StringID > list, FontSize fontsize=FS_NORMAL)
| Get maximum dimension of a list of strings.
int | GetStringHeight (std::string_view str, int maxw, FontSize fontsize=FS_NORMAL)
| Calculates height of string (in pixels).
int | GetStringHeight (StringID str, int maxw)
| Calculates height of string (in pixels).
int | GetStringLineCount (std::string_view str, int maxw)
| Calculates number of lines of string.
Dimension | GetStringMultiLineBoundingBox (StringID str, const Dimension &suggestion)
| Calculate string bounding box for multi-line strings.
Dimension | GetStringMultiLineBoundingBox (std::string_view str, const Dimension &suggestion, FontSize fontsize=FS_NORMAL)
| Calculate string bounding box for multi-line strings.
void | LoadStringWidthTable (FontSizes fontsizes=FONTSIZES_REQUIRED)
| Initialize _stringwidth_table cache for the specified font sizes.
void | DrawDirtyBlocks ()
| Repaints the rectangle blocks which are marked as 'dirty'.
void | AddDirtyBlock (int left, int top, int right, int bottom)
| Extend the internal _invalid_rect rectangle to contain the rectangle defined by the given parameters.
void | MarkWholeScreenDirty ()
| This function mark the whole screen as dirty.
void | CheckBlitter ()
| Check whether we still use the right blitter, or use another (better) one.
bool | FillDrawPixelInfo (DrawPixelInfo *n, int left, int top, int width, int height)
| Set up a clipping area for only drawing into a certain area.
bool | FillDrawPixelInfo (DrawPixelInfo *n, const Rect &r)
void | DrawOverlappedWindowForAll (int left, int top, int right, int bottom)
| From a rectangle that needs redrawing, find the windows that intersect with the rectangle.
void | SetMouseCursorBusy (bool busy)
| Set or unset the ZZZ cursor.
void | SetMouseCursor (CursorID cursor, PaletteID pal)
| Assign a single non-animated sprite to the cursor.
void | SetAnimatedMouseCursor (std::span< const AnimCursor > table)
| Assign an animation to the cursor.
void | CursorTick ()
void | UpdateCursorSize ()
| Update cursor dimension.
bool | ChangeResInGame (int w, int h)
void | SortResolutions ()
bool | ToggleFullScreen (bool fs)
uint8_t | GetCharacterWidth (FontSize size, char32_t key)
| Return width of character glyph.
uint8_t | GetDigitWidth (FontSize size=FS_NORMAL)
| Return the maximum width of single digit.
std::pair< uint8_t, uint8_t > | GetBroadestDigit (FontSize size)
| Determine the broadest digits for guessing the maximum width of a n-digit number.
int | GetCharacterHeight (FontSize size)
| Get height of a character for a given font size.

## Variables
uint8_t | _dirkeys
| 1 = left, 2 = up, 4 = right, 8 = down
bool | _fullscreen
uint8_t | _support8bpp
CursorVars | _cursor
bool | _ctrl_pressed
| Is Ctrl pressed?
bool | _shift_pressed
| Is Shift pressed?
uint16_t | _game_speed
| Current game-speed; 100 is 1x, 0 is infinite.
bool | _left_button_down
| Is left mouse button pressed?
bool | _left_button_clicked
| Is left mouse button clicked?
bool | _right_button_down
| Is right mouse button pressed?
bool | _right_button_clicked
| Is right mouse button clicked?
DrawPixelInfo | _screen
bool | _screen_disable_anim
| Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
std::vector< Dimension > | _resolutions
| List of resolutions.
Dimension | _cur_resolution
| The current resolution.
Palette | _cur_palette
| Current palette.
DrawPixelInfo * | _cur_dpi

## Detailed Description

Functions related to the gfx engine.

Definition in file gfx_func.h.

## Function Documentation

## ◆ AdjustGUIZoom()

bool AdjustGUIZoom | ( | bool | automatic | ) |

Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.

Parameters

  automatic | Set if the change is occurring due to OS DPI scaling being changed.

Returns
  true when the zoom level has changed, caller must call ReInitAllWindows(true) after resizing the application's window/buffer.

Definition at line 1815 of file gfx.cpp.

References _font_zoom, _gui_scale, _gui_zoom, _settings_client, Clamp(), FontCache::ClearFontCaches(), VideoDriver::ClearSystemSprites(), FONTSIZES_ALL, VideoDriver::GetInstance(), GfxClearFontSpriteCache(), ClientSettings::gui, LoadStringWidthTable(), SetupWidgetDimensions(), UpdateAllVirtCoords(), UpdateCursorSize(), UpdateGUIZoom(), GUISettings::zoom_max, and GUISettings::zoom_min.

Referenced by GameOptionsWindow::OnClick(), and GameOptionsWindow::OnMouseLoop().

## ◆ ChangeGameSpeed()

void ChangeGameSpeed | ( | bool | enable_fast_forward | ) |

Definition at line 1853 of file gfx.cpp.

## ◆ ChangeResInGame()

bool ChangeResInGame | ( | int | w,
|  | int | h
| ) |  |

Definition at line 1761 of file gfx.cpp.

## ◆ CheckBlitter()

void CheckBlitter | ( |  | ) |

Check whether we still use the right blitter, or use another (better) one.

Definition at line 325 of file gfxinit.cpp.

References FontCache::ClearFontCaches(), FONTSIZES_ALL, GfxClearSpriteCache(), ReInitAllWindows(), and SwitchNewGRFBlitter().

Referenced by MenuClickSettings(), and GameOptionsWindow::OnDropdownSelect().

## ◆ CreateConsole()

void CreateConsole | ( |  | ) |

Definition at line 110 of file win32.cpp.

## ◆ CursorTick()

void CursorTick | ( |  | ) |

Definition at line 1676 of file gfx.cpp.

## ◆ DrawBox()

void DrawBox | ( | int | x,
|  | int | y,
|  | int | dx1,
|  | int | dy1,
|  | int | dx2,
|  | int | dy2,
|  | int | dx3,
|  | int | dy3
| ) |  |

Draws the projection of a parallelepiped.

This can be used to draw boxes in world coordinates.

Parameters

  x | Screen X-coordinate of top front corner.
  y | Screen Y-coordinate of top front corner.
  dx1 | Screen X-length of first edge.
  dy1 | Screen Y-length of first edge.
  dx2 | Screen X-length of second edge.
  dy2 | Screen Y-length of second edge.
  dx3 | Screen X-length of third edge.
  dy3 | Screen Y-length of third edge.

Definition at line 422 of file gfx.cpp.

References PC_WHITE.

Referenced by ViewportDrawBoundingBoxes().

## ◆ DrawCharCentered()

void DrawCharCentered | ( | char32_t | c,
|  | const Rect & | r,
|  | TextColour | colour
| ) |  |

Draw single character horizontally centered around (x,y)

Parameters

  c | Character (glyph) to draw
  r | Rectangle to draw character within
  colour | Colour to use, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h

Definition at line 948 of file gfx.cpp.

References CentreBounds(), ColourRemap, FS_NORMAL, GetCharacterHeight(), GetCharacterWidth(), GetGlyph(), and SetColourRemap().

Referenced by OskWindow::DrawWidget().

## ◆ DrawMouseCursor()

void DrawMouseCursor | ( |  | ) |

Definition at line 1349 of file gfx.cpp.

## ◆ DrawOverlappedWindowForAll()

void DrawOverlappedWindowForAll | ( | int | left,
|  | int | top,
|  | int | right,
|  | int | bottom
| ) |  |

From a rectangle that needs redrawing, find the windows that intersect with the rectangle.

These windows should be re-painted.

Parameters

  left | Left edge of the rectangle that should be repainted
  top | Top edge of the rectangle that should be repainted
  right | Right edge of the rectangle that should be repainted
  bottom | Bottom edge of the rectangle that should be repainted

Definition at line 945 of file window.cpp.

References DrawOverlappedWindow(), and MayBeShown().

Referenced by RedrawScreenRect().

## ◆ DrawRectOutline()

void DrawRectOutline | ( | const Rect & | r,
|  | PixelColour | colour,
|  | int | width,
|  | int | dash
| ) |  |

Draw the outline of a Rect.

Parameters

  r | Rect to draw.
  colour | Colour of the outline.
  width | Width of the outline.
  dash | Length of dashes for dashed lines. 0 means solid lines.

Definition at line 460 of file gfx.cpp.

Referenced by CargoesField::Draw(), and SpriteAlignerWindow::DrawWidget().

## ◆ DrawSprite()

void DrawSprite | ( | SpriteID | img,
|  | PaletteID | pal,
|  | int | x,
|  | int | y,
|  | const SubSprite * | sub,
|  | ZoomLevel | zoom
| ) |  |

Draw a sprite, not in a viewport.

Parameters

  img | Image number to draw
  pal | Palette to use.
  x | Left coordinate of image in pixels
  y | Top coordinate of image in pixels
  sub | If available, draw only specified part of the sprite
  zoom | Zoom level of sprite

Definition at line 1031 of file gfx.cpp.

References GB(), GetBlitterMode(), HasBit(), Normal, PALETTE_MODIFIER_TRANSPARENT, PALETTE_TEXT_RECOLOUR, PALETTE_TO_TRANSPARENT, PALETTE_WIDTH, Recolour, SetColourRemap(), SPRITE_WIDTH, Transparent, and TransparentRemap.

Referenced by VehicleSpriteSeq::Draw(), StoryBookWindow::DrawActionElement(), DrawCargoIconOverlay(), StationViewWindow::DrawCargoIcons(), DrawCloseBox(), DrawCommonTileSeqInGUI(), DrawCompanyIcon(), DrawCompanyManagerFace(), DrawHouseInGUI(), DrawNewHouseTileInGUI(), DrawNewObjectTileInGUI(), DrawOrderString(), TownAuthorityWindow::DrawRatings(), DrawRoadDepotSprite(), DrawRoadStopTile(), SettingsPage::DrawSetting(), BuildSignalWindow::DrawSignalSprite(), DrawStationTile(), BaseVehicleListWindow::DrawVehicleListItems(), DrawVehicleProfitButton(), DrawVehicleRefitWindow(), BuildAirportWindow::DrawWidget(), SelectCompanyLiveryWindow::DrawWidget(), CompanyWindow::DrawWidget(), SpriteAlignerWindow::DrawWidget(), NewGRFWindow::DrawWidget(), PickerWindow::DrawWidget(), StatusBarWindow::DrawWidget(), ScenarioEditorLandscapeGenerationWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), TransparenciesWindow::DrawWidget(), BuildTreesWindow::DrawWidget(), and MainWindow::OnPaint().

## ◆ DrawSpriteIgnorePadding()

void DrawSpriteIgnorePadding | ( | SpriteID | img,
|  | PaletteID | pal,
|  | const Rect & | r,
|  | StringAlignment | align
| ) |  |

Definition at line 324 of file widget.cpp.

## ◆ DrawSpriteToRgbaBuffer()

std::unique_ptr< uint32_t[]> DrawSpriteToRgbaBuffer | ( | SpriteID | spriteId,
|  | ZoomLevel | zoom
| ) |  |

Draws a sprite to a new RGBA buffer (see Colour union) instead of drawing to the screen.

Parameters

  spriteId | The sprite to draw.
  zoom | The zoom level at which to draw the sprites.

Returns
  Pixel buffer, or nullptr if an 8bpp blitter is being used.

Definition at line 1187 of file gfx.cpp.

References _cur_palette, _screen_disable_anim, _settings_client, GB(), BlitterFactory::GetCurrentBlitter(), Blitter::GetScreenDepth(), GetSpriteSize(), ClientSettings::gui, Normal, Palette::palette, Backup< T >::Restore(), SPRITE_WIDTH, and GUISettings::zoom_max.

## ◆ DrawSpriteViewport()

void DrawSpriteViewport | ( | SpriteID | img,
|  | PaletteID | pal,
|  | int | x,
|  | int | y,
|  | const SubSprite * | sub
| ) |  |

Draw a sprite in a viewport.

Parameters

  img | Image number to draw
  pal | Palette to use.
  x | Left coordinate of image in viewport, scaled by zoom
  y | Top coordinate of image in viewport, scaled by zoom
  sub | If available, draw only specified part of the sprite

Definition at line 1003 of file gfx.cpp.

References GB(), GetBlitterMode(), HasBit(), Normal, PALETTE_MODIFIER_TRANSPARENT, PALETTE_TEXT_RECOLOUR, PALETTE_TO_TRANSPARENT, PALETTE_WIDTH, Recolour, SetColourRemap(), SPRITE_WIDTH, Transparent, and TransparentRemap.

## ◆ DrawString() [1/4]

int DrawString | ( | const Rect & | r,
|  | std::string_view | str,
|  | TextColour | colour = `TC_FROMSTRING`,
|  | StringAlignment | align = `SA_LEFT`,
|  | bool | underline = `false`,
|  | FontSize | fontsize = `FS_NORMAL`
| ) |  |
| inline

Definition at line 113 of file gfx_func.h.

## ◆ DrawString() [2/4]

int DrawString | ( | const Rect & | r,
|  | StringID | str,
|  | TextColour | colour = `TC_FROMSTRING`,
|  | StringAlignment | align = `SA_LEFT`,
|  | bool | underline = `false`,
|  | FontSize | fontsize = `FS_NORMAL`
| ) |  |
| inline

Definition at line 118 of file gfx_func.h.

## ◆ DrawString() [3/4]

int DrawString | ( | int | left,
|  | int | right,
|  | int | top,
|  | std::string_view | str,
|  | TextColour | colour,
|  | StringAlignment | align,
|  | bool | underline,
|  | FontSize | fontsize
| ) |  |

Draw string, possibly truncated to make it fit in its allocated space.

Parameters

  left | The left most position to draw on.
  right | The right most position to draw on.
  top | The top most position to draw on.
  str | String to draw.
  colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
  align | The alignment of the string when drawing left-to-right. In the case a right-to-left language is chosen this is inverted so it will be drawn in the right direction.
  underline | Whether to underline what has been drawn or not.
  fontsize | The size of the initial characters.

Returns
  In case of left or center alignment the right most pixel we have drawn to. In case of right alignment the left most pixel we have drawn to.

Definition at line 665 of file gfx.cpp.

References DrawLayoutLine(), FS_LARGE, FS_MONO, FS_NORMAL, FS_SMALL, and GetCharacterHeight().

Referenced by CargoesField::Draw(), CompanyButtonLine::Draw(), ClientButtonLine::Draw(), StoryBookWindow::DrawActionElement(), TownAuthorityWindow::DrawActions(), DrawAircraftDetails(), DrawAircraftPurchaseInfo(), TimetableWindow::DrawArrivalDeparturePanel(), DrawButtonDropdown(), DrawCaption(), StationViewWindow::DrawCargoRatings(), DrawCategories(), DrawCategory(), NetworkContentListWindow::DrawDetails(), FramerateWindow::DrawElementTimesColumn(), DrawEngineList(), StationViewWindow::DrawEntries(), DrawFrame(), BaseGraphWindow::DrawGraph(), VehicleGroupWindow::DrawGroupInfo(), DrawImageTextButtons(), SmallMapWindow::DrawIndustryNames(), IndustryViewWindow::DrawInfo(), DrawInset(), DrawLabel(), GoalListWindow::DrawListColumn(), NetworkContentListWindow::DrawMatrix(), DrawNewsString(), DrawOrderString(), DrawPrice(), TownAuthorityWindow::DrawRatings(), DrawRoadVehDetails(), NetworkGameWindow::DrawServerLine(), SettingEntry::DrawSetting(), SettingsPage::DrawSetting(), DrawShipDetails(), DrawSliderWidget(), DrawSmallOrderList(), DrawString(), TimetableWindow::DrawSummaryPanel(), DrawText(), TimetableWindow::DrawTimetablePanel(), SmallMapWindow::DrawTowns(), DrawTrainDetails(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), DrawVehiclePurchaseInfo(), DrawVehicleRefitWindow(), AIConfigWindow::DrawWidget(), BuildAirportWindow::DrawWidget(), ReplaceVehicleWindow::DrawWidget(), SelectCompanyLiveryWindow::DrawWidget(), SelectCompanyManagerFaceWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), EnginePreviewWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), FramerateWindow::DrawWidget(), FrametimeGraphWindow::DrawWidget(), GSConfigWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), BaseGraphWindow::DrawWidget(), BaseCargoGraphWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), PerformanceLeagueWindow::DrawWidget(), ScriptLeagueWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), LandInfoWindow::DrawWidget(), AboutWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), MusicWindow::DrawWidget(), BaseNetworkContentDownloadStatusWindow::DrawWidget(), NetworkStartServerWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), SpriteAlignerWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), NewGRFWindow::DrawWidget(), SavePresetWindow::DrawWidget(), ScanProgressWindow::DrawWidget(), MessageHistoryWindow::DrawWidget(), OrdersWindow::DrawWidget(), PickerWindow::DrawWidget(), ScriptListWindow::DrawWidget(), ScriptSettingsWindow::DrawWidget(), GameOptionsWindow::DrawWidget(), SignListWindow::DrawWidget(), SmallMapWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), SelectStationWindow< T >::DrawWidget(), StatusBarWindow::DrawWidget(), StoryBookWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), TextfileWindow::DrawWidget(), ScenarioEditorToolbarWindow::DrawWidget(), TownViewWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), VehicleDetailsWindow::DrawWidget(), VehicleViewWindow::DrawWidget(), ScriptDebugWindow::DrawWidgetLog(), DrawYearColumn(), BuildAirportWindow::OnPaint(), IConsoleWindow::OnPaint(), HighScoreWindow::OnPaint(), MainWindow::OnPaint(), StationsWndShowStationRating(), TrainDetailsCapacityTab(), TrainDetailsCargoTab(), and TrainDetailsInfoTab().

## ◆ DrawString() [4/4]

int DrawString | ( | int | left,
|  | int | right,
|  | int | top,
|  | StringID | str,
|  | TextColour | colour,
|  | StringAlignment | align,
|  | bool | underline,
|  | FontSize | fontsize
| ) |  |

Draw string, possibly truncated to make it fit in its allocated space.

Parameters

  left | The left most position to draw on.
  right | The right most position to draw on.
  top | The top most position to draw on.
  str | String to draw.
  colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
  align | The alignment of the string when drawing left-to-right. In the case a right-to-left language is chosen this is inverted so it will be drawn in the right direction.
  underline | Whether to underline what has been drawn or not.
  fontsize | The size of the initial characters.

Returns
  In case of left or center alignment the right most pixel we have drawn to. In case of right alignment the left most pixel we have drawn to.

Definition at line 701 of file gfx.cpp.

References DrawString(), and GetString().

## ◆ DrawStringMultiLine() [1/4]

int DrawStringMultiLine | ( | const Rect & | r,
|  | std::string_view | str,
|  | TextColour | colour = `TC_FROMSTRING`,
|  | StringAlignment | align = `(SA_TOP | SA_LEFT)`,
|  | bool | underline = `false`,
|  | FontSize | fontsize = `FS_NORMAL`
| ) |  |
| inline

Definition at line 123 of file gfx_func.h.

## ◆ DrawStringMultiLine() [2/4]

int DrawStringMultiLine | ( | const Rect & | r,
|  | StringID | str,
|  | TextColour | colour = `TC_FROMSTRING`,
|  | StringAlignment | align = `(SA_TOP | SA_LEFT)`,
|  | bool | underline = `false`,
|  | FontSize | fontsize = `FS_NORMAL`
| ) |  |
| inline

Definition at line 128 of file gfx_func.h.

## ◆ DrawStringMultiLine() [3/4]

int DrawStringMultiLine | ( | int | left,
|  | int | right,
|  | int | top,
|  | int | bottom,
|  | std::string_view | str,
|  | TextColour | colour,
|  | StringAlignment | align,
|  | bool | underline,
|  | FontSize | fontsize
| ) |  |

Draw string, possibly over multiple lines.

Parameters

  left | The left most position to draw on.
  right | The right most position to draw on.
  top | The top most position to draw on.
  bottom | The bottom most position to draw on.
  str | String to draw.
  colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
  align | The horizontal and vertical alignment of the string.
  underline | Whether to underline all strings
  fontsize | The size of the initial characters.

Returns
  If align is SA_BOTTOM, the top to where we have written, else the bottom to where we have written.

Definition at line 782 of file gfx.cpp.

References DrawLayoutLine(), Layouter::GetBounds(), RoundDivSU(), SA_BOTTOM, SA_TOP, SA_VERT_CENTER, and SA_VERT_MASK.

Referenced by StationViewWindow::DrawAcceptedCargo(), DrawBadgeNameList(), StationViewWindow::DrawCargoRatings(), NetworkContentListWindow::DrawDetails(), IndustryViewWindow::DrawInfo(), DrawStationCoverageAreaText(), DrawStringMultiLine(), DrawStringMultiLineWithClipping(), BuildAirportWindow::DrawWidget(), BootstrapErrorWindow::DrawWidget(), BootstrapAskForDownloadWindow::DrawWidget(), CompanyWindow::DrawWidget(), BuyCompanyWindow::DrawWidget(), EnginePreviewWindow::DrawWidget(), GoalQuestionWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), SelectGameWindow::DrawWidget(), ScriptLeagueWindow::DrawWidget(), LandInfoWindow::DrawWidget(), TooltipsWindow::DrawWidget(), QueryWindow::DrawWidget(), BaseNetworkContentDownloadStatusWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), NetworkAskRelayWindow::DrawWidget(), NetworkAskSurveyWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), NewsWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), ScriptListWindow::DrawWidget(), GameOptionsWindow::DrawWidget(), StoryBookWindow::DrawWidget(), TownAuthorityWindow::DrawWidget(), TownViewWindow::DrawWidget(), BuildHouseWindow::DrawWidget(), RefitWindow::DrawWidget(), NetworkDrawChatMessage(), IConsoleWindow::OnPaint(), EndGameWindow::OnPaint(), HighScoreWindow::OnPaint(), ShowAdditionalText(), and ShowRefitOptionsList().

## ◆ DrawStringMultiLine() [4/4]

int DrawStringMultiLine | ( | int | left,
|  | int | right,
|  | int | top,
|  | int | bottom,
|  | StringID | str,
|  | TextColour | colour,
|  | StringAlignment | align,
|  | bool | underline,
|  | FontSize | fontsize
| ) |  |

Draw string, possibly over multiple lines.

Parameters

  left | The left most position to draw on.
  right | The right most position to draw on.
  top | The top most position to draw on.
  bottom | The bottom most position to draw on.
  str | String to draw.
  colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
  align | The horizontal and vertical alignment of the string.
  underline | Whether to underline all strings
  fontsize | The size of the initial characters.

Returns
  If align is SA_BOTTOM, the top to where we have written, else the bottom to where we have written.

Definition at line 844 of file gfx.cpp.

References DrawStringMultiLine(), and GetString().

## ◆ DrawStringMultiLineWithClipping() [1/2]

bool DrawStringMultiLineWithClipping | ( | const Rect & | r,
|  | std::string_view | str,
|  | TextColour | colour = `TC_FROMSTRING`,
|  | StringAlignment | align = `(SA_TOP | SA_LEFT)`,
|  | bool | underline = `false`,
|  | FontSize | fontsize = `FS_NORMAL`
| ) |  |
| inline

Definition at line 133 of file gfx_func.h.

## ◆ DrawStringMultiLineWithClipping() [2/2]

bool DrawStringMultiLineWithClipping | ( | int | left,
|  | int | right,
|  | int | top,
|  | int | bottom,
|  | std::string_view | str,
|  | TextColour | colour,
|  | StringAlignment | align,
|  | bool | underline,
|  | FontSize | fontsize
| ) |  |

Draw a multiline string, possibly over multiple lines, if the region is within the current display clipping area.

Note
  With clipping, it is not possible to determine how tall the rendered text will be, as it's not layouted. Regular DrawStringMultiLine must be used if the height needs to be known.

Parameters

  left | The left most position to draw on.
  right | The right most position to draw on.
  top | The top most position to draw on.
  bottom | The bottom most position to draw on.
  str | String to draw.
  colour | Colour used for drawing the string, for details see _string_colourmap in table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h
  align | The horizontal and vertical alignment of the string.
  underline | Whether to underline all strings
  fontsize | The size of the initial characters.

Returns
  true iff the string was drawn.

Definition at line 867 of file gfx.cpp.

References DrawStringMultiLine(), FS_LARGE, FS_MONO, FS_NORMAL, FS_SMALL, and GetCharacterHeight().

Referenced by BaseGraphWindow::DrawGraph(), BuildBridgeWindow::DrawWidget(), ErrmsgWindow::DrawWidget(), StoryBookWindow::DrawWidget(), TextfileWindow::DrawWidget(), and GameOptionsWindow::OnPaint().

## ◆ FillDrawPixelInfo() [1/2]

bool FillDrawPixelInfo | ( | DrawPixelInfo * | n,
|  | const Rect & | r
| ) |  |
| inline

Definition at line 162 of file gfx_func.h.

## ◆ FillDrawPixelInfo() [2/2]

bool FillDrawPixelInfo | ( | DrawPixelInfo * | n,
|  | int | left,
|  | int | top,
|  | int | width,
|  | int | height
| ) |  |

Set up a clipping area for only drawing into a certain area.

To do this, Fill a DrawPixelInfo object with the supplied relative rectangle, backup the original (calling) _cur_dpi and assign the just returned DrawPixelInfo _cur_dpi. When you are done, give restore _cur_dpi's original value

Parameters

  *n | the DrawPixelInfo that will be the clipping rectangle box allowed for drawing
  left,top,width,height | the relative coordinates of the clipping rectangle relative to the current _cur_dpi. This will most likely be the offset from the calling window coordinates

Returns
  return false if the requested rectangle is not possible with the current dpi pointer. Only continue of the return value is true, or you'll get some nasty results

Definition at line 1565 of file gfx.cpp.

References BlitterFactory::GetCurrentBlitter(), Min, and Blitter::MoveTo().

Referenced by NWidgetMatrix::Draw(), NWidgetLeaf::Draw(), DrawRoadVehImage(), DrawTrainImage(), BuildDocksDepotWindow::DrawWidget(), DropdownWindow::DrawWidget(), IndustryDirectoryWindow::DrawWidget(), IndustryCargoesWindow::DrawWidget(), SpriteAlignerWindow::DrawWidget(), BuildObjectWindow::DrawWidget(), PickerWindow::DrawWidget(), BuildRailStationWindow::DrawWidget(), BuildRailDepotWindow::DrawWidget(), BuildRoadDepotWindow::DrawWidget(), BuildRoadStationWindow::DrawWidget(), GameOptionsWindow::DrawWidget(), SmallMapWindow::DrawWidget(), StoryBookWindow::DrawWidget(), TextfileWindow::DrawWidget(), and ScriptDebugWindow::DrawWidgetLog().

## ◆ GameLoop()

void GameLoop | ( |  | ) |

Definition at line 1336 of file openttd.cpp.

## ◆ GameSizeChanged()

void GameSizeChanged | ( |  | ) |

Size of the application screen changed.

Adapt the game screen-size, re-allocate the open windows, and repaint everything

Definition at line 596 of file main_gui.cpp.

References _cur_resolution, MarkWholeScreenDirty(), and RelocateAllWindows().

Referenced by VideoDriver_SDL_Base::ClientSizeChanged(), and VideoDriver_Win32Base::MakeWindow().

## ◆ GetBroadestDigit()

std::pair< uint8_t, uint8_t > GetBroadestDigit | ( | FontSize | size | ) |

Determine the broadest digits for guessing the maximum width of a n-digit number.

Parameters

  size | Font of the digit

Returns
  Broadest digits, first which is not 0 (use this digit as first digit for numbers with more than one digit.), second including 0 (use this digit for all digits, except the first one; or for numbers with only one digit.)

Definition at line 1299 of file gfx.cpp.

References GetCharacterWidth().

Referenced by GetParamMaxDigits().

## ◆ GetCharacterHeight()

int GetCharacterHeight | ( | FontSize | size | ) |

Get height of a character for a given font size.

Parameters

  size | Font size to get height of

Returns
  Height of characters in the given font (pixels)

Definition at line 87 of file fontcache.cpp.

References FontCache::Get(), and FontCache::GetHeight().

Referenced by CargoesField::CargoClickedAt(), CargoesField::CargoLabelClickedAt(), CheckClickOnViewportSign(), CargoesField::Draw(), CompanyButtonLine::Draw(), ClientButtonLine::Draw(), StationViewWindow::DrawAcceptedCargo(), TownAuthorityWindow::DrawActions(), DrawAircraftDetails(), DrawAircraftPurchaseInfo(), TimetableWindow::DrawArrivalDeparturePanel(), DrawButtonDropdown(), StationViewWindow::DrawCargoRatings(), DrawCategories(), DrawCategory(), DrawCharCentered(), NetworkContentListWindow::DrawDetails(), FramerateWindow::DrawElementTimesColumn(), DrawEngineList(), StationViewWindow::DrawEntries(), DrawFrame(), BaseGraphWindow::DrawGraph(), SmallMapWindow::DrawIndustryNames(), IndustryViewWindow::DrawInfo(), GoalListWindow::DrawListColumn(), NetworkContentListWindow::DrawMatrix(), DrawOrderString(), TownAuthorityWindow::DrawRatings(), DrawRoadVehDetails(), NetworkGameWindow::DrawServerLine(), SettingEntry::DrawSetting(), SettingsPage::DrawSetting(), DrawShipDetails(), DrawSliderWidget(), DrawSmallOrderList(), DrawString(), DrawStringMultiLineWithClipping(), TimetableWindow::DrawSummaryPanel(), TimetableWindow::DrawTimetablePanel(), SmallMapWindow::DrawTowns(), DrawTrainDetails(), DepotWindow::DrawVehicleInDepot(), BaseVehicleListWindow::DrawVehicleListItems(), DrawVehiclePurchaseInfo(), DrawVehicleRefitWindow(), SelectCompanyLiveryWindow::DrawWidget(), SelectCompanyManagerFaceWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), EnginePreviewWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), FramerateWindow::DrawWidget(), FrametimeGraphWindow::DrawWidget(), GSConfigWindow::DrawWidget(), GenerateProgressWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), BaseGraphWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), PerformanceLeagueWindow::DrawWidget(), ScriptLeagueWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), LandInfoWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), BaseNetworkContentDownloadStatusWindow::DrawWidget(), NetworkJoinStatusWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), NewGRFWindow::DrawWidget(), SavePresetWindow::DrawWidget(), ScanProgressWindow::DrawWidget(), ScriptListWindow::DrawWidget(), ScriptSettingsWindow::DrawWidget(), GameOptionsWindow::DrawWidget(), SignListWindow::DrawWidget(), SmallMapWindow::DrawWidget(), CompanyStationsWindow::DrawWidget(), StatusBarWindow::DrawWidget(), StoryBookWindow::DrawWidget(), SubsidyListWindow::DrawWidget(), TextfileWindow::DrawWidget(), ScenarioEditorToolbarWindow::DrawWidget(), TownViewWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), VehicleDetailsWindow::DrawWidget(), VehicleViewWindow::DrawWidget(), DrawYearCategory(), DrawYearColumn(), StoryBookWindow::EnsureStoryPageElementLayout(), CompanyInfrastructureWindow::FindWindowPlacementAndResize(), GetAutoPlacePosition(), TownViewWindow::GetDesiredInfoHeight(), GetEngineListHeight(), StoryBookWindow::GetHeadHeight(), TextfileWindow::GetHyperlink(), SmallMapWindow::GetLegendHeight(), SmallMapWindow::GetPositionOnLegend(), VehicleDetailsWindow::GetRoadVehDetailsHeight(), GetTotalCategoriesHeight(), GetVehicleListHeight(), LocalGetWindowPlacement(), ViewportSign::MarkDirty(), NetworkDrawChatMessage(), NetworkReInitChatBoxSize(), FramerateWindow::OnClick(), BaseGraphWindow::OnClick(), MusicTrackSelectionWindow::OnClick(), StationViewWindow::OnClick(), TownAuthorityWindow::OnClick(), SelectCompanyManagerFaceWindow::OnInit(), IConsoleWindow::OnInit(), BaseCargoGraphWindow::OnInit(), BuildIndustryWindow::OnInit(), IndustryViewWindow::OnInit(), IndustryCargoesWindow::OnInit(), GameOptionsWindow::OnInit(), SmallMapWindow::OnInit(), StationViewWindow::OnInit(), BaseGraphWindow::OnMouseOver(), BuildAirportWindow::OnPaint(), ReplaceVehicleWindow::OnPaint(), BuildVehicleWindow::OnPaint(), HighScoreWindow::OnPaint(), MainWindow::OnPaint(), GameOptionsWindow::OnPaint(), FramerateWindow::OnResize(), NWidgetResizeBase::SetMinimalSize(), NWidgetResizeBase::SetMinimalTextLines(), StationsWndShowStationRating(), NWidgetResizeBase::UpdateMultilineWidgetSize(), AIConfigWindow::UpdateWidgetSize(), BuildAirportWindow::UpdateWidgetSize(), ReplaceVehicleWindow::UpdateWidgetSize(), BuildVehicleWindow::UpdateWidgetSize(), CompanyFinancesWindow::UpdateWidgetSize(), SelectCompanyLiveryWindow::UpdateWidgetSize(), CompanyInfrastructureWindow::UpdateWidgetSize(), EnginePreviewWindow::UpdateWidgetSize(), SaveLoadWindow::UpdateWidgetSize(), FramerateWindow::UpdateWidgetSize(), GSConfigWindow::UpdateWidgetSize(), GenerateLandscapeWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), BaseCargoGraphWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), PerformanceLeagueWindow::UpdateWidgetSize(), ScriptLeagueWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), AboutWindow::UpdateWidgetSize(), NetworkContentListWindow::UpdateWidgetSize(), BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(), NetworkGameWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), NewGRFInspectWindow::UpdateWidgetSize(), SpriteAlignerWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), NewGRFWindow::UpdateWidgetSize(), SavePresetWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), OrdersWindow::UpdateWidgetSize(), PickerWindow::UpdateWidgetSize(), ScriptListWindow::UpdateWidgetSize(), ScriptSettingsWindow::UpdateWidgetSize(), ScriptDebugWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), SignListWindow::UpdateWidgetSize(), CompanyStationsWindow::UpdateWidgetSize(), StationViewWindow::UpdateWidgetSize(), StoryBookWindow::UpdateWidgetSize(), SubsidyListWindow::UpdateWidgetSize(), TextfileWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), TownAuthorityWindow::UpdateWidgetSize(), RefitWindow::UpdateWidgetSize(), VehicleDetailsWindow::UpdateWidgetSize(), VehicleViewWindow::UpdateWidgetSize(), and ViewportAddString().

## ◆ GetCharacterWidth()

uint8_t GetCharacterWidth | ( | FontSize | size,
|  | char32_t | key
| ) |  |

Return width of character glyph.

Parameters

  size | Font of the character
  key | Character code glyph

Returns
  Width of the character glyph

Definition at line 1270 of file gfx.cpp.

References _stringwidth_table, and GetGlyphWidth().

Referenced by DrawCharCentered(), GetBroadestDigit(), GetDigitWidth(), FallbackParagraphLayout::NextLine(), IConsoleWindow::OnInit(), and StationViewWindow::OnInit().

## ◆ GetDigitWidth()

uint8_t GetDigitWidth | ( | FontSize | size | ) |

Return the maximum width of single digit.

Parameters

  size | Font of the digit

Returns
  Width of the digit.

Definition at line 1283 of file gfx.cpp.

References GetCharacterWidth().

Referenced by BuildSignalWindow::UpdateWidgetSize().

## ◆ GetScaledSpriteSize()

Dimension GetScaledSpriteSize | ( | SpriteID | sprid | ) |

Scale sprite size for GUI.

Offset is ignored.

Definition at line 68 of file widget.cpp.

References GetSpriteSize(), Normal, ScaleGUITrad(), Coord2D< T >::x, and Coord2D< T >::y.

Referenced by VehicleGroupWindow::ComputeGroupInfoSize(), CompanyButtonLine::Draw(), ClientButtonLine::Draw(), DrawEngineList(), DrawImageTextButtons(), VehicleViewWindow::DrawWidget(), QueryString::GetBoundingRect(), QueryString::GetCaretPosition(), QueryString::GetCharAtPosition(), ClientButtonLine::GetTooltip(), DepotWindow::OnInit(), NetworkContentListWindow::OnInit(), NetworkGameWindow::OnInit(), NWidgetLeaf::SetupSmallestSize(), BuildBridgeWindow::UpdateWidgetSize(), SelectCompanyManagerFaceWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), BuyCompanyWindow::UpdateWidgetSize(), ErrmsgWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), NewGRFWindow::UpdateWidgetSize(), NewsWindow::UpdateWidgetSize(), and VehicleViewWindow::UpdateWidgetSize().

## ◆ GetSpriteSize()

Dimension GetSpriteSize | ( | SpriteID | sprid,
|  | Point * | offset,
|  | ZoomLevel | zoom
| ) |  |

Get the size of a sprite.

Parameters

  | sprid | Sprite to examine.
  [out] | offset | Optionally returns the sprite position offset.
  | zoom | The zoom level applicable to the sprite.

Returns
  Sprite size in pixels.

Note
  The size assumes (0, 0) as top-left coordinate and ignores any part of the sprite drawn at the left or above that position.

Definition at line 965 of file gfx.cpp.

References Sprite::height, Normal, UnScaleByZoom(), Sprite::width, Coord2D< T >::x, Sprite::x_offs, Coord2D< T >::y, and Sprite::y_offs.

Referenced by StoryBookWindow::DrawActionElement(), DrawCargoIconOverlay(), DrawCloseBox(), DrawCompanyManagerFace(), DrawEngineList(), DrawOrderString(), BuildSignalWindow::DrawSignalSprite(), DrawSpriteToRgbaBuffer(), TimetableWindow::DrawTimetablePanel(), BaseVehicleListWindow::DrawVehicleListItems(), DrawVehicleRefitWindow(), BuildAirportWindow::DrawWidget(), CompanyWindow::DrawWidget(), GraphLegendWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), NewGRFWindow::DrawWidget(), OrdersWindow::DrawWidget(), PickerWindow::DrawWidget(), SignListWindow::DrawWidget(), StatusBarWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), ScriptDebugWindow::DrawWidgetCompanyButton(), GetLargestCargoIconSize(), GetMaxTreeSpriteSize(), StoryBookWindow::GetPageElementHeight(), GetRailTypeDropDownList(), GetScaledSpriteSize(), MakeCompanyButtonRows(), MakeNWidgetCompanyLines(), CheatWindow::OnInit(), BuildSignalWindow::OnInit(), GameOptionsWindow::OnInit(), TownAuthorityWindow::OnInit(), MainWindow::OnPaint(), BuildAirportWindow::UpdateWidgetSize(), SelectCompanyLiveryWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), PerformanceLeagueWindow::UpdateWidgetSize(), ScriptLeagueWindow::UpdateWidgetSize(), SignListWindow::UpdateWidgetSize(), and TownDirectoryWindow::UpdateWidgetSize().

## ◆ GetStringBoundingBox() [1/2]

Dimension GetStringBoundingBox | ( | std::string_view | str,
|  | FontSize | start_fontsize
| ) |  |

Return the string dimension in pixels.

The height and width are returned in a single Dimension value. TINYFONT, BIGFONT modifiers are only supported as the first character of the string. The returned dimensions are therefore a rough estimation correct for all the current strings but not every possible combination

Parameters

  str | string to calculate pixel-width
  start_fontsize | Fontsize to start the text with

Returns
  string width and height in pixels

Definition at line 894 of file gfx.cpp.

References Layouter::GetBounds().

Referenced by VehicleGroupWindow::ComputeGroupInfoSize(), DrawCaption(), DrawEngineList(), DrawImageTextButtons(), SmallMapWindow::DrawIndustryNames(), DrawLabel(), DrawSliderWidget(), DrawText(), TimetableWindow::DrawTimetablePanel(), OrdersWindow::DrawWidget(), BaseVehicleListWindow::GetActionDropdownSize(), IndustryDirectoryWindow::GetIndustryListWidth(), ExpensesList::GetListWidth(), GetMaxCategoriesWidth(), StoryBookWindow::GetPageElementFloatWidth(), StoryBookWindow::GetPageElementHeight(), GetStringBoundingBox(), GetStringListBoundingBox(), GetStringListWidth(), GetUnitNumberWidth(), NWidgetSocialPlugins::GetWidestPlugin(), BaseGraphWindow::GetYLabelWidth(), IConsoleWindow::OnInit(), IndustryCargoesWindow::OnInit(), SmallMapWindow::OnInit(), BaseVehicleListWindow::OnInit(), ScriptDebugWindow::OnInvalidateData(), RefitWindow::OnInvalidateData(), GoalListWindow::OnPaint(), NWidgetBackground::SetupSmallestSize(), NWidgetLeaf::SetupSmallestSize(), NWidgetResizeBase::UpdateMultilineWidgetSize(), ViewportSign::UpdatePosition(), BuildAirportWindow::UpdateWidgetSize(), ReplaceVehicleWindow::UpdateWidgetSize(), BootstrapErrorWindow::UpdateWidgetSize(), BootstrapAskForDownloadWindow::UpdateWidgetSize(), BuildBridgeWindow::UpdateWidgetSize(), BuildVehicleWindow::UpdateWidgetSize(), CompanyFinancesWindow::UpdateWidgetSize(), SelectCompanyLiveryWindow::UpdateWidgetSize(), CompanyInfrastructureWindow::UpdateWidgetSize(), CompanyWindow::UpdateWidgetSize(), SetDateWindow::UpdateWidgetSize(), DepotWindow::UpdateWidgetSize(), SaveLoadWindow::UpdateWidgetSize(), FramerateWindow::UpdateWidgetSize(), FrametimeGraphWindow::UpdateWidgetSize(), GenerateLandscapeWindow::UpdateWidgetSize(), CreateScenarioWindow::UpdateWidgetSize(), GenerateProgressWindow::UpdateWidgetSize(), GoalListWindow::UpdateWidgetSize(), BaseGraphWindow::UpdateWidgetSize(), BaseCargoGraphWindow::UpdateWidgetSize(), PerformanceRatingDetailWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), BuildIndustryWindow::UpdateWidgetSize(), IndustryDirectoryWindow::UpdateWidgetSize(), PerformanceLeagueWindow::UpdateWidgetSize(), ScriptLeagueWindow::UpdateWidgetSize(), LinkGraphLegendWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), AboutWindow::UpdateWidgetSize(), TooltipsWindow::UpdateWidgetSize(), MusicTrackSelectionWindow::UpdateWidgetSize(), MusicWindow::UpdateWidgetSize(), NetworkContentListWindow::UpdateWidgetSize(), BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(), NetworkGameWindow::UpdateWidgetSize(), NetworkStartServerWindow::UpdateWidgetSize(), NetworkClientListWindow::UpdateWidgetSize(), NetworkJoinStatusWindow::UpdateWidgetSize(), NetworkAskRelayWindow::UpdateWidgetSize(), NetworkAskSurveyWindow::UpdateWidgetSize(), SpriteAlignerWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), NewGRFWindow::UpdateWidgetSize(), SavePresetWindow::UpdateWidgetSize(), ScanProgressWindow::UpdateWidgetSize(), NewsWindow::UpdateWidgetSize(), MessageHistoryWindow::UpdateWidgetSize(), OrdersWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), CustomCurrencyWindow::UpdateWidgetSize(), SignListWindow::UpdateWidgetSize(), CompanyStationsWindow::UpdateWidgetSize(), SelectStationWindow< T >::UpdateWidgetSize(), StatusBarWindow::UpdateWidgetSize(), StoryBookWindow::UpdateWidgetSize(), SubsidyListWindow::UpdateWidgetSize(), TimetableWindow::UpdateWidgetSize(), ScenarioEditorToolbarWindow::UpdateWidgetSize(), TownAuthorityWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), VehicleListWindow::UpdateWidgetSize(), VehicleDetailsWindow::UpdateWidgetSize(), and Textbuf::UpdateWidth().

## ◆ GetStringBoundingBox() [2/2]

Dimension GetStringBoundingBox | ( | StringID | strid,
|  | FontSize | start_fontsize
| ) |  |

Get bounding box of a string.

Has the same restrictions as GetStringBoundingBox(std::string_view str, FontSize start_fontsize).

Parameters

  strid | String to examine.

Returns
  Width and height of the bounding box for the string in pixels.

Definition at line 906 of file gfx.cpp.

References GetString(), and GetStringBoundingBox().

## ◆ GetStringHeight() [1/2]

int GetStringHeight | ( | std::string_view | str,
|  | int | maxw,
|  | FontSize | fontsize
| ) |  |

Calculates height of string (in pixels).

The string is changed to a multiline string if needed.

Parameters

  str | string to check
  maxw | maximum string width

Returns
  height of pixels of string when it is drawn

Definition at line 712 of file gfx.cpp.

References Layouter::GetBounds().

Referenced by TownViewWindow::GetDesiredInfoHeight(), StoryBookWindow::GetHeadHeight(), SettingEntry::GetMaxHelpHeight(), StoryBookWindow::GetPageElementHeight(), GetStringHeight(), GetStringMultiLineBoundingBox(), GetStringMultiLineBoundingBox(), CompanyWindow::OnResize(), NewsWindow::OnResize(), GameOptionsWindow::OnResize(), NWidgetResizeBase::UpdateMultilineWidgetSize(), BootstrapAskForDownloadWindow::UpdateWidgetSize(), BuyCompanyWindow::UpdateWidgetSize(), EnginePreviewWindow::UpdateWidgetSize(), ErrmsgWindow::UpdateWidgetSize(), GoalQuestionWindow::UpdateWidgetSize(), ScriptLeagueWindow::UpdateWidgetSize(), LandInfoWindow::UpdateWidgetSize(), and TooltipsWindow::UpdateWidgetSize().

## ◆ GetStringHeight() [2/2]

int GetStringHeight | ( | StringID | str,
|  | int | maxw
| ) |  |

Calculates height of string (in pixels).

The string is changed to a multiline string if needed.

Parameters

  str | string to check
  maxw | maximum string width

Returns
  height of pixels of string when it is drawn

Definition at line 725 of file gfx.cpp.

References GetString(), and GetStringHeight().

## ◆ GetStringLineCount()

int GetStringLineCount | ( | std::string_view | str,
|  | int | maxw
| ) |  |

Calculates number of lines of string.

The string is changed to a multiline string if needed.

Parameters

  str | string to check
  maxw | maximum string width

Returns
  number of lines of string when it is drawn

Definition at line 736 of file gfx.cpp.

Referenced by NetworkDrawChatMessage(), and GameOptionsWindow::OnPaint().

## ◆ GetStringListBoundingBox()

Dimension GetStringListBoundingBox | ( | std::span< const StringID > | list,
|  | FontSize | fontsize
| ) |  |

Get maximum dimension of a list of strings.

Parameters

  list | List of strings, terminated by INVALID_STRING_ID.
  fontsize | Font size to use.

Returns
  Dimension of highest and longest string within the list.

Definition at line 932 of file gfx.cpp.

References GetStringBoundingBox(), and maxdim().

Referenced by ReplaceVehicleWindow::UpdateWidgetSize(), BuildBridgeWindow::UpdateWidgetSize(), GenerateLandscapeWindow::UpdateWidgetSize(), IndustryDirectoryWindow::UpdateWidgetSize(), OrdersWindow::UpdateWidgetSize(), CompanyStationsWindow::UpdateWidgetSize(), TownDirectoryWindow::UpdateWidgetSize(), and VehicleDetailsWindow::UpdateWidgetSize().

## ◆ GetStringListWidth()

uint GetStringListWidth | ( | std::span< const StringID > | list,
|  | FontSize | fontsize
| ) |  |

Get maximum width of a list of strings.

Parameters

  list | List of strings.
  fontsize | Font size to use.

Returns
  Width of longest string within the list.

Definition at line 917 of file gfx.cpp.

References GetStringBoundingBox().

Referenced by CompanyInfrastructureWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), and VehicleListWindow::UpdateWidgetSize().

## ◆ GetStringMultiLineBoundingBox() [1/2]

Dimension GetStringMultiLineBoundingBox | ( | std::string_view | str,
|  | const Dimension & | suggestion,
|  | FontSize | fontsize
| ) |  |

Calculate string bounding box for multi-line strings.

Parameters

  str | String to check.
  suggestion | Suggested bounding box.

Returns
  Bounding box for the multi-line string, may be bigger than suggestion.

Definition at line 760 of file gfx.cpp.

References GetStringHeight().

## ◆ GetStringMultiLineBoundingBox() [2/2]

Dimension GetStringMultiLineBoundingBox | ( | StringID | str,
|  | const Dimension & | suggestion
| ) |  |

Calculate string bounding box for multi-line strings.

Parameters

  str | String to check.
  suggestion | Suggested bounding box.

Returns
  Bounding box for the multi-line string, may be bigger than suggestion.

Definition at line 748 of file gfx.cpp.

References GetStringHeight().

Referenced by BuildAirportWindow::UpdateWidgetSize(), QueryWindow::UpdateWidgetSize(), NewGRFParametersWindow::UpdateWidgetSize(), NewsWindow::UpdateWidgetSize(), and TownAuthorityWindow::UpdateWidgetSize().

## ◆ GfxDrawLine()

void GfxDrawLine | ( | int | left,
|  | int | top,
|  | int | right,
|  | int | bottom,
|  | PixelColour | colour,
|  | int | width = `1`,
|  | int | dash = `0`
| ) |  |

Definition at line 390 of file gfx.cpp.

## ◆ GfxFillPolygon()

void GfxFillPolygon | ( | std::span< const Point > | shape,
|  | const std::variant< PixelColour, PaletteID > & | colour,
|  | FillRectMode | mode
| ) |  |

Fill a polygon with colour.

The odd-even winding rule is used, i.e. self-intersecting polygons will have holes in them. Left and top edges are inclusive, right and bottom edges are exclusive.

Note
  For rectangles the GfxFillRect function will be faster.

Precondition
  dpi->zoom == ZoomLevel::Min

Parameters

  shape | List of points on the polygon.
  colour | An 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolour spritenumber (FILLRECT_RECOLOUR).
  mode | FILLRECT_OPAQUE: Fill the polygon with the specified colour. FILLRECT_CHECKER: Fill every other pixel with the specified colour, in a checkerboard pattern. FILLRECT_RECOLOUR: Apply a recolour sprite to every pixel in the polygon.

Definition at line 212 of file gfx.cpp.

References Blitter::DrawColourMappingRect(), Blitter::DrawRect(), FILLRECT_CHECKER, FILLRECT_RECOLOUR, GB(), BlitterFactory::GetCurrentBlitter(), MakePolygonSegments(), Min, Blitter::MoveTo(), PALETTE_WIDTH, and Blitter::SetPixel().

Referenced by DrawSliderWidget().

## ◆ GfxFillRect() [1/2]

void GfxFillRect | ( | const Rect & | r,
|  | const std::variant< PixelColour, PaletteID > & | colour,
|  | FillRectMode | mode = `FILLRECT_OPAQUE`
| ) |  |
| inline

Definition at line 138 of file gfx_func.h.

## ◆ GfxFillRect() [2/2]

void GfxFillRect | ( | int | left,
|  | int | top,
|  | int | right,
|  | int | bottom,
|  | const std::variant< PixelColour, PaletteID > & | colour,
|  | FillRectMode | mode
| ) |  |

Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.

Precondition
  dpi->zoom == ZoomLevel::Min, right >= left, bottom >= top

Parameters

  left | Minimum X (inclusive)
  top | Minimum Y (inclusive)
  right | Maximum X (inclusive)
  bottom | Maximum Y (inclusive)
  colour | A 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolour spritenumber (FILLRECT_RECOLOUR)
  mode | FILLRECT_OPAQUE: Fill the rectangle with the specified colour FILLRECT_CHECKER: Like FILLRECT_OPAQUE, but only draw every second pixel (used to grey out things) FILLRECT_RECOLOUR: Apply a recolour sprite to every pixel in the rectangle currently on screen

Definition at line 115 of file gfx.cpp.

References Blitter::DrawColourMappingRect(), Blitter::DrawRect(), FILLRECT_CHECKER, FILLRECT_RECOLOUR, GB(), BlitterFactory::GetCurrentBlitter(), Min, Blitter::MoveTo(), PALETTE_WIDTH, and Blitter::SetPixel().

Referenced by NWidgetToolbarContainer::Draw(), NWidgetMatrix::Draw(), NWidgetSpacer::Draw(), NWidgetBackground::Draw(), NWidgetViewport::Draw(), NWidgetScrollbar::Draw(), NWidgetLeaf::Draw(), CargoesField::Draw(), DrawArrowButtons(), DrawBoolButton(), ButtonLine::DrawButtons(), DrawCaption(), NetworkContentListWindow::DrawDetails(), DrawDropDownButton(), DrawFrame(), DrawFrameRect(), BaseGraphWindow::DrawGraph(), VehicleGroupWindow::DrawGroupInfo(), CargoesField::DrawHorConnection(), SmallMapWindow::DrawHorizMapIndicator(), DrawHorizontalScrollbar(), DrawLayoutLine(), NetworkContentListWindow::DrawMatrix(), DrawMatrix(), DrawResizeBox(), NetworkGameWindow::DrawServerLine(), SmallMapWindow::DrawSmallMap(), DrawTrainDetails(), DrawUpDownButtons(), LinkGraphOverlay::DrawVertex(), DrawVerticalScrollbar(), SmallMapWindow::DrawVertMapIndicator(), BuildAirportWindow::DrawWidget(), CompanyFinancesWindow::DrawWidget(), CompanyInfrastructureWindow::DrawWidget(), DropdownWindow::DrawWidget(), SaveLoadWindow::DrawWidget(), FrametimeGraphWindow::DrawWidget(), BaseGraphWindow::DrawWidget(), BaseCargoGraphWindow::DrawWidget(), PerformanceRatingDetailWindow::DrawWidget(), VehicleGroupWindow::DrawWidget(), BuildIndustryWindow::DrawWidget(), LinkGraphLegendWindow::DrawWidget(), TooltipsWindow::DrawWidget(), MusicTrackSelectionWindow::DrawWidget(), MusicWindow::DrawWidget(), NetworkClientListWindow::DrawWidget(), NewGRFWindow::DrawWidget(), SavePresetWindow::DrawWidget(), NewsWindow::DrawWidget(), OrdersWindow::DrawWidget(), PickerWindow::DrawWidget(), SmallMapWindow::DrawWidget(), TextfileWindow::DrawWidget(), BootstrapBackground::DrawWidget(), ScriptDebugWindow::DrawWidgetLog(), Window::DrawWidgets(), DrawYearCategory(), DrawYearColumn(), HighlightDragPosition(), NetworkDrawChatMessage(), IConsoleWindow::OnPaint(), and StationsWndShowStationRating().

## ◆ GfxScroll()

void GfxScroll | ( | int | left,
|  | int | top,
|  | int | width,
|  | int | height,
|  | int | xo,
|  | int | yo
| ) |  |

Definition at line 85 of file gfx.cpp.

## ◆ HandleCtrlChanged()

void HandleCtrlChanged | ( |  | ) |

State of CONTROL key has changed.

Definition at line 2706 of file window.cpp.

References ES_HANDLED, and Window::OnCTRLStateChange().

Referenced by VideoDriver_SDL_Base::InputLoop(), and VideoDriver_Win32Base::InputLoop().

## ◆ HandleKeypress()

void HandleKeypress | ( | uint | keycode,
|  | char32_t | key
| ) |  |

Handle keyboard input.

Parameters

  keycode | Virtual keycode of the key.
  key | Unicode character of the key.

Definition at line 2650 of file window.cpp.

References HotkeyList::CheckMatch(), EditBoxInGlobalFocus(), ES_HANDLED, FindWindowById(), Window::HandleEditBoxKey(), HasModalProgress(), WindowDesc::hotkeys, IsLocalCompany(), Window::nested_focus, Window::OnHotkey(), Window::OnKeyPress(), WC_CONSOLE, WC_MAIN_TOOLBAR, Window::window_class, and Window::window_desc.

Referenced by HandleCharMsg(), and VideoDriver_SDL_Base::PollEvent().

## ◆ HandleMouseEvents()

void HandleMouseEvents | ( |  | ) |

Handle a mouse event from the video driver.

Definition at line 2963 of file window.cpp.

References _left_button_clicked, _left_button_down, _mouse_hovering, _newgrf_debug_sprite_picker, _right_button_clicked, _right_button_down, _settings_client, abs(), NewGrfDebugSpritePicker::clicked_pixel, CursorVars::delta, BlitterFactory::GetCurrentBlitter(), ClientSettings::gui, HasModalProgress(), GUISettings::hover_delay_ms, CursorVars::in_window, IsLocalCompany(), MarkWholeScreenDirty(), MAX_OFFSET_DOUBLE_CLICK, MAX_OFFSET_HOVER, NewGrfDebugSpritePicker::mode, Blitter::MoveTo(), CursorVars::pos, NewGrfDebugSpritePicker::sprites, TIME_BETWEEN_DOUBLE_CLICK(), CursorVars::wheel, Coord2D< T >::x, and Coord2D< T >::y.

Referenced by InputLoop(), and VideoDriver_SDL_Base::PollEvent().

## ◆ HandleTextInput()

void HandleTextInput | ( | std::string_view | str,
|  | bool | marked,
|  | std::optional< size_t > | caret,
|  | std::optional< size_t > | insert_location,
|  | std::optional< size_t > | replacement_end
| ) |  |

Handle text input.

Parameters

  str | Text string to input.
  marked | Is the input a marked composition string from an IME?
  caret | Move the caret to this point in the insertion string.

Definition at line 2736 of file window.cpp.

References EditBoxInGlobalFocus(), Window::InsertTextString(), Window::nested_focus, WC_CONSOLE, and Window::window_class.

Referenced by CancelIMEComposition(), HandleIMEComposition(), and VideoDriver_SDL_Base::PollEvent().

## ◆ HandleToolbarHotkey()

void HandleToolbarHotkey | ( | int | hotkey | ) |

Handle Toolbar hotkey events - can come from a source like the MacBook Touch Bar.

Parameters

  hotkey | Hotkey code

Definition at line 2633 of file window.cpp.

References ES_HANDLED, FindWindowById(), HasModalProgress(), WindowDesc::hotkeys, IsLocalCompany(), Window::OnHotkey(), WC_MAIN_TOOLBAR, and Window::window_desc.

## ◆ LoadStringWidthTable()

void LoadStringWidthTable | ( | FontSizes | fontsizes | ) |

Initialize _stringwidth_table cache for the specified font sizes.

Parameters

  fontsizes | Font sizes to initialise.

Definition at line 1253 of file gfx.cpp.

References _stringwidth_table, FontCache::ClearFontCaches(), and GetGlyphWidth().

Referenced by AdjustGUIZoom(), AfterLoadGame(), CheckForMissingGlyphs(), GenerateWorld(), and ReloadNewGRFData().

## ◆ ScreenSizeChanged()

void ScreenSizeChanged | ( |  | ) |

Definition at line 1315 of file gfx.cpp.

## ◆ SetAnimatedMouseCursor()

void SetAnimatedMouseCursor | ( | std::span< const AnimCursor > | table | ) |

Assign an animation to the cursor.

Parameters

  table | Array of animation states.

See also
  SetMouseCursor

Definition at line 1716 of file gfx.cpp.

References CursorVars::animate_cur, CursorVars::animate_list, and CursorVars::sprites.

Referenced by SetObjectToPlace().

## ◆ SetMouseCursor()

void SetMouseCursor | ( | CursorID | sprite,
|  | PaletteID | pal
| ) |  |

Assign a single non-animated sprite to the cursor.

Parameters

  sprite | Sprite to draw for the cursor.
  pal | Palette to use for recolouring.

See also
  SetAnimatedMouseCursor

Definition at line 1703 of file gfx.cpp.

References CursorVars::animate_timeout, and SetCursorSprite().

Referenced by SetMouseCursorBusy(), and SetObjectToPlace().

## ◆ SetMouseCursorBusy()

void SetMouseCursorBusy | ( | bool | busy | ) |

Set or unset the ZZZ cursor.

Parameters

  busy | Whether to show the ZZZ cursor.

Definition at line 1687 of file gfx.cpp.

References SetMouseCursor(), SPR_CURSOR_MOUSE, and CursorVars::sprites.

Referenced by CleanupGeneration(), GenerateProgressWindow::OnClick(), SaveFileDone(), and SaveFileStart().

## ◆ SortResolutions()

void SortResolutions | ( |  | ) |

Definition at line 1775 of file gfx.cpp.

## ◆ ToggleFullScreen()

bool ToggleFullScreen | ( | bool | fs | ) |

Definition at line 1766 of file gfx.cpp.

## ◆ UndrawMouseCursor()

void UndrawMouseCursor | ( |  | ) |

Definition at line 1333 of file gfx.cpp.

## ◆ UpdateCursorSize()

void UpdateCursorSize | ( |  | ) |

Update cursor dimension.

Called when changing cursor sprite resp. reloading grfs.

Definition at line 1615 of file gfx.cpp.

References CursorVars::dirty, GB(), GetMaxSpriteID(), Sprite::height, Normal, SPRITE_WIDTH, CursorVars::sprites, CursorVars::total_size, UnScaleGUI(), Sprite::width, Coord2D< T >::x, Sprite::x_offs, Coord2D< T >::y, and Sprite::y_offs.

Referenced by AdjustGUIZoom(), GfxLoadSprites(), SetCursorSprite(), and SetMouseCursorVehicle().

## ◆ UpdateGUIZoom()

void UpdateGUIZoom | ( |  | ) |

Resolve GUI zoom level, if auto-suggestion is requested.

Definition at line 1787 of file gfx.cpp.

References _font_zoom, _gui_scale, _gui_scale_cfg, _gui_zoom, _settings_client, Clamp(), ClientSettings::gui, In2x, In4x, Normal, ScaleGUITrad(), GUISettings::zoom_max, and GUISettings::zoom_min.

Referenced by AdjustGUIZoom(), and openttd_main().

## ◆ UpdateWindows()

void UpdateWindows | ( |  | ) |

Update the continuously changing contents of the windows, such as the viewports.

Definition at line 3124 of file window.cpp.

References _network_dedicated, _newgrf_debug_sprite_picker, CallWindowRealtimeTickEvent(), DrawDirtyBlocks(), TimerManager< TTimerType >::Elapsed(), InvalidateWindowData(), Window::IsShaded(), NewGrfDebugSpritePicker::mode, NetworkDrawChatMessage(), PFE_DRAWING, PFE_DRAWWORLD, Window::ProcessHighlightedInvalidations(), ProcessPendingPerformanceMeasurements(), Window::ProcessScheduledInvalidations(), Window::ProcessScheduledResize(), PerformanceAccumulator::Reset(), UpdateViewportPosition(), Window::viewport, and WC_SPRITE_ALIGNER.

Referenced by VideoDriver_Null::MainLoop(), and VideoDriver::Tick().

## Variable Documentation

## ◆ _ctrl_pressed

bool _ctrl_pressed
| extern

Is Ctrl pressed?

Definition at line 38 of file gfx.cpp.

Referenced by CheckRedrawStationCoverage(), DepotWindow::DepotClick(), DispatchLeftClickEvent(), FindStationsAroundSelection(), GenerateDesertArea(), GenericPlaceSignals(), GetOrderCmdFromTile(), GUIPlaceProcDragXY(), HandleAutoSignalPlacement(), StationViewWindow::HandleCargoWaitingClick(), GoalListWindow::HandleClick(), HandleClickOnSign(), VideoDriver_SDL_Base::InputLoop(), VideoDriver_Win32Base::InputLoop(), TileHighlightData::IsDraggingDiagonal(), MenuClickHelp(), AIConfigWindow::OnClick(), ReplaceVehicleWindow::OnClick(), BuildVehicleWindow::OnClick(), CompanyFinancesWindow::OnClick(), SelectCompanyLiveryWindow::OnClick(), CompanyWindow::OnClick(), DepotWindow::OnClick(), GSConfigWindow::OnClick(), VehicleGroupWindow::OnClick(), IndustryViewWindow::OnClick(), IndustryDirectoryWindow::OnClick(), SelectGameWindow::OnClick(), LandInfoWindow::OnClick(), NetworkStartServerWindow::OnClick(), SpriteAlignerWindow::OnClick(), NewsWindow::OnClick(), OrdersWindow::OnClick(), PickerWindow::OnClick(), BuildRailToolbarWindow::OnClick(), BuildRoadToolbarWindow::OnClick(), ScriptDebugWindow::OnClick(), GameOptionsWindow::OnClick(), SignWindow::OnClick(), CompanyStationsWindow::OnClick(), StationViewWindow::OnClick(), TimetableWindow::OnClick(), TownViewWindow::OnClick(), TownDirectoryWindow::OnClick(), TransparenciesWindow::OnClick(), RefitWindow::OnClick(), VehicleListWindow::OnClick(), VehicleDetailsWindow::OnClick(), VehicleViewWindow::OnClick(), WaypointWindow::OnClick(), DepotWindow::OnCTRLStateChange(), DepotWindow::OnDragDrop(), SelectCompanyLiveryWindow::OnDropdownSelect(), CompanyStationsWindow::OnDropdownSelect(), StoryBookWindow::OnPageElementClick(), BuildDocksToolbarWindow::OnPlaceMouseUp(), BuildObjectWindow::OnPlaceMouseUp(), BuildRailToolbarWindow::OnPlaceMouseUp(), BuildRoadToolbarWindow::OnPlaceMouseUp(), TerraformToolbarWindow::OnPlaceMouseUp(), BuildTreesWindow::OnPlaceMouseUp(), BuildDocksToolbarWindow::OnPlaceObject(), DepotWindow::OnRightClick(), DepotWindow::OnVehicleSelect(), DepotWindow::OnVehicleSelect(), OrdersWindow::OnVehicleSelect(), OrdersWindow::OrderClick_Refit(), OrdersWindow::OrderClick_Skip(), OrdersWindow::OrderClick_StopSharing(), PlaceAirport(), PlaceRail_Station(), SmallMapWindow::SelectLegendItem(), ShowBuildBridgeWindow(), ShowCargoIconOverlay(), and StationJoinerNeeded().

## ◆ _cur_dpi

DrawPixelInfo* _cur_dpi
| extern

Definition at line 54 of file gfx.cpp.

## ◆ _cur_palette

Palette _cur_palette
| extern

Current palette.

Definition at line 24 of file palette.cpp.

Referenced by Convert32bppTo8bpp(), DrawSpriteToRgbaBuffer(), Blitter_32bppBase::LookupColourInPalette(), MakeLargeWorldScreenshot(), MakeMinimapWorldScreenshot(), and MakeSmallScreenshot().

## ◆ _cur_resolution

Dimension _cur_resolution
| extern

The current resolution.

Definition at line 29 of file driver.cpp.

## ◆ _cursor

CursorVars _cursor
| extern

Definition at line 37 of file gfx.cpp.

## ◆ _dirkeys

uint8_t _dirkeys
| extern

1 = left, 2 = up, 4 = right, 8 = down

Definition at line 34 of file gfx.cpp.

Referenced by VideoDriver_SDL_Base::InputLoop(), and VideoDriver_Win32Base::InputLoop().

## ◆ _fullscreen

bool _fullscreen
| extern

Definition at line 35 of file gfx.cpp.

## ◆ _game_speed

uint16_t _game_speed
| extern

Current game-speed; 100 is 1x, 0 is infinite.

Definition at line 40 of file gfx.cpp.

Referenced by ToolbarFastForwardClick().

## ◆ _left_button_clicked

bool _left_button_clicked
| extern

Is left mouse button clicked?

Definition at line 42 of file gfx.cpp.

Referenced by HandleMouseEvents(), GenerateLandscapeWindow::OnClick(), CreateScenarioWindow::OnClick(), NetworkStartServerWindow::OnClick(), DropdownWindow::OnMouseLoop(), and VideoDriver_SDL_Base::PollEvent().

## ◆ _left_button_down

bool _left_button_down
| extern

Is left mouse button pressed?

Definition at line 41 of file gfx.cpp.

Referenced by HandleActiveWidget(), HandleMouseDragDrop(), HandleMouseEvents(), HandleViewportScroll(), HandleWindowDragging(), TileHighlightData::IsDraggingDiagonal(), GameOptionsWindow::OnMouseLoop(), VideoDriver_SDL_Base::PollEvent(), and VpHandlePlaceSizingDrag().

## ◆ _resolutions

std::vector<Dimension> _resolutions
| extern

List of resolutions.

Definition at line 28 of file driver.cpp.

## ◆ _right_button_clicked

bool _right_button_clicked
| extern

Is right mouse button clicked?

Definition at line 44 of file gfx.cpp.

Referenced by HandleMouseEvents(), and VideoDriver_SDL_Base::PollEvent().

## ◆ _right_button_down

bool _right_button_down
| extern

Is right mouse button pressed?

Definition at line 43 of file gfx.cpp.

Referenced by HandleMouseEvents(), HandleViewportScroll(), ErrmsgWindow::OnMouseLoop(), TooltipsWindow::OnMouseLoop(), and VideoDriver_SDL_Base::PollEvent().

## ◆ _screen

DrawPixelInfo _screen
| extern

Definition at line 45 of file gfx.cpp.

## ◆ _screen_disable_anim

bool _screen_disable_anim
| extern

Disable palette animation (important for 32bpp-anim blitter during giant screenshot)

Definition at line 46 of file gfx.cpp.

Referenced by Blitter_32bppAnim::CopyFromBuffer(), Blitter_40bppAnim::CopyFromBuffer(), Blitter_32bppAnim::CopyToBuffer(), Blitter_40bppAnim::CopyToBuffer(), Blitter_32bppAnim::Draw(), Blitter_40bppAnim::Draw(), Blitter_32bppAnim::DrawColourMappingRect(), Blitter_40bppAnim::DrawColourMappingRect(), Blitter_32bppAnim::DrawLine(), Blitter_40bppAnim::DrawLine(), Blitter_32bppAnim::DrawRect(), Blitter_40bppAnim::DrawRect(), DrawSpriteToRgbaBuffer(), LargeWorldCallback(), Blitter_32bppAnim::PaletteAnimate(), Blitter_32bppAnim::ScrollBuffer(), Blitter_40bppAnim::ScrollBuffer(), Blitter_32bppAnim::SetPixel(), and Blitter_40bppAnim::SetPixel().

## ◆ _shift_pressed

bool _shift_pressed
| extern

Is Shift pressed?

Definition at line 39 of file gfx.cpp.

Referenced by VideoDriver_SDL_Base::InputLoop(), VideoDriver_Win32Base::InputLoop(), CommandHelperBase::InternalPostBefore(), EnginePreviewWindow::OnClick(), CompanyWindow::OnPlaceObject(), and ShowCargoIconOverlay().

## ◆ _support8bpp

uint8_t _support8bpp
| extern

Definition at line 36 of file gfx.cpp.