mirror of https://github.com/OpenRCT2/OpenRCT2.git
Rework tooltip to be more logical (#13137)
This commit is contained in:
parent
61c8cbf88b
commit
f28907a87d
|
@ -1398,8 +1398,7 @@ void input_state_widget_pressed(
|
|||
STR_COLOUR_BRIGHT_PINK_TIP,
|
||||
STR_COLOUR_LIGHT_PINK_TIP,
|
||||
};
|
||||
|
||||
window_tooltip_show(colourTooltips[dropdown_index], screenCoords);
|
||||
window_tooltip_show(OpenRCT2String{ colourTooltips[dropdown_index], {} }, screenCoords);
|
||||
}
|
||||
|
||||
if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && dropdown_is_disabled(dropdown_index))
|
||||
|
|
|
@ -180,7 +180,7 @@ static void window_editor_object_selection_update(rct_window *w);
|
|||
static void window_editor_object_selection_scrollgetsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
||||
static void window_editor_object_selection_scroll_mousedown(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
||||
static void window_editor_object_selection_scroll_mouseover(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
||||
static void window_editor_object_selection_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id *stringId);
|
||||
static OpenRCT2String window_editor_object_selection_tooltip(rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback);
|
||||
static void window_editor_object_selection_invalidate(rct_window *w);
|
||||
static void window_editor_object_selection_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
static void window_editor_object_selection_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
||||
|
@ -766,13 +766,16 @@ static void window_editor_object_selection_scroll_mouseover(
|
|||
*
|
||||
* rct2: 0x006AB058
|
||||
*/
|
||||
static void window_editor_object_selection_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id* stringId)
|
||||
static OpenRCT2String window_editor_object_selection_tooltip(
|
||||
rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback)
|
||||
{
|
||||
if (widgetIndex >= WIDX_TAB_1 && static_cast<size_t>(widgetIndex) < WIDX_TAB_1 + std::size(ObjectSelectionPages))
|
||||
{
|
||||
auto ft = Formatter::Common();
|
||||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(ObjectSelectionPages[(widgetIndex - WIDX_TAB_1)].Caption);
|
||||
return { fallback, ft };
|
||||
}
|
||||
return { fallback, {} };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,7 +68,7 @@ static rct_widget window_game_bottom_toolbar_widgets[] =
|
|||
uint8_t gToolbarDirtyFlags;
|
||||
|
||||
static void window_game_bottom_toolbar_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
||||
static void window_game_bottom_toolbar_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id *stringId);
|
||||
static OpenRCT2String window_game_bottom_toolbar_tooltip(rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback);
|
||||
static void window_game_bottom_toolbar_invalidate(rct_window *w);
|
||||
static void window_game_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
static void window_game_bottom_toolbar_update(rct_window* w);
|
||||
|
@ -189,10 +189,11 @@ static void window_game_bottom_toolbar_mouseup(rct_window* w, rct_widgetindex wi
|
|||
}
|
||||
}
|
||||
|
||||
static void window_game_bottom_toolbar_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id* stringId)
|
||||
static OpenRCT2String window_game_bottom_toolbar_tooltip(
|
||||
rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback)
|
||||
{
|
||||
int32_t month, day;
|
||||
auto ft = Formatter::Common();
|
||||
auto ft = Formatter();
|
||||
|
||||
switch (widgetIndex)
|
||||
{
|
||||
|
@ -211,6 +212,7 @@ static void window_game_bottom_toolbar_tooltip(rct_window* w, rct_widgetindex wi
|
|||
ft.Add<rct_string_id>(DateGameMonthNames[month]);
|
||||
break;
|
||||
}
|
||||
return { fallback, ft };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2107,21 +2107,24 @@ static void window_options_advanced_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
|||
DrawTextEllipsised(dpi, screenCoords, 277, STR_STRING, ft, w->colours[1]);
|
||||
}
|
||||
|
||||
static void window_options_advanced_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id* stringid)
|
||||
static OpenRCT2String window_options_advanced_tooltip(
|
||||
rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback)
|
||||
{
|
||||
if (widgetIndex == WIDX_PATH_TO_RCT1_BUTTON)
|
||||
{
|
||||
if (str_is_null_or_empty(gConfigGeneral.rct1_path))
|
||||
{
|
||||
// No tooltip if the path is empty
|
||||
*stringid = STR_NONE;
|
||||
return { STR_NONE, {} };
|
||||
}
|
||||
else
|
||||
{
|
||||
auto ft = Formatter::Common();
|
||||
auto ft = Formatter();
|
||||
ft.Add<utf8*>(gConfigGeneral.rct1_path);
|
||||
return { fallback, ft };
|
||||
}
|
||||
}
|
||||
return { fallback, {} };
|
||||
}
|
||||
|
||||
#pragma region Event lists
|
||||
|
|
|
@ -592,7 +592,7 @@ static void window_ride_graphs_mousedown(rct_window *w, rct_widgetindex widgetIn
|
|||
static void window_ride_graphs_update(rct_window *w);
|
||||
static void window_ride_graphs_scrollgetheight(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
||||
static void window_ride_graphs_15(rct_window *w, int32_t scrollIndex, int32_t scrollAreaType);
|
||||
static void window_ride_graphs_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id *stringId);
|
||||
static OpenRCT2String window_ride_graphs_tooltip(rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback);
|
||||
static void window_ride_graphs_invalidate(rct_window *w);
|
||||
static void window_ride_graphs_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
static void window_ride_graphs_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
||||
|
@ -5837,7 +5837,7 @@ static void window_ride_graphs_15(rct_window* w, int32_t scrollIndex, int32_t sc
|
|||
*
|
||||
* rct2: 0x006AEA05
|
||||
*/
|
||||
static void window_ride_graphs_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id* stringId)
|
||||
static OpenRCT2String window_ride_graphs_tooltip(rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback)
|
||||
{
|
||||
if (widgetIndex == WIDX_GRAPH)
|
||||
{
|
||||
|
@ -5847,21 +5847,23 @@ static void window_ride_graphs_tooltip(rct_window* w, rct_widgetindex widgetInde
|
|||
auto [measurement, message] = ride->GetMeasurement();
|
||||
if (measurement != nullptr && (measurement->flags & RIDE_MEASUREMENT_FLAG_RUNNING))
|
||||
{
|
||||
auto ft = Formatter::Common();
|
||||
auto ft = Formatter();
|
||||
ft.Increment(2);
|
||||
ft.Add<rct_string_id>(RideComponentNames[RideTypeDescriptors[ride->type].NameConvention.vehicle].number);
|
||||
ft.Add<uint16_t>(measurement->vehicle_index + 1);
|
||||
return { fallback, ft };
|
||||
}
|
||||
else
|
||||
{
|
||||
*stringId = message.str;
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*stringId = STR_NONE;
|
||||
return { STR_NONE, {} };
|
||||
}
|
||||
return { fallback, {} };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,7 +77,7 @@ static void window_scenery_periodic_update(rct_window *w);
|
|||
static void window_scenery_scrollgetsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
|
||||
static void window_scenery_scrollmousedown(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
||||
static void window_scenery_scrollmouseover(rct_window *w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords);
|
||||
static void window_scenery_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id *stringId);
|
||||
static OpenRCT2String window_scenery_tooltip(rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback);
|
||||
static void window_scenery_invalidate(rct_window *w);
|
||||
static void window_scenery_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
static void window_scenery_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
|
||||
|
@ -909,9 +909,9 @@ void window_scenery_scrollmouseover(rct_window* w, int32_t scrollIndex, const Sc
|
|||
*
|
||||
* rct2: 0x006E1C05
|
||||
*/
|
||||
void window_scenery_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_string_id* stringId)
|
||||
OpenRCT2String window_scenery_tooltip(rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback)
|
||||
{
|
||||
auto ft = Formatter::Common();
|
||||
auto ft = Formatter();
|
||||
|
||||
switch (widgetIndex)
|
||||
{
|
||||
|
@ -940,6 +940,7 @@ void window_scenery_tooltip(rct_window* w, rct_widgetindex widgetIndex, rct_stri
|
|||
ft.Add<rct_string_id>(STR_MISCELLANEOUS);
|
||||
break;
|
||||
}
|
||||
return { fallback, ft };
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,7 @@ void window_tooltip_reset(const ScreenCoordsXY& screenCoords)
|
|||
input_set_flag(INPUT_FLAG_4, false);
|
||||
}
|
||||
|
||||
void window_tooltip_show(rct_string_id id, ScreenCoordsXY screenCoords)
|
||||
void window_tooltip_show(const OpenRCT2String& message, ScreenCoordsXY screenCoords)
|
||||
{
|
||||
rct_window* w;
|
||||
int32_t width, height;
|
||||
|
@ -59,7 +59,7 @@ void window_tooltip_show(rct_string_id id, ScreenCoordsXY screenCoords)
|
|||
|
||||
char* buffer = gCommonStringFormatBuffer;
|
||||
|
||||
format_string(buffer, sizeof(gCommonStringFormatBuffer), id, gCommonFormatArgs);
|
||||
format_string(buffer, sizeof(gCommonStringFormatBuffer), message.str, message.args.Data());
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
|
||||
int32_t tooltip_text_width;
|
||||
|
@ -116,12 +116,6 @@ void window_tooltip_open(rct_window* widgetWindow, rct_widgetindex widgetIndex,
|
|||
window_event_invalidate_call(widgetWindow);
|
||||
|
||||
rct_string_id stringId = widget->tooltip;
|
||||
if (widget->flags & WIDGET_FLAGS::TOOLTIP_IS_STRING)
|
||||
{
|
||||
stringId = STR_STRING_TOOLTIP;
|
||||
auto ft = Formatter::Common();
|
||||
ft.Add<const char*>(widget->sztooltip);
|
||||
}
|
||||
|
||||
if (stringId == STR_NONE)
|
||||
return;
|
||||
|
@ -129,11 +123,17 @@ void window_tooltip_open(rct_window* widgetWindow, rct_widgetindex widgetIndex,
|
|||
gTooltipWidget.window_classification = widgetWindow->classification;
|
||||
gTooltipWidget.window_number = widgetWindow->number;
|
||||
gTooltipWidget.widget_index = widgetIndex;
|
||||
|
||||
if (window_event_tooltip_call(widgetWindow, widgetIndex) == STR_NONE)
|
||||
auto result = window_event_tooltip_call(widgetWindow, widgetIndex, stringId);
|
||||
if (result.str == STR_NONE)
|
||||
return;
|
||||
|
||||
window_tooltip_show(stringId, screenCords);
|
||||
if (widget->flags & WIDGET_FLAGS::TOOLTIP_IS_STRING)
|
||||
{
|
||||
result.str = STR_STRING_TOOLTIP;
|
||||
result.args = Formatter();
|
||||
result.args.Add<const char*>(widget->sztooltip);
|
||||
}
|
||||
window_tooltip_show(result, screenCords);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -193,7 +193,7 @@ void window_tile_inspector_clear_clipboard();
|
|||
rct_window* window_editor_object_selection_open();
|
||||
|
||||
void window_tooltip_reset(const ScreenCoordsXY& screenCoords);
|
||||
void window_tooltip_show(rct_string_id id, ScreenCoordsXY screenCoords);
|
||||
void window_tooltip_show(const OpenRCT2String& message, ScreenCoordsXY screenCoords);
|
||||
void window_tooltip_open(rct_window* widgetWindow, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
|
||||
void window_tooltip_close();
|
||||
|
||||
|
|
|
@ -1520,12 +1520,16 @@ void window_event_unknown_15_call(rct_window* w, int32_t scrollIndex, int32_t sc
|
|||
w->event_handlers->unknown_15(w, scrollIndex, scrollAreaType);
|
||||
}
|
||||
|
||||
rct_string_id window_event_tooltip_call(rct_window* w, rct_widgetindex widgetIndex)
|
||||
OpenRCT2String window_event_tooltip_call(rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback)
|
||||
{
|
||||
rct_string_id result = 0;
|
||||
if (w->event_handlers->tooltip != nullptr)
|
||||
w->event_handlers->tooltip(w, widgetIndex, &result);
|
||||
return result;
|
||||
{
|
||||
return w->event_handlers->tooltip(w, widgetIndex, fallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
return { fallback, {} };
|
||||
}
|
||||
}
|
||||
|
||||
int32_t window_event_cursor_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define _WINDOW_H_
|
||||
|
||||
#include "../common.h"
|
||||
#include "../localisation/Formatter.h"
|
||||
#include "../ride/RideTypes.h"
|
||||
#include "../world/Location.hpp"
|
||||
#include "../world/ScenerySelection.h"
|
||||
|
@ -237,7 +238,7 @@ struct rct_window_event_list
|
|||
void (*text_input)(struct rct_window*, rct_widgetindex, char*);
|
||||
void (*viewport_rotate)(struct rct_window*);
|
||||
void (*unknown_15)(struct rct_window*, int32_t, int32_t);
|
||||
void (*tooltip)(struct rct_window*, rct_widgetindex, rct_string_id*);
|
||||
OpenRCT2String (*tooltip)(struct rct_window*, const rct_widgetindex, const rct_string_id);
|
||||
void (*cursor)(struct rct_window*, rct_widgetindex, const ScreenCoordsXY&, int32_t*);
|
||||
void (*moved)(struct rct_window*, const ScreenCoordsXY&);
|
||||
void (*invalidate)(struct rct_window*);
|
||||
|
@ -796,7 +797,7 @@ void window_event_scroll_mouseover_call(rct_window* w, int32_t scrollIndex, cons
|
|||
void window_event_textinput_call(rct_window* w, rct_widgetindex widgetIndex, char* text);
|
||||
void window_event_viewport_rotate_call(rct_window* w);
|
||||
void window_event_unknown_15_call(rct_window* w, int32_t scrollIndex, int32_t scrollAreaType);
|
||||
rct_string_id window_event_tooltip_call(rct_window* w, rct_widgetindex widgetIndex);
|
||||
OpenRCT2String window_event_tooltip_call(rct_window* w, const rct_widgetindex widgetIndex, const rct_string_id fallback);
|
||||
int32_t window_event_cursor_call(rct_window* w, rct_widgetindex widgetIndex, const ScreenCoordsXY& screenCoords);
|
||||
void window_event_moved_call(rct_window* w, const ScreenCoordsXY& screenCoords);
|
||||
void window_event_invalidate_call(rct_window* w);
|
||||
|
|
Loading…
Reference in New Issue