/** * * rct2: 0x006B7220 */ static void window_new_ride_scroll_to_focused_ride(rct_window *w) { int scrollWidth = 0; int scrollHeight = 0; window_get_scroll_size(w, 0, &scrollWidth, &scrollHeight); // Find row index of the focused ride type rct_widget *listWidget = &window_new_ride_widgets[WIDX_RIDE_LIST]; int focusRideType = _windowNewRideHighlightedItem[_windowNewRideCurrentTab].ride_type_and_entry; int count = 0, row = 0; ride_list_item *listItem = _windowNewRideListItems; while (listItem->type != 255 || listItem->entry_index != 255) { if (listItem->type == focusRideType) { row = count / 5; break; } count++; listItem++; }; // Update the Y scroll position int listWidgetHeight = listWidget->bottom - listWidget->top - 1; scrollHeight = max(0, scrollHeight - listWidgetHeight); w->scrolls[0].v_top = min(row * 116, scrollHeight); widget_scroll_update_thumbs(w, WIDX_RIDE_LIST); }
/** * * rct2: 0x0066E464 */ void window_news_open() { rct_window* window; // Check if window is already open window = window_bring_to_front_by_id(WC_RECENT_NEWS, 0); if (window == NULL) { window = window_create_auto_pos( 400, 300, (uint32*)window_news_events, WC_RECENT_NEWS, 0 ); window->widgets = window_news_widgets; window->enabled_widgets = (1 << WIDX_CLOSE); window_init_scroll_widgets(window); window->colours[0] = 1; window->colours[1] = 1; window->colours[2] = 0; window->var_480 = -1; } // sub_66E4BA: int width, height; rct_widget *widget; window_get_scroll_size(window, 0, &width, &height); widget = &window_news_widgets[WIDX_SCROLL]; window->scrolls[0].v_top = max(0, height - (widget->bottom - widget->top - 1)); widget_scroll_update_thumbs(window, WIDX_SCROLL); }
/** * * rct2: 0x0066E464 */ rct_window * window_news_open() { rct_window* window; // Check if window is already open window = window_bring_to_front_by_class(WC_RECENT_NEWS); if (window == nullptr) { window = window_create_auto_pos( 400, 300, &window_news_events, WC_RECENT_NEWS, 0 ); window->widgets = window_news_widgets; window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_SETTINGS); window_init_scroll_widgets(window); window->news.var_480 = -1; } // sub_66E4BA: rct_widget *widget; sint32 width = 0; sint32 height = 0; window_get_scroll_size(window, 0, &width, &height); widget = &window_news_widgets[WIDX_SCROLL]; window->scrolls[0].v_top = Math::Max(0, height - (widget->bottom - widget->top - 1)); widget_scroll_update_thumbs(window, WIDX_SCROLL); return window; }
/** * * rct2: 0x006E99A9 */ static void input_scroll_part_update_vthumb(rct_window *w, rct_widgetindex widgetIndex, sint32 y, sint32 scroll_id) { assert(w != NULL); rct_widget *widget = &w->widgets[widgetIndex]; if (window_find_by_number(w->classification, w->number)) { sint32 newTop; newTop = w->scrolls[scroll_id].v_bottom; newTop *= y; y = widget->bottom - widget->top - 21; if (w->scrolls[scroll_id].flags & HSCROLLBAR_VISIBLE) y -= 11; newTop /= y; y = newTop; w->scrolls[scroll_id].flags |= VSCROLLBAR_THUMB_PRESSED; newTop = w->scrolls[scroll_id].v_top; newTop += y; if (newTop < 0) newTop = 0; y = widget->bottom - widget->top - 1; if (w->scrolls[scroll_id].flags & HSCROLLBAR_VISIBLE) y -= 11; y *= -1; y += w->scrolls[scroll_id].v_bottom; if (y < 0) y = 0; if (newTop > y) newTop = y; w->scrolls[scroll_id].v_top = newTop; widget_scroll_update_thumbs(w, widgetIndex); widget_invalidate_by_number(w->classification, w->number, widgetIndex); } }
/** * * rct2: 0x006E98F2 */ static void input_scroll_part_update_hthumb(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 scroll_id) { rct_widget *widget = &w->widgets[widgetIndex]; if (window_find_by_number(w->classification, w->number)) { sint32 newLeft; newLeft = w->scrolls[scroll_id].h_right; newLeft *= x; x = widget->right - widget->left - 21; if (w->scrolls[scroll_id].flags & VSCROLLBAR_VISIBLE) x -= 11; newLeft /= x; x = newLeft; w->scrolls[scroll_id].flags |= HSCROLLBAR_THUMB_PRESSED; newLeft = w->scrolls[scroll_id].h_left; newLeft += x; if (newLeft < 0) newLeft = 0; x = widget->right - widget->left - 1; if (w->scrolls[scroll_id].flags & VSCROLLBAR_VISIBLE) x -= 11; x *= -1; x += w->scrolls[scroll_id].h_right; if (x < 0) x = 0; if (newLeft > x) newLeft = x; w->scrolls[scroll_id].h_left = newLeft; widget_scroll_update_thumbs(w, widgetIndex); widget_invalidate_by_number(w->classification, w->number, widgetIndex); } }
/** * * rct2: 0x006E78E3 */ static void window_scroll_wheel_input(rct_window *w, int scrollIndex, int wheel) { int widgetIndex, size; rct_scroll *scroll; rct_widget *widget; scroll = &w->scrolls[scrollIndex]; widget = window_get_scroll_widget(w, scrollIndex); widgetIndex = window_get_widget_index(w, widget); if (scroll->flags & VSCROLLBAR_VISIBLE) { size = widget->bottom - widget->top - 1; if (scroll->flags & HSCROLLBAR_VISIBLE) size -= 11; size = max(0, scroll->v_bottom - size); scroll->v_top = min(max(0, scroll->v_top + wheel), size); } else { size = widget->right - widget->left - 1; if (scroll->flags & VSCROLLBAR_VISIBLE) size -= 11; size = max(0, scroll->h_right - size); scroll->h_left = min(max(0, scroll->h_left + wheel), size); } widget_scroll_update_thumbs(w, widgetIndex); widget_invalidate(w->classification, w->number, widgetIndex); }
/** * Based on (heavily changed) * rct2: 0x006E9E0E, 0x006E9ED0 */ static void input_scroll_drag_continue(int x, int y, rct_window* w) { rct_widgetindex widgetIndex = _dragWidget.widget_index; uint8 scrollIndex = _dragScrollIndex; rct_widget* widget = &w->widgets[widgetIndex]; rct_scroll* scroll = &w->scrolls[scrollIndex]; int dx, dy; dx = x - gInputDragLastX; dy = y - gInputDragLastY; if (scroll->flags & HSCROLLBAR_VISIBLE) { sint16 size = widget->right - widget->left - 1; if (scroll->flags & VSCROLLBAR_VISIBLE) size -= 11; size = max(0, scroll->h_right - size); scroll->h_left = min(max(0, scroll->h_left + dx), size); } if (scroll->flags & VSCROLLBAR_VISIBLE) { sint16 size = widget->bottom - widget->top - 1; if (scroll->flags & HSCROLLBAR_VISIBLE) size -= 11; size = max(0, scroll->v_bottom - size); scroll->v_top = min(max(0, scroll->v_top + dy), size); } widget_scroll_update_thumbs(w, widgetIndex); window_invalidate_by_number(w->classification, w->number); platform_set_cursor_position(gInputDragLastX, gInputDragLastY); }
/** * * rct2: 0x006E9C37 */ static void input_scroll_part_update_vtop(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id) { assert(w != NULL); if (window_find_by_number(w->classification, w->number)) { w->scrolls[scroll_id].flags |= VSCROLLBAR_UP_PRESSED; if (w->scrolls[scroll_id].v_top >= 3) w->scrolls[scroll_id].v_top -= 3; widget_scroll_update_thumbs(w, widgetIndex); widget_invalidate_by_number(w->classification, w->number, widgetIndex); } }
/** * * rct2: 0x006E9A60 */ static void input_scroll_part_update_hleft(rct_window *w, int widgetIndex, int scroll_id) { assert(w != NULL); if (window_find_by_number(w->classification, w->number)) { w->scrolls[scroll_id].flags |= HSCROLLBAR_LEFT_PRESSED; if (w->scrolls[scroll_id].h_left >= 3) w->scrolls[scroll_id].h_left -= 3; widget_scroll_update_thumbs(w, widgetIndex); widget_invalidate_by_number(w->classification, w->number, widgetIndex); } }
/** * * rct2: 0x006E9C96 */ static void input_scroll_part_update_vbottom(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id) { assert(w != NULL); rct_widget *widget = &w->widgets[widgetIndex]; if (window_find_by_number(w->classification, w->number)) { w->scrolls[scroll_id].flags |= VSCROLLBAR_DOWN_PRESSED; w->scrolls[scroll_id].v_top += 3; sint32 newTop = widget->bottom - widget->top - 1; if (w->scrolls[scroll_id].flags & HSCROLLBAR_VISIBLE) newTop -= 11; newTop *= -1; newTop += w->scrolls[scroll_id].v_bottom; if (newTop < 0) newTop = 0; if (w->scrolls[scroll_id].v_top > newTop) w->scrolls[scroll_id].v_top = newTop; widget_scroll_update_thumbs(w, widgetIndex); widget_invalidate_by_number(w->classification, w->number, widgetIndex); } }
/** * * rct2: 0x006E9ABF */ static void input_scroll_part_update_hright(rct_window *w, rct_widgetindex widgetIndex, sint32 scroll_id) { assert(w != NULL); rct_widget *widget = &w->widgets[widgetIndex]; if (window_find_by_number(w->classification, w->number)) { w->scrolls[scroll_id].flags |= HSCROLLBAR_RIGHT_PRESSED; w->scrolls[scroll_id].h_left += 3; sint32 newLeft = widget->right - widget->left - 1; if (w->scrolls[scroll_id].flags & VSCROLLBAR_VISIBLE) newLeft -= 11; newLeft *= -1; newLeft += w->scrolls[scroll_id].h_right; if (newLeft < 0) newLeft = 0; if (w->scrolls[scroll_id].h_left > newLeft) w->scrolls[scroll_id].h_left = newLeft; widget_scroll_update_thumbs(w, widgetIndex); widget_invalidate_by_number(w->classification, w->number, widgetIndex); } }
static void input_scroll_begin(rct_window *w, rct_widgetindex widgetIndex, sint32 x, sint32 y) { rct_widget *widget; widget = &w->widgets[widgetIndex]; _inputState = INPUT_STATE_SCROLL_LEFT; gPressedWidget.window_classification = w->classification; gPressedWidget.window_number = w->number; gPressedWidget.widget_index = widgetIndex; gTooltipCursorX = x; gTooltipCursorY = y; sint32 eax, ebx, scroll_area, scroll_id; scroll_id = 0; // safety widget_scroll_get_part(w, widget, x, y, &eax, &ebx, &scroll_area, &scroll_id); _currentScrollArea = scroll_area; _currentScrollIndex = scroll_id; window_event_unknown_15_call(w, scroll_id, scroll_area); if (scroll_area == SCROLL_PART_VIEW){ window_event_scroll_mousedown_call(w, scroll_id, eax, ebx); return; } rct_widget* widg = &w->widgets[widgetIndex]; rct_scroll* scroll = &w->scrolls[scroll_id]; sint32 widget_width = widg->right - widg->left - 1; if (scroll->flags & VSCROLLBAR_VISIBLE) widget_width -= 11; sint32 widget_content_width = max(scroll->h_right - widget_width, 0); sint32 widget_height = widg->bottom - widg->top - 1; if (scroll->flags & HSCROLLBAR_VISIBLE) widget_height -= 11; sint32 widget_content_height = max(scroll->v_bottom - widget_height, 0); switch (scroll_area) { case SCROLL_PART_HSCROLLBAR_LEFT: scroll->h_left = max(scroll->h_left - 3, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT: scroll->h_left = min(scroll->h_left + 3, widget_content_width); break; case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH: scroll->h_left = max(scroll->h_left - widget_width, 0); break; case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH: scroll->h_left = min(scroll->h_left + widget_width, widget_content_width); break; case SCROLL_PART_VSCROLLBAR_TOP: scroll->v_top = max(scroll->v_top - 3, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM: scroll->v_top = min(scroll->v_top + 3, widget_content_height); break; case SCROLL_PART_VSCROLLBAR_TOP_TROUGH: scroll->v_top = max(scroll->v_top - widget_height, 0); break; case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH: scroll->v_top = min(scroll->v_top + widget_height, widget_content_height); break; default: break; } widget_scroll_update_thumbs(w, widgetIndex); window_invalidate_by_number(widgetIndex, w->classification); }