forked from mirror/OpenTTD
Fix #7386: Measurement tooltip for tunnels, aqueducts & docks did not display or flickered.
Measurement tooltip was auto-closed as the hover/right-click test for tooltips was not satisfied in this case. This is fixed by keeping the tooltip visible and instead explicitly closing the tooltip when the PlaceObject is cancelled/completed.
This commit is contained in:
@@ -2508,12 +2508,17 @@ void UpdateTileSelection()
|
||||
* @param params (optional) up to 5 pieces of additional information that may be added to a tooltip
|
||||
* @param close_cond Condition for closing this tooltip.
|
||||
*/
|
||||
static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_LEFT_CLICK)
|
||||
static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_cond = TCC_NONE)
|
||||
{
|
||||
if (!_settings_client.gui.measure_tooltip) return;
|
||||
GuiShowTooltips(_thd.GetCallbackWnd(), str, paramcount, params, close_cond);
|
||||
}
|
||||
|
||||
void HideMeasurementTooltips()
|
||||
{
|
||||
DeleteWindowById(WC_TOOLTIPS, 0);
|
||||
}
|
||||
|
||||
/** highlighting tiles while only going over them with the mouse */
|
||||
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
|
||||
{
|
||||
@@ -2569,7 +2574,11 @@ void VpSetPresizeRange(TileIndex from, TileIndex to)
|
||||
_thd.next_drawstyle = HT_RECT;
|
||||
|
||||
/* show measurement only if there is any length to speak of */
|
||||
if (distance > 1) ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1, &distance, TCC_HOVER);
|
||||
if (distance > 1) {
|
||||
ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1, &distance);
|
||||
} else {
|
||||
HideMeasurementTooltips();
|
||||
}
|
||||
}
|
||||
|
||||
static void VpStartPreSizing()
|
||||
@@ -3221,7 +3230,10 @@ void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowC
|
||||
* this function might in some cases reset the newly set object to
|
||||
* place or not properly reset the original selection. */
|
||||
_thd.window_class = WC_INVALID;
|
||||
if (w != NULL) w->OnPlaceObjectAbort();
|
||||
if (w != NULL) {
|
||||
w->OnPlaceObjectAbort();
|
||||
HideMeasurementTooltips();
|
||||
}
|
||||
}
|
||||
|
||||
/* Mark the old selection dirty, in case the selection shape or colour changes */
|
||||
|
Reference in New Issue
Block a user