Exemplo n.º 1
0
/*
=================
PlayerModel_MenuKey
=================
*/
static sfxHandle_t PlayerModel_MenuKey(int key) {
	menucommon_s*	m;
	int				picnum;

	switch (key) {
		case K_KP_LEFTARROW:
		case K_LEFTARROW:
			m = Menu_ItemAtCursor(&s_playermodel.menu);
			picnum = m->id - ID_PLAYERPIC0;
			if (picnum >= 0 && picnum <= 15) {
				if (picnum > 0) {
					Menu_SetCursor(&s_playermodel.menu, s_playermodel.menu.cursor - 1);
					return (menu_move_sound);

				} else if (s_playermodel.modelpage > 0) {
					s_playermodel.modelpage--;
					Menu_SetCursor(&s_playermodel.menu, s_playermodel.menu.cursor + 15);
					PlayerModel_UpdateGrid();
					return (menu_move_sound);
				} else
					return (menu_buzz_sound);
			}
			break;

		case K_KP_RIGHTARROW:
		case K_RIGHTARROW:
			m = Menu_ItemAtCursor(&s_playermodel.menu);
			picnum = m->id - ID_PLAYERPIC0;
			if (picnum >= 0 && picnum <= 15) {
				if ((picnum < 15) && (s_playermodel.modelpage*MAX_MODELSPERPAGE + picnum + 1 < s_playermodel.nummodels)) {
					Menu_SetCursor(&s_playermodel.menu, s_playermodel.menu.cursor + 1);
					return (menu_move_sound);
				} else if ((picnum == 15) && (s_playermodel.modelpage < s_playermodel.numpages - 1)) {
					s_playermodel.modelpage++;
					Menu_SetCursor(&s_playermodel.menu, s_playermodel.menu.cursor - 15);
					PlayerModel_UpdateGrid();
					return (menu_move_sound);
				} else
					return (menu_buzz_sound);
			}
			break;

		case K_MOUSE2:
			trap_Cvar_Set("headmodel", s_playermodel.modelskin);
			trap_Cvar_Set("team_headmodel", s_playermodel.modelskin);
			PlayerModel_SaveChanges();
			PlayerModel_UpdateModel();
			return (menu_buzz_sound);

		case K_ESCAPE:
			PlayerModel_SaveChanges();
			break;
	}

	return (Menu_DefaultKey(&s_playermodel.menu, key));
}
Exemplo n.º 2
0
/*
=================
Menu_SetCursorToItem
=================
*/
void Menu_SetCursorToItem(menuframework_s* m, void* ptr) {
    int i;

    for (i = 0; i < m->nitems; i++) {
        if (m->items[i] == ptr) {
            Menu_SetCursor(m, i);
            return;
        }
    }
}
Exemplo n.º 3
0
/*
=================
UI_PushMenu
=================
*/
void UI_PushMenu( menuframework_s *menu )
{
	int				i;
	menucommon_s*	item;

	// avoid stacking menus invoked by hotkeys
	for (i=0 ; i<uis.menusp ; i++)
	{
		if (uis.stack[i] == menu)
		{
			uis.menusp = i;
			break;
		}
	}

	if (i == uis.menusp)
	{
		if (uis.menusp >= MAX_MENUDEPTH)
			trap_Error("UI_PushMenu: menu stack overflow");

		uis.stack[uis.menusp++] = menu;
	}

	uis.activemenu = menu;

	// default cursor position
	menu->cursor      = 0;
	menu->cursor_prev = 0;

	// pushmenu pushmenu has more priority than popmenu
	soundTime = 0;
	UI_StartSound( menu_in_sound );
	soundTime = uis.realtime + 150;

	trap_Key_SetCatcher( KEYCATCH_UI );

	// force first available item to have focus
	for (i=0; i<menu->nitems; i++)
	{
		item = (menucommon_s *)menu->items[i];
		if (!(item->flags & (QMF_GRAYED|QMF_MOUSEONLY|QMF_INACTIVE)))
		{
			menu->cursor_prev = -1;
			Menu_SetCursor( menu, i );
			break;
		}
	}

	uis.firstdraw = qtrue;
}