mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Use ScreenCoordsXY for Window functions (#10083)
This commit is contained in:
committed by
Michael Steenbeek
parent
6632b979d7
commit
2159fd282b
@@ -285,7 +285,7 @@ static void game_handle_input_mouse(int32_t x, int32_t y, int32_t state)
|
||||
switch (_inputState)
|
||||
{
|
||||
case INPUT_STATE_RESET:
|
||||
window_tooltip_reset(x, y);
|
||||
window_tooltip_reset(ScreenCoordsXY(x, y));
|
||||
// fall-through
|
||||
case INPUT_STATE_NORMAL:
|
||||
switch (state)
|
||||
@@ -1428,7 +1428,7 @@ void input_state_widget_pressed(
|
||||
STR_COLOUR_LIGHT_PINK_TIP,
|
||||
};
|
||||
|
||||
window_tooltip_show(colourTooltips[dropdown_index], x, y);
|
||||
window_tooltip_show(colourTooltips[dropdown_index], ScreenCoordsXY(x, y));
|
||||
}
|
||||
|
||||
if (dropdown_index < DROPDOWN_ITEMS_MAX_SIZE && dropdown_is_disabled(dropdown_index))
|
||||
@@ -1461,7 +1461,7 @@ static void input_update_tooltip(rct_window* w, rct_widgetindex widgetIndex, int
|
||||
if (_tooltipNotShownTicks > 50)
|
||||
{
|
||||
gTooltipTimeout = 0;
|
||||
window_tooltip_open(w, widgetIndex, x, y);
|
||||
window_tooltip_open(w, widgetIndex, ScreenCoordsXY(x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,17 +63,17 @@ static rct_window_event_list window_tooltip_events = {
|
||||
static utf8 _tooltipText[sizeof(gCommonStringFormatBuffer)];
|
||||
static int16_t _tooltipNumLines;
|
||||
|
||||
void window_tooltip_reset(int32_t x, int32_t y)
|
||||
void window_tooltip_reset(ScreenCoordsXY screenCoords)
|
||||
{
|
||||
gTooltipCursorX = x;
|
||||
gTooltipCursorY = y;
|
||||
gTooltipCursorX = screenCoords.x;
|
||||
gTooltipCursorY = screenCoords.y;
|
||||
gTooltipTimeout = 0;
|
||||
gTooltipWidget.window_classification = 255;
|
||||
input_set_state(INPUT_STATE_NORMAL);
|
||||
input_set_flag(INPUT_FLAG_4, false);
|
||||
}
|
||||
|
||||
void window_tooltip_show(rct_string_id id, int32_t x, int32_t y)
|
||||
void window_tooltip_show(rct_string_id id, ScreenCoordsXY screenCoords)
|
||||
{
|
||||
rct_window* w;
|
||||
int32_t width, height;
|
||||
@@ -107,20 +107,21 @@ void window_tooltip_show(rct_string_id id, int32_t x, int32_t y)
|
||||
|
||||
int32_t screenWidth = context_get_width();
|
||||
int32_t screenHeight = context_get_height();
|
||||
x = std::clamp(x - (width / 2), 0, screenWidth - width);
|
||||
screenCoords.x = std::clamp(screenCoords.x - (width / 2), 0, screenWidth - width);
|
||||
|
||||
// TODO The cursor size will be relative to the window DPI.
|
||||
// The amount to offset the y should be adjusted.
|
||||
|
||||
int32_t max_y = screenHeight - height;
|
||||
y += 26; // Normally, we'd display the tooltip 26 lower
|
||||
if (y > max_y)
|
||||
screenCoords.y += 26; // Normally, we'd display the tooltip 26 lower
|
||||
if (screenCoords.y > max_y)
|
||||
// If y is too large, the tooltip could be forced below the cursor if we'd just clamped y,
|
||||
// so we'll subtract a bit more
|
||||
y -= height + 40;
|
||||
y = std::clamp(y, 22, max_y);
|
||||
screenCoords.y -= height + 40;
|
||||
screenCoords.y = std::clamp(screenCoords.y, 22, max_y);
|
||||
|
||||
w = window_create(x, y, width, height, &window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT);
|
||||
w = window_create(
|
||||
screenCoords.x, screenCoords.y, width, height, &window_tooltip_events, WC_TOOLTIP, WF_TRANSPARENT | WF_STICK_TO_FRONT);
|
||||
w->widgets = window_tooltip_widgets;
|
||||
|
||||
reset_tooltip_not_shown();
|
||||
@@ -130,7 +131,7 @@ void window_tooltip_show(rct_string_id id, int32_t x, int32_t y)
|
||||
*
|
||||
* rct2: 0x006EA10D
|
||||
*/
|
||||
void window_tooltip_open(rct_window* widgetWindow, rct_widgetindex widgetIndex, int32_t x, int32_t y)
|
||||
void window_tooltip_open(rct_window* widgetWindow, rct_widgetindex widgetIndex, ScreenCoordsXY screenCords)
|
||||
{
|
||||
rct_widget* widget;
|
||||
|
||||
@@ -149,7 +150,7 @@ void window_tooltip_open(rct_window* widgetWindow, rct_widgetindex widgetIndex,
|
||||
if (window_event_tooltip_call(widgetWindow, widgetIndex) == STR_NONE)
|
||||
return;
|
||||
|
||||
window_tooltip_show(widget->tooltip, x, y);
|
||||
window_tooltip_show(widget->tooltip, screenCords);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -164,7 +164,7 @@ void window_tile_inspector_clear_clipboard();
|
||||
|
||||
rct_window* window_editor_object_selection_open();
|
||||
|
||||
void window_tooltip_reset(int32_t x, int32_t y);
|
||||
void window_tooltip_show(rct_string_id id, int32_t x, int32_t y);
|
||||
void window_tooltip_open(rct_window* widgetWindow, rct_widgetindex widgetIndex, int32_t x, int32_t y);
|
||||
void window_tooltip_reset(ScreenCoordsXY screenCoords);
|
||||
void window_tooltip_show(rct_string_id id, ScreenCoordsXY screenCoords);
|
||||
void window_tooltip_open(rct_window* widgetWindow, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords);
|
||||
void window_tooltip_close();
|
||||
|
||||
Reference in New Issue
Block a user