71 static const byte *_colour_remap_ptr;
74 static const uint DIRTY_BLOCK_HEIGHT = 8;
75 static const uint DIRTY_BLOCK_WIDTH = 64;
77 static uint _dirty_bytes_per_line = 0;
78 static byte *_dirty_blocks = NULL;
79 extern uint _dirty_block_colour;
81 void GfxScroll(
int left,
int top,
int width,
int height,
int xo,
int yo)
85 if (xo == 0 && yo == 0)
return;
87 if (_cursor.
visible) UndrawMouseCursor();
93 blitter->
ScrollBuffer(_screen.dst_ptr, left, top, width, height, xo, yo);
118 const int otop = top;
119 const int oleft = left;
122 if (left > right || top > bottom)
return;
123 if (right < dpi->left || left >= dpi->left + dpi->width)
return;
124 if (bottom < dpi->top || top >= dpi->top + dpi->height)
return;
126 if ( (left -= dpi->left) < 0) left = 0;
127 right = right - dpi->left + 1;
128 if (right > dpi->width) right = dpi->width;
132 if ( (top -= dpi->top) < 0) top = 0;
133 bottom = bottom - dpi->top + 1;
134 if (bottom > dpi->height) bottom = dpi->height;
138 dst = blitter->
MoveTo(dpi->dst_ptr, left, top);
142 blitter->
DrawRect(dst, right, bottom, (uint8)colour);
150 byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
152 for (
int i = (bo ^= 1); i < right; i += 2) blitter->
SetPixel(dst, i, 0, (uint8)colour);
153 dst = blitter->
MoveTo(dst, 0, 1);
154 }
while (--bottom > 0);
174 static inline void GfxDoDrawLine(
void *video,
int x,
int y,
int x2,
int y2,
int screen_width,
int screen_height, uint8 colour,
int width,
int dash = 0)
180 if (y2 == y || x2 == x) {
182 blitter->
DrawLine(video, x, y, x2, y2, screen_width, screen_height, colour, width, dash);
186 int grade_y = y2 - y;
187 int grade_x = x2 - x;
190 int extra = (int)
CeilDiv(3 * width, 4);
191 Rect clip = { -extra, -extra, screen_width - 1 + extra, screen_height - 1 + extra };
195 while (INT_MAX /
abs(grade_y) <
max(
abs(clip.left - x),
abs(clip.right - x))) {
205 int left_isec_y = y + (clip.left - x) * grade_y / grade_x;
206 int right_isec_y = y + (clip.right - x) * grade_y / grade_x;
207 if ((left_isec_y > clip.bottom + margin && right_isec_y > clip.bottom + margin) ||
208 (left_isec_y < clip.top - margin && right_isec_y < clip.top - margin)) {
218 blitter->
DrawLine(video, x, y, x2, y2, screen_width, screen_height, colour, width, dash);
240 if (x + width / 2 < 0 && x2 + width / 2 < 0 )
return false;
241 if (y + width / 2 < 0 && y2 + width / 2 < 0 )
return false;
242 if (x - width / 2 > dpi->width && x2 - width / 2 > dpi->width )
return false;
243 if (y - width / 2 > dpi->height && y2 - width / 2 > dpi->height)
return false;
247 void GfxDrawLine(
int x,
int y,
int x2,
int y2,
int colour,
int width,
int dash)
251 GfxDoDrawLine(dpi->dst_ptr, x, y, x2, y2, dpi->width, dpi->height, colour, width, dash);
255 void GfxDrawLineUnscaled(
int x,
int y,
int x2,
int y2,
int colour)
279 void DrawBox(
int x,
int y,
int dx1,
int dy1,
int dx2,
int dy2,
int dx3,
int dy3)
296 static const byte colour =
PC_WHITE;
298 GfxDrawLineUnscaled(x, y, x + dx1, y + dy1, colour);
299 GfxDrawLineUnscaled(x, y, x + dx2, y + dy2, colour);
300 GfxDrawLineUnscaled(x, y, x + dx3, y + dy3, colour);
302 GfxDrawLineUnscaled(x + dx1, y + dy1, x + dx1 + dx2, y + dy1 + dy2, colour);
303 GfxDrawLineUnscaled(x + dx1, y + dy1, x + dx1 + dx3, y + dy1 + dy3, colour);
304 GfxDrawLineUnscaled(x + dx2, y + dy2, x + dx2 + dx1, y + dy2 + dy1, colour);
305 GfxDrawLineUnscaled(x + dx2, y + dy2, x + dx2 + dx3, y + dy2 + dy3, colour);
306 GfxDrawLineUnscaled(x + dx3, y + dy3, x + dx3 + dx1, y + dy3 + dy1, colour);
307 GfxDrawLineUnscaled(x + dx3, y + dy3, x + dx3 + dx2, y + dy3 + dy2, colour);
316 if (colour == TC_INVALID)
return;
320 bool no_shade = (colour &
TC_NO_SHADE) != 0 || colour == TC_BLACK;
346 if (line->CountRuns() == 0)
return 0;
348 int w = line->GetWidth();
349 int h = line->GetLeading();
363 int max_w = right - left + 1;
369 truncation &= max_w < w;
371 const Sprite *dot_sprite = NULL;
380 FontCache *fc = ((
const Font*)line->GetVisualRun(0)->GetFont())->fc;
383 dot_sprite = fc->
GetGlyph(dot_glyph);
386 min_x += 3 * dot_width;
387 offset_x = w - 3 * dot_width - max_w;
389 max_x -= 3 * dot_width;
403 switch (align & SA_HOR_MASK) {
406 right = left + w - 1;
412 right = left + w - 1;
416 left = right + 1 - w;
424 bool draw_shadow =
false;
425 for (
int run_index = 0; run_index < line->CountRuns(); run_index++) {
427 const Font *f = (
const Font*)run->GetFont();
434 int dpi_left = dpi->left;
435 int dpi_right = dpi->left + dpi->width - 1;
439 for (
int i = 0; i < run->GetGlyphCount(); i++) {
440 GlyphID glyph = run->GetGlyphs()[i];
443 if (glyph == 0xFFFF)
continue;
445 int begin_x = (int)run->GetPositions()[i * 2] + left - offset_x;
446 int end_x = (int)run->GetPositions()[i * 2 + 2] + left - offset_x - 1;
447 int top = (int)run->GetPositions()[i * 2 + 1] + y;
450 if (truncation && (begin_x < min_x || end_x > max_x))
continue;
454 if (begin_x + sprite->
x_offs > dpi_right || begin_x + sprite->
x_offs + sprite->
width < dpi_left)
continue;
456 if (draw_shadow && (glyph & SPRITE_GLYPH) == 0) {
467 for (
int i = 0; i < 3; i++, x += dot_width) {
481 return (align & SA_HOR_MASK) ==
SA_RIGHT ? left : right;
506 int extra = max_height / 2;
508 if (_cur_dpi->top + _cur_dpi->height + extra < top || _cur_dpi->top > top + max_height + extra ||
509 _cur_dpi->left + _cur_dpi->width + extra < left || _cur_dpi->left > right + extra) {
513 Layouter layout(str, INT32_MAX, colour, fontsize);
514 if (layout.
Length() == 0)
return 0;
538 GetString(buffer, str,
lastof(buffer));
539 return DrawString(left, right, top, buffer, colour, align, underline, fontsize);
550 Layouter layout(str, maxw, TC_FROMSTRING, fontsize);
563 GetString(buffer, str,
lastof(buffer));
576 GetString(buffer, str,
lastof(buffer));
623 int maxw = right - left + 1;
624 int maxh = bottom - top + 1;
628 if (maxh <= 0)
return top;
630 Layouter layout(str, maxw, colour, fontsize);
631 int total_height = layout.
GetBounds().height;
639 y =
RoundDivSU(bottom + top - total_height, 2);
643 y = bottom - total_height;
646 default: NOT_REACHED();
650 int first_line = bottom;
655 int line_height = line->GetLeading();
656 if (y >= top && y < bottom) {
657 last_line = y + line_height;
658 if (first_line > y) first_line = y;
665 return ((align & SA_VERT_MASK) ==
SA_BOTTOM) ? first_line : last_line;
686 GetString(buffer, str,
lastof(buffer));
687 return DrawStringMultiLine(left, right, top, bottom, buffer, colour, align, underline, fontsize);
702 Layouter layout(str, INT32_MAX, TC_FROMSTRING, start_fontsize);
716 GetString(buffer, strid,
lastof(buffer));
730 Layouter layout(str, INT32_MAX, TC_FROMSTRING, start_fontsize);
743 if (x < 0)
return NULL;
745 Layouter layout(str, INT32_MAX, TC_FROMSTRING, start_fontsize);
773 if (offset != NULL) {
813 }
else if (pal != PAL_NONE) {
821 GfxMainBlitterViewport(GetSprite(real_sprite,
ST_NORMAL), x, y,
BM_NORMAL, sub, real_sprite);
840 }
else if (pal != PAL_NONE) {
848 GfxMainBlitter(GetSprite(real_sprite,
ST_NORMAL), x, y,
BM_NORMAL, sub, real_sprite, zoom);
863 template <
int ZOOM_BASE,
bool SCALED_XY>
887 int clip_left =
max(0, -sprite->
x_offs + sub->left * ZOOM_BASE );
888 int clip_top =
max(0, -sprite->
y_offs + sub->top * ZOOM_BASE );
889 int clip_right =
max(0, sprite->
width - (-sprite->
x_offs + (sub->right + 1) * ZOOM_BASE));
890 int clip_bottom =
max(0, sprite->
height - (-sprite->
y_offs + (sub->bottom + 1) * ZOOM_BASE));
892 if (clip_left + clip_right >= sprite->
width)
return;
893 if (clip_top + clip_bottom >= sprite->
height)
return;
911 bp.
dst = dpi->dst_ptr;
912 bp.
pitch = dpi->pitch;
913 bp.
remap = _colour_remap_ptr;
915 assert(sprite->
width > 0);
916 assert(sprite->
height > 0);
918 if (bp.
width <= 0)
return;
919 if (bp.
height <= 0)
return;
921 y -= SCALED_XY ?
ScaleByZoom(dpi->top, zoom) : dpi->top;
926 if (bp.
height <= 0)
return;
937 if (bp.
height <= 0)
return;
940 x -= SCALED_XY ?
ScaleByZoom(dpi->left, zoom) : dpi->left;
944 bp.
width -= -x_unscaled;
945 if (bp.
width <= 0)
return;
949 bp.
left = x_unscaled;
956 if (bp.
width <= 0)
return;
970 if (topleft <= clicked && clicked <= bottomright) {
971 uint offset = (((size_t)clicked - (
size_t)topleft) / (blitter->
GetScreenDepth() / 8)) % bp.
pitch;
972 if (offset < (uint)bp.
width) {
983 GfxBlitter<ZOOM_LVL_BASE, false>(sprite, x, y, mode, sub, sprite_id, _cur_dpi->zoom);
988 GfxBlitter<1, true>(sprite, x, y, mode, sub, sprite_id, zoom);
991 void DoPaletteAnimations();
993 void GfxInitPalettes()
995 memcpy(&_cur_palette, &
_palette,
sizeof(_cur_palette));
996 DoPaletteAnimations();
999 #define EXTR(p, q) (((uint16)(palette_animation_counter * (p)) * (q)) >> 16) 1000 #define EXTR2(p, q) (((uint16)(~palette_animation_counter * (p)) * (q)) >> 16) 1002 void DoPaletteAnimations()
1005 static int palette_animation_counter = 0;
1006 palette_animation_counter += 8;
1012 const uint old_tc = palette_animation_counter;
1017 palette_animation_counter = 0;
1023 memcpy(old_val, palette_pos,
sizeof(old_val));
1029 *palette_pos++ = s[j];
1038 *palette_pos++ = s[j];
1045 byte i = (palette_animation_counter >> 1) & 0x7F;
1050 }
else if (i < 0x4A || i >= 0x75) {
1063 }
else if (i < 0x4A || i >= 0x75) {
1078 *palette_pos++ = s[j];
1087 *palette_pos++ = s[j];
1096 *palette_pos++ = s[j];
1102 palette_animation_counter = old_tc;
1123 uint sq1000_brightness = c.r * c.r * 299 + c.g * c.g * 587 + c.b * c.b * 114;
1125 return sq1000_brightness < ((uint) threshold) * ((uint) threshold) * 1000 ? TC_WHITE : TC_BLACK;
1137 for (uint i = 0; i != 224; i++) {
1167 for (
char c =
'0'; c <=
'9'; c++) {
1182 for (
char c =
'9'; c >=
'0'; c--) {
1187 if (c !=
'0') *front = c -
'0';
1192 void ScreenSizeChanged()
1194 _dirty_bytes_per_line =
CeilDiv(_screen.width, DIRTY_BLOCK_WIDTH);
1195 _dirty_blocks = ReallocT<byte>(_dirty_blocks, _dirty_bytes_per_line *
CeilDiv(_screen.height, DIRTY_BLOCK_HEIGHT));
1198 if (_invalid_rect.right >= _screen.width) _invalid_rect.right = _screen.width;
1199 if (_invalid_rect.bottom >= _screen.height) _invalid_rect.bottom = _screen.height;
1205 void UndrawMouseCursor()
1208 if (_screen.dst_ptr == NULL)
return;
1218 void DrawMouseCursor()
1221 if (_screen.dst_ptr == NULL)
return;
1230 if (!_cursor.
dirty)
return;
1231 UndrawMouseCursor();
1235 int left = _cursor.
pos.x + _cursor.total_offs.x;
1241 if (left + width > _screen.width) {
1242 width = _screen.width - left;
1244 if (width <= 0)
return;
1246 int top = _cursor.
pos.y + _cursor.total_offs.y;
1252 if (top + height > _screen.height) {
1253 height = _screen.height - top;
1255 if (height <= 0)
return;
1257 _cursor.draw_pos.x = left;
1258 _cursor.draw_pos.y = top;
1268 _cur_dpi = &_screen;
1276 _cursor.
dirty =
false;
1279 void RedrawScreenRect(
int left,
int top,
int right,
int bottom)
1281 assert(right <= _screen.width && bottom <= _screen.height);
1283 if (right > _cursor.draw_pos.x &&
1284 left < _cursor.draw_pos.x + _cursor.
draw_size.x &&
1285 bottom > _cursor.draw_pos.y &&
1286 top < _cursor.draw_pos.y + _cursor.
draw_size.y) {
1287 UndrawMouseCursor();
1291 #ifdef ENABLE_NETWORK 1307 byte *b = _dirty_blocks;
1308 const int w =
Align(_screen.width, DIRTY_BLOCK_WIDTH);
1309 const int h =
Align(_screen.height, DIRTY_BLOCK_HEIGHT);
1343 int right = x + DIRTY_BLOCK_WIDTH;
1351 p += _dirty_bytes_per_line;
1352 bottom += DIRTY_BLOCK_HEIGHT;
1353 }
while (bottom != h && *p != 0);
1356 h2 = (bottom - y) / DIRTY_BLOCK_HEIGHT;
1360 while (right != w) {
1365 if (!*p2)
goto no_more_coalesc;
1366 p2 += _dirty_bytes_per_line;
1371 right += DIRTY_BLOCK_WIDTH;
1377 p2 += _dirty_bytes_per_line;
1385 if (left < _invalid_rect.left ) left = _invalid_rect.left;
1386 if (top < _invalid_rect.top ) top = _invalid_rect.top;
1387 if (right > _invalid_rect.right ) right = _invalid_rect.right;
1388 if (bottom > _invalid_rect.bottom) bottom = _invalid_rect.bottom;
1390 if (left < right && top < bottom) {
1391 RedrawScreenRect(left, top, right, bottom);
1395 }
while (b++, (x += DIRTY_BLOCK_WIDTH) != w);
1396 }
while (b += -(
int)(w / DIRTY_BLOCK_WIDTH) + _dirty_bytes_per_line, (y += DIRTY_BLOCK_HEIGHT) != h);
1398 ++_dirty_block_colour;
1399 _invalid_rect.left = w;
1400 _invalid_rect.top = h;
1401 _invalid_rect.right = 0;
1402 _invalid_rect.bottom = 0;
1426 if (left < 0) left = 0;
1427 if (top < 0) top = 0;
1428 if (right > _screen.width) right = _screen.width;
1429 if (bottom > _screen.height) bottom = _screen.height;
1431 if (left >= right || top >= bottom)
return;
1433 if (left < _invalid_rect.left ) _invalid_rect.left = left;
1434 if (top < _invalid_rect.top ) _invalid_rect.top = top;
1435 if (right > _invalid_rect.right ) _invalid_rect.right = right;
1436 if (bottom > _invalid_rect.bottom) _invalid_rect.bottom = bottom;
1438 left /= DIRTY_BLOCK_WIDTH;
1439 top /= DIRTY_BLOCK_HEIGHT;
1441 b = _dirty_blocks + top * _dirty_bytes_per_line + left;
1443 width = ((right - 1) / DIRTY_BLOCK_WIDTH) - left + 1;
1444 height = ((bottom - 1) / DIRTY_BLOCK_HEIGHT) - top + 1;
1446 assert(width > 0 && height > 0);
1451 do b[--i] = 0xFF;
while (i != 0);
1453 b += _dirty_bytes_per_line;
1454 }
while (--height != 0);
1492 if ((left -= o->left) < 0) {
1494 if (width <= 0)
return false;
1501 if (width > o->width - left) {
1502 width = o->width - left;
1503 if (width <= 0)
return false;
1507 if ((top -= o->top) < 0) {
1509 if (height <= 0)
return false;
1516 n->dst_ptr = blitter->
MoveTo(o->dst_ptr, left, top);
1517 n->pitch = o->pitch;
1519 if (height > o->height - top) {
1520 height = o->height - top;
1521 if (height <= 0)
return false;
1548 _cursor.total_offs = offs;
1551 int right =
max(_cursor.total_offs.x + _cursor.
total_size.x, offs.x + size.x);
1552 int bottom =
max(_cursor.total_offs.y + _cursor.
total_size.y, offs.y + size.y);
1553 if (offs.x < _cursor.total_offs.x) _cursor.total_offs.x = offs.x;
1554 if (offs.y < _cursor.total_offs.y) _cursor.total_offs.y = offs.y;
1555 _cursor.
total_size.x = right - _cursor.total_offs.x;
1556 _cursor.
total_size.y = bottom - _cursor.total_offs.y;
1560 _cursor.
dirty =
true;
1581 static void SwitchAnimatedCursor()
1596 SwitchAnimatedCursor();
1637 SwitchAnimatedCursor();
1660 if (x == this->
pos.x && y == this->pos.y) {
1662 this->queued_warp =
false;
1665 this->
delta.x = x - (this->queued_warp ? this->last_position.x : this->
pos.x);
1666 this->
delta.y = y - (this->queued_warp ? this->last_position.y : this->
pos.y);
1668 this->last_position.x = x;
1669 this->last_position.y = y;
1671 bool need_warp =
false;
1673 if (this->
delta.x != 0 || this->delta.y != 0) {
1678 this->queued_warp = queued_warp;
1681 }
else if (this->
pos.x != x || this->pos.y != y) {
1682 this->queued_warp =
false;
1690 bool ChangeResInGame(
int width,
int height)
1695 bool ToggleFullScreen(
bool fs)
1699 DEBUG(driver, 0,
"Could not find a suitable fullscreen resolution");
1706 int x = pa->width - pb->width;
1707 if (x != 0)
return x;
1708 return pa->height - pb->height;
1711 void SortResolutions(
int count)
virtual void MakeDirty(int left, int top, int width, int height)=0
Mark a particular area dirty.
Functions related to OTTD's strings.
int left
The left offset in the 'dst' in pixels to start drawing.
Functions/types related to NewGRF debugging.
uint32 PaletteID
The number of the palette.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
bool _networking
are we in networking mode?
Base of all video drivers.
bool dirty
the rect occupied by the mouse is dirty (redraw)
Data about how and where to blit pixels.
static const uint8 PC_WHITE
White palette colour.
Horizontally center the text.
uint32 _realtime_tick
The real time in the game.
Control codes that are embedded in the translation strings.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen...
Point pos
logical mouse position
byte landscape
the landscape we're currently in
static void SetColourRemap(TextColour colour)
Set the colour remap to be for the given colour.
int sprite_width
Real width of the sprite.
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
Information about the currently used palette.
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
virtual void ReleaseBlitterLock()
Release any lock(s) required to be held when changing blitters.
static const PaletteID PALETTE_ALL_BLACK
Exchange any color by black, needed for painting fictive tiles outside map.
int height
The height in pixels that needs to be drawn to dst.
static byte _string_colourremap[3]
Recoloursprite for stringdrawing. The grf loader ensures that ST_FONT sprites only use colours 0 to 2...
bool _right_button_down
Is right mouse button pressed?
Point sprite_pos[16]
relative position of individual sprites
Perform transparency colour remapping.
static int UnScaleByZoomLower(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!
int skip_top
How much pixels of the source to skip on the top (based on zoom of dst)
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
static int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL) When shifting right...
StringAlignment
How to align the to-be drawn text.
uint sprite_count
number of sprites to draw
#define FONT_HEIGHT_MONO
Height of characters in the large (FS_MONO) font.
Index of the monospaced font in the font tables.
Data structure describing a sprite.
Mask for horizontal alignment.
int sprite_height
Real height of the sprite.
static const ExtraPaletteValues _extra_palette_values
Actual palette animation tables.
int width
The width in pixels that needs to be drawn to dst.
virtual void SetPixel(void *video, int x, int y, uint8 colour)=0
Draw a pixel with a given colour on the video-buffer.
static bool GfxPreprocessLine(DrawPixelInfo *dpi, int &x, int &y, int &x2, int &y2, int width)
Align parameters of a line to the given DPI and check simple clipping.
const AnimCursor * animate_list
in case of animated cursor, list of frames
static int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) When shifting right...
byte GetCharacterWidth(FontSize size, WChar key)
Return width of character glyph.
const T * Begin() const
Get the pointer to the first item (const)
virtual bool ToggleFullscreen(bool fullscreen)=0
Change the full screen setting.
void * clicked_pixel
Clicked pixel (pointer to blitter buffer)
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
const char * GetCharAtPosition(int x) const
Get the character that is at a position.
int _num_resolutions
The number of resolutions.
#define lastof(x)
Get the last element of an fixed size array.
ZoomLevelByte _gui_zoom
GUI Zoom level.
int skip_left
How much pixels of the source to skip on the left (based on zoom of dst)
Visual run contains data about the bit of text with the same font.
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
The most basic (normal) sprite.
How all blitters should look like.
static const uint MODAL_PROGRESS_REDRAW_TIMEOUT
Timeout between redraws.
static T max(const T a, const T b)
Returns the maximum of two values.
Functions related to laying out the texts.
virtual void EndCritical(bool allow_recursive=false)=0
End of the critical section.
static const uint EPV_CYCLES_OIL_REFINERY
length of the oil refinery's fire animation
bool visible
cursor is visible
const T * End() const
Get the pointer behind the last valid item (const)
NewGrfDebugSpritePicker _newgrf_debug_sprite_picker
The sprite picker.
static uint GetGlyphWidth(FontSize size, WChar key)
Get the width of a glyph.
static int RoundDivSU(int a, uint b)
Computes round(a / b) for signed a and unsigned b.
FillRectMode
Define the operation GfxFillRect performs.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Point total_size
union of sprite properties
bool _left_button_clicked
Is left mouse button clicked?
Force the alignment, i.e. don't swap for RTL languages.
ThreadMutex * _modal_progress_work_mutex
Rights for the performing work.
bool _ctrl_pressed
Is Ctrl pressed?
Point draw_size
position and size bounding-box for drawing
The colour translation of the GRF palettes.
CursorID sprite
Must be set to LAST_ANIM when it is the last sprite of the loop.
Collection of variables for cursor-display and -animation.
virtual bool ChangeResolution(int w, int h)=0
Change the resolution of the window.
bool IsFirstModalProgressLoop()
Check whether this is the first modal progress loop.
int16 y_offs
Number of pixels to shift the sprite downwards.
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
A single line worth of VisualRuns.
bool _right_button_clicked
Is right mouse button clicked?
static Rect _invalid_rect
The rect for repaint.
uint Length() const
Get the number of items in the list.
static T Align(const T x, uint n)
Return the smallest multiple of n equal or greater than x.
GameMode
Mode which defines the state of the game.
const T * GetBuffer() const
Get the currently allocated buffer.
Parameters related to blitting.
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub)
Draw a sprite in a viewport.
bool _left_button_down
Is left mouse button pressed?
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
virtual uint GetGlyphWidth(GlyphID key)=0
Get the width of the glyph with the given key.
Apply a recolour sprite to the screen content.
Types related to global configuration settings.
Functions related to modal progress.
Definition of base types and functions in a cross-platform compatible way.
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
A number of safeguards to prevent using unsafe methods.
int pitch
The pitch of the destination buffer.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
bool UpdateCursorPosition(int x, int y, bool queued_warp)
Update cursor position on mouse movement.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
virtual void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)=0
Draw an image to the screen, given an amount of params defined above.
T * Allocate(size_t count)
Get buffer of at least count times T.
number of animated colours
byte _dirkeys
1 = left, 2 = up, 4 = right, 8 = down
Perform a crash remapping.
bool fix_at
mouse is moving, but cursor is not (used for scrolling)
void DrawCharCentered(WChar c, int x, int y, TextColour colour)
Draw single character horizontally centered around (x,y)
virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash=0)=0
Draw a line with a given colour.
bool _screen_disable_anim
Disable palette animation (important for 32bpp-anim blitter during giant screenshot) ...
Point GetCharPosInString(const char *str, const char *ch, FontSize start_fontsize)
Get the leading corner of a character in a single-line string relative to the start of the string...
static const uint EPV_CYCLES_FIZZY_DRINK
length of the fizzy drinks animation
A reusable buffer that can be used for places that temporary allocate a bit of memory and do that ver...
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Basic functions/variables used all over the place.
static const Palette _palette
Colour palette (DOS)
A single sprite of a list of animated cursors.
byte display_time
Amount of ticks this sprite will be shown.
Mask for vertical alignment.
void SetDirtyBlocks(int left, int top, int right, int bottom)
This function extends the internal _invalid_rect rectangle as it now contains the rectangle defined b...
#define FONT_HEIGHT_LARGE
Height of characters in the large (FS_LARGE) font.
virtual void AcquireBlitterLock()
Acquire any lock(s) required to be held when changing blitters.
#define lengthof(x)
Return the length of an fixed size array.
PauseModeByte _pause_mode
The current pause mode.
void DrawDirtyBlocks()
Repaints the rectangle blocks which are marked as 'dirty'.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
number of bits for the sprite number
int first_dirty
The first dirty element.
Perform remapping to a completely blackened sprite.
static const Sprite * GetGlyph(FontSize size, WChar key)
Get the Sprite for a glyph.
ThreadMutex * _modal_progress_paint_mutex
Rights for the painting.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
From a rectangle that needs redrawing, find the windows that intersect with the rectangle.
virtual void CopyToBuffer(const void *video, void *dst, int width, int height)=0
Copy from the screen to a buffer.
virtual GlyphID MapCharToGlyph(WChar key)=0
Map a character into a glyph.
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3)
Draws the projection of a parallelepiped.
Font cache for basic fonts.
Template of struct holding enum types (on most archs, enums are stored in an int32).
Palette _cur_palette
Current palette.
uint16 height
Height of the sprite.
Dimension GetBounds()
Get the boundaries of this paragraph.
bool _shift_pressed
Is Shift pressed?
void NetworkUndrawChatMessage()
Hide the chatbox.
#define DEBUG(name, level,...)
Output a line of debugging information.
Dimension _resolutions[32]
List of resolutions.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
virtual Blitter::PaletteAnimation UsePaletteAnimation()=0
Check if the blitter uses palette animation at all.
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
static const uint EPV_CYCLES_DARK_WATER
Description of the length of the palette cycle animations.
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Draw only every second pixel, used for greying-out.
PalSpriteID sprite_seq[16]
current image of cursor
uint GetMaxSpriteID()
Get a reasonable (upper bound) estimate of the maximum SpriteID used in OpenTTD; there will be no spr...
virtual int BufferSize(int width, int height)=0
Calculate how much memory there is needed for an image of this size in the video-buffer.
void SetAnimatedMouseCursor(const AnimCursor *table)
Assign an animation to the cursor.
virtual void DrawRect(void *video, int width, int height, uint8 colour)=0
Make a single horizontal line in a single colour on the video-buffer.
ZoomLevel
All zoom levels we know.
uint16 width
Width of the sprite.
static void GfxBlitter(const Sprite *const sprite, int x, int y, BlitterMode mode, const SubSprite *const sub, SpriteID sprite_id, ZoomLevel zoom)
The code for setting up the blitter mode and sprite information before finally drawing the sprite...
int top
The top offset in the 'dst' in pixels to start drawing.
void ReInitAllWindows()
Re-initialize all windows.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
void UpdateCursorSize()
Update cursor dimension.
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
static void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash=0)
Check line clipping by using a linear equation and draw the visible part of the line given by x/y and...
TextColour GetContrastColour(uint8 background, uint8 threshold)
Determine a contrasty text colour for a coloured background.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
uint animate_timeout
in case of animated cursor, number of ticks to show the current cursor
static const byte _string_colourmap[17]
Colour mapping for TextColour.
const byte * remap
XXX – Temporary storage for remap array.
TextDirection _current_text_dir
Text direction of the currently selected language.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
virtual void CopyFromBuffer(void *video, const void *src, int width, int height)=0
Copy from a buffer to the screen.
const void * sprite
Pointer to the sprite how ever the encoder stored it.
static void SetCursorSprite(CursorID cursor, PaletteID pal)
Switch cursor to different sprite.
void GetBroadestDigit(uint *front, uint *next, FontSize size)
Determine the broadest digits for guessing the maximum width of a n-digit number. ...
when a sprite is to be displayed transparently, this bit needs to be set.
static T abs(const T a)
Returns the absolute value of (scalar) variable.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Do not add shading to this text colour.
virtual const Sprite * GetGlyph(GlyphID key)=0
Get the glyph (sprite) of the given key.
Functions related to zooming.
FontSize
Available font sizes.
Perform a colour remapping.
bool Include(const T &item)
Tests whether a item is present in the vector, and appends it to the end if not.
Set if palette is actually a magic text recolour.
Index of the normal font in the font tables.
bool in_window
mouse inside this window, determines drawing logic
SwitchMode _switch_mode
The next mainloop command.
int16 x_offs
Number of pixels to shift the sprite to the right.
Used to only draw a part of the sprite.
virtual void * MoveTo(void *video, int x, int y)=0
Move the destination pointer the requested amount x and y, keeping in mind any pitch and bpp of the r...
void * dst
Destination buffer.
virtual bool GetDrawGlyphShadow()=0
Do we need to draw a glyph shadow?
Network functions used by other parts of OpenTTD.
uint32 CursorID
The number of the cursor (sprite)
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
Perform the simple blitting.
The colour translation of GRF's strings.
virtual uint8 GetScreenDepth()=0
Get the screen depth this blitter works for.
Colour value is already a real palette colour index, not an index of a StringColour.
ZoomLevelByte _font_zoom
Font Zoom level.
BlitterMode
The modes of blitting we can do.
number of bits of the sprite containing the recolour palette
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
virtual void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)=0
Draw a colourtable to the screen.
The layouter performs all the layout work.
GameCreationSettings game_creation
settings used during the creation of a game (map)
virtual void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)=0
Scroll the videobuffer some 'x' and 'y' value.
Specification of a rectangle with absolute coordinates of all edges.
Text is written right-to-left by default.
Right align the text (must be a single bit).
virtual void BeginCritical(bool allow_recursive=false)=0
Begin the critical section.
const char * GetCharAtPosition(const char *str, int x, FontSize start_fontsize)
Get the character from a string that is drawn at a specific position.
Window functions not directly related to making/drawing windows.
Point delta
relative mouse movement in this tick
const AnimCursor * animate_cur
in case of animated cursor, current frame
uint32 GlyphID
Glyphs are characters from a font.
Vertically center the text.
static byte _stringwidth_table[FS_END][224]
Cache containing width of often used characters.
SpriteID sprite
The 'real' sprite.
int count_dirty
The number of dirty elements.
SmallVector< SpriteID, 256 > sprites
Sprites found.
static const uint EPV_CYCLES_LIGHTHOUSE
length of the lighthouse/stadium animation
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Index in the _palettes array from which all animations are taking places (table/palettes.h)
static void QSortT(T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
Type safe qsort()
uint32 WChar
Type for wide characters, i.e.
static BlitterMode GetBlitterMode(PaletteID pal)
Helper function to get the blitter mode for different types of palettes.
Dimensions (a width and height) of a rectangle in 2D.
static int DrawLayoutLine(const ParagraphLayouter::Line *line, int y, int left, int right, StringAlignment align, bool underline, bool truncation)
Drawing routine for drawing a laid out line of text.
This file contains all sprite-related enums and defines.
NewGrfDebugSpritePickerMode mode
Current state.
Factory to 'query' all available blitters.
Point GetCharPosition(const char *ch) const
Get the position of a character in the layout.
static const uint EPV_CYCLES_GLITTER_WATER
length of the glittery water animation
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
SwitchMode
Mode which defines what mode we're switching to.
static bool HasModalProgress()
Check if we are currently in a modal progress state.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
PaletteID pal
The palette (use PAL_NONE) if not needed)