Esempio n. 1
0
/**
 *
 *  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);
	}
}
Esempio n. 2
0
/**
 *
 *  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);
	}
}
Esempio n. 3
0
/**
 *
 *  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);
	}
}
Esempio n. 4
0
/**
 *
 *  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);
	}
}
Esempio n. 5
0
/**
 * Used to invalidate flat button widgets when the mouse leaves and enters them. This should be generalised so that all widgets
 * can use this in the future.
 */
static void input_widget_over_flatbutton_invalidate()
{
	rct_window *w = window_find_by_number(gHoverWidget.window_classification, gHoverWidget.window_number);
	if (w != NULL) {
		window_event_invalidate_call(w);
		if (w->widgets[gHoverWidget.widget_index].type == WWT_FLATBTN) {
			widget_invalidate_by_number(
				gHoverWidget.window_classification,
				gHoverWidget.window_number,
				gHoverWidget.widget_index
			);
		}
	}
}
Esempio n. 6
0
/**
 *
 *  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);
	}
}
Esempio n. 7
0
/**
 *
 *  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);
	}
}
Esempio n. 8
0
/**
 *
 *  rct2: 0x006E95F9
 */
static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex widgetIndex)
{
	rct_windowclass windowClass = 255;
	rct_windownumber windowNumber = 0;
	rct_widget *widget;

	if (w != NULL) {
		windowClass = w->classification;
		windowNumber = w->number;
	}

	window_close_by_class(WC_ERROR);
	window_close_by_class(WC_TOOLTIP);

	// Window might have changed position in the list, therefore find it again
	w = window_find_by_number(windowClass, windowNumber);
	if (w == NULL)
		return;

	w = window_bring_to_front(w);
	if (widgetIndex == -1)
		return;

	if (windowClass != gCurrentTextBox.window.classification ||
		windowNumber != gCurrentTextBox.window.number ||
		widgetIndex != gCurrentTextBox.widget_index) {
		window_cancel_textbox();
	}

	widget = &w->widgets[widgetIndex];

	switch (widget->type) {
	case WWT_FRAME:
	case WWT_RESIZE:
		if (window_can_resize(w) && (x >= w->x + w->width - 19 && y >= w->y + w->height - 19))
			input_window_resize_begin(w, widgetIndex, x, y);
		break;
	case WWT_VIEWPORT:
		_inputState = INPUT_STATE_VIEWPORT_LEFT;
		gInputDragLastX = x;
		gInputDragLastY = y;
		_dragWidget.window_classification = windowClass;
		_dragWidget.window_number = windowNumber;
		if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE) {
			w = window_find_by_number(
				gCurrentToolWidget.window_classification,
				gCurrentToolWidget.window_number
				);
			if (w != NULL) {
				window_event_tool_down_call(w, gCurrentToolWidget.widget_index, x, y);
				_inputFlags |= INPUT_FLAG_4;
			}
		}
		break;
	case WWT_CAPTION:
		input_window_position_begin(w, widgetIndex, x, y);
		break;
	case WWT_SCROLL:
		input_scroll_begin(w, widgetIndex, x, y);
		break;
	default:
		if (widget_is_enabled(w, widgetIndex) && !widget_is_disabled(w, widgetIndex)) {
			audio_play_sound_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2, 0, 0, 0);

			// Set new cursor down widget
			gPressedWidget.window_classification = windowClass;
			gPressedWidget.window_number = windowNumber;
			gPressedWidget.widget_index = widgetIndex;
			_inputFlags |= INPUT_FLAG_WIDGET_PRESSED;
			_inputState = INPUT_STATE_WIDGET_PRESSED;
			_clickRepeatTicks = 1;

			widget_invalidate_by_number(windowClass, windowNumber, widgetIndex);
			window_event_mouse_down_call(w, widgetIndex);
		}
		break;
	}
}
Esempio n. 9
0
/**
 *
 *  rct2: 0x006E8DA7
 */
void input_state_widget_pressed(sint32 x, sint32 y, sint32 state, rct_widgetindex widgetIndex, rct_window *w, rct_widget *widget)
{
	rct_windowclass cursor_w_class;
	rct_windownumber cursor_w_number;
	cursor_w_class = gPressedWidget.window_classification;
	cursor_w_number = gPressedWidget.window_number;
	rct_widgetindex cursor_widgetIndex = gPressedWidget.widget_index;

	rct_window *cursor_w = window_find_by_number(cursor_w_class, cursor_w_number);
	if (cursor_w == NULL) {
		_inputState = INPUT_STATE_RESET;
		return;
	}

	switch (state) {
	case MOUSE_STATE_RELEASED:
		if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex)
			break;

		if (w->disabled_widgets & (1ULL << widgetIndex))
			break;

		if (_clickRepeatTicks != 0) {
			_clickRepeatTicks++;

			// Handle click repeat
			if (_clickRepeatTicks >= 16 && (_clickRepeatTicks & 3) != 0) {
				if (w->hold_down_widgets & (1ULL << widgetIndex)) {
					window_event_mouse_down_call(w, widgetIndex);
				}
			}
		}

		if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) {
			if (_inputState == INPUT_STATE_DROPDOWN_ACTIVE) {
				gDropdownHighlightedIndex = gDropdownDefaultIndex;
				window_invalidate_by_class(WC_DROPDOWN);
			}
			return;
		}

		_inputFlags |= INPUT_FLAG_WIDGET_PRESSED;
		widget_invalidate_by_number(cursor_w_class, cursor_w_number, widgetIndex);
		return;
	case MOUSE_STATE_LEFT_RELEASE:
	case MOUSE_STATE_RIGHT_PRESS:
		if (_inputState == INPUT_STATE_DROPDOWN_ACTIVE) {
			if (w) {
				sint32 dropdown_index = 0;

				if (w->classification == WC_DROPDOWN) {
					dropdown_index = dropdown_index_from_point(x, y, w);
					if (dropdown_index == -1) {
						goto dropdown_cleanup;
					}

					if (dropdown_index < 64 && gDropdownItemsDisabled & (1ULL << dropdown_index)) {
						goto dropdown_cleanup;
					}

					if (gDropdownItemsFormat[dropdown_index] == 0) {
						goto dropdown_cleanup;
					}
				}
				else {
					if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex)
						goto dropdown_cleanup;
					dropdown_index = -1;
					if (_inputFlags & INPUT_FLAG_DROPDOWN_STAY_OPEN){
						if (!(_inputFlags & INPUT_FLAG_DROPDOWN_MOUSE_UP)){
							_inputFlags |= INPUT_FLAG_DROPDOWN_MOUSE_UP;
							return;
						}
					}
				}

				window_close_by_class(WC_DROPDOWN);
				cursor_w = window_find_by_number(cursor_w_class, cursor_w_number);
				if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED) {
					_inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED;
					widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex);
				}

				_inputState = INPUT_STATE_NORMAL;
				gTooltipTimeout = 0;
				gTooltipWidget.widget_index = cursor_widgetIndex;
				gTooltipWidget.window_classification = cursor_w_class;
				gTooltipWidget.window_number = cursor_w_number;

				if (dropdown_index == -1) {
					if (!dropdown_is_disabled(gDropdownDefaultIndex)) {
						dropdown_index = gDropdownDefaultIndex;
					}
				}
				window_event_dropdown_call(cursor_w, cursor_widgetIndex, dropdown_index);
			}
		dropdown_cleanup:
			window_close_by_class(WC_DROPDOWN);
		}
		if (state == MOUSE_STATE_RIGHT_PRESS) {
			return;
		}

		_inputState = INPUT_STATE_NORMAL;
		gTooltipTimeout = 0;
		gTooltipWidget.widget_index = cursor_widgetIndex;

		if (!w)
			break;

		if (!widget)
			break;

		sint32 mid_point_x = (widget->left + widget->right) / 2 + w->x;
		audio_play_sound_panned(5, mid_point_x, 0, 0, 0);
		if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex)
			break;

		if (w->disabled_widgets & (1ULL << widgetIndex))
			break;

		widget_invalidate_by_number(cursor_w_class, cursor_w_number, widgetIndex);
		window_event_mouse_up_call(w, widgetIndex);
	default:
		return;
	}

	_clickRepeatTicks = 0;
	if (_inputState != INPUT_STATE_DROPDOWN_ACTIVE){
		// Hold down widget and drag outside of area??
		if (_inputFlags & INPUT_FLAG_WIDGET_PRESSED){
			_inputFlags &= ~INPUT_FLAG_WIDGET_PRESSED;
			widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex);
		}
		return;
	}

	gDropdownHighlightedIndex = -1;
	window_invalidate_by_class(WC_DROPDOWN);
	if (w == NULL) {
		return;
	}

	if (w->classification == WC_DROPDOWN){
		sint32 dropdown_index = dropdown_index_from_point(x, y, w);
		if (dropdown_index == -1) {
			return;
		}

		if (gDropdownIsColour && gDropdownLastColourHover != dropdown_index) {
			gDropdownLastColourHover = dropdown_index;
			window_tooltip_close();

			static const rct_string_id colourTooltips[] = {
				STR_COLOUR_BLACK_TIP,
				STR_COLOUR_GREY_TIP,
				STR_COLOUR_WHITE_TIP,
				STR_COLOUR_DARK_PURPLE_TIP,
				STR_COLOUR_LIGHT_PURPLE_TIP,
				STR_COLOUR_BRIGHT_PURPLE_TIP,
				STR_COLOUR_DARK_BLUE_TIP,
				STR_COLOUR_LIGHT_BLUE_TIP,
				STR_COLOUR_ICY_BLUE_TIP,
				STR_COLOUR_TEAL_TIP,
				STR_COLOUR_AQUAMARINE_TIP,
				STR_COLOUR_SATURATED_GREEN_TIP,
				STR_COLOUR_DARK_GREEN_TIP,
				STR_COLOUR_MOSS_GREEN_TIP,
				STR_COLOUR_BRIGHT_GREEN_TIP,
				STR_COLOUR_OLIVE_GREEN_TIP,
				STR_COLOUR_DARK_OLIVE_GREEN_TIP,
				STR_COLOUR_BRIGHT_YELLOW_TIP,
				STR_COLOUR_YELLOW_TIP,
				STR_COLOUR_DARK_YELLOW_TIP,
				STR_COLOUR_LIGHT_ORANGE_TIP,
				STR_COLOUR_DARK_ORANGE_TIP,
				STR_COLOUR_LIGHT_BROWN_TIP,
				STR_COLOUR_SATURATED_BROWN_TIP,
				STR_COLOUR_DARK_BROWN_TIP,
				STR_COLOUR_SALMON_PINK_TIP,
				STR_COLOUR_BORDEAUX_RED_TIP,
				STR_COLOUR_SATURATED_RED_TIP,
				STR_COLOUR_BRIGHT_RED_TIP,
				STR_COLOUR_DARK_PINK_TIP,
				STR_COLOUR_BRIGHT_PINK_TIP,
				STR_COLOUR_LIGHT_PINK_TIP,
			};

			window_tooltip_show(colourTooltips[dropdown_index], x, y);
		}

		if (dropdown_index < 64 && gDropdownItemsDisabled & (1ULL << dropdown_index)) {
			return;
		}

		if (gDropdownItemsFormat[dropdown_index] == 0) {
			return;
		}

		gDropdownHighlightedIndex = dropdown_index;
		window_invalidate_by_class(WC_DROPDOWN);
	} else {
		gDropdownLastColourHover = -1;
		window_tooltip_close();
	}
}
Esempio n. 10
0
/**
 *
 *  rct2: 0x006E8DA7
 */
void input_state_widget_pressed(int x, int y, int state, int widgetIndex, rct_window *w, rct_widget *widget)
{
	RCT2_GLOBAL(0x1420054, uint16) = x;
	RCT2_GLOBAL(0x1420056, uint16) = y;

	rct_windowclass cursor_w_class;
	rct_windownumber cursor_w_number;
	cursor_w_class = gPressedWidget.window_classification;
	cursor_w_number = gPressedWidget.window_number;
	int cursor_widgetIndex = gPressedWidget.widget_index;

	rct_window *cursor_w = window_find_by_number(cursor_w_class, cursor_w_number);
	if (cursor_w == NULL) {
		gInputState = INPUT_STATE_RESET;
		return;
	}

	switch (state) {
	case MOUSE_STATE_RELEASED:
		if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex)
			break;

		if (w->disabled_widgets & (1ULL << widgetIndex))
			break;

		if (RCT2_GLOBAL(0x009DE528, uint16) != 0)
			RCT2_GLOBAL(0x009DE528, uint16)++;

		if (w->hold_down_widgets & (1ULL << widgetIndex) &&
			RCT2_GLOBAL(0x009DE528, uint16) >= 16 &&
			!(RCT2_GLOBAL(0x009DE528, uint16) & 3)
			) {
			window_event_mouse_down_call(w, widgetIndex);
		}

		if (gInputFlags & INPUT_FLAG_WIDGET_PRESSED) {
			if (gInputState == INPUT_STATE_DROPDOWN_ACTIVE) {
				gDropdownHighlightedIndex = gDropdownDefaultIndex;
				window_invalidate_by_class(WC_DROPDOWN);
			}
			return;
		}

		gInputFlags |= INPUT_FLAG_WIDGET_PRESSED;
		widget_invalidate_by_number(cursor_w_class, cursor_w_number, widgetIndex);
		return;
	case MOUSE_STATE_LEFT_RELEASE:
	case MOUSE_STATE_RIGHT_PRESS:
		if (gInputState == INPUT_STATE_DROPDOWN_ACTIVE) {
			if (w) {
				int dropdown_index = 0;

				if (w->classification == WC_DROPDOWN) {
					dropdown_index = dropdown_index_from_point(x, y, w);
					if (dropdown_index == -1) {
						goto dropdown_cleanup;
					}

					if (dropdown_index < 64 && gDropdownItemsDisabled & (1ULL << dropdown_index)) {
						goto dropdown_cleanup;
					}

					if (gDropdownItemsFormat[dropdown_index] == 0) {
						goto dropdown_cleanup;
					}
				}
				else {
					if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex)
						goto dropdown_cleanup;
					dropdown_index = -1;
					if (gInputFlags & INPUT_FLAG_DROPDOWN_STAY_OPEN){
						if (!(gInputFlags & INPUT_FLAG_DROPDOWN_MOUSE_UP)){
							gInputFlags |= INPUT_FLAG_DROPDOWN_MOUSE_UP;
							return;
						}
					}
				}

				window_close_by_class(WC_DROPDOWN);
				cursor_w = window_find_by_number(cursor_w_class, cursor_w_number);
				if (gInputFlags & INPUT_FLAG_WIDGET_PRESSED) {
					gInputFlags &= ~INPUT_FLAG_WIDGET_PRESSED;
					widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex);
				}

				gInputState = INPUT_STATE_NORMAL;
				gTooltipTimeout = 0;
				gTooltipWidget.widget_index = cursor_widgetIndex;
				gTooltipWidget.window_classification = cursor_w_class;
				gTooltipWidget.window_number = cursor_w_number;

				if (dropdown_index == -1) {
					if (!dropdown_is_disabled(gDropdownDefaultIndex)) {
						dropdown_index = gDropdownDefaultIndex;
					}
				}
				window_event_dropdown_call(cursor_w, cursor_widgetIndex, dropdown_index);
			}
		dropdown_cleanup:
			window_close_by_class(WC_DROPDOWN);
		}
		if (state == MOUSE_STATE_RIGHT_PRESS) {
			return;
		}

		gInputState = INPUT_STATE_NORMAL;
		gTooltipTimeout = 0;
		gTooltipWidget.widget_index = cursor_widgetIndex;

		if (!w)
			break;

		if (!widget)
			break;

		int mid_point_x = (widget->left + widget->right) / 2 + w->x;
		audio_play_sound_panned(5, mid_point_x, 0, 0, 0);
		if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex)
			break;

		if (w->disabled_widgets & (1ULL << widgetIndex))
			break;

		widget_invalidate_by_number(cursor_w_class, cursor_w_number, widgetIndex);
		window_event_mouse_up_call(w, widgetIndex);
	default:
		return;
	}

	RCT2_GLOBAL(0x009DE528, uint16) = 0;
	if (gInputState != INPUT_STATE_DROPDOWN_ACTIVE){
		// Hold down widget and drag outside of area??
		if (gInputFlags & INPUT_FLAG_WIDGET_PRESSED){
			gInputFlags &= ~INPUT_FLAG_WIDGET_PRESSED;
			widget_invalidate_by_number(cursor_w_class, cursor_w_number, cursor_widgetIndex);
		}
		return;
	}

	gDropdownHighlightedIndex = -1;
	window_invalidate_by_class(WC_DROPDOWN);
	if (w == NULL) {
		return;
	}

	if (w->classification == WC_DROPDOWN){
		int dropdown_index = dropdown_index_from_point(x, y, w);
		if (dropdown_index == -1) {
			return;
		}

		if (gDropdownIsColour && gDropdownLastColourHover != dropdown_index) {
			gDropdownLastColourHover = dropdown_index;
			window_tooltip_close();
			window_tooltip_show(STR_COLOUR_NAMES_START + dropdown_index, x, y);
		}

		if (dropdown_index < 64 && gDropdownItemsDisabled & (1ULL << dropdown_index)) {
			return;
		}

		if (gDropdownItemsFormat[dropdown_index] == 0) {
			return;
		}

		gDropdownHighlightedIndex = dropdown_index;
		window_invalidate_by_class(WC_DROPDOWN);
	} else {
		gDropdownLastColourHover = -1;
		window_tooltip_close();
	}
}