52extern bool _fullscreen;
53extern uint8_t _support8bpp;
73void HandleTextInput(
const char *str,
bool marked =
false,
const char *caret =
nullptr,
const char *insert_location =
nullptr,
const char *replacement_end =
nullptr);
77void ChangeGameSpeed(
bool enable_fast_forward);
79void DrawMouseCursor();
80void ScreenSizeChanged();
84void UndrawMouseCursor();
87void GfxScroll(
int left,
int top,
int width,
int height,
int xo,
int yo);
105void GfxDrawLine(
int left,
int top,
int right,
int bottom,
int colour,
int width = 1,
int dash = 0);
106void DrawBox(
int x,
int y,
int dx1,
int dy1,
int dx2,
int dy2,
int dx3,
int dy3);
112 return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
117 return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
122 return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
127 return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
132 GfxFillRect(r.left, r.top, r.right, r.bottom, colour, mode);
168 return (min + max - size + 1) / 2;
179bool ChangeResInGame(
int w,
int h);
180void SortResolutions();
181bool ToggleFullScreen(
bool fs);
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize=FS_NORMAL)
Return the string dimension in pixels.
void UpdateCursorSize()
Update cursor dimension.
bool _shift_pressed
Is Shift pressed?
void HandleCtrlChanged()
State of CONTROL key has changed.
void GfxFillPolygon(const std::vector< Point > &shape, int colour, FillRectMode mode=FILLRECT_OPAQUE)
Fill a polygon with colour.
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
bool _left_button_down
Is left mouse button pressed?
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
From a rectangle that needs redrawing, find the windows that intersect with the rectangle.
Dimension GetStringListBoundingBox(std::span< const StringID > list, FontSize fontsize=FS_NORMAL)
Get maximum dimension of a list of strings.
std::unique_ptr< uint32_t[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom=ZOOM_LVL_GUI)
Draws a sprite to a new RGBA buffer (see Colour union) instead of drawing to the screen.
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
void DrawRectOutline(const Rect &r, int colour, int width=1, int dash=0)
Draw the outline of a Rect.
void HandleToolbarHotkey(int hotkey)
Handle Toolbar hotkey events - can come from a source like the MacBook Touch Bar.
bool _ctrl_pressed
Is Ctrl pressed?
void GameSizeChanged()
Size of the application screen changed.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub=nullptr, ZoomLevel zoom=ZOOM_LVL_GUI)
Draw a sprite, not in a viewport.
uint8_t _dirkeys
1 = left, 2 = up, 4 = right, 8 = down
bool _screen_disable_anim
Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
bool _left_button_clicked
Is left mouse button clicked?
void SetMouseCursor(CursorID cursor, PaletteID pal)
Assign a single non-animated sprite to the cursor.
uint16_t _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
void UpdateGUIZoom()
Resolve GUI zoom level, if auto-suggestion is requested.
uint8_t GetDigitWidth(FontSize size=FS_NORMAL)
Return the maximum width of single digit.
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.
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize=FS_NORMAL)
Calculates height of string (in pixels).
void HandleMouseEvents()
Handle a mouse event from the video driver.
void GetBroadestDigit(uint *front, uint *next, FontSize size=FS_NORMAL)
Determine the broadest digits for guessing the maximum width of a n-digit number.
Palette _cur_palette
Current palette.
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub=nullptr)
Draw a sprite in a viewport.
bool _right_button_clicked
Is right mouse button clicked?
void HandleKeypress(uint keycode, char32_t key)
Handle keyboard input.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
uint8_t GetCharacterWidth(FontSize size, char32_t key)
Return width of character glyph.
void HandleTextInput(const char *str, bool marked=false, const char *caret=nullptr, const char *insert_location=nullptr, const char *replacement_end=nullptr)
Handle text input.
Dimension GetSpriteSize(SpriteID sprid, Point *offset=nullptr, ZoomLevel zoom=ZOOM_LVL_GUI)
Get the size of a sprite.
void LoadStringWidthTable(bool monospace=false)
Initialize _stringwidth_table cache.
void SetAnimatedMouseCursor(const AnimCursor *table)
Assign an animation to the cursor.
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
std::vector< Dimension > _resolutions
List of resolutions.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension _cur_resolution
The current resolution.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode=FILLRECT_OPAQUE)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3)
Draws the projection of a parallelepiped.
uint GetStringListWidth(std::span< const StringID > list, FontSize fontsize=FS_NORMAL)
Get maximum width of a list of strings.
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.
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 _right_button_down
Is right mouse button pressed?
bool AdjustGUIZoom(bool automatic)
Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
void DrawCharCentered(char32_t c, const Rect &r, TextColour colour)
Draw single character horizontally centered around (x,y)
Types related to the graphics and/or input devices.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
StringAlignment
How to align the to-be drawn text.
@ SA_TOP
Top align the text.
@ SA_LEFT
Left align the text.
uint32_t CursorID
The number of the cursor (sprite)
FontSize
Available font sizes.
@ FS_NORMAL
Index of the normal font in the font tables.
uint32_t PaletteID
The number of the palette.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
FillRectMode
Define the operation GfxFillRect performs.
@ FILLRECT_OPAQUE
Fill rectangle with a single colour.
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 DrawDirtyBlocks()
Repaints the rectangle blocks which are marked as 'dirty'.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
void RedrawScreenRect(int left, int top, int right, int bottom)
Repaints a specific rectangle of the screen.
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
A single sprite of a list of animated cursors.
Collection of variables for cursor-display and -animation.
Dimensions (a width and height) of a rectangle in 2D.
Data about how and where to blit pixels.
Information about the currently used palette.
Coordinates of a point in 2D.
Specification of a rectangle with absolute coordinates of all edges.
int Width() const
Get width of Rect.
int Height() const
Get height of Rect.
Used to only draw a part of the sprite.
ZoomLevel
All zoom levels we know.