MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / DrawTowns

Method DrawTowns

src/smallmap_gui.cpp:988–1005  ·  view source on GitHub ↗

* Adds town names to the smallmap. * @param dpi the part of the smallmap to be drawn into */

Source from the content-addressed store, hash-verified

986 * @param dpi the part of the smallmap to be drawn into
987 */
988 void DrawTowns(const DrawPixelInfo *dpi, const int vertical_padding) const
989 {
990 for (const Town *t : Town::Iterate()) {
991 /* Remap the town coordinate */
992 Point pt = this->RemapTile(TileX(t->xy), TileY(t->xy));
993 int x = pt.x - this->subscroll - (t->cache.sign.width_small >> 1);
994 int y = pt.y + vertical_padding;
995
996 /* Check if the town sign is within bounds */
997 if (x + t->cache.sign.width_small > dpi->left &&
998 x < dpi->left + dpi->width &&
999 y + GetCharacterHeight(FS_SMALL) > dpi->top &&
1000 y < dpi->top + dpi->height) {
1001 /* And draw it. */
1002 DrawString(x, x + t->cache.sign.width_small, y, GetString(STR_SMALLMAP_TOWN, t->index));
1003 }
1004 }
1005 }
1006
1007 /**
1008 * Adds industry names to the smallmap.

Callers 1

DrawSmallMapMethod · 0.95

Calls 6

RemapTileMethod · 0.95
TileXFunction · 0.85
TileYFunction · 0.85
GetCharacterHeightFunction · 0.85
DrawStringFunction · 0.70
GetStringFunction · 0.70

Tested by

no test coverage detected