/* ================ VID_MenuKey ================ */ const char *VID_MenuKey( int key ) { extern void M_PopMenu( void ); menuframework_s *m = s_current_menu; static const char *sound = "misc/menu1.wav"; switch ( key ) { case K_ESCAPE: M_PopMenu(); return NULL; case K_UPARROW: m->cursor--; Menu_AdjustCursor( m, -1 ); break; case K_DOWNARROW: m->cursor++; Menu_AdjustCursor( m, 1 ); break; case K_LEFTARROW: Menu_SlideItem( m, -1 ); break; case K_RIGHTARROW: Menu_SlideItem( m, 1 ); break; case K_ENTER: Menu_SelectItem( m ); break; } return sound; }
const char *VID_MenuKey( int key ) { menuframework_t *m = s_current_menu; static const char *insound = "misc/menu1.wav"; static const char *movesound = "misc/menu2.wav"; // NeVo static const char *exitsound = "misc/menu3.wav"; // NeVo const char *sound = NULL; switch ( key ) { case K_ESCAPE: M_PopMenu(); // NeVo return exitsound; // NeVo break; case K_KP_UPARROW: case K_UPARROW: m->cursor--; Menu_AdjustCursor( m, -1 ); sound = movesound; break; case K_KP_DOWNARROW: case K_DOWNARROW: m->cursor++; Menu_AdjustCursor( m, 1 ); sound = movesound; break; case K_KP_LEFTARROW: case K_LEFTARROW: Menu_SlideItem( m, -1 ); sound = movesound; break; case K_KP_RIGHTARROW: case K_RIGHTARROW: Menu_SlideItem( m, 1 ); sound = movesound; break; case K_KP_ENTER: case K_ENTER: if ( !Menu_SelectItem( m ) ) ApplyChanges( NULL ); sound = movesound; break; } return sound; }
/* ================= Menu_ClickSlideItem ================= */ void Menu_ClickSlideItem (menuframework_s *menu, void *menuitem) { int min, max; float x, w; menucommon_s *item = (menucommon_s *) menuitem; menuslider_s *slider = (menuslider_s *) menuitem; x = menu->x + item->x + Slider_CursorPositionX(slider) - 4; w = 8; SCR_AdjustFrom640 (&x, NULL, &w, NULL, ALIGN_CENTER); min = x; max = x + w; if (cursor.x < min) Menu_SlideItem( menu, -1 ); if (cursor.x > max) Menu_SlideItem( menu, 1 ); }
/* ================ VID_MenuKey ================ */ const char *VID_MenuKey( int key ) { menuframework_s *m = s_current_menu; static const char *sound = "misc/menu1.wav"; switch ( key ) { case K_ESCAPE: ApplyChanges( 0 ); return NULL; case K_KP_UPARROW: case K_UPARROW: m->cursor--; Menu_AdjustCursor( m, -1 ); break; case K_KP_DOWNARROW: case K_DOWNARROW: m->cursor++; Menu_AdjustCursor( m, 1 ); break; case K_KP_LEFTARROW: case K_LEFTARROW: Menu_SlideItem( m, -1 ); break; case K_KP_RIGHTARROW: case K_RIGHTARROW: Menu_SlideItem( m, 1 ); break; case K_KP_ENTER: case K_ENTER: if ( !Menu_SelectItem( m ) ) ApplyChanges( NULL ); break; } return sound; }
/* * ================= * Default_MenuKey * ================= */ const char *Default_MenuKey(menuframework_s *m, int key) { const char *sound = NULL; menucommon_s *item; if (m) { if ((item = Menu_ItemAtCursor(m)) != 0) { if (item->type == MTYPE_FIELD) { if (Field_Key(( menufield_s * )item, key)) { return NULL; } } } } switch (key) { case K_ESCAPE: UI_PopMenu(); return menu_out_sound; case K_KP_UPARROW: case K_UPARROW: if (m) { m->cursor--; // Knightmare- added Psychospaz's mouse support UI_RefreshCursorLink(); Menu_AdjustCursor(m, -1); sound = menu_move_sound; } break; case K_TAB: case K_KP_DOWNARROW: case K_DOWNARROW: if (m) { m->cursor++; // Knightmare- added Psychospaz's mouse support UI_RefreshCursorLink(); Menu_AdjustCursor(m, 1); sound = menu_move_sound; } break; case K_KP_LEFTARROW: case K_LEFTARROW: if (m) { Menu_SlideItem(m, -1); sound = menu_move_sound; } break; case K_KP_RIGHTARROW: case K_RIGHTARROW: if (m) { Menu_SlideItem(m, 1); sound = menu_move_sound; } break; /*case K_MOUSE1: * case K_MOUSE2: * case K_MOUSE3: * //Knightmare 12/22/2001 * case K_MOUSE4: * case K_MOUSE5:*/ //end Knightmare 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_AUX17: case K_AUX18: case K_AUX19: case K_AUX20: case K_AUX21: case K_AUX22: case K_AUX23: case K_AUX24: case K_AUX25: case K_AUX26: case K_AUX27: case K_AUX28: case K_AUX29: case K_AUX30: case K_AUX31: case K_AUX32: case K_KP_ENTER: case K_ENTER: if (m) { Menu_SelectItem(m); } sound = menu_move_sound; break; } return sound; }
/* ================= UI_Think_MouseCursor ================= */ void UI_Think_MouseCursor (void) { char * sound = NULL; menuframework_s *m = (menuframework_s *)cursor.menu; if (m_drawfunc == M_Main_Draw) // have to hack for main menu :p { UI_CheckMainMenuMouse(); return; } if (m_drawfunc == M_Credits_MenuDraw) // have to hack for credits :p { if (cursor.buttonclicks[MOUSEBUTTON2]) { cursor.buttonused[MOUSEBUTTON2] = true; cursor.buttonclicks[MOUSEBUTTON2] = 0; cursor.buttonused[MOUSEBUTTON1] = true; cursor.buttonclicks[MOUSEBUTTON1] = 0; S_StartLocalSound( menu_out_sound ); if (creditsBuffer) FS_FreeFile (creditsBuffer); UI_PopMenu(); return; } } /* // clicking on the player model menu... if (m_drawfunc == PlayerConfig_MenuDraw) PlayerConfig_MouseClick(); // clicking on the screen menu if (m_drawfunc == Options_Screen_MenuDraw) MenuCrosshair_MouseClick();*/ if (!m) return; // Exit with double click 2nd mouse button if (cursor.menuitem) { // MOUSE1 if (cursor.buttondown[MOUSEBUTTON1]) { if (cursor.menuitemtype == MENUITEM_SLIDER && !cursor.buttonused[MOUSEBUTTON1]) { // Menu_DragSlideItem(m, cursor.menuitem); Menu_SlideItem(m, 1); sound = menu_move_sound; cursor.buttonused[MOUSEBUTTON1] = true; } else if (!cursor.buttonused[MOUSEBUTTON1] && cursor.buttonclicks[MOUSEBUTTON1]) { if (cursor.menuitemtype == MENUITEM_ROTATE) { if (menu_rotate->value) Menu_SlideItem( m, -1 ); else Menu_SlideItem( m, 1 ); sound = menu_move_sound; cursor.buttonused[MOUSEBUTTON1] = true; } else { cursor.buttonused[MOUSEBUTTON1] = true; Menu_MouseSelectItem( cursor.menuitem ); sound = menu_move_sound; } } } // MOUSE2 if (cursor.buttondown[MOUSEBUTTON2] && cursor.buttonclicks[MOUSEBUTTON2]) { if (cursor.menuitemtype == MENUITEM_SLIDER && !cursor.buttonused[MOUSEBUTTON2]) { // Menu_ClickSlideItem(m, cursor.menuitem); Menu_SlideItem(m, -1); sound = menu_move_sound; cursor.buttonused[MOUSEBUTTON2] = true; } else if (!cursor.buttonused[MOUSEBUTTON2]) { if (cursor.menuitemtype == MENUITEM_ROTATE) { if (menu_rotate->value) Menu_SlideItem( m, 1 ); else Menu_SlideItem( m, -1 ); sound = menu_move_sound; cursor.buttonused[MOUSEBUTTON2] = true; } } } } else if (!cursor.buttonused[MOUSEBUTTON2] && (cursor.buttonclicks[MOUSEBUTTON2] == 2) && cursor.buttondown[MOUSEBUTTON2]) { if (m_drawfunc==PlayerConfig_MenuDraw) PConfigAccept(); UI_PopMenu(); sound = menu_out_sound; cursor.buttonused[MOUSEBUTTON2] = true; cursor.buttonclicks[MOUSEBUTTON2] = 0; cursor.buttonused[MOUSEBUTTON1] = true; cursor.buttonclicks[MOUSEBUTTON1] = 0; } // clicking on the player model menu... if (m_drawfunc == PlayerConfig_MenuDraw) PlayerConfig_MouseClick(); // clicking on the screen menu if (m_drawfunc == Options_Screen_MenuDraw) MenuCrosshair_MouseClick(); if ( sound ) S_StartLocalSound ( sound ); }
/** * \brief Handle menu navigation */ const char *Default_MenuKey( menuframework_s *m, int key ) { const char *sound = NULL; menucommon_s *item; if( m ) { if( ( item = Menu_ItemAtCursor( m ) ) != 0 ) { if ( item->type == MTYPE_FIELD ) { if ( Field_Key( ( menufield_s * ) item, key ) ) { return NULL; } } } } switch( key ) { case K_ESCAPE: M_PopMenu(); return menu_out_sound; case K_KP_UPARROW: case K_UPARROW: if ( m ) { m->cursor--; Menu_AdjustCursor( m, -1 ); sound = menu_move_sound; } break; case K_TAB: if ( m ) { m->cursor++; Menu_AdjustCursor( m, 1 ); sound = menu_move_sound; } break; case K_KP_DOWNARROW: case K_DOWNARROW: if ( m ) { m->cursor++; Menu_AdjustCursor( m, 1 ); sound = menu_move_sound; } break; case K_KP_LEFTARROW: case K_LEFTARROW: if ( m ) { Menu_SlideItem( m, -1 ); sound = menu_move_sound; } break; case K_KP_RIGHTARROW: case K_RIGHTARROW: if ( m ) { Menu_SlideItem( m, 1 ); sound = menu_move_sound; } break; case K_MOUSE1: case K_MOUSE2: case K_MOUSE3: 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( m ) { Menu_SelectItem( m ); } sound = menu_move_sound; break; } return sound; }
const char *Default_MenuKey( menuframework_s *m, int key ) { const char *sound = NULL; menucommon_t *item = NULL; if( m ) { item = Menu_ItemAtCursor( m ); if( item != NULL ) { if( item->type == MTYPE_FIELD ) { if( Field_Key( item, key ) ) return NULL; } } } switch( key ) { case 70: //F for adding to favorites case 102: //f if( m && ( item->type == MTYPE_ACTION ) ) M_AddToFavorites( item ); break; case 82: //R for removing favorites case 114: //r if( m && ( item->type == MTYPE_ACTION ) ) M_RemoveFromFavorites( item ); break; case K_ESCAPE: M_PopMenu(); return menu_out_sound; case K_MOUSE1: if( !Menu_SlideItem( m, 1, key ) ) Menu_SelectItem( m ); sound = menu_move_sound; break; case K_MOUSE2: if( m && ( m_cursoritem == item ) && Menu_SlideItem( m, -1, key ) ) sound = menu_move_sound; else { M_PopMenu(); sound = menu_out_sound; } break; case K_MWHEELUP: if( Menu_ItemAtCursor( m )->scrollbar_id ) //sliding a scrollbar moves 3 lines Menu_SlideItem( m, -3, key ); //scrolling up is the equivalent of sliding left, therefore inverted. else if( Menu_ItemAtCursor( m )->type == MTYPE_SPINCONTROL || Menu_ItemAtCursor( m )->type == MTYPE_SLIDER ) //sliding a spincontrol moves 1 item Menu_SlideItem( m, 1, key ); break; case KP_UPARROW: case K_UPARROW: if( m ) { menucommon_t *item = Menu_ItemAtCursor( m ); menucommon_t *scroll = m->items[item->scrollbar_id]; if( item->scrollbar_id && item->type == MTYPE_ACTION && item->localdata[0] == 0 && scroll->curvalue > 0 ) Menu_SlideItem( m, -1, key ); else m->cursor--; Menu_AdjustCursor( m, -1 ); sound = menu_move_sound; } break; case K_TAB: if( m ) { if( Menu_ItemAtCursor( m )->scrollbar_id && Menu_ItemAtCursor( m )->type == MTYPE_ACTION ) { int i = Menu_ItemAtCursor( m )->scrollbar_id; while( i <= MAXMENUITEMS ) { if( !m->items[i]->scrollbar_id ) { m->cursor = i; break; } i++; } } else m->cursor++; Menu_AdjustCursor( m, 1 ); sound = menu_move_sound; } break; case K_MWHEELDOWN: if( Menu_ItemAtCursor( m )->scrollbar_id ) //sliding a scrollbar moves 3 lines Menu_SlideItem( m, 3, key ); //scrolling down is the equivalent of sliding right, therefore inverted. else if( Menu_ItemAtCursor( m )->type == MTYPE_SPINCONTROL || Menu_ItemAtCursor( m )->type == MTYPE_SLIDER ) //sliding a spincontrol moves 1 item Menu_SlideItem( m, -1, key ); break; case KP_DOWNARROW: case K_DOWNARROW: if( m ) { menucommon_t *item = Menu_ItemAtCursor( m ); menucommon_t *scroll = m->items[item->scrollbar_id]; if( item->scrollbar_id && item->type == MTYPE_ACTION && m->items[m->cursor + 1]->scrollbar_id != item->scrollbar_id && scroll->curvalue < scroll->maxvalue ) Menu_SlideItem( m, 1, key ); else m->cursor++; Menu_AdjustCursor( m, 1 ); sound = menu_move_sound; } break; case KP_LEFTARROW: case K_LEFTARROW: if( m ) { Menu_SlideItem( m, -1, key ); sound = menu_move_sound; } break; case KP_RIGHTARROW: case K_RIGHTARROW: if( m ) { Menu_SlideItem( m, 1, key ); sound = menu_move_sound; } break; case K_MOUSE3: 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_AUX17: case K_AUX18: case K_AUX19: case K_AUX20: case K_AUX21: case K_AUX22: case K_AUX23: case K_AUX24: case K_AUX25: case K_AUX26: case K_AUX27: case K_AUX28: case K_AUX29: case K_AUX30: case K_AUX31: case K_AUX32: case KP_ENTER: case K_ENTER: if( m ) Menu_SelectItem( m ); sound = menu_move_sound; break; case K_MOUSE1DBLCLK: if (m) { menucommon_t *item; Menu_SelectItem( m ); item = Menu_ItemAtCursor( m ); if (item && item->callback_doubleclick) item->callback_doubleclick(item); } sound = menu_move_sound; break; } return sound; }
const char *Default_MenuKey( menuframework_s *m, int key ) { const char *sound = NULL; menucommon_s *item = NULL; int index; if ( m ) { if (key == K_MOUSE1) { index = Menu_ClickHit(m, m_mouse[0], m_mouse[1]); if( index != -1 && m_active->cursor != index) { m_active->cursor = index; } } if ( ( item = Menu_ItemAtCursor( m ) ) != 0 ) { if ( item->type == MTYPE_FIELD ) { if ( Field_Key( ( menufield_s * ) item, key ) ) return NULL; } else if ( item->type == MTYPE_LIST ) { if ( List_Key( ( menulist_s * ) item, key ) ) return NULL; } } } // Little hack if( item && (item->type == MTYPE_SLIDER || item->type == MTYPE_SPINCONTROL) ) { if( key == K_MOUSE1 ) { key = K_RIGHTARROW; } else if( key == K_MOUSE2 ) { key = K_LEFTARROW; } } switch ( key ) { case K_MOUSE2: case K_ESCAPE: M_PopMenu(); return menu_out_sound; case K_KP_UPARROW: case K_UPARROW: if ( m ) { m->cursor--; Menu_AdjustCursor( m, -1 ); sound = menu_move_sound; } break; case K_TAB: if ( m ) { m->cursor++; Menu_AdjustCursor( m, 1 ); sound = menu_move_sound; } break; case K_KP_DOWNARROW: case K_DOWNARROW: if ( m ) { m->cursor++; Menu_AdjustCursor( m, 1 ); sound = menu_move_sound; } break; case K_KP_LEFTARROW: case K_LEFTARROW: if ( m ) { Menu_SlideItem( m, -1 ); sound = menu_move_sound; } break; case K_KP_RIGHTARROW: case K_RIGHTARROW: if ( m ) { Menu_SlideItem( m, 1 ); sound = menu_move_sound; } break; case K_MOUSE1: //case K_MOUSE2: case K_MOUSE3: #ifdef JOYSTICK 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_AUX17: case K_AUX18: case K_AUX19: case K_AUX20: case K_AUX21: case K_AUX22: case K_AUX23: case K_AUX24: case K_AUX25: case K_AUX26: case K_AUX27: case K_AUX28: case K_AUX29: case K_AUX30: case K_AUX31: case K_AUX32: #endif case K_KP_ENTER: case K_ENTER: if ( m ) Menu_SelectItem( m ); sound = menu_move_sound; break; } return sound; }
/* ================= UI_Think_MouseCursor ================= */ void UI_Think_MouseCursor (void) { char * sound = NULL; menuframework_s *m = (menuframework_s *)cursor.menu; if (m_drawfunc == M_Main_Draw) //have to hack for main menu :p { UI_CheckMainMenuMouse(); return; } if (m_drawfunc == M_Credits_MenuDraw) //have to hack for credits :p { if ((cursor.buttonclicks[MOUSEBUTTON1])||(cursor.buttonclicks[MOUSEBUTTON2])) { cursor.buttonused[MOUSEBUTTON2] = true; cursor.buttonclicks[MOUSEBUTTON2] = 0; cursor.buttonused[MOUSEBUTTON1] = true; cursor.buttonclicks[MOUSEBUTTON1] = 0; S_StartLocalSound( menu_out_sound ); if (creditsBuffer) FS_FreeFile (creditsBuffer); UI_PopMenu(); return; } } else if (m_drawfunc == M_Quit_Draw) //hack for quit menu { if (cursor.buttonclicks[MOUSEBUTTON2]) { cursor.buttonused[MOUSEBUTTON2] = true; cursor.buttonclicks[MOUSEBUTTON2] = 0; cursor.buttonused[MOUSEBUTTON1] = true; cursor.buttonclicks[MOUSEBUTTON1] = 0; S_StartLocalSound ("world/cheer.wav"); UI_PopMenu (); return; } } //mouse clicking on the player model menu... if (m_drawfunc == PlayerConfig_MenuDraw) PlayerConfig_MouseClick(); if (m_drawfunc == Options_Ingame_MenuDraw) MenuCrosshair_MouseClick(); if (!m) return; //Exit with double click 2nd mouse button if (cursor.menuitem) { if (!hasitem) { sound = menu_move_sound; hasitem=true; } //MOUSE1 if (cursor.buttondown[MOUSEBUTTON1]) { if (cursor.menuitemtype == MENUITEM_SLIDER) { Menu_DragSlideItem(m, cursor.menuitem); } else if (!cursor.buttonused[MOUSEBUTTON1] && cursor.buttonclicks[MOUSEBUTTON1]) { if (cursor.menuitemtype == MENUITEM_ROTATE) { if (menu_rotate->value) Menu_SlideItem( m, -1 ); else Menu_SlideItem( m, 1 ); //zzzzzz //if ( item->type == MTYPE_CHECKBOX ) //sound = menu_move_sound; sound = menu_click; cursor.buttonused[MOUSEBUTTON1] = true; } else { cursor.buttonused[MOUSEBUTTON1] = true; Menu_MouseSelectItem( cursor.menuitem ); sound = menu_move_sound; } } } //MOUSE2 if (cursor.buttondown[MOUSEBUTTON2] && cursor.buttonclicks[MOUSEBUTTON2]) { if (cursor.menuitemtype == MENUITEM_SLIDER && !cursor.buttonused[MOUSEBUTTON2]) { Menu_ClickSlideItem(m, cursor.menuitem); sound = menu_move_sound; cursor.buttonused[MOUSEBUTTON2] = true; } else if (!cursor.buttonused[MOUSEBUTTON2]) { if (cursor.menuitemtype == MENUITEM_ROTATE) { if (menu_rotate->value) Menu_SlideItem( m, 1 ); else Menu_SlideItem( m, -1 ); sound = menu_move_sound; cursor.buttonused[MOUSEBUTTON2] = true; } } } } else if (!cursor.buttonused[MOUSEBUTTON2] && cursor.buttonclicks[MOUSEBUTTON2]==2 && cursor.buttondown[MOUSEBUTTON2]) { if (m_drawfunc==PlayerConfig_MenuDraw) PConfigAccept(); UI_PopMenu(); sound = menu_out_sound; cursor.buttonused[MOUSEBUTTON2] = true; cursor.buttonclicks[MOUSEBUTTON2] = 0; cursor.buttonused[MOUSEBUTTON1] = true; cursor.buttonclicks[MOUSEBUTTON1] = 0; } else { if (hasitem==true) hasitem=false; } if ( sound ) S_StartLocalSound( sound ); }