void Menu_SlideItem (menuframework_s *s, int32_t dir) { menucommon_s *item = (menucommon_s *) Menu_ItemAtCursor(s); if (item) { switch (item->type) { case MTYPE_SLIDER: Slider_DoSlide ((menuslider_s *) item, dir); break; case MTYPE_SPINCONTROL: SpinControl_DoSlide ((menulist_s *) item, dir); break; } } }
static const char *Keys_MenuKey( int key ) { menuaction_s *item = ( menuaction_s * ) Menu_ItemAtCursor( &s_keys_menu ); //pressing mouse1 to pick a new bind wont force bind/unbind itself - spaz if ( bind_grab && !(cursor.buttonused[MOUSEBUTTON1]&&key==K_MOUSE1)) { if ( key != K_ESCAPE && key != '`' ) { char cmd[1024]; Com_sprintf (cmd, sizeof(cmd), "bind \"%s\" \"%s\"\n", Key_KeynumToString(key), bindnames[item->generic.localdata[0]][0]); Cbuf_InsertText (cmd); } // Knightmare- added Psychospaz's mouse support //dont let selecting with mouse buttons screw everything up UI_RefreshCursorButtons(); if (key==K_MOUSE1) cursor.buttonclicks[MOUSEBUTTON1] = -1; //Menu_SetStatusBar( &s_keys_menu, "enter to change, backspace to clear" ); Menu_SetStatusBar( &s_keys_menu, "Press ENTER or LEFT CLICK to change the key. Press BACKSPACE to clear." ); bind_grab = false; return menu_out_sound; } switch ( key ) { case K_KP_ENTER: case K_ENTER: if (item == &s_keys_back_action) { // back action hack UI_BackMenu(item); return NULL; } KeyBindingFunc( item ); return menu_in_sound; case K_BACKSPACE: // delete bindings case K_DEL: // delete bindings case K_KP_DEL: M_UnbindCommand( bindnames[item->generic.localdata[0]][0] ); return menu_out_sound; default: return Default_MenuKey( &s_keys_menu, key ); } }
void Field_Draw(menufield_s * f) { int i; char tempbuffer[128] = ""; int alpha = mouseOverAlpha(&f->generic); if (f->generic.name) Menu_DrawStringR2LDark(f->generic.x + f->generic.parent->x + LCOLUMN_OFFSET, f->generic.y + f->generic.parent->y, f->generic.name, 255); Q_strncpyz(tempbuffer, f->buffer + f->visible_offset, f->visible_length); Draw_Char(f->generic.x + f->generic.parent->x + 16, f->generic.y + f->generic.parent->y - 4, 18, 255); Draw_Char(f->generic.x + f->generic.parent->x + 16, f->generic.y + f->generic.parent->y + 4, 24, 255); Draw_Char(f->generic.x + f->generic.parent->x + 24 + f->visible_length * 8, f->generic.y + f->generic.parent->y - 4, 20, 255); Draw_Char(f->generic.x + f->generic.parent->x + 24 + f->visible_length * 8, f->generic.y + f->generic.parent->y + 4, 26, 255); for (i = 0; i < f->visible_length; i++) { Draw_Char(f->generic.x + f->generic.parent->x + 24 + i * 8, f->generic.y + f->generic.parent->y - 4, 19, 255); Draw_Char(f->generic.x + f->generic.parent->x + 24 + i * 8, f->generic.y + f->generic.parent->y + 4, 25, 255); } Menu_DrawString(f->generic.x + f->generic.parent->x + 24, f->generic.y + f->generic.parent->y, tempbuffer, alpha); if (Menu_ItemAtCursor(f->generic.parent) == f) { int offset; if (f->visible_offset) offset = f->visible_length; else offset = f->cursor; if (((int)(Sys_Milliseconds() / 250)) & 1) { Draw_Char(f->generic.x + f->generic.parent->x + (offset + 2) * 8 + 8, f->generic.y + f->generic.parent->y, 11, 255); } else { Draw_Char(f->generic.x + f->generic.parent->x + (offset + 2) * 8 + 8, f->generic.y + f->generic.parent->y, ' ', 255); } } }
/* =============== UI_SaveConfigMenu_SavenameDraw =============== */ static void UI_SaveConfigMenu_SavenameDraw(void* self) { menufield_s* f; int style; float* color; f = (menufield_s*)self; if (f == Menu_ItemAtCursor(&saveConfig.menu)) { style = UI_LEFT | UI_PULSE | UI_SMALLFONT; color = text_color_highlight; } else { style = UI_LEFT | UI_SMALLFONT; color = colorRed; } UI_DrawProportionalString(320, 192, "Enter filename:", UI_CENTER | UI_SMALLFONT, color_orange); UI_FillRect(f->generic.x, f->generic.y, f->field.widthInChars * SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, colorBlack); MField_Draw(&f->field, f->generic.x, f->generic.y, style, color); }
const char *Default_MenuCharEvent( menuframework_s *m, qwchar key ) { menucommon_t *item = NULL; if( m ) { item = Menu_ItemAtCursor( m ); if( item != NULL ) { if( item->type == MTYPE_FIELD ) { if( Field_CharEvent( item, key ) ) return NULL; } } } return NULL; }
/* ================= ArenaServers_MenuKey ================= */ static sfxHandle_t ArenaServers_MenuKey( int key ) { if( key == K_SPACE && g_arenaservers.refreshservers ) { ArenaServers_StopRefresh(); return menu_move_sound; } if( ( key == K_DEL || key == K_KP_DEL ) && ( g_servertype == UIAS_FAVORITES ) && ( Menu_ItemAtCursor( &g_arenaservers.menu) == &g_arenaservers.list ) ) { ArenaServers_Remove(); ArenaServers_UpdateMenu(); return menu_move_sound; } if( key == K_MOUSE2 || key == K_ESCAPE ) { ArenaServers_StopRefresh(); ArenaServers_SaveChanges(); } return Menu_DefaultKey( &g_arenaservers.menu, key ); }
qboolean Menu_SelectItem(menuframework_s * s) { menucommon_s *item = (menucommon_s *) Menu_ItemAtCursor(s); if (item) { switch (item->type) { case MTYPE_FIELD: return Field_DoEnter((menufield_s *) item); case MTYPE_ACTION: Action_DoEnter((menuaction_s *) item); return true; case MTYPE_LIST: /* Menulist_DoEnter( ( menulist_s * ) item ); */ return false; case MTYPE_SPINCONTROL: /* SpinControl_DoEnter( ( menulist_s * ) item ); */ return false; } } return false; }
int Menu_SelectItem( menuframework_t *s ) { menucommon_t *item = ( menucommon_t * ) Menu_ItemAtCursor( s ); if ( item ) { switch ( item->type ) { case MTYPE_FIELD: return Field_DoEnter( ( menufield_t * ) item ) ; case MTYPE_ACTION: Action_DoEnter( ( menuaction_t * ) item ); return 1; case MTYPE_LIST: // Menulist_DoEnter( ( menulist_t * ) item ); return 0; case MTYPE_SPINCONTROL: // SpinControl_DoEnter( ( menulist_t * ) item ); return 0; } } return 0; }
void Menu_Draw( menuframework_s *menu ) { int i; menucommon_s *item; /* ** draw contents */ for ( i = 0; i < menu->nitems; i++ ) { switch ( ( ( menucommon_s * ) menu->items[i] )->type ) { case MTYPE_FIELD: Field_Draw( ( menufield_s * ) menu->items[i] ); break; case MTYPE_SLIDER: Slider_Draw( ( menuslider_s * ) menu->items[i] ); break; case MTYPE_LIST: MenuList_Draw( ( menulist_s * ) menu->items[i] ); break; case MTYPE_SPINCONTROL: SpinControl_Draw( ( menulist_s * ) menu->items[i] ); break; case MTYPE_ACTION: Action_Draw( ( menuaction_s * ) menu->items[i] ); break; case MTYPE_SEPARATOR: Separator_Draw( ( menuseparator_s * ) menu->items[i] ); break; } } item = (menucommon_s *) Menu_ItemAtCursor( menu ); if ( item && item->cursordraw ) { item->cursordraw( item ); } else if ( menu->cursordraw ) { menu->cursordraw( menu ); } else if ( item && item->type != MTYPE_FIELD ) { if ( item->flags & QMF_LEFT_JUSTIFY ) { Draw_Char( menu->x + item->x - 24 + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) ); } else { Draw_Char( menu->x + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) ); } } if ( item ) { if ( item->statusbarfunc ) item->statusbarfunc( ( void * ) item ); else if ( item->statusbar ) Menu_DrawStatusBar( item->statusbar ); else Menu_DrawStatusBar( menu->statusbar ); } else { Menu_DrawStatusBar( menu->statusbar ); } }
void Menu_Draw ( menuframework_t *menu ) { char scratch[MAX_QPATH]; static int yaw; // int maxframe = 29; entity_t entity; int i; menucommon_t *item; refdef_t refdef; // Draw rotating Quake II Symbol memset( &refdef, 0, sizeof( refdef ) ); memset( &entity, 0, sizeof( entity ) ); refdef.x = 0; refdef.y = 0; refdef.width = viddef.width; refdef.height = viddef.height; refdef.fov_x = 35; refdef.fov_y = CalcFov( refdef.fov_x, refdef.width, refdef.height ); refdef.time = cls.realtime * 0.001; refdef.areabits = NULL; refdef.num_entities = 1; //refdef.lightstyles = 5; // Gentle Pulse refdef.lightstyles = 63; // Testing (FULLBRIGHT) refdef.rdflags = RDF_NOWORLDMODEL; refdef.blend[0] = 1.0; refdef.blend[1] = 1.0; refdef.blend[2] = 1.0; refdef.blend[3] = 0.0; refdef.dlights = NULL; refdef.num_dlights = 0; refdef.num_particles = 0; refdef.particles = NULL; VectorSet(refdef.viewangles, 1.0, 0.0, 0.0); VectorClear(refdef.vieworg); //if (!strcmp(vid_ref->string, "soft")) // Com_sprintf( scratch, sizeof( scratch ), "models/items/quaddama/tris.md2"); //else Com_sprintf( scratch, sizeof( scratch ), "models/MenuModel/quad.md2"); entity.model = re.RegisterModel( scratch ); //entity.Model_Type = 0; entity.flags = RF_MINLIGHT | RF_DEPTHHACK | RF_FULLBRIGHT | RF_GLOW | RF_NOSHADOW; entity.origin[0] = 80; entity.origin[1] = 0; entity.origin[2] = -18; // -18 compensates for the float height of the model VectorCopy( entity.origin, entity.oldorigin ); entity.frame = 0; entity.oldframe = 0; entity.backlerp = 0.0; entity.angles[1] = yaw++; if ( ++yaw > 360 ) yaw -= 360; refdef.entities = &entity; // Fog the scene //refdef.blend[0] = 0.55; //refdef.blend[1] = 0.55; //refdef.blend[2] = 0.55; //refdef.blend[3] = 0.55; if (cl_3dmenubg->value) { // Draw scene MenuRefdefActive = 1; re.RenderFrame( &refdef ); //Menu_DrawBackground("q2bg.tga"); } // Draw the menu version information if (cl_menustamp->value > 0) { /* 1 - Regular string 2 - Regular string plus drop shadow (green... not effective) 3 - All green string */ if (cl_menustamp->value == 1) { // Draw the text Menu_DrawString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3), viddef.height - FONTSIZE, MENUSTAMP); } else if (cl_menustamp->value == 2) { // Draw the drop shadow (we need black characters) DrawAltString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3) - 1, viddef.height - FONTSIZE, MENUSTAMP); // Draw the text Menu_DrawString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3), viddef.height - FONTSIZE - 1, MENUSTAMP); } else if (cl_menustamp->value == 3) { // Draw the text DrawAltString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3), viddef.height - FONTSIZE, MENUSTAMP); } } // Menu drawing prevention hack for main menu if ((menu->x == -1) && (menu->y == -1)) return; /* ** draw contents */ for ( i = 0; i < menu->nitems; i++ ) { switch ( ( ( menucommon_t * ) menu->items[i] )->type ) { case MTYPE_FIELD: Field_Draw( ( menufield_t * ) menu->items[i] ); break; case MTYPE_SLIDER: Slider_Draw( ( menuslider_t * ) menu->items[i] ); break; case MTYPE_LIST: MenuList_Draw( ( menulist_t * ) menu->items[i] ); break; case MTYPE_SPINCONTROL: SpinControl_Draw( ( menulist_t * ) menu->items[i] ); break; case MTYPE_ACTION: Action_Draw( ( menuaction_t * ) menu->items[i] ); break; case MTYPE_SEPARATOR: Separator_Draw( ( menuseparator_t * ) menu->items[i] ); break; } } item = Menu_ItemAtCursor( menu ); if ( item && item->cursordraw ) { item->cursordraw( item ); } else if ( menu->cursordraw ) { menu->cursordraw( menu ); } else if ( item && item->type != MTYPE_FIELD ) { if ( item->flags & QMF_LEFT_JUSTIFY ) { Draw_Char( menu->x + item->x - 24 + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) ); } else { Draw_Char( menu->x + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) ); } } if ( item ) { if ( item->statusbarfunc ) item->statusbarfunc( ( void * ) item ); else if ( item->statusbar ) Menu_DrawStatusBar( item->statusbar ); else Menu_DrawStatusBar( menu->statusbar ); } else { Menu_DrawStatusBar( menu->statusbar ); } }
/* * ================= * 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; }
void Menu_Draw(menuframework_s * menu) { int i; menucommon_s *item; /* * * draw contents */ for (i = 0; i < menu->nitems; i++) { switch (((menucommon_s *) menu->items[i])->type) { case MTYPE_FIELD: Field_Draw((menufield_s *) menu->items[i]); break; case MTYPE_SLIDER: Slider_Draw((menuslider_s *) menu->items[i]); break; case MTYPE_LIST: MenuList_Draw((menulist_s *) menu->items[i]); break; case MTYPE_SPINCONTROL: SpinControl_Draw((menulist_s *) menu->items[i]); break; case MTYPE_ACTION: Action_Draw((menuaction_s *) menu->items[i]); break; case MTYPE_SEPARATOR: Separator_Draw((menuseparator_s *) menu->items[i]); break; } } /* * * now check mouseovers - psychospaz */ cursor.menu = menu; if (cursor.mouseaction) { menucommon_s *lastitem = cursor.menuitem; refreshCursorLink(); for (i = menu->nitems; i >= 0; i--) { int type; int len; int min [2], max[2]; item = ((menucommon_s *) menu->items[i]); if (!item || item->type == MTYPE_SEPARATOR) continue; max[0] = min[0] = menu->x + item->x + RCOLUMN_OFFSET; /* + 2 chars for space + * cursor */ max[1] = min[1] = menu->y + item->y; max[1] += 8; switch (item->type) { case MTYPE_ACTION: { len = strlen(item->name); if (item->flags & QMF_LEFT_JUSTIFY) { min[0] += LCOLUMN_OFFSET * 2; max[0] = min[0] + len * 8; } else { min[0] -= len * 8 + 24; } type = MENUITEM_ACTION; } break; case MTYPE_SLIDER: { min[0] -= 16; max[0] += (SLIDER_RANGE + 2) * 8 + 16; type = MENUITEM_SLIDER; } break; case MTYPE_LIST: case MTYPE_SPINCONTROL: { int len; menulist_s *spin = menu->items[i]; if (item->name) { len = strlen(item->name); min[0] -= len * 8 - LCOLUMN_OFFSET * 2; } len = strlen(spin->itemnames[spin->curvalue]); max[0] += len * 8; type = MENUITEM_ROTATE; } break; case MTYPE_FIELD: { menufield_s *text = menu->items[i]; len = text->visible_length + 2; max[0] += len * 8; type = MENUITEM_TEXT; } break; default: continue; } if (cursor.x >= min[0] && cursor.x <= max[0] && cursor.y >= min[1] && cursor.y <= max[1]) { /* new item */ if (lastitem != item) { int j; for (j = 0; j < MENU_CURSOR_BUTTON_MAX; j++) { cursor.buttonclicks[j] = 0; cursor.buttontime[j] = 0; } } cursor.menuitem = item; cursor.menuitemtype = type; menu->cursor = i; break; } } } cursor.mouseaction = false; item = Menu_ItemAtCursor(menu); if (item && item->cursordraw) { item->cursordraw(item); } else if (menu->cursordraw) { menu->cursordraw(menu); } else if (item && item->type != MTYPE_FIELD) { if (item->flags & QMF_LEFT_JUSTIFY) { Draw_Char(menu->x + item->x - 24 + item->cursor_offset, menu->y + item->y, 12 + ((int)(Sys_Milliseconds() / 250) & 1), 255); } else { Draw_Char(menu->x + item->cursor_offset, menu->y + item->y, 12 + ((int)(Sys_Milliseconds() / 250) & 1), 255); } } if (item) { if (item->statusbarfunc) item->statusbarfunc((void *)item); else if (item->statusbar) Menu_DrawStatusBar(item->statusbar); else Menu_DrawStatusBar(menu->statusbar); } else { Menu_DrawStatusBar(menu->statusbar); } }
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; }
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; }
static void UI_SPLevelMenu_MenuDraw( void ) { int n, i; int x, y; vec4_t color; int level; // int fraglimit; int pad; char buf[MAX_INFO_VALUE]; char string[64]; if( levelMenuInfo.reinit ) { UI_PopMenu(); UI_SPLevelMenu(); return; } // draw player name trap_Cvar_VariableStringBuffer( "name", string, 32 ); Q_CleanStr( string ); UI_DrawProportionalString( 320, PLAYER_Y, string, UI_CENTER|UI_SMALLFONT, color_orange ); // check for model changes trap_Cvar_VariableStringBuffer( "model", buf, sizeof(buf) ); if( Q_stricmp( buf, levelMenuInfo.playerModel ) != 0 ) { Q_strncpyz( levelMenuInfo.playerModel, buf, sizeof(levelMenuInfo.playerModel) ); PlayerIcon( levelMenuInfo.playerModel, levelMenuInfo.playerPicName, sizeof(levelMenuInfo.playerPicName) ); levelMenuInfo.item_player.shader = 0; } // standard menu drawing Menu_Draw( &levelMenuInfo.menu ); // draw player award levels y = AWARDS_Y; i = 0; for( n = 0; n < 6; n++ ) { level = levelMenuInfo.awardLevels[n]; if( level > 0 ) { if( i & 1 ) { x = 224 - (i - 1 ) / 2 * (48 + 16); } else { x = 368 + i / 2 * (48 + 16); } i++; if( level == 1 ) { continue; } if( level >= 1000000 ) { Com_sprintf( string, sizeof(string), "%im", level / 1000000 ); } else if( level >= 1000 ) { Com_sprintf( string, sizeof(string), "%ik", level / 1000 ); } else { Com_sprintf( string, sizeof(string), "%i", level ); } UI_DrawString( x + 24, y + 48, string, UI_CENTER, color_yellow ); } } UI_DrawProportionalString( 18, 38, va( "Tier %i", selectedArenaSet + 1 ), UI_LEFT|UI_SMALLFONT, color_orange ); for ( n = 0; n < levelMenuInfo.numMaps; n++ ) { x = levelMenuInfo.item_maps[n].generic.x; y = levelMenuInfo.item_maps[n].generic.y; UI_FillRect( x, y + 96, 128, 18, color_black ); } if ( selectedArenaSet > currentSet ) { UI_DrawProportionalString( 320, 216, "ACCESS DENIED", UI_CENTER|UI_BIGFONT, color_red ); return; } // show levelshots for levels of current tier Vector4Copy( color_white, color ); color[3] = 0.5+0.5*sin(uis.realtime/PULSE_DIVISOR); for ( n = 0; n < levelMenuInfo.numMaps; n++ ) { x = levelMenuInfo.item_maps[n].generic.x; y = levelMenuInfo.item_maps[n].generic.y; UI_DrawString( x + 64, y + 96, levelMenuInfo.levelNames[n], UI_CENTER|UI_SMALLFONT, color_orange ); if( levelMenuInfo.levelScores[n] == 1 ) { UI_DrawHandlePic( x, y, 128, 96, levelMenuInfo.levelCompletePic[levelMenuInfo.levelScoresSkill[n] - 1] ); } if ( n == selectedArena ) { if( Menu_ItemAtCursor( &levelMenuInfo.menu ) == &levelMenuInfo.item_maps[n] ) { trap_R_SetColor( color ); } UI_DrawHandlePic( x-1, y-1, 130, 130 - 14, levelMenuInfo.levelSelectedPic ); trap_R_SetColor( NULL ); } else if( Menu_ItemAtCursor( &levelMenuInfo.menu ) == &levelMenuInfo.item_maps[n] ) { trap_R_SetColor( color ); UI_DrawHandlePic( x-31, y-30, 256, 256-27, levelMenuInfo.levelFocusPic); trap_R_SetColor( NULL ); } } // show map name and long name of selected level y = 192; Q_strncpyz( buf, Info_ValueForKey( levelMenuInfo.selectedArenaInfo, "map" ), 20 ); Q_strupr( buf ); Com_sprintf( string, sizeof(string), "%s: %s", buf, Info_ValueForKey( levelMenuInfo.selectedArenaInfo, "longname" ) ); UI_DrawProportionalString( 320, y, string, UI_CENTER|UI_SMALLFONT, color_orange ); // fraglimit = atoi( Info_ValueForKey( levelMenuInfo.selectedArenaInfo, "fraglimit" ) ); // UI_DrawString( 18, 212, va("Frags %i", fraglimit) , UI_LEFT|UI_SMALLFONT, color_orange ); // draw bot opponents y += 24; pad = (7 - levelMenuInfo.numBots) * (64 + 26) / 2; for( n = 0; n < levelMenuInfo.numBots; n++ ) { x = 18 + pad + (64 + 26) * n; if( levelMenuInfo.botPics[n] ) { UI_DrawHandlePic( x, y, 64, 64, levelMenuInfo.botPics[n]); } else { UI_FillRect( x, y, 64, 64, color_black ); UI_DrawProportionalString( x+22, y+18, "?", UI_BIGFONT, color_orange ); } UI_DrawString( x, y + 64, levelMenuInfo.botNames[n], UI_SMALLFONT|UI_LEFT, color_orange ); } }
/* ================= 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: case K_ESCAPE: PlayerModel_SaveChanges(); break; } return ( Menu_DefaultKey( &s_playermodel.menu, key ) ); }
/** * \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; }
/* ================= Controls_DrawKeyBinding ================= */ static void Controls_DrawKeyBinding( void *self ) { menuaction_s* a; int x; int y; int b1; int b2; qboolean c; char name[32]; char name2[32]; a = (menuaction_s*) self; x = a->generic.x; y = a->generic.y; c = (Menu_ItemAtCursor( a->generic.parent ) == a); b1 = g_bindings[a->generic.id].bind1; if (b1 == -1) strcpy(name,"???"); else { trap_Key_KeynumToStringBuf( b1, name, 32 ); Q_strupr(name); b2 = g_bindings[a->generic.id].bind2; if (b2 != -1) { trap_Key_KeynumToStringBuf( b2, name2, 32 ); Q_strupr(name2); strcat( name, " or " ); strcat( name, name2 ); } } if (c) { UI_FillRect( a->generic.left, a->generic.top, a->generic.right-a->generic.left+1, a->generic.bottom-a->generic.top+1, listbar_color ); UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_highlight ); UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT|UI_PULSE, text_color_highlight ); if (s_controls.waitingforkey) { UI_DrawChar( x, y, '=', UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight); UI_DrawString(500, SCREEN_HEIGHT * 0.85, "Waiting for new key ... ESCAPE to cancel", UI_SMALLFONT|UI_CENTER|UI_PULSE, colorWhite ); } else { UI_DrawChar( x, y, 13, UI_CENTER|UI_BLINK|UI_SMALLFONT, text_color_highlight); UI_DrawString(500, SCREEN_HEIGHT * 0.83, "Press ENTER or CLICK to change", UI_SMALLFONT|UI_CENTER, colorWhite ); UI_DrawString(500, SCREEN_HEIGHT * 0.87, "Press BACKSPACE to clear", UI_SMALLFONT|UI_CENTER, colorWhite ); } } else { if (a->generic.flags & QMF_GRAYED) { UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, text_color_disabled ); UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, text_color_disabled ); } else { UI_DrawString( x - SMALLCHAR_WIDTH, y, g_bindings[a->generic.id].label, UI_RIGHT|UI_SMALLFONT, controls_binding_color ); UI_DrawString( x + SMALLCHAR_WIDTH, y, name, UI_LEFT|UI_SMALLFONT, controls_binding_color ); } } }
/* ================= 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; }
/* ========================== Menu_Draw ========================== */ void Menu_Draw (menuframework_s *menu) { int i; menucommon_s *item; // // draw contents // for (i = 0; i < menu->nitems; i++) { // skip hidden items if ( ((menucommon_s *)menu->items[i])->flags & QMF_HIDDEN ) continue; switch ( ((menucommon_s *)menu->items[i])->type ) { case MTYPE_FIELD: Field_Draw( ( menufield_s * )menu->items[i] ); break; case MTYPE_SLIDER: Slider_Draw( (menuslider_s *)menu->items[i] ); break; case MTYPE_LIST: MenuList_Draw( (menulist_s *)menu->items[i] ); break; case MTYPE_SPINCONTROL: SpinControl_Draw( (menulist_s *)menu->items[i] ); break; case MTYPE_ACTION: Action_Draw( (menuaction_s *)menu->items[i] ); break; case MTYPE_SEPARATOR: Separator_Draw( (menuseparator_s *)menu->items[i] ); break; } } // added Psychspaz's mouse support // // now check mouseovers - psychospaz // cursor.menu = menu; if (cursor.mouseaction) { menucommon_s *lastitem = cursor.menuitem; UI_RefreshCursorLink(); for (i = menu->nitems; i >= 0 ; i--) { int type, len; int min[2], max[2]; float x1, y1, w1, h1; item = ((menucommon_s * )menu->items[i]); if (!item || item->type == MTYPE_SEPARATOR) continue; x1 = menu->x + item->x + RCOLUMN_OFFSET; // + 2 chars for space + cursor y1 = menu->y + item->y; w1 = 0; h1 = MENU_FONT_SIZE; SCR_AdjustFrom640 (&x1, &y1, &w1, &h1, ALIGN_CENTER); min[0] = x1; max[0] = x1+w1; min[1] = y1; max[1] = y1+h1; // max[0] = min[0] = SCR_ScaledVideo(menu->x + item->x + RCOLUMN_OFFSET); //+ 2 chars for space + cursor // max[1] = min[1] = SCR_ScaledVideo(menu->y + item->y); // max[1] += SCR_ScaledVideo(MENU_FONT_SIZE); switch (item->type) { case MTYPE_ACTION: { len = strlen(item->name); if (item->flags & QMF_LEFT_JUSTIFY) { min[0] += SCR_ScaledVideo(LCOLUMN_OFFSET*2); max[0] = min[0] + SCR_ScaledVideo(len*MENU_FONT_SIZE); } else min[0] -= SCR_ScaledVideo(len*MENU_FONT_SIZE + MENU_FONT_SIZE*3); type = MENUITEM_ACTION; } break; case MTYPE_SLIDER: { if (item->name) { len = strlen(item->name); min[0] -= SCR_ScaledVideo(len*MENU_FONT_SIZE - LCOLUMN_OFFSET*2); } else min[0] -= SCR_ScaledVideo(16); max[0] += SCR_ScaledVideo((SLIDER_RANGE + 4)*MENU_FONT_SIZE); type = MENUITEM_SLIDER; } break; case MTYPE_LIST: case MTYPE_SPINCONTROL: { int len; menulist_s *spin = menu->items[i]; if (item->name) { len = strlen(item->name); min[0] -= SCR_ScaledVideo(len*MENU_FONT_SIZE - LCOLUMN_OFFSET*2); } len = strlen(spin->itemnames[spin->curvalue]); max[0] += SCR_ScaledVideo(len*MENU_FONT_SIZE); type = MENUITEM_ROTATE; } break; case MTYPE_FIELD: { menufield_s *text = menu->items[i]; len = text->visible_length + 2; max[0] += SCR_ScaledVideo(len*MENU_FONT_SIZE); type = MENUITEM_TEXT; } break; default: continue; } if (cursor.x>=min[0] && cursor.x<=max[0] && cursor.y>=min[1] && cursor.y<=max[1]) { // new item if (lastitem!=item) { int j; for (j=0; j<MENU_CURSOR_BUTTON_MAX; j++) { cursor.buttonclicks[j] = 0; cursor.buttontime[j] = 0; } } cursor.menuitem = item; cursor.menuitemtype = type; menu->cursor = i; break; } } } cursor.mouseaction = false; // end mouseover code item = Menu_ItemAtCursor(menu); if (item && item->cursordraw) { item->cursordraw(item); } else if (menu->cursordraw) { menu->cursordraw(menu); } else if (item && item->type != MTYPE_FIELD) { if (item->flags & QMF_LEFT_JUSTIFY) { SCR_DrawChar (menu->x+item->x+item->cursor_offset-24, menu->y+item->y, ALIGN_CENTER, 12+((int)(Sys_Milliseconds()/250)&1), 255,255,255,255, false, true); } else { SCR_DrawChar (menu->x+item->cursor_offset, menu->y+item->y, ALIGN_CENTER, 12+((int)(Sys_Milliseconds()/250)&1), 255,255,255,255, false, true); } } if (item) { if (item->statusbarfunc) item->statusbarfunc ( (void *)item ); else if (item->statusbar) Menu_DrawStatusBar (item->statusbar); else Menu_DrawStatusBar (menu->statusbar); } else Menu_DrawStatusBar( menu->statusbar ); }
void Menu_Draw(menuframework_s *menu) { int i; menucommon_s *itemptr; // draw menu for (i=0; i<menu->nitems; i++) { itemptr = (menucommon_s*)menu->items[i]; if (itemptr->flags & QMF_HIDDEN) { continue; } if (itemptr->ownerdraw) { // total subclassing, owner draws everything itemptr->ownerdraw(itemptr); } else { switch (itemptr->type) { case MTYPE_RADIOBUTTON: RadioButton_Draw((menuradiobutton_s*)itemptr); break; case MTYPE_FIELD: MenuField_Draw((menufield_s*)itemptr); break; case MTYPE_SLIDER: Slider_Draw((menuslider_s*)itemptr); break; case MTYPE_SPINCONTROL: SpinControl_Draw((menulist_s*)itemptr); break; case MTYPE_ACTION: Action_Draw((menuaction_s*)itemptr); break; case MTYPE_BITMAP: Bitmap_Draw((menubitmap_s*)itemptr); break; case MTYPE_TEXT: Text_Draw((menutext_s*)itemptr); break; case MTYPE_SCROLLLIST: ScrollList_Draw((menulist_s*)itemptr); break; case MTYPE_PTEXT: PText_Draw((menutext_s*)itemptr); break; case MTYPE_BTEXT: BText_Draw((menutext_s*)itemptr); break; case MTYPE_BUTTON: Button_Draw((menubutton_s*)itemptr); break; default: trap_Error(va("Menu_Draw: unknown type %d", itemptr->type)); } } #ifndef NDEBUG if (uis.debug) { int x; int y; int w; int h; if (!(itemptr->flags & QMF_INACTIVE)) { x = itemptr->left; y = itemptr->top; w = itemptr->right - itemptr->left + 1; h = itemptr->bottom - itemptr->top + 1; if (itemptr->flags & QMF_HASMOUSEFOCUS) { SCR_DrawRect(x, y, w, h, 1.0f, colorYellow); } else { SCR_DrawRect(x, y, w, h, 1.0f, colorWhite); } } } #endif } itemptr = Menu_ItemAtCursor(menu); if (itemptr && itemptr->statusbar) { itemptr->statusbar((void *) itemptr); } }
/* ================= UI_TeamOrdersMenu_Key ================= */ sfxHandle_t UI_TeamOrdersMenu_Key( int key ) { menulist_s *l; int x; int y; int index; l = (menulist_s *)Menu_ItemAtCursor( &teamOrdersMenuInfo.menu ); if( l != &teamOrdersMenuInfo.list ) { return Menu_DefaultKey( &teamOrdersMenuInfo.menu, key ); } switch( key ) { case K_MOUSE1: x = l->generic.left; y = l->generic.top; if( UI_CursorInRect( x, y, l->generic.right - x, l->generic.bottom - y ) ) { index = (uis.cursory - y) / PROP_HEIGHT; l->oldvalue = l->curvalue; l->curvalue = index; if( l->generic.callback ) { l->generic.callback( l, QM_ACTIVATED ); return menu_move_sound; } } return menu_null_sound; 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: l->oldvalue = l->curvalue; if( l->curvalue == 0 ) { l->curvalue = l->numitems - 1; } else { l->curvalue--; } return menu_move_sound; 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: l->oldvalue = l->curvalue; if( l->curvalue == l->numitems - 1 ) { l->curvalue = 0;; } else { l->curvalue++; } return menu_move_sound; } return Menu_DefaultKey( &teamOrdersMenuInfo.menu, key ); }
void Bitmap_Draw(menubitmap_s *b) { float x; float y; float w; float h; vec4_t tempcolor; float* color; x = b->generic.x; y = b->generic.y; w = b->width; h = b->height; if (b->generic.flags & QMF_RIGHT_JUSTIFY) { x = x - w; } else if (b->generic.flags & QMF_CENTER_JUSTIFY) { x = x - w/2; } // used to refresh shader if (b->generic.name && !b->shader) { b->shader = trap_R_RegisterShaderNoMip(b->generic.name); if (!b->shader && b->errorpic) { b->shader = trap_R_RegisterShaderNoMip(b->errorpic); } } if (b->focuspic && !b->focusshader) { b->focusshader = trap_R_RegisterShaderNoMip(b->focuspic); } if (b->generic.flags & QMF_GRAYED) { if (b->shader) { trap_R_SetColor(colorMdGrey); UI_DrawHandlePic(x, y, w, h, b->shader); trap_R_SetColor(NULL); } } else { if (b->shader) { UI_DrawHandlePic(x, y, w, h, b->shader); } if ( ((b->generic.flags & QMF_PULSE) || (b->generic.flags & QMF_PULSEIFFOCUS)) && (Menu_ItemAtCursor(b->generic.parent) == b)) { if (b->focuscolor) { tempcolor[0] = b->focuscolor[0]; tempcolor[1] = b->focuscolor[1]; tempcolor[2] = b->focuscolor[2]; color = tempcolor; } else { color = colorPulse; } color[3] = 0.5+0.5*sin(uis.realtime/PULSE_DIVISOR); trap_R_SetColor(color); UI_DrawHandlePic(x, y, w, h, b->focusshader); trap_R_SetColor(NULL); } else if ((b->generic.flags & QMF_HIGHLIGHT) || ((b->generic.flags & QMF_HIGHLIGHT_IF_FOCUS) && (Menu_ItemAtCursor(b->generic.parent) == b))) { if (b->focuscolor) { trap_R_SetColor(b->focuscolor); UI_DrawHandlePic(x, y, w, h, b->focusshader); trap_R_SetColor(NULL); } else { UI_DrawHandlePic(x, y, w, h, b->focusshader); } } } }
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; }