示例#1
0
/*
=================
Menu_SetCursor
=================
*/
void Menu_SetCursor(menuframework_s* m, int cursor) {
    if (((menucommon_s*)(m->items[cursor]))->flags & (QMF_GRAYED | QMF_INACTIVE)) {
        // cursor can't go there
        return;
    }

    m->cursor_prev = m->cursor;
    m->cursor      = cursor;

    Menu_CursorMoved(m);
}
示例#2
0
sfxHandle_t Menu_DefaultKey(menuframework_s *m, int key)
{
	sfxHandle_t		sound = 0;
	menucommon_s	*item;
	int				cursor_prev;

	// menu system keys
	switch (key) {
	case K_MOUSE2:
	case K_ESCAPE:
		UI_PopMenu();
		return menu_out_sound;
	}

	if (!m || !m->nitems) {
		return 0;
	}

	// route key stimulus to widget
	item = Menu_ItemAtCursor(m);
	if (item && !(item->flags & (QMF_GRAYED|QMF_INACTIVE))) {
		switch (item->type) {
		case MTYPE_SPINCONTROL:
			sound = SpinControl_Key((menulist_s*)item, key);
			break;

		case MTYPE_RADIOBUTTON:
			sound = RadioButton_Key((menuradiobutton_s*)item, key);
			break;

		case MTYPE_SLIDER:
			sound = Slider_Key((menuslider_s*)item, key);
			break;

		case MTYPE_SCROLLLIST:
			sound = ScrollList_Key((menulist_s*)item, key);
			break;

		case MTYPE_FIELD:
			sound = MenuField_Key((menufield_s*)item, &key);
			break;
		}

		if (sound) {
			// key was handled
			return sound;
		}
	}

	// default handling
	switch (key) {
#ifndef NDEBUG
	case K_F11:
		uis.debug ^= 1;
		break;

	case K_F12:
		trap_Cmd_ExecuteText(EXEC_APPEND, "screenshot\n");
		break;
#endif
	case K_KP_UPARROW:
	case K_UPARROW:
		cursor_prev    = m->cursor;
		m->cursor_prev = m->cursor;
		m->cursor--;
		Menu_AdjustCursor(m, -1);
		if (cursor_prev != m->cursor) {
			Menu_CursorMoved(m);
			sound = menu_move_sound;
		}
		break;

	case K_TAB:
	case K_KP_DOWNARROW:
	case K_DOWNARROW:
		cursor_prev    = m->cursor;
		m->cursor_prev = m->cursor;
		m->cursor++;
		Menu_AdjustCursor(m, 1);
		if (cursor_prev != m->cursor) {
			Menu_CursorMoved(m);
			sound = menu_move_sound;
		}
		break;

	case K_MOUSE1:
	case K_MOUSE3:
		if (item)
			if ((item->flags & QMF_HASMOUSEFOCUS) && !(item->flags & (QMF_GRAYED|QMF_INACTIVE)))
				return (Menu_ActivateItem(m, item));
		break;

	case K_JOY1:
	case K_JOY2:
	case K_JOY3:
	case K_JOY4:
	case K_AUX1:
	case K_AUX2:
	case K_AUX3:
	case K_AUX4:
	case K_AUX5:
	case K_AUX6:
	case K_AUX7:
	case K_AUX8:
	case K_AUX9:
	case K_AUX10:
	case K_AUX11:
	case K_AUX12:
	case K_AUX13:
	case K_AUX14:
	case K_AUX15:
	case K_AUX16:
	case K_KP_ENTER:
	case K_ENTER:
		if (item && !(item->flags & (QMF_MOUSEONLY|QMF_GRAYED|QMF_INACTIVE))) {
			return (Menu_ActivateItem(m, item));
		}
		break;
	}

	return sound;
}
示例#3
0
/*
=================
Menu_DefaultKey
=================
*/
sfxHandle_t Menu_DefaultKey( menuframework_s *m, int key )
{
	sfxHandle_t		sound = 0;
	menucommon_s	*item;
	int				cursor_prev;

	// menu system keys
	switch ( key )
	{
		case K_JOY_B:
		case K_2JOY_B:
		case K_3JOY_B:
		case K_4JOY_B:
#ifndef TA_MISC // MENU: Right Mouse button = left arrow
		case K_MOUSE2:
#endif
		case K_ESCAPE:
#ifdef IOQ3ZTM
			if (uis.activemenu->noEscape)
			{
				return sound;
			}
			else
			{
#endif
			UI_PopMenu();
			return menu_out_sound;
#ifdef IOQ3ZTM
			}
#endif
	}

	if (!m || !m->nitems)
		return 0;

	// route key stimulus to widget
	item = Menu_ItemAtCursor( m );
	if (item && !(item->flags & (QMF_GRAYED|QMF_INACTIVE)))
	{
		switch (item->type)
		{
			case MTYPE_SPINCONTROL:
				sound = SpinControl_Key( (menulist_s*)item, key );
				break;

			case MTYPE_RADIOBUTTON:
				sound = RadioButton_Key( (menuradiobutton_s*)item, key );
				break;

			case MTYPE_SLIDER:
				sound = Slider_Key( (menuslider_s*)item, key );
				break;

			case MTYPE_SCROLLLIST:
				sound = ScrollList_Key( (menulist_s*)item, key );
				break;

			case MTYPE_FIELD:
				sound = MenuField_Key( (menufield_s*)item, &key );
				break;
		}

		if (sound) {
			// key was handled
			return sound;		
		}
	}

	// default handling
	switch ( key )
	{
		case K_F11:
			if ( trap_Cvar_VariableValue( "developer" ) ) {
				uis.debug ^= 1;
			}
			break;

		case K_F12:
			if ( trap_Cvar_VariableValue( "developer" ) ) {
				trap_Cmd_ExecuteText( EXEC_APPEND, "screenshot\n" );
			}
			break;

		case K_JOY_DPAD_UP:
		case K_JOY_LEFTSTICK_UP:
		case K_2JOY_DPAD_UP:
		case K_2JOY_LEFTSTICK_UP:
		case K_3JOY_DPAD_UP:
		case K_3JOY_LEFTSTICK_UP:
		case K_4JOY_DPAD_UP:
		case K_4JOY_LEFTSTICK_UP:
		case K_KP_UPARROW:
		case K_UPARROW:
			cursor_prev    = m->cursor;
			m->cursor_prev = m->cursor;
			m->cursor--;
			Menu_AdjustCursor( m, -1 );
			if ( cursor_prev != m->cursor ) {
				Menu_CursorMoved( m );
				sound = menu_move_sound;
			}
			break;

		case K_TAB:
		case K_JOY_DPAD_DOWN:
		case K_JOY_LEFTSTICK_DOWN:
		case K_2JOY_DPAD_DOWN:
		case K_2JOY_LEFTSTICK_DOWN:
		case K_3JOY_DPAD_DOWN:
		case K_3JOY_LEFTSTICK_DOWN:
		case K_4JOY_DPAD_DOWN:
		case K_4JOY_LEFTSTICK_DOWN:
		case K_KP_DOWNARROW:
		case K_DOWNARROW:
			cursor_prev    = m->cursor;
			m->cursor_prev = m->cursor;
			m->cursor++;
			Menu_AdjustCursor( m, 1 );
			if ( cursor_prev != m->cursor ) {
				Menu_CursorMoved( m );
				sound = menu_move_sound;
			}
			break;

		case K_MOUSE1:
		case K_MOUSE3:
			if (item)
				if ((item->flags & QMF_HASMOUSEFOCUS) && !(item->flags & (QMF_GRAYED|QMF_INACTIVE)))
					return (Menu_ActivateItem( m, item ));
			break;

		case K_JOY_A:
		case K_2JOY_A:
		case K_3JOY_A:
		case K_4JOY_A:
		case K_AUX1:
		case K_AUX2:
		case K_AUX3:
		case K_AUX4:
		case K_AUX5:
		case K_AUX6:
		case K_AUX7:
		case K_AUX8:
		case K_AUX9:
		case K_AUX10:
		case K_AUX11:
		case K_AUX12:
		case K_AUX13:
		case K_AUX14:
		case K_AUX15:
		case K_AUX16:
		case K_KP_ENTER:
		case K_ENTER:
			if (item)
				if (!(item->flags & (QMF_MOUSEONLY|QMF_GRAYED|QMF_INACTIVE)))
					return (Menu_ActivateItem( m, item ));
			break;
	}

	return sound;
}