94 #include "table/strings.h" 99 Point _tile_fract_coords;
170 int foundation[FOUNDATION_PART_END];
172 int *last_foundation_child[FOUNDATION_PART_END];
173 Point foundation_offset[FOUNDATION_PART_END];
182 bool _draw_bounding_boxes =
false;
183 bool _draw_dirty_blocks =
false;
184 uint _dirty_block_colour = 0;
187 static Point MapXYZToViewport(
const ViewPort *vp,
int x,
int y,
int z)
195 void DeleteWindowViewport(
Window *w)
217 int width,
int height, uint32 follow_flags,
ZoomLevel zoom)
235 if (follow_flags & 0x80000000) {
246 pt = MapXYZToViewport(vp, x, y, GetSlopePixelZ(x, y));
261 static Point _vp_move_offs;
263 static void DoSetViewportPosition(
const Window *w,
int left,
int top,
int width,
int height)
266 if (left + width > w->
left &&
268 top + height > w->
top &&
271 if (left < w->left) {
272 DoSetViewportPosition(w, left, top, w->
left - left, height);
273 DoSetViewportPosition(w, left + (w->
left - left), top, width - (w->
left - left), height);
278 DoSetViewportPosition(w, left, top, (w->
left + w->
width - left), height);
279 DoSetViewportPosition(w, left + (w->
left + w->
width - left), top, width - (w->
left + w->
width - left), height);
284 DoSetViewportPosition(w, left, top, width, (w->
top - top));
285 DoSetViewportPosition(w, left, top + (w->
top - top), width, height - (w->
top - top));
290 DoSetViewportPosition(w, left, top, width, (w->
top + w->
height - top));
291 DoSetViewportPosition(w, left, top + (w->
top + w->
height - top), width, height - (w->
top + w->
height - top));
300 int xo = _vp_move_offs.x;
301 int yo = _vp_move_offs.y;
303 if (
abs(xo) >= width ||
abs(yo) >= height) {
305 RedrawScreenRect(left, top, left + width, top + height);
309 GfxScroll(left, top, width, height, xo, yo);
312 RedrawScreenRect(left, top, xo + left, top + height);
316 RedrawScreenRect(left + width + xo, top, left + width, top + height);
321 RedrawScreenRect(left, top, width + left, top + yo);
323 RedrawScreenRect(left, top + height + yo, width + left, top + height);
328 static void SetViewportPosition(
Window *w,
int x,
int y)
334 int left, top, width, height;
350 if (old_top == 0 && old_left == 0)
return;
352 _vp_move_offs.x = old_left;
353 _vp_move_offs.y = old_top;
365 i = left + width - _screen.width;
366 if (i >= 0) width -= i;
374 i = top + height - _screen.height;
375 if (i >= 0) height -= i;
377 if (height > 0) DoSetViewportPosition(w->
z_front, left, top, width, height);
416 Point pt = { -1, -1 };
428 static Point GetTileFromScreenXY(
int x,
int y,
int zoom_x,
int zoom_y)
442 Point GetTileBelowCursor()
444 return GetTileFromScreenXY(_cursor.
pos.x, _cursor.
pos.y, _cursor.
pos.x, _cursor.
pos.y);
454 x = ((_cursor.
pos.x - vp->
left) >> 1) + (vp->
width >> 2);
455 y = ((_cursor.
pos.y - vp->
top) >> 1) + (vp->
height >> 2);
461 return GetTileFromScreenXY(_cursor.
pos.x, _cursor.
pos.y, x + vp->
left, y + vp->
top);
502 ts->
x = pt.x + extra_offs_x;
503 ts->
y = pt.y + extra_offs_y;
520 assert(
IsInsideMM(foundation_part, 0, FOUNDATION_PART_END));
521 assert(_vd.
foundation[foundation_part] != -1);
525 int *old_child = _vd.last_child;
528 AddChildSpriteScreen(image, pal, offs.x + extra_offs_x, offs.y + extra_offs_y,
false, sub,
false);
531 _vd.last_child = old_child;
556 AddTileSpriteToDraw(image, pal, _cur_ti->
x + x, _cur_ti->
y + y, _cur_ti->
z + z, sub, extra_offs_x * ZOOM_LVL_BASE, extra_offs_y * ZOOM_LVL_BASE);
592 default: NOT_REACHED();
619 if (pt.x + spr->
x_offs >= _vd.dpi.left + _vd.dpi.width ||
621 pt.y + spr->
y_offs >= _vd.dpi.top + _vd.dpi.height ||
654 void AddSortableSpriteToDraw(
SpriteID image,
PaletteID pal,
int x,
int y,
int w,
int h,
int dz,
int z,
bool transparent,
int bb_offset_x,
int bb_offset_y,
int bb_offset_z,
const SubSprite *sub)
656 int32 left, right, top, bottom;
671 _vd.last_child = NULL;
674 int tmp_left, tmp_top, tmp_x = pt.x, tmp_y = pt.y;
677 if (image == SPR_EMPTY_BOUNDING_BOX) {
678 left = tmp_left =
RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x;
679 right =
RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1;
680 top = tmp_top =
RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y;
681 bottom =
RemapCoords(x + w , y + h , z + bb_offset_z).y + 1;
684 left = tmp_left = (pt.x += spr->
x_offs);
685 right = (pt.x + spr->
width );
686 top = tmp_top = (pt.y += spr->
y_offs);
687 bottom = (pt.y + spr->
height);
690 if (_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX)) {
692 left =
min(left ,
RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x);
693 right =
max(right ,
RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1);
694 top =
min(top ,
RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y);
695 bottom =
max(bottom,
RemapCoords(x + w , y + h , z + bb_offset_z).y + 1);
699 if (left >= _vd.dpi.left + _vd.dpi.width ||
700 right <= _vd.dpi.left ||
701 top >= _vd.dpi.top + _vd.dpi.height ||
702 bottom <= _vd.dpi.top) {
716 ps->
xmin = x + bb_offset_x;
717 ps->
xmax = x +
max(bb_offset_x, w) - 1;
719 ps->
ymin = y + bb_offset_y;
720 ps->
ymax = y +
max(bb_offset_y, h) - 1;
722 ps->
zmin = z + bb_offset_z;
723 ps->
zmax = z +
max(bb_offset_z, dz) - 1;
778 if (begin > end)
Swap(begin, end);
779 return begin <= check && check <= end;
790 int dist_a = (_thd.
size.x + _thd.
size.y);
791 int dist_b = (_thd.
size.x - _thd.
size.y);
792 int a = ((x - _thd.
pos.x) + (y - _thd.
pos.y));
793 int b = ((x - _thd.
pos.x) - (y - _thd.
pos.y));
814 if (_vd.last_child == NULL)
return;
822 *_vd.last_child = _vd.child_screen_sprites_to_draw.
Length();
828 cs->x = scale ? x * ZOOM_LVL_BASE : x;
829 cs->y = scale ? y * ZOOM_LVL_BASE : y;
837 _vd.last_child = &cs->
next;
840 static void AddStringToDraw(
int x,
int y,
StringID string, uint64 params_1, uint64 params_2, Colours colour, uint16 width)
847 ss->params[0] = params_1;
848 ss->params[1] = params_2;
890 SpriteID sel2 = SPR_HALFTILE_SELECTION_FLAT + halftile_corner;
895 sel = SPR_HALFTILE_SELECTION_DOWN;
899 sel += opposite_corner;
906 static bool IsPartOfAutoLine(
int px,
int py)
916 case HT_DIR_HU:
return px == -py || px == -py - 16;
917 case HT_DIR_HL:
return px == -py || px == -py + 16;
918 case HT_DIR_VL:
return px == py || px == py + 16;
919 case HT_DIR_VR:
return px == py || px == py - 16;
952 static const uint _lower_rail[4] = { 5U, 2U, 4U, 3U };
954 if (autorail_type != _lower_rail[halftile_corner]) {
961 offset = _AutorailTilehSprite[autorail_tileh][autorail_type];
963 image = SPR_AUTORAIL_BASE + offset;
966 image = SPR_AUTORAIL_BASE - offset;
1007 if ((halftile_corner == CORNER_W) || (halftile_corner == CORNER_E)) z +=
TILE_HEIGHT;
1008 if (halftile_corner != CORNER_S) {
1019 }
else if (IsPartOfAutoLine(ti->
x, ti->
y)) {
1037 if (!is_redsq && _thd.
outersize.x > 0 &&
1063 assert(_vd.dpi.top <= _vd.dpi.top + _vd.dpi.height);
1064 assert(_vd.dpi.left <= _vd.dpi.left + _vd.dpi.width);
1082 int left_column = (upper_left.y - upper_left.x) / (
int)
TILE_SIZE - 2;
1083 int right_column = (upper_right.y - upper_right.x) / (
int)
TILE_SIZE + 2;
1091 int row = (upper_left.x + upper_left.y) / (
int)
TILE_SIZE - 2;
1092 bool last_row =
false;
1093 for (; !last_row; row++) {
1095 for (
int column = left_column; column <= right_column; column++) {
1097 if ((row + column) % 2 != 0)
continue;
1100 tilecoord.x = (row - column) / 2;
1101 tilecoord.y = (row + column) / 2;
1102 assert(column == tilecoord.y - tilecoord.x);
1103 assert(row == tilecoord.y + tilecoord.x);
1107 _cur_ti = &tile_info;
1113 tile_info.
tile =
TileXY(tilecoord.x, tilecoord.y);
1137 int min_visible_height = viewport_y - (_vd.dpi.top + _vd.dpi.height);
1138 bool tile_visible = min_visible_height <= 0;
1157 if ((tilecoord.x <= 0 || tilecoord.y <= 0) && min_visible_height < potential_bridge_height +
MAX_TILE_EXTENT_TOP) last_row =
false;
1187 bool small = dpi->zoom >= small_from;
1189 int left = dpi->left;
1191 int right = left + dpi->width;
1192 int bottom = top + dpi->height;
1197 if (bottom < sign->top ||
1198 top > sign->
top + sign_height ||
1199 right < sign->center - sign_half_width ||
1200 left > sign->
center + sign_half_width) {
1205 AddStringToDraw(sign->
center - sign_half_width, sign->
top, string_normal, params_1, params_2, colour, sign->
width_normal);
1207 int shadow_offset = 0;
1208 if (string_small_shadow != STR_NULL) {
1210 AddStringToDraw(sign->
center - sign_half_width + shadow_offset, sign->
top, string_small_shadow, params_1, params_2, INVALID_COLOUR, sign->
width_small);
1212 AddStringToDraw(sign->
center - sign_half_width, sign->
top - shadow_offset, string_small, params_1, params_2,
1225 STR_VIEWPORT_TOWN_TINY_WHITE, STR_VIEWPORT_TOWN_TINY_BLACK,
1236 FOR_ALL_BASE_STATIONS(st) {
1247 is_station ? STR_VIEWPORT_STATION : STR_VIEWPORT_WAYPOINT,
1248 (is_station ? STR_VIEWPORT_STATION : STR_VIEWPORT_WAYPOINT) + 1, STR_NULL,
1282 if (this->width_normal != 0) this->MarkDirty();
1288 GetString(buffer, str,
lastof(buffer));
1290 this->center = center;
1293 if (str_small != STR_NULL) {
1294 GetString(buffer, str_small,
lastof(buffer));
1313 zoomlevels[zoom].left = this->center -
ScaleByZoom(this->width_normal / 2 + 1, zoom);
1314 zoomlevels[zoom].top = this->top -
ScaleByZoom(1, zoom);
1315 zoomlevels[zoom].right = this->center +
ScaleByZoom(this->width_normal / 2 + 1, zoom);
1320 FOR_ALL_WINDOWS_FROM_BACK(w) {
1322 if (vp != NULL && vp->
zoom <= maxzoom) {
1323 assert(vp->
width != 0);
1349 while (psd != psdvend) {
1395 *psd3 = *(psd3 - 1);
1410 while (child_idx >= 0) {
1412 child_idx = cs->
next;
1433 pt2.x - pt1.x, pt2.y - pt1.y,
1434 pt3.x - pt1.x, pt3.y - pt1.y,
1435 pt4.x - pt1.x, pt4.y - pt1.y);
1454 byte bo =
UnScaleByZoom(dpi->left + dpi->top, dpi->zoom) & 1;
1456 for (
int i = (bo ^= 1); i < right; i += 2) blitter->
SetPixel(dst, i, 0, (uint8)colour);
1457 dst = blitter->
MoveTo(dst, 0, 1);
1458 }
while (--bottom > 0);
1466 bool small =
HasBit(ss->width, 15);
1467 int w =
GB(ss->width, 0, 15);
1475 if (ss->colour != INVALID_COLOUR) {
1488 x, y, x + w, y + h, ss->colour,
1498 void ViewportDoDraw(
const ViewPort *vp,
int left,
int top,
int right,
int bottom)
1501 _cur_dpi = &_vd.dpi;
1503 _vd.dpi.zoom = vp->
zoom;
1508 _vd.dpi.width = (right - left) & mask;
1509 _vd.dpi.height = (bottom - top) & mask;
1510 _vd.dpi.left = left & mask;
1511 _vd.dpi.top = top & mask;
1512 _vd.dpi.pitch = old_dpi->pitch;
1513 _vd.last_child = NULL;
1523 ViewportAddTownNames(&_vd.dpi);
1524 ViewportAddStationNames(&_vd.dpi);
1525 ViewportAddSigns(&_vd.dpi);
1527 DrawTextEffects(&_vd.dpi);
1529 if (_vd.tile_sprites_to_draw.
Length() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw);
1553 vp->overlay->
Draw(&dp);
1556 if (_vd.string_sprites_to_draw.
Length() != 0) {
1560 ViewportDrawStrings(zoom, &_vd.string_sprites_to_draw);
1565 _vd.string_sprites_to_draw.
Clear();
1566 _vd.tile_sprites_to_draw.
Clear();
1567 _vd.parent_sprites_to_draw.
Clear();
1569 _vd.child_screen_sprites_to_draw.
Clear();
1579 if ((bottom - top) > (right - left)) {
1580 int t = (top + bottom) >> 1;
1584 int t = (left + right) >> 1;
1598 static inline void ViewportDraw(
const ViewPort *vp,
int left,
int top,
int right,
int bottom)
1600 if (right <= vp->left || bottom <= vp->top)
return;
1602 if (left >= vp->
left + vp->
width)
return;
1604 if (left < vp->left) left = vp->
left;
1607 if (top >= vp->
top + vp->
height)
return;
1609 if (top < vp->top) top = vp->
top;
1624 dpi->left += this->left;
1625 dpi->top += this->top;
1627 ViewportDraw(this->viewport, dpi->left, dpi->top, dpi->left + dpi->width, dpi->top + dpi->height);
1629 dpi->left -= this->left;
1630 dpi->top -= this->top;
1677 SetViewportPosition(w, pt.x, pt.y);
1685 bool update_overlay =
false;
1686 if (delta_x != 0 || delta_y != 0) {
1703 if (update_overlay) RebuildViewportOverlay(w);
1719 right += (1 << vp->
zoom) - 1;
1720 bottom += (1 << vp->
zoom) - 1;
1723 if (right <= 0)
return;
1726 if (bottom <= 0)
return;
1755 FOR_ALL_WINDOWS_FROM_BACK(w) {
1758 assert(vp->
width != 0);
1764 void ConstrainAllViewportsZoom()
1767 FOR_ALL_WINDOWS_FROM_FRONT(w) {
1804 int x_size = _thd.
size.x;
1805 int y_size = _thd.
size.y;
1808 int x_start = _thd.
pos.x;
1809 int y_start = _thd.
pos.y;
1813 x_start += _thd.
offs.x;
1815 y_start += _thd.
offs.y;
1821 assert(x_size >= 0);
1822 assert(y_size >= 0);
1831 assert((x_end | y_end | x_start | y_start) %
TILE_SIZE == 0);
1852 int top_y = y_start;
1873 static const int OVERLAY_WIDTH = 4 * ZOOM_LVL_BASE;
1879 if (top_x != x_start) {
1886 if (bot_y != y_end) {
1891 }
while (bot_x >= top_x);
1894 int a_size = x_size + y_size, b_size = x_size - y_size;
1899 for (
int a = -interval_a; a != a_size + interval_a; a += interval_a) {
1900 for (
int b = -interval_b; b != b_size + interval_b; b += interval_b) {
1913 void SetSelectionRed(
bool b)
1936 return y >= sign->
top && y < sign->
top + sign_height &&
1937 x >= sign->
center - sign_half_width && x < sign->
center + sign_half_width;
1940 static bool CheckClickOnTown(
const ViewPort *vp,
int x,
int y)
1947 ShowTownViewWindow(t->
index);
1955 static bool CheckClickOnStation(
const ViewPort *vp,
int x,
int y)
1960 FOR_ALL_BASE_STATIONS(st) {
1984 static bool CheckClickOnSign(
const ViewPort *vp,
int x,
int y)
1993 if (si->owner ==
OWNER_DEITY && _game_mode != GM_EDITOR)
continue;
2005 static bool CheckClickOnLandscape(
const ViewPort *vp,
int x,
int y)
2009 if (pt.x != -1)
return ClickTile(
TileVirtXY(pt.x, pt.y));
2013 static void PlaceObject()
2018 pt = GetTileBelowCursor();
2019 if (pt.x == -1)
return;
2034 bool HandleViewportClicked(
const ViewPort *vp,
int x,
int y)
2048 if (CheckClickOnTown(vp, x, y))
return true;
2049 if (CheckClickOnStation(vp, x, y))
return true;
2050 if (CheckClickOnSign(vp, x, y))
return true;
2051 bool result = CheckClickOnLandscape(vp, x, y);
2068 void RebuildViewportOverlay(
Window *w)
2070 if (w->
viewport->overlay != NULL &&
2093 z = GetSlopePixelZ(x, y);
2107 RebuildViewportOverlay(w);
2168 void SetTileSelectBigSize(
int ox,
int oy,
int sx,
int sy)
2189 this->new_pos.x = 0;
2190 this->new_pos.y = 0;
2226 bool new_diagonal =
false;
2238 new_diagonal =
true;
2240 if (x1 >= x2)
Swap(x1, x2);
2241 if (y1 >= y2)
Swap(y1, y2);
2247 if (!new_diagonal) {
2254 Point pt = GetTileBelowCursor();
2286 default: NOT_REACHED();
2334 static void HideMeasurementTooltips()
2373 void VpSetPlaceSizingLimit(
int limit)
2397 HideMeasurementTooltips();
2401 static void VpStartPreSizing()
2413 int fxpy = _tile_fract_coords.x + _tile_fract_coords.y;
2415 int fxmy = _tile_fract_coords.x - _tile_fract_coords.y;
2419 default: NOT_REACHED();
2421 if (fxpy >= 20 && sxpy <= 12)
return HT_DIR_HL;
2422 if (fxmy < -3 && sxmy > 3)
return HT_DIR_VR;
2426 if (fxmy > 3 && sxmy < -3)
return HT_DIR_VL;
2427 if (fxpy <= 12 && sxpy >= 20)
return HT_DIR_HU;
2431 if (fxmy > 3 && sxmy < -3)
return HT_DIR_VL;
2432 if (fxpy >= 20 && sxpy <= 12)
return HT_DIR_HL;
2436 if (fxmy < -3 && sxmy > 3)
return HT_DIR_VR;
2437 if (fxpy <= 12 && sxpy >= 20)
return HT_DIR_HU;
2457 uint start_x =
TileX(start_tile);
2458 uint start_y =
TileY(start_tile);
2459 uint end_x =
TileX(end_tile);
2460 uint end_y =
TileY(end_tile);
2464 case HT_LINE:
return (end_x > start_x || (end_x == start_x && end_y > start_y));
2467 case HT_POINT:
return (end_x != start_x && end_y < start_y);
2468 default: NOT_REACHED();
2494 if (start_tile == end_tile)
return 0;
2495 if (swap)
Swap(start_tile, end_tile);
2506 byte style_t = (byte)(
TileX(end_tile) >
TileX(start_tile));
2521 {1, 0}, {1, 1}, {0, 1}, {1, 1},
2522 {1, 0}, {0, 0}, {1, 0}, {1, 1},
2523 {1, 0}, {1, 1}, {0, 1}, {1, 1},
2525 {0, 1}, {0, 0}, {1, 0}, {0, 0},
2526 {0, 1}, {0, 0}, {1, 1}, {0, 1},
2527 {1, 0}, {0, 0}, {0, 0}, {0, 1},
2537 if (swap && distance == 0) style = flip_style_direction[style];
2540 byte style_t = style * 2;
2541 assert(style_t <
lengthof(heightdiff_line_by_dir) - 13);
2548 if (distance == 0) style_t = flip_style_direction[style] * 2;
2549 assert(style_t <
lengthof(heightdiff_line_by_dir) - 13);
2557 if (swap)
Swap(h0, h1);
2561 static const StringID measure_strings_length[] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF};
2571 if (test >= 0)
return;
2573 other += mult * test;
2586 if (test <= max)
return;
2588 other += mult * (test -
max);
2631 int offset = (raw_dx - raw_dy) / 2;
2666 int offset = (raw_dx + raw_dy + (int)
TILE_SIZE) / 2;
2715 }
else if (w > h * 2) {
2718 }
else if (h > w * 2) {
2732 }
else if (d >= 0) {
2743 }
else if (d >= 0) {
2756 }
else if (d >= 0) {
2767 }
else if (d >= 0) {
2785 if (distance != 1) {
2791 distance =
CeilDiv(distance, 2);
2794 params[index++] = distance;
2795 if (heightdiff != 0) params[index++] = heightdiff;
2844 if (
abs(sy - y) <
abs(sx - x)) {
2851 goto calc_heightdiff_single_direction;
2860 goto calc_heightdiff_single_direction;
2870 calc_heightdiff_single_direction:;
2872 x = sx +
Clamp(x - sx, -limit, limit);
2873 y = sy +
Clamp(y - sy, -limit, limit);
2882 if (distance != 1) {
2890 params[index++] = distance;
2891 if (heightdiff != 0) params[index++] = heightdiff;
2900 x = sx +
Clamp(x - sx, -limit, limit);
2901 y = sy +
Clamp(y - sy, -limit, limit);
2906 static const StringID measure_strings_area[] = {
2907 STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF
2933 int a_max = dist_x + dist_y;
2934 int b_max = dist_y - dist_x;
2938 a_max =
abs(a_max + (a_max > 0 ? 2 : -2)) / 2;
2939 b_max =
abs(b_max + (b_max > 0 ? 2 : -2)) / 2;
2945 if (a_max != 1 || b_max != 1) {
2952 }
else if (dy == 1) {
2957 if (dx != 1 || dy != 1) {
2960 params[index++] = dx - (style &
HT_POINT ? 1 : 0);
2961 params[index++] = dy - (style &
HT_POINT ? 1 : 0);
2962 if (heightdiff != 0) params[index++] = heightdiff;
2969 default: NOT_REACHED();
3012 HideMeasurementTooltips();
3053 HideMeasurementTooltips();
3114 { &ViewportSortParentSpritesSSE41Checker, &ViewportSortParentSpritesSSE41 },
3122 for (uint i = 0; i <
lengthof(_vp_sprite_sorters); i++) {
3123 if (_vp_sprite_sorters[i].fct_checker()) {
3124 _vp_sprite_sorter = _vp_sprite_sorters[i].
fct_sorter;
3128 assert(_vp_sprite_sorter != NULL);
3151 #ifdef ENABLE_NETWORK EventState
State of handling an event.
void ViewportAddVehicles(DrawPixelInfo *dpi)
Add the vehicle sprites that should be drawn at a part of the screen.
bool DoZoomInOutWindow(ZoomStateChange how, Window *w)
Zooms a viewport in a window in or out.
Functions related to OTTD's strings.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it...
bool measure_tooltip
show a permanent tooltip when dragging tools
static bool IsHalftileSlope(Slope s)
Checks for non-continuous slope on halftile foundations.
static void DrawAutorailSelection(const TileInfo *ti, uint autorail_type)
Draws autorail highlights.
static const PaletteID PALETTE_SEL_TILE_RED
makes a square red. is used when removing rails or other stuff
static void Swap(T &a, T &b)
Type safe swap operation.
the north corner of the tile is raised
Corner
Enumeration of tile corners.
uint32 PaletteID
The number of the palette.
static const uint TILE_PIXELS
Pixel distance between tile columns/rows in #ZOOM_LVL_BASE.
WindowNumber window_number
The WindowNumber of the window that is responsible for the selection mode.
static uint MapSizeX()
Get the size of the map along the X.
static const int MAX_TILE_EXTENT_RIGHT
Maximum right extent of tile relative to north corner.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
bool IsDraggingDiagonal()
Is the user dragging a 'diagonal rectangle'?
int32 zmin
minimal world Z coordinate of bounding box
Definition of stuff that is very close to a company, like the company struct itself.
int32 zmax
maximal world Z coordinate of bounding box
static const PaletteID PALETTE_TO_TRANSPARENT
This sets the sprite to transparent.
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
void ShowWaypointWindow(const Waypoint *wp)
Show the window for the given waypoint.
int virtual_left
Virtual left coordinate.
int32 top
minimal screen Y coordinate of sprite (= y + sprite->y_offs), reference point for child sprites ...
void InitializeWindowViewport(Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom)
Initialize viewport of the window for use.
static bool SwapDirection(HighLightStyle style, TileIndex start_tile, TileIndex end_tile)
Check if the direction of start and end tile should be swapped based on the dragging-style.
Data about how and where to blit pixels.
static uint MapSizeY()
Get the size of the map along the Y.
Horizontally center the text.
Tile information, used while rendering the tile.
Sprite combining will start with the next unclipped sprite.
SpriteCombineMode
Mode of "sprite combining".
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Point pos
Location, in tile "units", of the northern tile of the selected area.
Point pos
logical mouse position
All zoomlevels below or equal to this, will result in details on the screen, like road-work...
area of land of limited size
void(* VpSpriteSorter)(ParentSpriteToSortVector *psd)
Type for the actual viewport sprite sorter.
ZoomLevelByte zoom_max
maximum zoom out level
The mask to for the main sprite.
static const PaletteID PALETTE_TILE_RED_PULSATING
pulsating red tile drawn if you try to build a wrong tunnel or raise/lower land where it is not possi...
uint32 GetCompanyMask()
Get a bitmask of the currently shown companies.
byte _display_opt
What do we want to draw/do?
int left
x position of left edge of the window
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
Zoom out (get helicopter view).
static int GetTilePixelZ(TileIndex tile)
Get bottom height of the tile.
int height
Screen height of the viewport.
static Titem * Get(size_t index)
Returns Titem with given index.
int32 y
screen Y coordinate of sprite
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
Update the status of the zoom-buttons according to the zoom-level of the viewport.
static Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap...
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
VpSorterChecker fct_checker
The check function.
TileType
The different types of tiles.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
static int UnScaleByZoomLower(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
int next
next child to draw (-1 at the end)
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
The passed event is not handled.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
static int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL) When shifting right...
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Data structure describing a sprite.
Slope tileh
Slope of the tile.
Sprite combining is active. AddSortableSpriteToDraw outputs child sprites.
Types for recording game performance data.
Drag only in X axis with limited size.
static const AnimCursor *const _animcursors[]
This is an array of pointers to all the animated cursor definitions we have above.
similar to VMP_RAILDIRS, but with different cursor
bool IsInUse() const
Check whether the base station currently is in use; in use means that it is not scheduled for deletio...
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
Shows a tooltip.
Slope GetTilePixelSlopeOutsideMap(int x, int y, int *h)
Return the slope of a given tile, also for tiles outside the map (virtual "black" tiles)...
static void CheckUnderflow(int &test, int &other, int mult)
Check for underflowing the map.
Point size
Size, in tile "units", of the white/red selection area.
virtual void SetPixel(void *video, int x, int y, uint8 colour)=0
Draw a pixel with a given colour on the video-buffer.
bool population_in_label
show the population of a town in his label?
Drag only in Y axis with limited size.
Functions related to vehicles.
static const int MAX_TILE_EXTENT_LEFT
Maximum left extent of tile relative to north corner.
int virtual_height
height << zoom
Point new_size
New value for size; used to determine whether to redraw the selection.
static uint TileX(TileIndex tile)
Get the X component of a tile.
Point new_pos
New value for pos; used to determine whether to redraw the selection.
int top
y position of top edge of the window
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
static bool IsInsideBS(const T x, const uint base, const uint size)
Checks if a value is between a window started at some base point.
void Clear()
Remove all items from the list.
static int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) When shifting right...
const T * Begin() const
Get the pointer to the first item (const)
Tindex index
Index of this pool item.
int foundation[FOUNDATION_PART_END]
Foundation sprites (index into parent_sprites_to_draw).
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
static bool IsSteepSlope(Slope s)
Checks if a slope is steep.
Display signs, station names and waypoint names of opponent companies. Buoys and oilrig-stations are ...
Zoom in (get more detailed view).
Maximum number of sprites that can be loaded at a given time.
#define lastof(x)
Get the last element of an fixed size array.
The client is spectating.
SpriteCombineMode combine_sprites
Current mode of "sprite combining".
Second part (halftile foundation)
static Corner GetHalftileSlopeCorner(Slope s)
Returns the leveled halftile of a halftile slope.
WindowClass
Window classes.
ParentSpriteToSortVector parent_sprites_to_sort
Parent sprite pointer array used for sorting.
The most basic (normal) sprite.
static int DivAwayFromZero(int a, uint b)
Computes (a / b) rounded away from zero.
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
The user is dragging over the map when the tile highlight mode has been set.
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
Common return value for all commands.
How all blitters should look like.
static Slope SlopeWithOneCornerRaised(Corner corner)
Returns the slope with a specific corner raised.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
void StartSpriteCombine()
Starts a block of sprites, which are "combined" into a single bounding box.
Functions related to signs.
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
static T max(const T a, const T b)
Returns the maximum of two values.
uint32 population
Current population of people.
Presizing mode (docks, tunnels).
const T * End() const
Get the pointer behind the last valid item (const)
Functions related to the vehicle's GUIs.
Window * GetCallbackWnd()
Get the window that started the current highlighting.
static const uint TILE_SIZE
Tile size in world coordinates.
FoundationPart foundation_part
Currently active foundation for ground sprite drawing.
void MarkDirty(ZoomLevel maxzoom=ZOOM_LVL_MAX) const
Mark the sign dirty in all viewports.
int32 x
screen X coordinate of sprite
Highlight/sprite information for autorail.
CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
Scroll players main viewport.
HighLightStyle place_mode
Method which is used to place the selection.
Functions, definitions and such used only by the GUI.
TileIndex GetNorthernBridgeEnd(TileIndex t)
Finds the northern end of a bridge starting at a middle tile.
static Waypoint * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
ViewportScrollTarget
Target of the viewport scrolling GS method.
Point foundation_offset[FOUNDATION_PART_END]
Pixel offset for ground sprites on the foundations.
T * Append(uint to_add=1)
Append an item and return it.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to (drawing on) viewports.
void Draw(const DrawPixelInfo *dpi)
Draw the linkgraph overlay or some part of it, in the area given.
The object is owned by a superuser / goal script.
Declaration of linkgraph overlay GUI.
Data structure for an opened window.
bool _ctrl_pressed
Is Ctrl pressed?
Data structure storing rendering information.
static bool IsValidTile(TileIndex tile)
Checks if a tile is valid.
void EndSpriteCombine()
Terminates a block of sprites started by StartSpriteCombine.
static bool IsBridgeAbove(TileIndex t)
checks if a bridge is set above the ground of this tile
Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y, bool clamp_to_map)
Translate screen coordinate in a viewport to underlying tile coordinate.
dragging items in the depot windows
ViewportSign sign
NOSAVE: Dimensions of sign.
static HighLightStyle GetAutorailHT(int x, int y)
returns the best autorail highlight type from map coordinates
Point selstart
The location where the dragging started.
Main window; Window numbers:
byte sizelimit
Whether the selection is limited in length, and what the maximum length is.
First part (normal foundation or no foundation)
Point selend
The location where the drag currently ends.
uint x
X position of the tile in unit coordinates.
Every AddSortableSpriteToDraw start its own bounding box.
int16 y_offs
Number of pixels to shift the sprite downwards.
ViewportSign sign
Location of name sign, UpdateVirtCoord updates this.
TileIndex tile
Tile index.
UnitID unitnumber
unit number, for display purposes only
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
int32 ymin
minimal world Y coordinate of bounding box
uint Length() const
Get the number of items in the list.
int32 first_child
the first child to draw.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
static T Align(const T x, uint n)
Return the smallest multiple of n equal or greater than x.
int32 top
The top of the sign.
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Tooltip window; Window numbers:
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
int32 x
screen X coordinate of sprite
void MarkAllViewportsDirty(int left, int top, int right, int bottom)
Mark all viewports that display an area as dirty (in need of repaint).
Point offs
Offset, in tile "units", for the blue coverage area from the selected area's northern tile...
uint32 VehicleID
The type all our vehicle IDs have.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub)
Draw a sprite in a viewport.
DoCommandFlag
List of flags for a command.
bool _left_button_down
Is left mouse button pressed?
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
ClientID _network_own_client_id
Our client identifier.
ClientSettings _settings_client
The current settings for this game.
static const CursorID ANIMCURSOR_FLAG
Flag for saying a cursor sprite is an animated cursor.
static void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond=TCC_NONE)
Displays the measurement tooltips when selecting multiple tiles.
static ViewportSSCSS _vp_sprite_sorters[]
List of sorters ordered from best to worst.
static void ViewportDrawChk(const ViewPort *vp, int left, int top, int right, int bottom)
Make sure we don't draw a too big area at a time.
Definition of base types and functions in a cross-platform compatible way.
Location information about a sign as seen on the viewport.
static void ViewportDrawBoundingBoxes(const ParentSpriteToSortVector *psd)
Draws the bounding boxes of all ParentSprites.
static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv)
Sort parent sprites pointer array.
A number of safeguards to prevent using unsafe methods.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
static void SetSelectionTilesDirty()
Marks the selected tiles as dirty.
static void CheckOverflow(int &test, int &other, int max, int mult)
Check for overflowing the map.
rectangle (stations, depots, ...)
uint y
Y position of the tile in unit coordinates.
int32 y
screen Y coordinate of sprite
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
ViewportPlaceMethod select_method
The method which governs how tiles are selected.
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
Data structure for a window viewport.
static Slope GetTilePixelSlope(TileIndex tile, int *h)
Return the slope of a given tile.
static const uint TILE_HEIGHT
Height of a height level in world coordinate AND in pixels in #ZOOM_LVL_BASE.
int32 scrollpos_x
Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport).
int32 xmin
minimal world X coordinate of bounding box
HighLightStyle drawstyle
Lower bits 0-3 are reserved for detailed highlight information.
uint16 width_normal
The width when not zoomed out (normal font)
static void DrawTileSelectionRect(const TileInfo *ti, PaletteID pal)
Draws a selection rectangle on a tile.
Map accessor functions for bridges.
bool IsInsideRotatedRectangle(int x, int y)
Checks whether a point is inside the selected a diagonal rectangle given by _thd.size and _thd...
static Slope SlopeWithThreeCornersRaised(Corner corner)
Returns the slope with all except one corner raised.
int virtual_width
width << zoom
The tile has no ownership.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
static const PaletteID PALETTE_SEL_TILE_BLUE
This draws a blueish square (catchment areas for example)
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.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_tile, TileIndex end_tile)
Calculates height difference between one tile and another.
StationFacilityByte facilities
The facilities that this station has.
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...
bool smooth_scroll
smooth scroll viewports
autorail (one piece), lower bits: direction
static int GetViewportY(Point tile)
Returns the y coordinate in the viewport coordinate system where the given tile is painted...
#define lengthof(x)
Return the length of an fixed size array.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
static T min(const T a, const T b)
Returns the minimum of two values.
static void ClampViewportToMap(const ViewPort *vp, int *scroll_x, int *scroll_y)
Ensure that a given viewport has a valid scroll position.
static void AddCombinedSprite(SpriteID image, PaletteID pal, int x, int y, int z, const SubSprite *sub)
Adds a child sprite to a parent sprite.
bool ScrollWindowToTile(TileIndex tile, Window *w, bool instant)
Scrolls the viewport in a window to a given location.
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
Point new_outersize
New value for outersize; used to determine whether to redraw the selection.
drag only in horizontal direction
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3)
Draws the projection of a parallelepiped.
ViewPort * IsPtInWindowViewport(const Window *w, int x, int y)
Is a xy position inside the viewport of the window?
int32 dest_scrollpos_y
Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewp...
const SubSprite * sub
only draw a rectangular part of the sprite
void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub)
Draw a (transparent) sprite at given coordinates with a given bounding box.
static Slope RemoveHalftileSlope(Slope s)
Removes a halftile slope from a slope.
void ShowStationViewWindow(StationID station)
Opens StationViewWindow for given station.
bool make_square_red
Whether to give a tile a red selection.
uint16 height
Height of the sprite.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static const int MAX_TILE_EXTENT_TOP
Maximum top extent of tile relative to north corner (not considering bridges).
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
#define DEBUG(name, level,...)
Output a line of debugging information.
point (lower land, raise land, level land, ...)
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
static HighLightStyle Check2x1AutoRail(int mode)
returns information about the 2x1 piece to be build.
int32 center
The center position of the sign.
static void MarkViewportDirty(const ViewPort *vp, int left, int top, int right, int bottom)
Marks a viewport as dirty for repaint if it displays (a part of) the area the needs to be repainted...
const SubSprite * sub
only draw a rectangular part of the sprite
ViewportDragDropSelectionProcess select_proc
The procedure that has to be called when the selection is done.
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
OwnerByte owner
The owner of this station.
Mask for the tile drag-type modes.
void UpdateTileSelection()
Updates tile highlighting for all cases.
static uint ScaleByMapSize1D(uint n)
Scales the given value by the maps circumference, where the given value is for a 256 by 256 map...
A pair-construct of a TileIndexDiff.
int * last_foundation_child[FOUNDATION_PART_END]
Tail of ChildSprite list of the foundations. (index into child_screen_sprites_to_draw) ...
int left
Screen coordinate left egde of the viewport.
static const int TILE_HEIGHT_STEP
One Z unit tile height difference is displayed as 50m.
void DrawViewport() const
Draw the viewport of this window.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
ZoomLevelByte zoom_min
minimum zoom out level
static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
Return the offset between to tiles from a TileIndexDiffC struct.
execute the given command
static bool IsInRangeInclusive(int begin, int end, int check)
Check if the parameter "check" is inside the interval between begin and end, including both begin and...
void SetAnimatedMouseCursor(const AnimCursor *table)
Assign an animation to the cursor.
ZoomLevel
All zoom levels we know.
uint16 width
Width of the sprite.
Functions related to companies.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
bool ScrollMainWindowTo(int x, int y, int z, bool instant)
Scrolls the main window to given coordinates.
int32 dest_scrollpos_x
Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewp...
area of land in X and Y directions
static bool ViewportSortParentSpritesChecker()
This fallback sprite checker always exists.
static void AddChildSpriteToFoundation(SpriteID image, PaletteID pal, const SubSprite *sub, FoundationPart foundation_part, int extra_offs_x, int extra_offs_y)
Adds a child sprite to the active foundation.
Parent sprite that should be drawn.
static uint TilePixelHeightOutsideMap(int x, int y)
Returns the height of a tile in pixels, also for tiles outside the map (virtual "black" tiles)...
GUISettings gui
settings related to the GUI
SpriteID image
sprite to draw
Invisible tiles at the SW and SE border.
Base class for all vehicles.
Data structure for viewport, display of a part of the world.
static void DrawTileSelection(const TileInfo *ti)
Checks if the specified tile is selected and if so draws selection using correct selectionstyle.
static void ViewportAddLandscape()
Add the landscape to the viewport, i.e.
Point InverseRemapCoords2(int x, int y, bool clamp_to_map, bool *clamped)
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Time spent drawing world viewports in GUI.
CompanyByte _current_company
Company currently doing an action.
uint32 TileIndex
The index/ID of a Tile.
Window * z_front
The window in front of us in z-order.
static const byte _string_colourmap[17]
Colour mapping for TextColour.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
bool diagonal
Whether the dragged area is a 45 degrees rotated rectangle.
All players in specific company.
void HandleClickOnSign(const Sign *si)
Handle clicking on a sign.
Helper class for getting the best sprite sorter.
static int GetBridgePixelHeight(TileIndex tile)
Get the height ('z') of a bridge in pixels.
bool(* VpSorterChecker)()
Type for method for checking whether a viewport sprite sorter exists.
TileIndex redsq
The tile that has to get a red selection.
static const int MAX_TILE_EXTENT_BOTTOM
Maximum bottom extent of tile relative to north corner (worst case: SLOPE_STEEP_N).
int32 ymax
maximal world Y coordinate of bounding box
static void AddTileSpriteToDraw(SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub=NULL, int extra_offs_x=0, int extra_offs_y=0)
Schedules a tile sprite for drawing.
ClientID
'Unique' identifier to be given to clients
static uint TileY(TileIndex tile)
Get the Y component of a tile.
int32 xmax
maximal world X coordinate of bounding box
when a sprite is to be displayed transparently, this bit needs to be set.
OwnerByte owner
Which company owns the vehicle?
static T abs(const T a)
Returns the absolute value of (scalar) variable.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
TileIndex xy
Base tile of the station.
void Reset()
Reset tile highlighting.
static void DrawSelectionSprite(SpriteID image, PaletteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part)
Draws sprites between ground sprite and everything above.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Functions related to zooming.
static Point InverseRemapCoords(int x, int y)
Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
Slope
Enumeration for the slope-type.
Neither foundation nor groundsprite drawn yet.
const TileTypeProcs *const _tile_type_procs[16]
Tile callback functions for each type of tile.
TownCache cache
Container for all cacheable data.
static uint MapMaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
int16 x_offs
Number of pixels to shift the sprite to the right.
Used to only draw a part of the sprite.
Vehicle * CheckClickOnVehicle(const ViewPort *vp, int x, int y)
Find the vehicle close to the clicked coordinates.
byte max_bridge_height
maximum height of bridges
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...
static const uint TILE_UNIT_MASK
For masking in/out the inner-tile world coordinate units.
static const uint MAX_BUILDING_PIXELS
Maximum height of a building in pixels in #ZOOM_LVL_BASE. (Also applies to "bridge buildings" on the ...
Functions related to OTTD's landscape.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
void OffsetGroundSprite(int x, int y)
Called when a foundation has been drawn for the current tile.
Functions related to commands.
Network functions used by other parts of OpenTTD.
VpSpriteSorter fct_sorter
The sorting function.
uint32 CursorID
The number of the cursor (sprite)
Coordinates of a point in 2D.
used for autorail highlighting (longer stretches), lower bits: direction
a steep slope falling to south (from north)
void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite for the current tile.
Colours _company_colours[MAX_COMPANIES]
NOSAVE: can be determined from company structs.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
The colour translation of GRF's strings.
special mode used for highlighting while dragging (and for tunnels/docks)
static bool CheckClickOnViewportSign(const ViewPort *vp, int x, int y, const ViewportSign *sign)
Test whether a sign is below the mouse.
EventState VpHandlePlaceSizingDrag()
Handle the mouse while dragging for placement/resizing.
Index of the small font in the font tables.
static uint SlopeToSpriteOffset(Slope s)
Returns the Sprite offset for a given Slope.
ConstructionSettings construction
construction of things in-game
Colour value is already a real palette colour index, not an index of a StringColour.
HighLightStyle
Highlighting draw styles.
Functions related to waypoints.
DrawTileProc * draw_tile_proc
Called to render the tile and its contents to the screen.
void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent, const SubSprite *sub, bool scale)
Add a child sprite to a parent sprite.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
drag only in vertical direction
vehicle is accepted as target as well (bitmask)
ZoomLevel zoom
The zoom level of the viewport.
int width
width of the window (number of pixels to the right in x direction)
Metadata about the current highlighting.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
void InitializeSpriteSorter()
Choose the "best" sprite sorter and set _vp_sprite_sorter.
Types related to sprite sorting.
PaletteID pal
palette to use
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
static uint TileHeightOutsideMap(int x, int y)
Returns the height of a tile, also for tiles outside the map (virtual "black" tiles).
const T * Get(uint index) const
Get the pointer to item "number" (const)
int virtual_top
Virtual top coordinate.
void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const ViewportSign *sign, StringID string_normal, StringID string_small, StringID string_small_shadow, uint64 params_1, uint64 params_2, Colours colour)
Add a string to draw in the viewport.
int32 left
minimal screen X coordinate of sprite (= x + sprite->x_offs), reference point for child sprites ...
int32 WindowNumber
Number to differentiate different windows of the same class.
WindowClass window_class
Window class.
Specification of a rectangle with absolute coordinates of all edges.
WindowClass window_class
The WindowClass of the window that is responsible for the selection mode.
virtual void OnPlaceObject(Point pt, TileIndex tile)
The user clicked some place on the map when a tile highlight mode has been set.
The passed event is handled.
uint16 width_small
The width when zoomed out (small font)
static uint MapMaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
WindowNumber window_number
Window number within the window class.
void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub, int extra_offs_x, int extra_offs_y)
Draws a ground sprite at a specific world-coordinate relative to the current tile.
static bool IsInvisibilitySet(TransparencyOption to)
Check if the invisibility option bit is set and if we aren't in the game menu (there's never transpar...
FoundationPart
Enumeration of multi-part foundations.
Functions related to tile highlights.
HighLightStyle next_drawstyle
Queued, but not yet drawn style.
Owner
Enum for all companies/owners.
Window functions not directly related to making/drawing windows.
int top
Screen coordinate top edge of the viewport.
void SetDirty()
Mark the linkgraph dirty to be rebuilt next time Draw() is called.
static void ViewportDrawDirtyBlocks()
Draw/colour the blocks that have been redrawn.
Point outersize
Size, in tile "units", of the blue coverage area excluding the side of the selected area...
Makes the background transparent if set.
#define TILE_ADD(x, y)
Adds to tiles together.
ViewportData * viewport
Pointer to viewport data, if present.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Base classes/functions for stations.
static T Delta(const T a, const T b)
Returns the (absolute) difference between two (scalar) variables.
bool comparison_done
Used during sprite sorting: true if sprite has been compared with all other sprites.
CargoTypes GetCargoMask()
Get a bitmask of the currently shown cargoes.
static Point RemapCoords2(int x, int y)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap...
int32 scrollpos_y
Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport).
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
const SubSprite * sub
only draw a rectangular part of the sprite
bool ScrollWindowTo(int x, int y, int z, Window *w, bool instant)
Scrolls the viewport in a window to a given location.
Base class for all station-ish types.
static bool IsTransparencySet(TransparencyOption to)
Check if the transparency option bit is set and if we aren't in the game menu (there's never transpar...
Factory to 'query' all available blitters.
byte dirty
Whether the build station window needs to redraw due to the changed selection.
static uint TilePixelHeight(TileIndex tile)
Returns the height of a tile in pixels.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static Corner OppositeCorner(Corner corner)
Returns the opposite corner.
This file defines all the the animated cursors.
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
int height
Height of the window (number of pixels down in y direction)
void UpdateViewportPosition(Window *w)
Update the viewport position being displayed.
#define FOR_ALL_WINDOWS_FROM_BACK_FROM(w, start)
Iterate over all windows.
static int GetTileMaxPixelZ(TileIndex tile)
Get top height of the tile.
static void CalcRaildirsDrawstyle(int x, int y, int method)
while dragging
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
int width
Screen width of the viewport.