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

Method DrawContent

src/linkgraph/linkgraph_gui.cpp:297–316  ·  view source on GitHub ↗

* Draw one specific link. * @param pta Source of the link. * @param ptb Destination of the link. * @param cargo Properties of the link. */

Source from the content-addressed store, hash-verified

295 * @param cargo Properties of the link.
296 */
297void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &cargo) const
298{
299 uint usage_or_plan = std::min(cargo.capacity * 2 + 1, cargo.Usage());
300 PixelColour colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][usage_or_plan * lengthof(LinkGraphOverlay::LINK_COLOURS[0]) / (cargo.capacity * 2 + 2)];
301 int width = ScaleGUITrad(this->scale);
302 int dash = cargo.shared ? width * 4 : 0;
303
304 /* Move line a bit 90° against its dominant direction to prevent it from
305 * being hidden below the grey line. */
306 int side = _settings_game.vehicle.road_side ? 1 : -1;
307 if (abs(pta.x - ptb.x) < abs(pta.y - ptb.y)) {
308 int offset_x = (pta.y > ptb.y ? 1 : -1) * side * width;
309 GfxDrawLine(pta.x + offset_x, pta.y, ptb.x + offset_x, ptb.y, colour, width, dash);
310 } else {
311 int offset_y = (pta.x < ptb.x ? 1 : -1) * side * width;
312 GfxDrawLine(pta.x, pta.y + offset_y, ptb.x, ptb.y + offset_y, colour, width, dash);
313 }
314
315 GfxDrawLine(pta.x, pta.y, ptb.x, ptb.y, GetColourGradient(COLOUR_GREY, SHADE_DARKEST), width);
316}
317
318/**
319 * Draw dots for stations into the smallmap. The dots' sizes are determined by the amount of

Callers 1

DrawLinksMethod · 0.95

Calls 5

absFunction · 0.85
GfxDrawLineFunction · 0.85
GetColourGradientFunction · 0.85
UsageMethod · 0.80
ScaleGUITradFunction · 0.50

Tested by

no test coverage detected