MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / updateLabel

Method updateLabel

src/OpenLoco/src/World/Town.cpp:105–131  ·  view source on GitHub ↗

0x00497616

Source from the content-addressed store, hash-verified

103
104 // 0x00497616
105 void Town::updateLabel()
106 {
107 char buffer[256]{};
108 StringManager::formatString(buffer, 256, name);
109
110 auto height = TileManager::getHeight(Pos2(x, y));
111 auto pos = Pos3(x + kTileSize / 2, y + kTileSize / 2, height.landHeight);
112
113 auto rotated = World::gameToScreen(pos, Ui::WindowManager::getCurrentRotation());
114 rotated.y -= 48;
115
116 for (auto zoomLevel = 0; zoomLevel < 4; zoomLevel++)
117 {
118 auto font = kZoomToTownFonts[zoomLevel];
119
120 auto nameWidth = (Gfx::TextRenderer::getStringWidth(font, buffer) + 2) << zoomLevel;
121 auto nameHeight = 11 << zoomLevel; // was a lookup on 0x4FF6FC; same for all zoom levels
122
123 auto xOffset = rotated.x - (nameWidth / 2);
124 auto yOffset = rotated.y - (nameHeight / 2);
125
126 labelFrame.left[zoomLevel] = xOffset >> zoomLevel;
127 labelFrame.right[zoomLevel] = (xOffset + nameWidth) >> zoomLevel;
128 labelFrame.top[zoomLevel] = yOffset >> zoomLevel;
129 labelFrame.bottom[zoomLevel] = (yOffset + nameHeight) >> zoomLevel;
130 }
131 }
132
133 // 0x0049749B
134 void Town::updateMonthly()

Callers 15

generateTownNameFunction · 0.45
updateLabelsFunction · 0.45
updateLabelsFunction · 0.45
renameStationFunction · 0.45
createAirportFunction · 0.45
loc_49372FFunction · 0.45
removeTrainStationFunction · 0.45
createTrainStationFunction · 0.45
removePortFunction · 0.45
createPortFunction · 0.45
aiTrackReplacementFunction · 0.45
renameTownFunction · 0.45

Calls 5

formatStringFunction · 0.85
getHeightFunction · 0.85
gameToScreenFunction · 0.85
getCurrentRotationFunction · 0.85
getStringWidthFunction · 0.85

Tested by

no test coverage detected