////////////////////////////////////Fonctions clavier déplacées en fonction indépendantes pour mapping/////////////////////////
int key_switch_window_up()
{
//solo des fenetres
if (key_shifts & KB_CTRL_FLAG || index_false_control==1) //appel une par une

{
pos_focus_window=window_focus_id;
substract_a_window(pos_focus_window);
if(pos_focus_window<900){pos_focus_window=899;}
pos_focus_window++;
if(pos_focus_window>max_window_identity_is){pos_focus_window=900;}
add_a_window(pos_focus_window);
}

else//passage dune fenetre à l autre
{
index_to_navigate_between_window++;
nbre_fenetre_actives=check_nbre_opened_windows();
if(index_to_navigate_between_window>=nbre_fenetre_actives+1){index_to_navigate_between_window=0;}
if(window_opened[index_to_navigate_between_window]>0)
{
window_bring_to_front(window_opened[index_to_navigate_between_window]);
}
else {window_bring_to_front(window_opened[0]);   }
}
 return(0);
}
示例#2
0
static void window_title_menu_mouseup(rct_window *w, rct_widgetindex widgetIndex)
{
    rct_window *windowToOpen = nullptr;

    switch (widgetIndex) {
    case WIDX_START_NEW_GAME:
        windowToOpen = window_find_by_class(WC_SCENARIO_SELECT);
        if (windowToOpen != nullptr) {
            window_bring_to_front(windowToOpen);
        }
        else {
            window_close_by_class(WC_LOADSAVE);
            window_close_by_class(WC_SERVER_LIST);
            window_scenarioselect_open(window_title_menu_scenarioselect_callback, false);
        }
        break;
    case WIDX_CONTINUE_SAVED_GAME:
        windowToOpen = window_find_by_class(WC_LOADSAVE);
        if (windowToOpen != nullptr) {
            window_bring_to_front(windowToOpen);
        }
        else {
            window_close_by_class(WC_SCENARIO_SELECT);
            window_close_by_class(WC_SERVER_LIST);
            game_do_command(0, 1, 0, 0, GAME_COMMAND_LOAD_OR_QUIT, 0, 0);
        }
        break;
    case WIDX_MULTIPLAYER:
        windowToOpen = window_find_by_class(WC_SERVER_LIST);
        if (windowToOpen != nullptr) {
            window_bring_to_front(windowToOpen);
        }
        else {
            window_close_by_class(WC_SCENARIO_SELECT);
            window_close_by_class(WC_LOADSAVE);
            context_open_window(WC_SERVER_LIST);
        }
        break;
    }
}
示例#3
0
/**
 * 
 *  rct2: 0x006E95F9
 */
static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex)
{
	// RCT2_CALLPROC_X(0x006E95F9, x, y, state, widgetIndex, w, widget, 0);

	rct_windowclass windowClass = 255;
	rct_windownumber windowNumber = 0;
	rct_widget *widget;

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

	window_close_by_id(WC_ERROR, 0);
	window_close_by_id(WC_TOOLTIP, 0);

	w = window_find_by_id(windowClass, windowNumber);
	if (w == NULL)
		return;

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

	switch (widget->type) {
	case WWT_FRAME:
	case WWT_RESIZE:
		if (!(w->flags & WF_RESIZABLE))
			break;
		if (w->min_width == w->max_width && w->min_height == w->max_height)
			break;
		if (x < w->x + w->width - 19 || y < w->y + w->height - 19)
			break;

		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESIZING;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber;
		break;
	case WWT_VIEWPORT:
		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_VIEWPORT_LEFT;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber;
		if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)))
			break;

		w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber));
		if (w == NULL)
			break;

		RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_DOWN], x, y, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), w, 0, 0);
		RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 4);
		break;
	case WWT_CAPTION:
		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_DRAGGING;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, uint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, uint16) = y;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber) = windowNumber;
		break;
	case WWT_SCROLL:
		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_SCROLL_LEFT;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint16) = widgetIndex;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windowclass) = windowNumber;
		RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_X, uint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_CURSOR_Y, uint16) = y;

		int eax, ebx, ecx, edx, esi, edi, ebp;
		eax = x;
		ebx = y;
		esi = w;
		edi = widget;
		RCT2_CALLFUNC_X(0x006E9F92, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); // widget_scoll_get_part
		eax &= 0xFFFF;
		ebx &= 0xFFFF;
		ecx &= 0xFFFF;
		edx &= 0xFFFF;

		RCT2_GLOBAL(0x009DE548, uint16) = ecx;
		RCT2_GLOBAL(0x009DE54C, uint32) = edx;
		RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_15], RCT2_GLOBAL(0x009DE54C, uint32), ebx, ecx, edx, w, widget, 0);
		switch (ecx) {
		case SCROLL_PART_VIEW:
			RCT2_CALLPROC_X(w->event_handlers[WE_SCROLL_MOUSEDOWN], edx / sizeof(rct_scroll), ebx, eax, ebx, w, widget, 0);
			break;
		case SCROLL_PART_HSCROLLBAR_LEFT:
			// 0x006E9A60
			RCT2_CALLPROC_X(0x006E9A60, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_HSCROLLBAR_RIGHT:
			// 0x006E9ABF
			RCT2_CALLPROC_X(0x006E9ABF, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_HSCROLLBAR_LEFT_TROUGH:
			// 0x006E9B47
			RCT2_CALLPROC_X(0x006E9B47, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH:
			// 0x006E9BB7
			RCT2_CALLPROC_X(0x006E9BB7, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_VSCROLLBAR_TOP:
			// 0x006E9C37
			RCT2_CALLPROC_X(0x006E9C37, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_VSCROLLBAR_BOTTOM:
			// 0x006E9C96
			RCT2_CALLPROC_X(0x006E9C96, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_VSCROLLBAR_TOP_TROUGH:
			// 0x006E9D1E
			RCT2_CALLPROC_X(0x006E9D1E, 0, 0, 0, 0, w, 0, 0);
			break;
		case SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH:
			// 0x006E9D8E
			RCT2_CALLPROC_X(0x006E9D8E, 0, 0, 0, 0, w, 0, 0);
			break;
		}
		break;
	default:
		if (!widget_is_enabled(w, widgetIndex))
			break;
		if (widget_is_disabled(w, widgetIndex))
			break;

		sound_play_panned(4, w->x + (widget->left + widget->right) / 2);
		
		// Set new cursor down widget
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = windowClass;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windowclass) = windowNumber;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, rct_windowclass) = widgetIndex;
		RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 0);
		RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_WIDGET_PRESSED;
		RCT2_GLOBAL(0x009DE528, uint16) = 1;

		widget_invalidate(windowClass, windowNumber, widgetIndex);
		RCT2_CALLPROC_X(w->event_handlers[WE_MOUSE_DOWN], 0, 0, 0, widgetIndex, w, widget, 0);
		break;
	}
}
示例#4
0
/**
 * 
 *  rct2: 0x006E8655
 */
static void game_handle_input_mouse(int x, int y, int state)
{
	rct_window *w, *w2;
	rct_widget *widget;
	int widgetIndex;
	rct_windowclass windowClass;
	rct_windownumber windowNumber;

	// Get window and widget under cursor position
	w = window_find_from_point(x, y);
	widgetIndex = w == NULL ? -1 : window_find_widget_from_point(w, x, y);
	widget = widgetIndex == -1 ? 0 : &w->widgets[widgetIndex];

	switch (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8)) {
	case INPUT_STATE_RESET:
		window_tooltip_reset(x, y);
		// fall-through
	case INPUT_STATE_NORMAL:
		switch (state) {
		case 0:
			input_mouseover(x, y, w, widgetIndex);
			break;
		case 1:
			input_leftmousedown(x, y, w, widgetIndex);
			break;
		case 3:
			// Close tooltip
			window_close_by_id(5, 0);
			
			if (w != NULL)
				window_bring_to_front(w);
			
			if (widgetIndex == -1)
				break;
			
			if (widget->type == WWT_VIEWPORT) {
				if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 9)
					break;
				w->flags &= ~(1 << 3);
				RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_VIEWPORT_DRAG;
				RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
				RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;
				RCT2_GLOBAL(0x009DE530, rct_windowclass) = w->classification;
				RCT2_GLOBAL(0x009DE52E, rct_windownumber) = w->number;
				RCT2_GLOBAL(0x009DE540, sint16) = 0;
				// hide cursor
				// RCT2_CALLPROC_X(0x00407045, 0, 0, 0, 0, 0, 0, 0);
				// RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 5);

				GetCursorPos(&_dragPosition);
				ShowCursor(FALSE);

			} else if (widget->type == WWT_SCROLL) {

			}

			break;
		}

		break;
	case INPUT_STATE_WIDGET_PRESSED:
		RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0);
		break;
	case INPUT_STATE_DRAGGING:
		// RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0);

		w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber));
		if (w == NULL) {
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
			break;
		}

		if (state == 0) {
			y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34);
			window_move_position(
				w,
				x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16),
				y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16)
			);
			RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
			RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;
		} else if (state == 2) {
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL;
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0;
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16);
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass);
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber);
			y = clamp(29, y, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 34);
			window_move_position(
				w,
				x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16),
				y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16)
			);
			RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
			RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;

			RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_18], 0, 0, x, y, w, 0, 0);
		}
		break;
	case INPUT_STATE_VIEWPORT_DRAG:
	{
		int dx, dy;
		
		dx = x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16);
		dy = y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16);
		w = window_find_by_id(RCT2_GLOBAL(0x009DE530, rct_windowclass), RCT2_GLOBAL(0x009DE52E, rct_windownumber));
		if (state == 0) {
			rct_viewport *viewport = w->viewport;
			RCT2_GLOBAL(0x009DE540, sint16) += RCT2_GLOBAL(0x009DE588, sint16);
			if (viewport == NULL) {
				ShowCursor(TRUE);
				RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
			} else if (dx != 0 || dy != 0) {
				if (!(w->flags & (1 << 2))) {
					RCT2_GLOBAL(0x009DE540, sint16) = 1000;
					dx <<= viewport->zoom + 1;
					dy <<= viewport->zoom + 1;
					w->var_4B2 += dx;
					w->var_4B4 += dy;
				}
			}
		} else if (state == 4) {
			ShowCursor(TRUE);
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
			if (RCT2_GLOBAL(0x009DE540, sint16) < 500) {
				// Right click
				{
					int eax, ebx, ecx, edx, esi, edi, ebp;
					eax = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16);
					ebx = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16);
					RCT2_CALLFUNC_X(0x006EDE88, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
					switch (ebx & 0xFF) {
					case 2:
						if (*((uint8*)edx) == 0)
							RCT2_CALLPROC_X(0x006B4857, eax, 0, ecx, 0, 0, 0, 0);
						break;
					case 3:
						RCT2_CALLPROC_X(0x006CC056, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 5:
						RCT2_CALLPROC_X(0x006E08D2, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 6:
						RCT2_CALLPROC_X(0x006A614A, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 7:
						RCT2_CALLPROC_X(0x006A61AB, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 8:
						RCT2_CALLPROC_X(0x00666C0E, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 9:
						RCT2_CALLPROC_X(0x006E57A9, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 10:
						RCT2_CALLPROC_X(0x006B88DC, eax, 0, ecx, edx, 0, 0, 0);
						break;
					case 12:
						RCT2_CALLPROC_X(0x006BA233, eax, 0, ecx, edx, 0, 0, 0);
						break;
					default:
						break;
					}
				}
			}
		}

		//
		//
		SetCursorPos(_dragPosition.x, _dragPosition.y);
		// RCT2_CALLPROC_X(0x006E89C6, x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16), y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16), state, widgetIndex, w, widget, 0);
		break;
	}
	case INPUT_STATE_DROPDOWN_ACTIVE:
		RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, w, widget, 0);
		break;
	case INPUT_STATE_VIEWPORT_LEFT:
		RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, w, widget, 0);
		break;
	case INPUT_STATE_SCROLL_LEFT:
		RCT2_CALLPROC_X(0x006E8676, x, y, state, widgetIndex, w, widget, 0);
		break;
	case INPUT_STATE_RESIZING:
		// RCT2_CALLPROC_X(0x006E8B46, x, y, state, widgetIndex, w, widget, 0);

		w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_WINDOWNUMBER, rct_windownumber));
		if (w == NULL) {
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_RESET;
			break;
		}

		if (state != 0 && state != 2)
			break;
		if (state == 2) {
			RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = INPUT_STATE_NORMAL;
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint8) = 0;
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint8) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, sint16);
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass);
			RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber);
		}

		if (y < RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 2) {
			window_resize(
				w,
				x - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16),
				y - RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16)
			);
		}
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_X, sint16) = x;
		RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DRAG_LAST_Y, sint16) = y;
		break;
	case 9:
		RCT2_CALLPROC_X(0x006E8ACB, x, y, state, widgetIndex, w, widget, 0);
		break;
	}
}
示例#5
0
文件: input.c 项目: LucaRed/OpenRCT2
/**
 *
 *  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;
	}
}
示例#6
0
文件: input.c 项目: LucaRed/OpenRCT2
/**
 *
 *  rct2: 0x006E8655
 */
static void game_handle_input_mouse(sint32 x, sint32 y, sint32 state)
{
	rct_window *w;
	rct_widget *widget;
	rct_widgetindex widgetIndex;

	// Get window and widget under cursor position
	w = window_find_from_point(x, y);
	widgetIndex = w == NULL ? -1 : window_find_widget_from_point(w, x, y);
	widget = widgetIndex == -1 ? 0 : &w->widgets[widgetIndex];

	switch (_inputState) {
	case INPUT_STATE_RESET:
		window_tooltip_reset(x, y);
		// fall-through
	case INPUT_STATE_NORMAL:
		switch (state) {
		case MOUSE_STATE_RELEASED:
			input_widget_over(x, y, w, widgetIndex);
			break;
		case MOUSE_STATE_LEFT_PRESS:
			input_widget_left(x, y, w, widgetIndex);
			break;
		case MOUSE_STATE_RIGHT_PRESS:
			window_close_by_class(WC_TOOLTIP);

			if (w != NULL) {
				w = window_bring_to_front(w);
			}

			if (widgetIndex != -1) {
				switch (widget->type) {
				case WWT_VIEWPORT:
					if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_MANAGER | SCREEN_FLAGS_TITLE_DEMO))) {
						input_viewport_drag_begin(w, x, y);
					}
					break;
				case WWT_SCROLL:
					input_scroll_drag_begin(x, y, w, widget, widgetIndex);
					break;
				}
			}
			break;
		}
		break;
	case INPUT_STATE_WIDGET_PRESSED:
		input_state_widget_pressed(x, y, state, widgetIndex, w, widget);
		break;
	case INPUT_STATE_POSITIONING_WINDOW:
		w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number);
		if (w == NULL) {
			_inputState = INPUT_STATE_RESET;
		} else {
			input_window_position_continue(w, gInputDragLastX, gInputDragLastY, x, y);
			if (state == MOUSE_STATE_LEFT_RELEASE) {
				input_window_position_end(w, x, y);
			}
		}
		break;
	case INPUT_STATE_VIEWPORT_RIGHT:
		if (state == MOUSE_STATE_RELEASED) {
			input_viewport_drag_continue();
		} else if (state == MOUSE_STATE_RIGHT_RELEASE) {
			input_viewport_drag_end();
			if (_ticksSinceDragStart < 500) {
				// If the user pressed the right mouse button for less than 500 ticks, interpret as right click
				viewport_interaction_right_click(x, y);
			}
		}
		break;
	case INPUT_STATE_DROPDOWN_ACTIVE:
		input_state_widget_pressed(x, y, state, widgetIndex, w, widget);
		break;
	case INPUT_STATE_VIEWPORT_LEFT:
		w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number);
		if (w == NULL) {
			_inputState = INPUT_STATE_RESET;
			break;
		}

		switch (state) {
		case MOUSE_STATE_RELEASED:
			if (w->viewport == NULL) {
				_inputState = INPUT_STATE_RESET;
				break;
			}

			if (w->classification != _dragWidget.window_classification ||
				w->number != _dragWidget.window_number ||
				!(_inputFlags & INPUT_FLAG_TOOL_ACTIVE)
			) {
				break;
			}

			w = window_find_by_number(
				gCurrentToolWidget.window_classification,
				gCurrentToolWidget.window_number
			);
			if (w == NULL) {
				break;
			}

			window_event_tool_drag_call(w, gCurrentToolWidget.widget_index, x, y);
			break;
		case MOUSE_STATE_LEFT_RELEASE:
			_inputState = INPUT_STATE_RESET;
			if (_dragWidget.window_number == w->number) {
				if ((_inputFlags & INPUT_FLAG_TOOL_ACTIVE)) {
					w = window_find_by_number(
						gCurrentToolWidget.window_classification,
						gCurrentToolWidget.window_number
						);
					if (w != NULL) {
						window_event_tool_up_call(w, gCurrentToolWidget.widget_index, x, y);
					}
				} else if (!(_inputFlags & INPUT_FLAG_4)) {
					viewport_interaction_left_click(x, y);
				}
			}
			break;
		}
		break;
	case INPUT_STATE_SCROLL_LEFT:
		switch (state) {
		case MOUSE_STATE_RELEASED:
			input_scroll_continue(w, widgetIndex, state, x, y);
			break;
		case MOUSE_STATE_LEFT_RELEASE:
			input_scroll_end();
			break;
		}
		break;
	case INPUT_STATE_RESIZING:
		w = window_find_by_number(_dragWidget.window_classification, _dragWidget.window_number);
		if (w == NULL) {
			_inputState = INPUT_STATE_RESET;
		} else {
			if (state == MOUSE_STATE_LEFT_RELEASE) {
				input_window_resize_end();
			}
			if (state == MOUSE_STATE_RELEASED || state == MOUSE_STATE_LEFT_RELEASE) {
				input_window_resize_continue(w, x, y);
			}
		}
		break;
	case INPUT_STATE_SCROLL_RIGHT:
		input_scroll_right(x, y, state);
		break;
	}
}
int detection_over_window()
{
bool stop_detect=0;
int window_is=0;
if(mouse_y>hauteur_ChannelMenu )
{
for(int i=0;i<63;i++)
{
switch(window_opened[i])
{
        case W_SAVEREPORT:
        if( mouse_x>= report_SL_X && mouse_x<= report_SL_X+350 && mouse_y>=report_SL_Y && mouse_y<=report_SL_Y+160)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_TRICHROMY:
        if( mouse_x>= xtrichro_window-158 && mouse_x<= xtrichro_window+157 && mouse_y>=ytrichro_window-206  && mouse_y<= ytrichro_window+344)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_NUMPAD:
        if( mouse_x>= xnum_window && mouse_x<= xnum_window+480 && mouse_y>=ynum_window  && mouse_y<= ynum_window+300)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_TRACKINGVIDEO:
        if( mouse_x>= videoX && mouse_x<= videoX+video_size_x+35 && mouse_y>=videoY  && mouse_y<= videoY+video_size_y+500)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_ARTPOLLREPLY:
        if ( mouse_x>=artpoll_replyX && mouse_x<=artpoll_replyX+500 && mouse_y>=artpoll_replyY && mouse_y<=artpoll_replyY+400)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_FADERS :
        if(mouse_y>(YFader-80) && mouse_x<LargeurEspaceFaderSize)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_PATCH:
        if( (index_menu_curve==0 && mouse_x>=xpatch_window && mouse_x<=xpatch_window+450 && mouse_y>=ypatch_window && mouse_y<=ypatch_window+600)
        || ( index_menu_curve==1 && mouse_x>=xpatch_window && mouse_x<=xpatch_window+450+320 && mouse_y>=ypatch_window && mouse_y<=ypatch_window+600))
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_TIME:
        if (mouse_x>=xtime_window && mouse_x<=xtime_window+370 && mouse_y>=ytime_window && mouse_y<=ytime_window+300)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_SEQUENCIEL:
        if(mouse_x>=xseq_window && mouse_x<=xseq_window+670+(260*show_gridplayer_in_seq) && mouse_y>=yseq_window && mouse_y<=yseq_window+hauteur_globale_sequenciel)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_ASKCONFIRM:
        if(mouse_x>=XConfirm && mouse_x<=XConfirm+400 && mouse_y>=YConfirm && mouse_y<=YConfirm+100 )
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_PLOT:
        if(mouse_x>=x_plot && mouse_x<=x_plot+plot_window_x_size && mouse_y>=y_plot && mouse_y<=y_plot+plot_window_y_size )
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_ECHO:
        if(mouse_x>=x_echo && mouse_x<=x_echo+echo_window_x_size && mouse_y>=y_echo && mouse_y<=y_echo+echo_window_y_size )
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_DRAW:
        if(mouse_x>=x_Wdraw && mouse_x<=x_Wdraw+draw_window_x_size && mouse_y>=y_Wdraw && mouse_y<=y_Wdraw+draw_window_y_size )
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_LIST:
        if(mouse_x>=Xlistproj && mouse_x<=Xlistproj+350 && mouse_y>=Ylistproj && mouse_y<=Ylistproj+600)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_SAVE:
        if(mouse_x>=xsave_window && mouse_x<=xsave_window+420 && mouse_y>=ysave_window && mouse_y<=ysave_window+520)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_MAINMENU:
        if(mouse_x>x_mainmenu && mouse_x<=x_mainmenu+size_x_mainmenu && mouse_y>=y_mainmenu && mouse_y<=y_mainmenu+size_y_mainmenu)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_BANGER:
        if(mouse_x>=X_banger && mouse_x<=X_banger+size_X_Banger && mouse_y>=Y_banger && mouse_y<=Y_banger+size_Y_Banger)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_ALARM:
        if( mouse_x>=XAlarm && mouse_x<=XAlarm+300 && mouse_y>=YAlarm && mouse_y<=YAlarm+110)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_AUDIO:
        if(mouse_x>=XAudio && mouse_x<=XAudio+600 && mouse_y>=YAudio && mouse_y<=YAudio+150+(index_nbre_players_visibles*6*20))
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_CFGMENU:
        if(mouse_x>=window_cfgX && mouse_x<=window_cfgX+largeurCFGwindow && mouse_y>=window_cfgY  && mouse_y<=window_cfgY+hauteurCFGwindow+40)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_WIZARD:
        if( mouse_x>=Xwizard && mouse_x<=Xwizard+480 && mouse_y>=Ywizard && mouse_y<=Ywizard+420)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_MINIFADERS:
        if( mouse_x>=xMinifaders-10 && mouse_x<=xMinifaders+700 && mouse_y>=yMinifaders-50 && mouse_y<=yMinifaders+400)
        {window_is=window_opened[i];stop_detect=1;}//index_over_minifaders=1 index_show_minifaders==1
        break;
        case W_CHASERS:
        if( mouse_x>=Xchasers && mouse_x<=Xchasers+620 && mouse_y>=Ychasers && mouse_y<=Ychasers+160+(nbre_track_visualisables*40))
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_MOVER:
        if(mouse_x>=xmover_window && mouse_x<=xmover_window+1000 && mouse_y>=ymover_window-40 && mouse_y<=ymover_window+660)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_iCAT:
        if(mouse_x>=X_gui_iCat && mouse_x<=X_gui_iCat+largeuriCat && mouse_y>=Y_gui_iCat && mouse_y<=Y_gui_iCat+hauteuriCat)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_GRID:
        if( mouse_x>=grider_window_x && mouse_x<=grider_window_x+largeurGrider && mouse_y>=grider_window_y && mouse_y<=grider_window_y+hauteurGrider)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        case W_MY_WINDOW:
        if( mouse_x>=my_window_x && mouse_x<=my_window_x+largeur_my_window && mouse_y>=my_window_y && mouse_y<=my_window_y+hauteur_my_window)
        {window_is=window_opened[i];stop_detect=1;}
        break;
        default:
        break;
break;
}
if(stop_detect==1){break;}
}
}
if(stop_detect==0){index_over_A_window=0;}
else {index_over_A_window=1;window_bring_to_front(window_is);}






if(index_over_A_window==0 && mouse_y> hauteur_ChannelMenu && mouse_x<560 )
{
index_over_channelspace=1;
}
else {index_over_channelspace=0;}

return(window_is);
}