コード例 #1
0
ファイル: input.c プロジェクト: 1337Noob1337/OpenRCT2
/**
 * 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);
}
コード例 #2
0
ファイル: input.c プロジェクト: LucaRed/OpenRCT2
/**
 *
 *  rct2: 0x006E876D
 */
void invalidate_scroll()
{
	rct_window* w = window_find_by_number(gPressedWidget.window_classification, gPressedWidget.window_number);
	if (w != NULL) {
		// Reset to basic scroll
		w->scrolls[_currentScrollIndex].flags &= 0xFF11;
		window_invalidate_by_number(gPressedWidget.window_classification, gPressedWidget.window_number);
	}
}
コード例 #3
0
ファイル: input.c プロジェクト: LucaRed/OpenRCT2
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);
}