Exemple #1
0
/**
 *
 *  rct2: 0x006E9253
 */
static void input_widget_over(sint32 x, sint32 y, rct_window *w, rct_widgetindex widgetIndex)
{
	rct_windowclass windowClass = 255;
	rct_windownumber windowNumber = 0;
	rct_widget *widget = NULL;

	if (w != NULL) {
		windowClass = w->classification;
		windowNumber = w->number;
		widget = &w->widgets[widgetIndex];
	}

	input_widget_over_change_check(windowClass, windowNumber, widgetIndex);

	if (w != NULL && widgetIndex != -1 && widget->type == WWT_SCROLL) {
		sint32 eax, ebx, scroll_part, edx;
		widget_scroll_get_part(w, widget, x, y, &eax, &ebx, &scroll_part, &edx);

		if (scroll_part != SCROLL_PART_VIEW)
			window_tooltip_close();
		else {
			window_event_scroll_mouseover_call(w, edx, eax, ebx);
			input_update_tooltip(w, widgetIndex, x, y);
		}
	}
	else {
		input_update_tooltip(w, widgetIndex, x, y);
	}

	gTooltipTimeout = 0;
	gTooltipCursorX = x;
	gTooltipCursorY = y;
}
Exemple #2
0
static void input_scroll_continue(rct_window *w, int widgetIndex, int state, int x, int y)
{
	rct_widget *widget;
	int scroll_part, scroll_id;
	int x2, y2;

	assert(w != NULL);

	widget = &w->widgets[widgetIndex];
	if (w->classification != gPressedWidget.window_classification ||
		w->number != gPressedWidget.window_number ||
		widgetIndex != gPressedWidget.widget_index
	) {
		invalidate_scroll();
		return;
	}

	widget_scroll_get_part(w, widget, x, y, &x2, &y2, &scroll_part, &scroll_id);

	if (_currentScrollArea == SCROLL_PART_HSCROLLBAR_THUMB){
		int originalTooltipCursorX = gTooltipCursorX;
		gTooltipCursorX = x;
		input_scroll_part_update_hthumb(w, widgetIndex, x - originalTooltipCursorX, scroll_id);
		return;
	}

	if (_currentScrollArea == SCROLL_PART_VSCROLLBAR_THUMB){
		int originalTooltipCursorY = gTooltipCursorY;
		gTooltipCursorY = y;
		input_scroll_part_update_vthumb(w, widgetIndex, y - originalTooltipCursorY, scroll_id);
		return;
	}

	x = x2;
	y = y2;

	if (scroll_part != _currentScrollArea) {
		invalidate_scroll();
		return;
	}

	switch (scroll_part){
	case SCROLL_PART_VIEW:
		window_event_scroll_mousedrag_call(w, scroll_id, x, y);
		break;
	case SCROLL_PART_HSCROLLBAR_LEFT:
		input_scroll_part_update_hleft(w, widgetIndex, scroll_id);
		break;
	case SCROLL_PART_HSCROLLBAR_RIGHT:
		input_scroll_part_update_hright(w, widgetIndex, scroll_id);
		break;
	case SCROLL_PART_HSCROLLBAR_THUMB:
	case SCROLL_PART_VSCROLLBAR_TOP:
		input_scroll_part_update_vtop(w, widgetIndex, scroll_id);
		break;
	case SCROLL_PART_VSCROLLBAR_BOTTOM:
		input_scroll_part_update_vbottom(w, widgetIndex, scroll_id);
		break;
	}
}
static rct_research_item* get_research_item_at(int32_t x, int32_t y)
{
    rct_window* w = window_find_by_class(WC_EDITOR_INVENTION_LIST);
    if (w != nullptr && w->x <= x && w->y < y && w->x + w->width > x && w->y + w->height > y)
    {
        rct_widgetindex widgetIndex = window_find_widget_from_point(w, x, y);
        rct_widget* widget = &w->widgets[widgetIndex];
        if (widgetIndex == WIDX_PRE_RESEARCHED_SCROLL || widgetIndex == WIDX_RESEARCH_ORDER_SCROLL)
        {
            gPressedWidget.widget_index = widgetIndex;
            int32_t outX, outY, outScrollArea, outScrollId;
            widget_scroll_get_part(w, widget, x, y, &outX, &outY, &outScrollArea, &outScrollId);
            if (outScrollArea == SCROLL_PART_VIEW)
            {
                outScrollId = outScrollId == 0 ? 0 : 1;

                int32_t scrollY = y - (w->y + widget->top) + w->scrolls[outScrollId].v_top + 5;
                return window_editor_inventions_list_get_item_from_scroll_y_include_seps(outScrollId, scrollY);
            }
        }
    }

    return nullptr;
}
Exemple #4
0
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);
}
Exemple #5
0
/**
 *
*  rct2: 0x006ED833
 */
void process_mouse_over(sint32 x, sint32 y)
{
	rct_window* window;

	sint32 cursorId;

	cursorId = CURSOR_ARROW;
	set_map_tooltip_format_arg(0, rct_string_id, STR_NONE);
	window = window_find_from_point(x, y);

	if (window != NULL) {
		sint32 ebx, edi;
		rct_window* subWindow;
		rct_widgetindex widgetId = window_find_widget_from_point(window, x, y);
		if (widgetId != -1) {
			switch (window->widgets[widgetId].type){

			case WWT_VIEWPORT:
				if (!(_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) {
					if (viewport_interaction_left_over(x, y)) {
						sub_6ED990(CURSOR_HAND_POINT);
						return;
					}
					break;
				}
				cursorId = gCurrentToolId;
				subWindow = window_find_by_number(
					gCurrentToolWidget.window_classification,
					gCurrentToolWidget.window_number
					);
				if (subWindow == NULL)
					break;

				ebx = 0;
				edi = cursorId;
				// Window event WE_UNKNOWN_0E was called here, but no windows actually implemented a handler and
				// its not known what it was for
				cursorId = edi;
				if ((ebx & 0xFF) != 0)
				{
					sub_6ED990(cursorId);
					return;
				}
				break;

			case WWT_FRAME:
			case WWT_RESIZE:
				if (!(window->flags & WF_RESIZABLE))
					break;

				if (window->min_width == window->max_width && window->min_height == window->max_height)
					break;

				if (x < window->x + window->width - 0x13)
					break;

				if (y < window->y + window->height - 0x13)
					break;

				cursorId = CURSOR_DIAGONAL_ARROWS;
				break;

			case WWT_SCROLL:
			{
				sint32 output_scroll_area, scroll_id;
				sint32 scroll_x, scroll_y;
				widget_scroll_get_part(window, &window->widgets[widgetId], x, y, &scroll_x, &scroll_y, &output_scroll_area, &scroll_id);
				cursorId = scroll_id;
				if (output_scroll_area != SCROLL_PART_VIEW)
				{
					cursorId = CURSOR_ARROW;
					break;
				}
				// Same as default but with scroll_x/y
				cursorId = window_event_cursor_call(window, widgetId, scroll_x, scroll_y);
				if (cursorId == -1)
					cursorId = CURSOR_ARROW;
				break;
			}
			default:
				cursorId = window_event_cursor_call(window, widgetId, x, y);
				if (cursorId == -1)
					cursorId = CURSOR_ARROW;
				break;
			}
		}
	}

	viewport_interaction_right_over(x, y);
	sub_6ED990(cursorId);
}
Exemple #6
0
/**
 *
*  rct2: 0x006ED833
 */
void process_mouse_over(int x, int y)
{
	rct_window* window;
	rct_window* subWindow;

	int widgetId;
	int cursorId;
	int ebx, esi, edi, ebp;

	cursorId = CURSOR_ARROW;
	RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS, sint16) = -1;
	window = window_find_from_point(x, y);

	if (window != NULL) {
		widgetId = window_find_widget_from_point(window, x, y);
		RCT2_GLOBAL(0x1420046, sint16) = (widgetId & 0xFFFF);
		if (widgetId != -1) {
			switch (window->widgets[widgetId].type){

			case WWT_VIEWPORT:
				if (!(gInputFlags & INPUT_FLAG_TOOL_ACTIVE)) {
					if (viewport_interaction_left_over(x, y)) {
						sub_6ED990(CURSOR_HAND_POINT);
						return;
					}
					break;
				}
				cursorId = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8);
				subWindow = window_find_by_number(
					RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass),
					RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)
					);
				ebp = (int)subWindow;
				if (subWindow == NULL)
					break;

				ebx = 0;
				edi = cursorId;
				esi = (int)subWindow;
				// Window event WE_UNKNOWN_0E was called here, but no windows actually implemented a handler and
				// its not known what it was for
				cursorId = edi;
				if ((ebx & 0xFF) != 0)
				{
					sub_6ED990(cursorId);
					return;
				}
				break;

			case WWT_FRAME:
			case WWT_RESIZE:
				if (!(window->flags & 0x100))
					break;

				if (window->min_width == window->max_width && window->min_height == window->max_height)
					break;

				if (x < window->x + window->width - 0x13)
					break;

				if (y < window->y + window->height - 0x13)
					break;

				cursorId = CURSOR_DIAGONAL_ARROWS;
				break;

			case WWT_SCROLL:
				RCT2_GLOBAL(0x9DE558, uint16) = x;
				RCT2_GLOBAL(0x9DE55A, uint16) = y;
				int output_scroll_area, scroll_id;
				int scroll_x, scroll_y;
				widget_scroll_get_part(window, &window->widgets[widgetId], x, y, &scroll_x, &scroll_y, &output_scroll_area, &scroll_id);
				cursorId = scroll_id;
				if (output_scroll_area != SCROLL_PART_VIEW)
				{
					cursorId = CURSOR_ARROW;
					break;
				}
				// Same as default but with scroll_x/y
				cursorId = window_event_cursor_call(window, widgetId, scroll_x, scroll_y);
				if (cursorId == -1)
					cursorId = CURSOR_ARROW;
				break;
			default:
				cursorId = window_event_cursor_call(window, widgetId, x, y);
				if (cursorId == -1)
					cursorId = CURSOR_ARROW;
				break;
			}
		}
	}

	viewport_interaction_right_over(x, y);
	sub_6ED990(cursorId);
}