Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13477: Plug-in widget tooltips do not work #13486

Merged
merged 1 commit into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions distribution/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fix: [#13427] Newly created Go-Karts show "Race won by <blank>".
- 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).

Expand Down
35 changes: 20 additions & 15 deletions src/openrct2-ui/windows/Tooltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>(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);
}

Expand Down