From 35c8f8f528b9efafb74130775e5f6d8e88aeb811 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 29 Nov 2020 15:12:21 +0000 Subject: [PATCH] Fix #13477: Plug-in widget tooltips do not work --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/Tooltip.cpp | 35 ++++++++++++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 7580262f3f4c..feb9627f35ba 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -10,6 +10,7 @@ - Fix: [#13427] Newly created Go-Karts show "Race won by ". - Fix: [#13454] Plug-ins do not load on Windows if the user directory contains non-ASCII characters. - Fix: [#13469] Exception thrown from plugin in context.subscribe. +- Fix: [#13477] Plug-in widget tooltips do not work. - Improved: [#12917] Changed peep movement so that they stay more spread out over the full width of single tile paths. - Removed: [#13423] Built-in explode guests cheat (replaced by plug-in). diff --git a/src/openrct2-ui/windows/Tooltip.cpp b/src/openrct2-ui/windows/Tooltip.cpp index 2e9e16fab528..e8bda62e1f99 100644 --- a/src/openrct2-ui/windows/Tooltip.cpp +++ b/src/openrct2-ui/windows/Tooltip.cpp @@ -103,32 +103,37 @@ void window_tooltip_show(const OpenRCT2String& message, ScreenCoordsXY screenCoo */ void window_tooltip_open(rct_window* widgetWindow, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCords) { - rct_widget* widget; - if (widgetWindow == nullptr || widgetIndex == -1) return; - widget = &widgetWindow->widgets[widgetIndex]; + auto widget = &widgetWindow->widgets[widgetIndex]; window_event_invalidate_call(widgetWindow); - rct_string_id stringId = widget->tooltip; - - if (stringId == STR_NONE) - return; - - gTooltipWidget.window_classification = widgetWindow->classification; - gTooltipWidget.window_number = widgetWindow->number; - gTooltipWidget.widget_index = widgetIndex; - auto result = window_event_tooltip_call(widgetWindow, widgetIndex, stringId); - if (result.str == STR_NONE) - return; - + OpenRCT2String result; if (widget->flags & WIDGET_FLAGS::TOOLTIP_IS_STRING) { result.str = STR_STRING_TOOLTIP; result.args = Formatter(); result.args.Add(widget->sztooltip); + + gTooltipWidget.window_classification = widgetWindow->classification; + gTooltipWidget.window_number = widgetWindow->number; + gTooltipWidget.widget_index = widgetIndex; } + else + { + auto stringId = widget->tooltip; + if (stringId == STR_NONE) + return; + + gTooltipWidget.window_classification = widgetWindow->classification; + gTooltipWidget.window_number = widgetWindow->number; + gTooltipWidget.widget_index = widgetIndex; + result = window_event_tooltip_call(widgetWindow, widgetIndex, stringId); + if (result.str == STR_NONE) + return; + } + window_tooltip_show(result, screenCords); }