diff --git a/src/lang/extra/english.txt b/src/lang/extra/english.txt index 29a9bcc614..97d87e729b 100644 --- a/src/lang/extra/english.txt +++ b/src/lang/extra/english.txt @@ -767,6 +767,8 @@ STR_TRANSPARENT_TUNNELS_TOOLTIP :{BLACK}Toggle t STR_LINKGRAPH_STATS_TOOLTIP_TIME_EXTENSION_GENERAL :{}Average travel time: {STRING1} STR_LINKGRAPH_STATS_TOOLTIP_CAPACITY :{}Capacity: {CARGO_LONG} +STR_LINKGRAPH_STATS_TOOLTIP_USAGE :{}Usage: {CARGO_LONG} +STR_LINKGRAPH_STATS_TOOLTIP_PLANNED :{}Planned: {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 diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 716bc06595..97189a6e20 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -518,7 +518,7 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) pt.y - 2 <= std::max(pta.y, ptb.y) && check_distance()) { - static char buf[1024 + 512]; + char buf[2048]; char *buf_end = buf; buf[0] = 0; @@ -535,11 +535,24 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) } }; - if (_ctrl_pressed) { - SetDParam(0, link.cargo); - SetDParam(1, link.capacity); + auto add_extra_info = [&](const LinkProperties &info_link) { + if (info_link.usage < info_link.planned) { + SetDParam(0, info_link.cargo); + SetDParam(1, info_link.usage); + buf_end = GetString(buf_end, STR_LINKGRAPH_STATS_TOOLTIP_USAGE, lastof(buf)); + } else if (info_link.planned < info_link.usage) { + SetDParam(0, info_link.cargo); + SetDParam(1, info_link.planned); + buf_end = GetString(buf_end, STR_LINKGRAPH_STATS_TOOLTIP_PLANNED, lastof(buf)); + } + SetDParam(0, info_link.cargo); + SetDParam(1, info_link.capacity); buf_end = GetString(buf_end, STR_LINKGRAPH_STATS_TOOLTIP_CAPACITY, lastof(buf)); - add_travel_time(link.time); + add_travel_time(info_link.time); + }; + + if (_ctrl_pressed) { + add_extra_info(link); } /* Fill buf with more information if this is a bidirectional link. */ @@ -554,10 +567,7 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) SetDParam(2, j->prop.Usage() * 100 / (j->prop.capacity + 1)); buf_end = GetString(buf_end, STR_LINKGRAPH_STATS_TOOLTIP_RETURN_EXTENSION, lastof(buf)); if (_ctrl_pressed) { - SetDParam(0, j->prop.cargo); - SetDParam(1, j->prop.capacity); - buf_end = GetString(buf_end, STR_LINKGRAPH_STATS_TOOLTIP_CAPACITY, lastof(buf)); - add_travel_time(back_time); + add_extra_info(j->prop); } } break;