OpenTTD Source  13.2.1
gfx_func.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
40 #ifndef GFX_FUNC_H
41 #define GFX_FUNC_H
42 
43 #include "gfx_type.h"
44 #include "strings_type.h"
45 #include "string_type.h"
46 
47 void GameLoop();
48 
49 void CreateConsole();
50 
51 extern byte _dirkeys;
52 extern bool _fullscreen;
53 extern byte _support8bpp;
54 extern CursorVars _cursor;
55 extern bool _ctrl_pressed;
56 extern bool _shift_pressed;
57 extern uint16 _game_speed;
58 
59 extern bool _left_button_down;
60 extern bool _left_button_clicked;
61 extern bool _right_button_down;
62 extern bool _right_button_clicked;
63 
64 extern DrawPixelInfo _screen;
65 extern bool _screen_disable_anim;
66 
67 extern std::vector<Dimension> _resolutions;
69 extern Palette _cur_palette;
70 
71 void HandleToolbarHotkey(int hotkey);
72 void HandleKeypress(uint keycode, WChar key);
73 void HandleTextInput(const char *str, bool marked = false, const char *caret = nullptr, const char *insert_location = nullptr, const char *replacement_end = nullptr);
74 void HandleCtrlChanged();
75 void HandleMouseEvents();
76 void UpdateWindows();
77 void ChangeGameSpeed(bool enable_fast_forward);
78 
79 void DrawMouseCursor();
80 void ScreenSizeChanged();
81 void GameSizeChanged();
82 bool AdjustGUIZoom(bool automatic);
83 void UndrawMouseCursor();
84 
86 static const int DRAW_STRING_BUFFER = 2048;
87 
88 void RedrawScreenRect(int left, int top, int right, int bottom);
89 void GfxScroll(int left, int top, int width, int height, int xo, int yo);
90 
91 Dimension GetSpriteSize(SpriteID sprid, Point *offset = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
92 Dimension GetScaledSpriteSize(SpriteID sprid); /* widget.cpp */
93 void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr);
94 void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
95 void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, bool clicked, StringAlignment align); /* widget.cpp */
96 std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom = ZOOM_LVL_GUI);
97 
98 int DrawString(int left, int right, int top, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
99 int DrawString(int left, int right, int top, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
100 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);
101 int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
102 int DrawStringMultiLine(int left, int right, int top, int bottom, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
103 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);
104 
105 void DrawCharCentered(WChar c, const Rect &r, TextColour colour);
106 
107 void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE);
108 void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode = FILLRECT_OPAQUE);
109 void GfxDrawLine(int left, int top, int right, int bottom, int colour, int width = 1, int dash = 0);
110 void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
111 
112 /* Versions of DrawString/DrawStringMultiLine that accept a Rect instead of separate left, right, top and bottom parameters. */
113 static inline int DrawString(const Rect &r, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
114 {
115  return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
116 }
117 
118 static inline int DrawString(const Rect &r, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
119 {
120  return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
121 }
122 
123 static inline int DrawString(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
124 {
125  return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
126 }
127 
128 static inline int DrawStringMultiLine(const Rect &r, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
129 {
130  return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
131 }
132 
133 static inline int DrawStringMultiLine(const Rect &r, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
134 {
135  return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
136 }
137 
138 static inline int DrawStringMultiLine(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
139 {
140  return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
141 }
142 
143 static inline void GfxFillRect(const Rect &r, int colour, FillRectMode mode = FILLRECT_OPAQUE)
144 {
145  GfxFillRect(r.left, r.top, r.right, r.bottom, colour, mode);
146 }
147 
148 Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize = FS_NORMAL);
149 Dimension GetStringBoundingBox(const std::string &str, FontSize start_fontsize = FS_NORMAL);
150 Dimension GetStringBoundingBox(StringID strid, FontSize start_fontsize = FS_NORMAL);
151 uint GetStringListWidth(const StringID *list, FontSize fontsize = FS_NORMAL);
152 int GetStringHeight(const char *str, int maxw, FontSize fontsize = FS_NORMAL);
153 int GetStringHeight(StringID str, int maxw);
154 int GetStringLineCount(StringID str, int maxw);
156 Dimension GetStringMultiLineBoundingBox(const char *str, const Dimension &suggestion);
157 void LoadStringWidthTable(bool monospace = false);
158 Point GetCharPosInString(const char *str, const char *ch, FontSize start_fontsize = FS_NORMAL);
159 const char *GetCharAtPosition(const char *str, int x, FontSize start_fontsize = FS_NORMAL);
160 
161 void DrawDirtyBlocks();
162 void AddDirtyBlock(int left, int top, int right, int bottom);
163 void MarkWholeScreenDirty();
164 
165 bool CopyPalette(Palette &local_palette, bool force_copy = false);
166 void GfxInitPalettes();
167 void CheckBlitter();
168 
169 bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height);
170 
178 static inline int CenterBounds(int min, int max, int size)
179 {
180  return (min + max - size + 1) / 2;
181 }
182 
183 /* window.cpp */
184 void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
185 
186 void SetMouseCursorBusy(bool busy);
187 void SetMouseCursor(CursorID cursor, PaletteID pal);
188 void SetAnimatedMouseCursor(const AnimCursor *table);
189 void CursorTick();
190 void UpdateCursorSize();
191 bool ChangeResInGame(int w, int h);
192 void SortResolutions();
193 bool ToggleFullScreen(bool fs);
194 
195 /* gfx.cpp */
196 byte GetCharacterWidth(FontSize size, WChar key);
197 byte GetDigitWidth(FontSize size = FS_NORMAL);
198 void GetBroadestDigit(uint *front, uint *next, FontSize size = FS_NORMAL);
199 
200 int GetCharacterHeight(FontSize size);
201 
203 #define FONT_HEIGHT_SMALL (GetCharacterHeight(FS_SMALL))
204 
206 #define FONT_HEIGHT_NORMAL (GetCharacterHeight(FS_NORMAL))
207 
209 #define FONT_HEIGHT_LARGE (GetCharacterHeight(FS_LARGE))
210 
212 #define FONT_HEIGHT_MONO (GetCharacterHeight(FS_MONO))
213 
214 extern DrawPixelInfo *_cur_dpi;
215 
222 static inline bool IsValidColours(Colours colours)
223 {
224  return colours < COLOUR_END;
225 }
226 
227 TextColour GetContrastColour(uint8 background, uint8 threshold = 128);
228 
233 extern byte _colour_gradient[COLOUR_END][8];
234 
240 #define GREY_SCALE(level) (level)
241 
242 static const uint8 PC_BLACK = GREY_SCALE(1);
243 static const uint8 PC_DARK_GREY = GREY_SCALE(6);
244 static const uint8 PC_GREY = GREY_SCALE(10);
245 static const uint8 PC_WHITE = GREY_SCALE(15);
246 
247 static const uint8 PC_VERY_DARK_RED = 0xB2;
248 static const uint8 PC_DARK_RED = 0xB4;
249 static const uint8 PC_RED = 0xB8;
250 
251 static const uint8 PC_VERY_DARK_BROWN = 0x56;
252 
253 static const uint8 PC_ORANGE = 0xC2;
254 
255 static const uint8 PC_YELLOW = 0xBF;
256 static const uint8 PC_LIGHT_YELLOW = 0x44;
257 static const uint8 PC_VERY_LIGHT_YELLOW = 0x45;
258 
259 static const uint8 PC_GREEN = 0xD0;
260 
261 static const uint8 PC_VERY_DARK_BLUE = 0x9A;
262 static const uint8 PC_DARK_BLUE = 0x9D;
263 static const uint8 PC_LIGHT_BLUE = 0x98;
264 
265 static const uint8 PC_ROUGH_LAND = 0x52;
266 static const uint8 PC_GRASS_LAND = 0x54;
267 static const uint8 PC_BARE_LAND = 0x37;
268 static const uint8 PC_RAINFOREST = 0x5C;
269 static const uint8 PC_FIELDS = 0x25;
270 static const uint8 PC_TREES = 0x57;
271 static const uint8 PC_WATER = 0xC9;
272 #endif /* GFX_FUNC_H */
_cur_palette
Palette _cur_palette
Current palette.
Definition: gfx.cpp:51
SetMouseCursorBusy
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
Definition: gfx.cpp:1908
PC_WHITE
static const uint8 PC_WHITE
White palette colour.
Definition: gfx_func.h:245
SetMouseCursor
void SetMouseCursor(CursorID cursor, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Definition: gfx.cpp:1923
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:42
_dirkeys
byte _dirkeys
1 = left, 2 = up, 4 = right, 8 = down
Definition: gfx.cpp:34
CursorVars
Collection of variables for cursor-display and -animation.
Definition: gfx_type.h:115
_left_button_down
bool _left_button_down
Is left mouse button pressed?
Definition: gfx.cpp:41
WChar
char32_t WChar
Type for wide characters, i.e.
Definition: string_type.h:36
AddDirtyBlock
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.
Definition: gfx.cpp:1724
_right_button_down
bool _right_button_down
Is right mouse button pressed?
Definition: gfx.cpp:43
DrawSpriteViewport
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub=nullptr)
Draw a sprite in a viewport.
Definition: gfx.cpp:1031
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
HandleTextInput
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.
Definition: window.cpp:2713
PC_YELLOW
static const uint8 PC_YELLOW
Yellow palette colour.
Definition: gfx_func.h:255
PC_DARK_RED
static const uint8 PC_DARK_RED
Dark red palette colour.
Definition: gfx_func.h:248
HandleKeypress
void HandleKeypress(uint keycode, WChar key)
Handle keyboard input.
Definition: window.cpp:2627
PC_ORANGE
static const uint8 PC_ORANGE
Orange palette colour.
Definition: gfx_func.h:253
PC_RED
static const uint8 PC_RED
Red palette colour.
Definition: gfx_func.h:249
GfxFillPolygon
void GfxFillPolygon(const std::vector< Point > &shape, int colour, FillRectMode mode=FILLRECT_OPAQUE)
Fill a polygon with colour.
Definition: gfx.cpp:212
PC_RAINFOREST
static const uint8 PC_RAINFOREST
Pale green palette colour for rainforest.
Definition: gfx_func.h:268
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize=FS_NORMAL)
Calculates height of string (in pixels).
Definition: gfx.cpp:715
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:253
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:19
StringAlignment
StringAlignment
How to align the to-be drawn text.
Definition: gfx_type.h:333
FillRectMode
FillRectMode
Define the operation GfxFillRect performs.
Definition: gfx_type.h:292
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset=nullptr, ZoomLevel zoom=ZOOM_LVL_GUI)
Get the size of a sprite.
Definition: gfx.cpp:993
_screen_disable_anim
bool _screen_disable_anim
Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
Definition: gfx.cpp:46
PC_GRASS_LAND
static const uint8 PC_GRASS_LAND
Dark green palette colour for grass land.
Definition: gfx_func.h:266
strings_type.h
GfxFillRect
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.
Definition: gfx.cpp:116
SubSprite
Used to only draw a part of the sprite.
Definition: gfx_type.h:225
DrawCharCentered
void DrawCharCentered(WChar c, const Rect &r, TextColour colour)
Draw single character horizontally centered around (x,y)
Definition: gfx.cpp:976
_cur_resolution
Dimension _cur_resolution
The current resolution.
Definition: driver.cpp:32
GetStringListWidth
uint GetStringListWidth(const StringID *list, FontSize fontsize=FS_NORMAL)
Get maximum width of a list of strings.
Definition: gfx.cpp:931
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
UpdateWindows
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
Definition: window.cpp:3075
PC_VERY_LIGHT_YELLOW
static const uint8 PC_VERY_LIGHT_YELLOW
Almost-white yellow palette colour.
Definition: gfx_func.h:257
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.
Definition: window.cpp:985
SetAnimatedMouseCursor
void SetAnimatedMouseCursor(const AnimCursor *table)
Assign an animation to the cursor.
Definition: gfx.cpp:1936
FillDrawPixelInfo
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition: gfx.cpp:1786
CopyPalette
bool CopyPalette(Palette &local_palette, bool force_copy=false)
Copy the current palette if the palette was updated.
Definition: gfx.cpp:1294
DRAW_STRING_BUFFER
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Definition: gfx_func.h:86
CursorID
uint32 CursorID
The number of the cursor (sprite)
Definition: gfx_type.h:19
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
DrawString
int DrawString(int left, int right, int top, const char *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.
Definition: gfx.cpp:644
SA_TOP
@ SA_TOP
Top align the text.
Definition: gfx_type.h:339
HandleMouseEvents
void HandleMouseEvents()
Handle a mouse event from the video driver.
Definition: window.cpp:2932
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour=TC_FROMSTRING, StringAlignment align=(SA_TOP|SA_LEFT), bool underline=false, FontSize fontsize=FS_NORMAL)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:789
GetCharPosInString
Point GetCharPosInString(const char *str, const char *ch, FontSize start_fontsize=FS_NORMAL)
Get the leading corner of a character in a single-line string relative to the start of the string.
Definition: gfx.cpp:948
_right_button_clicked
bool _right_button_clicked
Is right mouse button clicked?
Definition: gfx.cpp:44
GetCharacterWidth
byte GetCharacterWidth(FontSize size, WChar key)
Return width of character glyph.
Definition: gfx.cpp:1465
UpdateCursorSize
void UpdateCursorSize()
Update cursor dimension.
Definition: gfx.cpp:1836
DrawSprite
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.
Definition: gfx.cpp:1058
RedrawScreenRect
void RedrawScreenRect(int left, int top, int right, int bottom)
Repaints a specific rectangle of the screen.
Definition: gfx.cpp:1609
DrawDirtyBlocks
void DrawDirtyBlocks()
Repaints the rectangle blocks which are marked as 'dirty'.
Definition: gfx.cpp:1635
GetStringLineCount
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
Definition: gfx.cpp:740
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
CheckBlitter
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition: gfxinit.cpp:334
GetStringMultiLineBoundingBox
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Definition: gfx.cpp:755
string_type.h
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:242
GetContrastColour
TextColour GetContrastColour(uint8 background, uint8 threshold=128)
Determine a contrasty text colour for a coloured background.
Definition: gfx.cpp:1432
PC_TREES
static const uint8 PC_TREES
Green palette colour for trees.
Definition: gfx_func.h:270
_resolutions
std::vector< Dimension > _resolutions
List of resolutions.
Definition: driver.cpp:31
PC_GREY
static const uint8 PC_GREY
Grey palette colour.
Definition: gfx_func.h:244
PC_FIELDS
static const uint8 PC_FIELDS
Light brown palette colour for fields.
Definition: gfx_func.h:269
FILLRECT_OPAQUE
@ FILLRECT_OPAQUE
Fill rectangle with a single colour.
Definition: gfx_type.h:293
PC_VERY_DARK_BROWN
static const uint8 PC_VERY_DARK_BROWN
Almost-black brown palette colour.
Definition: gfx_func.h:251
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
GetBroadestDigit
void GetBroadestDigit(uint *front, uint *next, FontSize size=FS_NORMAL)
Determine the broadest digits for guessing the maximum width of a n-digit number.
Definition: gfx.cpp:1493
PC_VERY_DARK_RED
static const uint8 PC_VERY_DARK_RED
Almost-black red palette colour.
Definition: gfx_func.h:247
PC_LIGHT_YELLOW
static const uint8 PC_LIGHT_YELLOW
Light yellow palette colour.
Definition: gfx_func.h:256
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
PC_ROUGH_LAND
static const uint8 PC_ROUGH_LAND
Dark green palette colour for rough land.
Definition: gfx_func.h:265
PC_DARK_BLUE
static const uint8 PC_DARK_BLUE
Dark blue palette colour.
Definition: gfx_func.h:262
PaletteID
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:18
GetDigitWidth
byte GetDigitWidth(FontSize size=FS_NORMAL)
Return the maximum width of single digit.
Definition: gfx.cpp:1478
LoadStringWidthTable
void LoadStringWidthTable(bool monospace=false)
Initialize _stringwidth_table cache.
Definition: gfx.cpp:1446
GetCharAtPosition
const char * GetCharAtPosition(const char *str, int x, FontSize start_fontsize=FS_NORMAL)
Get the character from a string that is drawn at a specific position.
Definition: gfx.cpp:961
PC_VERY_DARK_BLUE
static const uint8 PC_VERY_DARK_BLUE
Almost-black blue palette colour.
Definition: gfx_func.h:261
HandleToolbarHotkey
void HandleToolbarHotkey(int hotkey)
Handle Toolbar hotkey events - can come from a source like the MacBook Touch Bar.
Definition: window.cpp:2610
AnimCursor
A single sprite of a list of animated cursors.
Definition: gfx_type.h:108
PC_WATER
static const uint8 PC_WATER
Dark blue palette colour for water.
Definition: gfx_func.h:271
SA_LEFT
@ SA_LEFT
Left align the text.
Definition: gfx_type.h:334
GameSizeChanged
void GameSizeChanged()
Size of the application screen changed.
Definition: main_gui.cpp:580
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:62
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize=FS_NORMAL)
Return the string dimension in pixels.
Definition: gfx.cpp:890
CenterBounds
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:178
HandleCtrlChanged
void HandleCtrlChanged()
State of CONTROL key has changed.
Definition: window.cpp:2683
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1767
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.
Definition: gfx.cpp:420
AdjustGUIZoom
bool AdjustGUIZoom(bool automatic)
Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
Definition: gfx.cpp:2023
_shift_pressed
bool _shift_pressed
Is Shift pressed?
Definition: gfx.cpp:39
FontSize
FontSize
Available font sizes.
Definition: gfx_type.h:202
_colour_gradient
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:55
GREY_SCALE
#define GREY_SCALE(level)
Return the colour for a particular greyscale level.
Definition: gfx_func.h:240
PC_DARK_GREY
static const uint8 PC_DARK_GREY
Dark grey palette colour.
Definition: gfx_func.h:243
PC_LIGHT_BLUE
static const uint8 PC_LIGHT_BLUE
Light blue palette colour.
Definition: gfx_func.h:263
GetScaledSpriteSize
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
Definition: widget.cpp:187
gfx_type.h
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
Palette
Information about the currently used palette.
Definition: gfx_type.h:319
_game_speed
uint16 _game_speed
Current game-speed; 100 is 1x, 0 is infinite.
Definition: gfx.cpp:40
IsValidColours
static bool IsValidColours(Colours colours)
Checks if a Colours value is valid.
Definition: gfx_func.h:222
DrawSpriteToRgbaBuffer
std::unique_ptr< uint32[]> 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.
Definition: gfx.cpp:1213
PC_GREEN
static const uint8 PC_GREEN
Green palette colour.
Definition: gfx_func.h:259
PC_BARE_LAND
static const uint8 PC_BARE_LAND
Brown palette colour for bare land.
Definition: gfx_func.h:267
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:151