Show distance information in linkgraph tooltip when ctrl pressed
This commit is contained in:
@@ -767,6 +767,7 @@ STR_TRANSPARENT_TUNNELS_TOOLTIP :{BLACK}Toggle t
|
|||||||
|
|
||||||
STR_LINKGRAPH_STATS_TOOLTIP_TIME_EXTENSION_GENERAL :{}Average travel time: {STRING1}
|
STR_LINKGRAPH_STATS_TOOLTIP_TIME_EXTENSION_GENERAL :{}Average travel time: {STRING1}
|
||||||
STR_LINKGRAPH_STATS_TOOLTIP_CAPACITY :{}Capacity: {CARGO_LONG}
|
STR_LINKGRAPH_STATS_TOOLTIP_CAPACITY :{}Capacity: {CARGO_LONG}
|
||||||
|
STR_LINKGRAPH_STATS_TOOLTIP_DISTANCE :Manhattan Distance: {COMMA} tile{P 0 "" s}{}Bird Fly Distance: {COMMA} tile{P 1 "" s}
|
||||||
|
|
||||||
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_POLYRAIL :{BLACK}Build railway track using the Polyline mode. Ctrl toggles build/remove for railway construction. Shift toggles building/showing cost estimate
|
STR_RAIL_TOOLBAR_TOOLTIP_BUILD_POLYRAIL :{BLACK}Build railway track using the Polyline mode. Ctrl toggles build/remove for railway construction. Shift toggles building/showing cost estimate
|
||||||
|
|
||||||
|
@@ -518,7 +518,7 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond)
|
|||||||
pt.y - 2 <= std::max(pta.y, ptb.y) &&
|
pt.y - 2 <= std::max(pta.y, ptb.y) &&
|
||||||
check_distance()) {
|
check_distance()) {
|
||||||
|
|
||||||
static char buf[1024];
|
static char buf[1024 + 512];
|
||||||
char *buf_end = buf;
|
char *buf_end = buf;
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
|
|
||||||
@@ -568,6 +568,18 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond)
|
|||||||
add_travel_time(link.time ? (back_time ? ((link.time + back_time) / 2) : link.time) : back_time);
|
add_travel_time(link.time ? (back_time ? ((link.time + back_time) / 2) : link.time) : back_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_ctrl_pressed) {
|
||||||
|
/* Add distance information */
|
||||||
|
buf_end = strecat(buf_end, "\n\n", lastof(buf));
|
||||||
|
TileIndex t0 = Station::Get(i->from_id)->xy;
|
||||||
|
TileIndex t1 = Station::Get(i->to_id)->xy;
|
||||||
|
uint dx = Delta(TileX(t0), TileX(t1));
|
||||||
|
uint dy = Delta(TileY(t0), TileY(t1));
|
||||||
|
SetDParam(0, DistanceManhattan(t0, t1));
|
||||||
|
SetDParam(1, IntSqrt64(((uint64)dx * (uint64)dx) + ((uint64)dy * (uint64)dy))); // Avoid overflow in DistanceSquare
|
||||||
|
buf_end = GetString(buf_end, STR_LINKGRAPH_STATS_TOOLTIP_DISTANCE, lastof(buf));
|
||||||
|
}
|
||||||
|
|
||||||
SetDParam(0, link.cargo);
|
SetDParam(0, link.cargo);
|
||||||
SetDParam(1, link.Usage());
|
SetDParam(1, link.Usage());
|
||||||
SetDParam(2, i->from_id);
|
SetDParam(2, i->from_id);
|
||||||
|
Reference in New Issue
Block a user