diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 90731a267f..ffd85a95d7 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -109,10 +109,9 @@ enum DDIDX_FAVOURITE }; -static int32_t _hoverButtonIndex = -1; +static bool _showNetworkVersionTooltip = false; static std::string _version; -static void server_list_get_item_button(int32_t buttonIndex, int32_t x, int32_t y, int32_t width, int32_t* outX, int32_t* outY); static void join_server(std::string address); static void server_list_fetch_servers_begin(); static void server_list_fetch_servers_check(rct_window* w); @@ -281,45 +280,28 @@ static void window_server_list_scroll_mousedown(rct_window* w, int32_t scrollInd static void window_server_list_scroll_mouseover(rct_window* w, int32_t scrollIndex, const ScreenCoordsXY& screenCoords) { - // Item - int32_t index = screenCoords.y / ITEM_HEIGHT; - if (index < 0 || index >= w->no_list_items) - { - index = -1; - } - - int32_t hoverButtonIndex = -1; auto& listWidget = w->widgets[WIDX_LIST]; - if (index != -1) - { - int32_t width = listWidget.width(); - int32_t sy = index * ITEM_HEIGHT; - for (int32_t i = 0; i < 2; i++) - { - int32_t bx, by; - server_list_get_item_button(i, 0, sy, width, &bx, &by); - if (screenCoords.x >= bx && screenCoords.y >= by && screenCoords.x < bx + 24 && screenCoords.y < by + 24) - { - hoverButtonIndex = i; - break; - } - } + int32_t itemIndex = screenCoords.y / ITEM_HEIGHT; + bool showNetworkVersionTooltip = false; + if (itemIndex < 0 || itemIndex >= w->no_list_items) + { + itemIndex = -1; + } + else + { + const int32_t iconX = listWidget.width() - SCROLLBAR_WIDTH - 7 - 10; + showNetworkVersionTooltip = screenCoords.x > iconX; } - int32_t width = listWidget.width(); - int32_t right = width - 3 - 14 - 10; - if (screenCoords.x < right) + if (w->selected_list_item != itemIndex || _showNetworkVersionTooltip != showNetworkVersionTooltip) { - listWidget.tooltip = STR_NONE; - window_tooltip_close(); - } + w->selected_list_item = itemIndex; + _showNetworkVersionTooltip = showNetworkVersionTooltip; - if (w->selected_list_item != index || _hoverButtonIndex != hoverButtonIndex) - { - w->selected_list_item = index; - _hoverButtonIndex = hoverButtonIndex; + listWidget.tooltip = showNetworkVersionTooltip ? static_cast(STR_NETWORK_VERSION_TIP) : STR_NONE; window_tooltip_close(); + w->Invalidate(); } } @@ -429,7 +411,6 @@ static void window_server_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi ScreenCoordsXY screenCoords; screenCoords.y = 0; - listWidget.tooltip = STR_NONE; for (int32_t i = 0; i < w->no_list_items; i++) { if (screenCoords.y >= dpi->y + dpi->height) @@ -443,7 +424,6 @@ static void window_server_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi { gfx_filter_rect(dpi, { 0, screenCoords.y, width, screenCoords.y + ITEM_HEIGHT }, FilterPaletteID::PaletteDarken1); _version = serverDetails.Version; - listWidget.tooltip = STR_NETWORK_VERSION_TIP; } colour_t colour = w->colours[1]; @@ -516,12 +496,6 @@ static void window_server_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi } } -static void server_list_get_item_button(int32_t buttonIndex, int32_t x, int32_t y, int32_t width, int32_t* outX, int32_t* outY) -{ - *outX = width - 3 - 36 - (30 * buttonIndex); - *outY = y + 2; -} - static void join_server(std::string address) { int32_t port = NETWORK_DEFAULT_PORT;