vkQuake2 doxygen  1.0 dev
qmenu.c File Reference
#include <string.h>
#include <ctype.h>
#include "client.h"
#include "qmenu.h"

Go to the source code of this file.

Macros

#define RCOLUMN_OFFSET   16 * vid_hudscale->value
 
#define LCOLUMN_OFFSET   -16 * vid_hudscale->value
 
#define VID_WIDTH   viddef.width
 
#define VID_HEIGHT   viddef.height
 
#define Draw_Char   re.DrawChar
 
#define Draw_Fill   re.DrawFill
 
#define SLIDER_RANGE   10
 

Functions

static void Action_DoEnter (menuaction_s *a)
 
static void Action_Draw (menuaction_s *a)
 
static void Menu_DrawStatusBar (const char *string)
 
static void Menulist_DoEnter (menulist_s *l)
 
static void MenuList_Draw (menulist_s *l)
 
static void Separator_Draw (menuseparator_s *s)
 
static void Slider_DoSlide (menuslider_s *s, int dir)
 
static void Slider_Draw (menuslider_s *s)
 
static void SpinControl_DoEnter (menulist_s *s)
 
static void SpinControl_Draw (menulist_s *s)
 
static void SpinControl_DoSlide (menulist_s *s, int dir)
 
qboolean Field_DoEnter (menufield_s *f)
 
void Field_Draw (menufield_s *f)
 
qboolean Field_Key (menufield_s *f, int key)
 
void Menu_AddItem (menuframework_s *menu, void *item)
 
void Menu_AdjustCursor (menuframework_s *m, int dir)
 
void Menu_Center (menuframework_s *menu)
 
void Menu_Draw (menuframework_s *menu)
 
void Menu_DrawString (int x, int y, const char *string)
 
void Menu_DrawStringDark (int x, int y, const char *string)
 
void Menu_DrawStringR2L (int x, int y, const char *string)
 
void Menu_DrawStringR2LDark (int x, int y, const char *string)
 
voidMenu_ItemAtCursor (menuframework_s *m)
 
qboolean Menu_SelectItem (menuframework_s *s)
 
void Menu_SetStatusBar (menuframework_s *m, const char *string)
 
void Menu_SlideItem (menuframework_s *s, int dir)
 
int Menu_TallySlots (menuframework_s *menu)
 

Variables

refexport_t re
 
viddef_t viddef
 
cvar_tvid_hudscale
 

Macro Definition Documentation

◆ Draw_Char

#define Draw_Char   re.DrawChar

Definition at line 48 of file qmenu.c.

◆ Draw_Fill

#define Draw_Fill   re.DrawFill

Definition at line 49 of file qmenu.c.

◆ LCOLUMN_OFFSET

#define LCOLUMN_OFFSET   -16 * vid_hudscale->value

Definition at line 39 of file qmenu.c.

◆ RCOLUMN_OFFSET

#define RCOLUMN_OFFSET   16 * vid_hudscale->value

Definition at line 38 of file qmenu.c.

◆ SLIDER_RANGE

#define SLIDER_RANGE   10

Definition at line 605 of file qmenu.c.

◆ VID_HEIGHT

#define VID_HEIGHT   viddef.height

Definition at line 46 of file qmenu.c.

◆ VID_WIDTH

#define VID_WIDTH   viddef.width

Definition at line 45 of file qmenu.c.

Function Documentation

◆ Action_DoEnter()

void Action_DoEnter ( menuaction_s a)
static

Definition at line 51 of file qmenu.c.

52 {
53  if ( a->generic.callback )
54  a->generic.callback( a );
55 }

Referenced by Menu_SelectItem().

◆ Action_Draw()

void Action_Draw ( menuaction_s a)
static

Definition at line 57 of file qmenu.c.

58 {
59  if ( a->generic.flags & QMF_LEFT_JUSTIFY )
60  {
61  if ( a->generic.flags & QMF_GRAYED )
63  else
65  }
66  else
67  {
68  if ( a->generic.flags & QMF_GRAYED )
70  else
72  }
73  if ( a->generic.ownerdraw )
74  a->generic.ownerdraw( a );
75 }

Referenced by Menu_Draw().

◆ Field_DoEnter()

qboolean Field_DoEnter ( menufield_s f)

Definition at line 77 of file qmenu.c.

78 {
79  if ( f->generic.callback )
80  {
81  f->generic.callback( f );
82  return true;
83  }
84  return false;
85 }

Referenced by Menu_SelectItem().

◆ Field_Draw()

void Field_Draw ( menufield_s f)

Definition at line 87 of file qmenu.c.

88 {
89  int i;
90  char tempbuffer[128]="";
91 
92  if ( f->generic.name )
94 
95  strncpy( tempbuffer, f->buffer + f->visible_offset, f->visible_length );
96 
97  Draw_Char( f->generic.x + f->generic.parent->x + 16 * vid_hudscale->value, f->generic.y + f->generic.parent->y - 4 * vid_hudscale->value, 18 );
98  Draw_Char( f->generic.x + f->generic.parent->x + 16 * vid_hudscale->value, f->generic.y + f->generic.parent->y + 4 * vid_hudscale->value, 24 );
99 
102 
103  for ( i = 0; i < f->visible_length; i++ )
104  {
105  Draw_Char( f->generic.x + f->generic.parent->x + 24 * vid_hudscale->value + i * 8 * vid_hudscale->value, f->generic.y + f->generic.parent->y - 4 * vid_hudscale->value, 19 );
106  Draw_Char( f->generic.x + f->generic.parent->x + 24 * vid_hudscale->value + i * 8 * vid_hudscale->value, f->generic.y + f->generic.parent->y + 4 * vid_hudscale->value, 25 );
107  }
108 
109  Menu_DrawString( f->generic.x + f->generic.parent->x + 24 * vid_hudscale->value, f->generic.y + f->generic.parent->y, tempbuffer );
110 
111  if ( Menu_ItemAtCursor( f->generic.parent ) == f )
112  {
113  int offset;
114 
115  if ( f->visible_offset )
116  offset = f->visible_length;
117  else
118  offset = f->cursor;
119 
120  if ( ( ( int ) ( Sys_Milliseconds() / 250 ) ) & 1 )
121  {
122  Draw_Char( f->generic.x + f->generic.parent->x + ( offset + 2 ) * 8 * vid_hudscale->value + 8 * vid_hudscale->value,
123  f->generic.y + f->generic.parent->y,
124  11 );
125  }
126  else
127  {
128  Draw_Char( f->generic.x + f->generic.parent->x + ( offset + 2 ) * 8 * vid_hudscale->value + 8 * vid_hudscale->value,
129  f->generic.y + f->generic.parent->y,
130  ' ' );
131  }
132  }
133 }

Referenced by Menu_Draw().

◆ Field_Key()

qboolean Field_Key ( menufield_s f,
int  key 
)

Definition at line 135 of file qmenu.c.

136 {
137  extern int keydown[];
138 
139  switch ( key )
140  {
141  case K_KP_SLASH:
142  key = '/';
143  break;
144  case K_KP_MINUS:
145  key = '-';
146  break;
147  case K_KP_PLUS:
148  key = '+';
149  break;
150  case K_KP_HOME:
151  key = '7';
152  break;
153  case K_KP_UPARROW:
154  key = '8';
155  break;
156  case K_KP_PGUP:
157  key = '9';
158  break;
159  case K_KP_LEFTARROW:
160  key = '4';
161  break;
162  case K_KP_5:
163  key = '5';
164  break;
165  case K_KP_RIGHTARROW:
166  key = '6';
167  break;
168  case K_KP_END:
169  key = '1';
170  break;
171  case K_KP_DOWNARROW:
172  key = '2';
173  break;
174  case K_KP_PGDN:
175  key = '3';
176  break;
177  case K_KP_INS:
178  key = '0';
179  break;
180  case K_KP_DEL:
181  key = '.';
182  break;
183  }
184 
185  if ( key > 127 )
186  {
187  switch ( key )
188  {
189  case K_DEL:
190  default:
191  return false;
192  }
193  }
194 
195  /*
196  ** support pasting from the clipboard
197  */
198  if ( ( toupper( key ) == 'V' && keydown[K_CTRL] ) ||
199  ( ( ( key == K_INS ) || ( key == K_KP_INS ) ) && keydown[K_SHIFT] ) )
200  {
201  char *cbd;
202 
203  if ( ( cbd = Sys_GetClipboardData() ) != 0 )
204  {
205  strtok( cbd, "\n\r\b" );
206 
207  strncpy( f->buffer, cbd, f->length - 1 );
208  f->cursor = (int)strlen( f->buffer );
209  f->visible_offset = f->cursor - f->visible_length;
210  if ( f->visible_offset < 0 )
211  f->visible_offset = 0;
212 
213  free( cbd );
214  }
215  return true;
216  }
217 
218  switch ( key )
219  {
220  case K_KP_LEFTARROW:
221  case K_LEFTARROW:
222  case K_BACKSPACE:
223  if ( f->cursor > 0 )
224  {
225  memmove( &f->buffer[f->cursor-1], &f->buffer[f->cursor], strlen( &f->buffer[f->cursor] ) + 1 );
226  f->cursor--;
227 
228  if ( f->visible_offset )
229  {
230  f->visible_offset--;
231  }
232  }
233  break;
234 
235  case K_KP_DEL:
236  case K_DEL:
237  memmove( &f->buffer[f->cursor], &f->buffer[f->cursor+1], strlen( &f->buffer[f->cursor+1] ) + 1 );
238  break;
239 
240  case K_KP_ENTER:
241  case K_ENTER:
242  case K_ESCAPE:
243  case K_TAB:
244  return false;
245 
246  case K_SPACE:
247  default:
248  if ( !isdigit( key ) && ( f->generic.flags & QMF_NUMBERSONLY ) )
249  return false;
250 
251  if ( f->cursor < f->length )
252  {
253  f->buffer[f->cursor++] = key;
254  f->buffer[f->cursor] = 0;
255 
256  if ( f->cursor > f->visible_length )
257  {
258  f->visible_offset++;
259  }
260  }
261  }
262 
263  return true;
264 }

Referenced by Default_MenuKey().

◆ Menu_AddItem()

void Menu_AddItem ( menuframework_s menu,
void item 
)

Definition at line 266 of file qmenu.c.

267 {
268  if ( menu->nitems == 0 )
269  menu->nslots = 0;
270 
271  if ( menu->nitems < MAXMENUITEMS )
272  {
273  menu->items[menu->nitems] = item;
274  ( ( menucommon_s * ) menu->items[menu->nitems] )->parent = menu;
275  menu->nitems++;
276  }
277 
278  menu->nslots = Menu_TallySlots( menu );
279 }

Referenced by AddressBook_MenuInit(), DMOptions_MenuInit(), DownloadOptions_MenuInit(), Game_MenuInit(), JoinServer_MenuInit(), Keys_MenuInit(), LoadGame_MenuInit(), Multiplayer_MenuInit(), Options_MenuInit(), PlayerConfig_MenuInit(), SaveGame_MenuInit(), StartServer_MenuInit(), and VID_MenuInit().

◆ Menu_AdjustCursor()

void Menu_AdjustCursor ( menuframework_s m,
int  dir 
)

Definition at line 288 of file qmenu.c.

289 {
290  menucommon_s *citem;
291 
292  /*
293  ** see if it's in a valid spot
294  */
295  if ( m->cursor >= 0 && m->cursor < m->nitems )
296  {
297  if ( ( citem = Menu_ItemAtCursor( m ) ) != 0 )
298  {
299  if ( citem->type != MTYPE_SEPARATOR )
300  return;
301  }
302  }
303 
304  /*
305  ** it's not in a valid spot, so crawl in the direction indicated until we
306  ** find a valid spot
307  */
308  if ( dir == 1 )
309  {
310  while ( 1 )
311  {
312  citem = Menu_ItemAtCursor( m );
313  if ( citem )
314  if ( citem->type != MTYPE_SEPARATOR )
315  break;
316  m->cursor += dir;
317  if ( m->cursor >= m->nitems )
318  m->cursor = 0;
319  }
320  }
321  else
322  {
323  while ( 1 )
324  {
325  citem = Menu_ItemAtCursor( m );
326  if ( citem )
327  if ( citem->type != MTYPE_SEPARATOR )
328  break;
329  m->cursor += dir;
330  if ( m->cursor < 0 )
331  m->cursor = m->nitems - 1;
332  }
333  }
334 }

Referenced by Default_MenuKey(), Game_MenuDraw(), Keys_MenuDraw(), Multiplayer_MenuDraw(), Options_MenuDraw(), SaveGame_MenuDraw(), VID_MenuDraw(), and VID_MenuKey().

◆ Menu_Center()

void Menu_Center ( menuframework_s menu)

Definition at line 336 of file qmenu.c.

337 {
338  int height;
339 
340  height = ( ( menucommon_s * ) menu->items[menu->nitems-1])->y;
341  height += 10;
342 
343  menu->y = ( VID_HEIGHT - height ) / 2;
344 }

Referenced by DMOptions_MenuInit(), DownloadOptions_MenuInit(), Game_MenuInit(), JoinServer_MenuInit(), Keys_MenuInit(), Multiplayer_MenuInit(), StartServer_MenuInit(), and VID_MenuInit().

◆ Menu_Draw()

void Menu_Draw ( menuframework_s menu)

Definition at line 346 of file qmenu.c.

347 {
348  int i;
350 
351  /*
352  ** draw contents
353  */
354  for ( i = 0; i < menu->nitems; i++ )
355  {
356  switch ( ( ( menucommon_s * ) menu->items[i] )->type )
357  {
358  case MTYPE_FIELD:
359  Field_Draw( ( menufield_s * ) menu->items[i] );
360  break;
361  case MTYPE_SLIDER:
362  Slider_Draw( ( menuslider_s * ) menu->items[i] );
363  break;
364  case MTYPE_LIST:
365  MenuList_Draw( ( menulist_s * ) menu->items[i] );
366  break;
367  case MTYPE_SPINCONTROL:
368  SpinControl_Draw( ( menulist_s * ) menu->items[i] );
369  break;
370  case MTYPE_ACTION:
371  Action_Draw( ( menuaction_s * ) menu->items[i] );
372  break;
373  case MTYPE_SEPARATOR:
374  Separator_Draw( ( menuseparator_s * ) menu->items[i] );
375  break;
376  }
377  }
378 
379  item = Menu_ItemAtCursor( menu );
380 
381  if ( item && item->cursordraw )
382  {
383  item->cursordraw( item );
384  }
385  else if ( menu->cursordraw )
386  {
387  menu->cursordraw( menu );
388  }
389  else if ( item && item->type != MTYPE_FIELD )
390  {
391  if ( item->flags & QMF_LEFT_JUSTIFY )
392  {
393  Draw_Char( menu->x + item->x - 24*vid_hudscale->value + item->cursor_offset*vid_hudscale->value, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
394  }
395  else
396  {
397  Draw_Char( menu->x + item->cursor_offset*vid_hudscale->value, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
398  }
399  }
400 
401  if ( item )
402  {
403  if ( item->statusbarfunc )
404  item->statusbarfunc( ( void * ) item );
405  else if ( item->statusbar )
406  Menu_DrawStatusBar( item->statusbar );
407  else
408  Menu_DrawStatusBar( menu->statusbar );
409 
410  }
411  else
412  {
413  Menu_DrawStatusBar( menu->statusbar );
414  }
415 }

Referenced by AddressBook_MenuDraw(), DMOptions_MenuDraw(), DownloadOptions_MenuDraw(), Game_MenuDraw(), JoinServer_MenuDraw(), Keys_MenuDraw(), LoadGame_MenuDraw(), Multiplayer_MenuDraw(), Options_MenuDraw(), PlayerConfig_MenuDraw(), SaveGame_MenuDraw(), StartServer_MenuDraw(), and VID_MenuDraw().

◆ Menu_DrawStatusBar()

void Menu_DrawStatusBar ( const char *  string)
static

Definition at line 417 of file qmenu.c.

418 {
419  if ( string )
420  {
421  int l = (int)strlen( string );
422  int maxcol = VID_WIDTH / (8*vid_hudscale->value);
423  int col = maxcol / 2 - l / 2;
424 
427  }
428  else
429  {
431  }
432 }

Referenced by Menu_Draw().

◆ Menu_DrawString()

void Menu_DrawString ( int  x,
int  y,
const char *  string 
)

Definition at line 434 of file qmenu.c.

435 {
436  unsigned i;
437 
438  for ( i = 0; i < strlen( string ); i++ )
439  {
440  Draw_Char( ( x + i*8*vid_hudscale->value ), y, string[i] );
441  }
442 }

Referenced by Action_Draw(), DrawKeyBindingFunc(), Field_Draw(), Menu_DrawStatusBar(), and SpinControl_Draw().

◆ Menu_DrawStringDark()

void Menu_DrawStringDark ( int  x,
int  y,
const char *  string 
)

Definition at line 444 of file qmenu.c.

445 {
446  unsigned i;
447 
448  for ( i = 0; i < strlen( string ); i++ )
449  {
450  Draw_Char( ( x + i*8*vid_hudscale->value ), y, string[i] + 128 );
451  }
452 }

Referenced by Action_Draw().

◆ Menu_DrawStringR2L()

void Menu_DrawStringR2L ( int  x,
int  y,
const char *  string 
)

Definition at line 454 of file qmenu.c.

455 {
456  unsigned i;
457 
458  for ( i = 0; i < strlen( string ); i++ )
459  {
460  Draw_Char( ( x - i*8*vid_hudscale->value), y, string[strlen(string)-i-1] );
461  }
462 }

Referenced by Action_Draw().

◆ Menu_DrawStringR2LDark()

void Menu_DrawStringR2LDark ( int  x,
int  y,
const char *  string 
)

Definition at line 464 of file qmenu.c.

465 {
466  unsigned i;
467 
468  for ( i = 0; i < strlen( string ); i++ )
469  {
470  Draw_Char( ( x - i*8*vid_hudscale->value ), y, string[strlen(string)-i-1]+128 );
471  }
472 }

Referenced by Action_Draw(), Field_Draw(), MenuList_Draw(), Separator_Draw(), Slider_Draw(), and SpinControl_Draw().

◆ Menu_ItemAtCursor()

void* Menu_ItemAtCursor ( menuframework_s m)

Definition at line 474 of file qmenu.c.

475 {
476  if ( m->cursor < 0 || m->cursor >= m->nitems )
477  return 0;
478 
479  return m->items[m->cursor];
480 }

Referenced by Default_MenuKey(), Field_Draw(), Keys_MenuKey(), Menu_AdjustCursor(), Menu_Draw(), Menu_SelectItem(), and Menu_SlideItem().

◆ Menu_SelectItem()

qboolean Menu_SelectItem ( menuframework_s s)

Definition at line 482 of file qmenu.c.

483 {
485 
486  if ( item )
487  {
488  switch ( item->type )
489  {
490  case MTYPE_FIELD:
491  return Field_DoEnter( ( menufield_s * ) item ) ;
492  case MTYPE_ACTION:
494  return true;
495  case MTYPE_LIST:
496 // Menulist_DoEnter( ( menulist_s * ) item );
497  return false;
498  case MTYPE_SPINCONTROL:
499 // SpinControl_DoEnter( ( menulist_s * ) item );
500  return false;
501  }
502  }
503  return false;
504 }

Referenced by Default_MenuKey(), and VID_MenuKey().

◆ Menu_SetStatusBar()

void Menu_SetStatusBar ( menuframework_s m,
const char *  string 
)

Definition at line 506 of file qmenu.c.

507 {
508  m->statusbar = string;
509 }

Referenced by DMOptions_MenuInit(), KeyBindingFunc(), Keys_MenuInit(), Keys_MenuKey(), M_Menu_PlayerConfig_f(), and Multiplayer_MenuInit().

◆ Menu_SlideItem()

void Menu_SlideItem ( menuframework_s s,
int  dir 
)

Definition at line 511 of file qmenu.c.

512 {
514 
515  if ( item )
516  {
517  switch ( item->type )
518  {
519  case MTYPE_SLIDER:
520  Slider_DoSlide( ( menuslider_s * ) item, dir );
521  break;
522  case MTYPE_SPINCONTROL:
523  SpinControl_DoSlide( ( menulist_s * ) item, dir );
524  break;
525  }
526  }
527 }

Referenced by Default_MenuKey(), and VID_MenuKey().

◆ Menu_TallySlots()

int Menu_TallySlots ( menuframework_s menu)

Definition at line 529 of file qmenu.c.

530 {
531  int i;
532  int total = 0;
533 
534  for ( i = 0; i < menu->nitems; i++ )
535  {
536  if ( ( ( menucommon_s * ) menu->items[i] )->type == MTYPE_LIST )
537  {
538  int nitems = 0;
539  const char **n = ( ( menulist_s * ) menu->items[i] )->itemnames;
540 
541  while (*n)
542  nitems++, n++;
543 
544  total += nitems;
545  }
546  else
547  {
548  total++;
549  }
550  }
551 
552  return total;
553 }

Referenced by Menu_AddItem().

◆ Menulist_DoEnter()

void Menulist_DoEnter ( menulist_s l)
static

Definition at line 555 of file qmenu.c.

556 {
557  int start;
558 
559  start = l->generic.y / 10 + 1;
560 
561  l->curvalue = l->generic.parent->cursor - start;
562 
563  if ( l->generic.callback )
564  l->generic.callback( l );
565 }

◆ MenuList_Draw()

void MenuList_Draw ( menulist_s l)
static

Definition at line 567 of file qmenu.c.

568 {
569  const char **n;
570  int y = 0;
571 
573 
574  n = l->itemnames;
575 
576  Draw_Fill( l->generic.x - 112 + l->generic.parent->x, l->generic.parent->y + l->generic.y + l->curvalue*10 + 10, 128, 10, 16 );
577  while ( *n )
578  {
579  Menu_DrawStringR2LDark( l->generic.x + l->generic.parent->x + LCOLUMN_OFFSET, l->generic.y + l->generic.parent->y + y + 10, *n );
580 
581  n++;
582  y += 10;
583  }
584 }

Referenced by Menu_Draw().

◆ Separator_Draw()

void Separator_Draw ( menuseparator_s s)
static

Definition at line 586 of file qmenu.c.

587 {
588  if ( s->generic.name )
589  Menu_DrawStringR2LDark( s->generic.x + s->generic.parent->x, s->generic.y + s->generic.parent->y, s->generic.name );
590 }

Referenced by Menu_Draw().

◆ Slider_DoSlide()

void Slider_DoSlide ( menuslider_s s,
int  dir 
)
static

Definition at line 592 of file qmenu.c.

593 {
594  s->curvalue += dir;
595 
596  if ( s->curvalue > s->maxvalue )
597  s->curvalue = s->maxvalue;
598  else if ( s->curvalue < s->minvalue )
599  s->curvalue = s->minvalue;
600 
601  if ( s->generic.callback )
602  s->generic.callback( s );
603 }

Referenced by Menu_SlideItem().

◆ Slider_Draw()

void Slider_Draw ( menuslider_s s)
static

Definition at line 607 of file qmenu.c.

608 {
609  int i;
610 
611  Menu_DrawStringR2LDark( s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
612  s->generic.y + s->generic.parent->y,
613  s->generic.name );
614 
615  s->range = ( s->curvalue - s->minvalue ) / ( float ) ( s->maxvalue - s->minvalue );
616 
617  if ( s->range < 0)
618  s->range = 0;
619  if ( s->range > 1)
620  s->range = 1;
621  Draw_Char( s->generic.x + s->generic.parent->x + RCOLUMN_OFFSET, s->generic.y + s->generic.parent->y, 128);
622  for ( i = 0; i < SLIDER_RANGE; i++ )
623  Draw_Char( RCOLUMN_OFFSET + s->generic.x + i*8*vid_hudscale->value + s->generic.parent->x + 8*vid_hudscale->value, s->generic.y + s->generic.parent->y, 129);
624  Draw_Char( RCOLUMN_OFFSET + s->generic.x + i*8*vid_hudscale->value + s->generic.parent->x + 8*vid_hudscale->value, s->generic.y + s->generic.parent->y, 130);
625  Draw_Char( ( int ) ( 8*vid_hudscale->value + RCOLUMN_OFFSET + s->generic.parent->x + s->generic.x + (SLIDER_RANGE-1)*8*vid_hudscale->value * s->range ), s->generic.y + s->generic.parent->y, 131);
626 }

Referenced by Menu_Draw().

◆ SpinControl_DoEnter()

void SpinControl_DoEnter ( menulist_s s)
static

Definition at line 628 of file qmenu.c.

629 {
630  s->curvalue++;
631  if ( s->itemnames[s->curvalue] == 0 )
632  s->curvalue = 0;
633 
634  if ( s->generic.callback )
635  s->generic.callback( s );
636 }

◆ SpinControl_DoSlide()

void SpinControl_DoSlide ( menulist_s s,
int  dir 
)
static

Definition at line 638 of file qmenu.c.

639 {
640  s->curvalue += dir;
641 
642  if ( s->curvalue < 0 )
643  s->curvalue = 0;
644  else if ( s->itemnames[s->curvalue] == 0 )
645  s->curvalue--;
646 
647  if ( s->generic.callback )
648  s->generic.callback( s );
649 }

Referenced by Menu_SlideItem().

◆ SpinControl_Draw()

void SpinControl_Draw ( menulist_s s)
static

Definition at line 651 of file qmenu.c.

652 {
653  char buffer[100];
654 
655  if ( s->generic.name )
656  {
657  Menu_DrawStringR2LDark( s->generic.x + s->generic.parent->x + LCOLUMN_OFFSET,
658  s->generic.y + s->generic.parent->y,
659  s->generic.name );
660  }
661  if ( !strchr( s->itemnames[s->curvalue], '\n' ) )
662  {
663  Menu_DrawString( RCOLUMN_OFFSET + s->generic.x + s->generic.parent->x, s->generic.y + s->generic.parent->y, s->itemnames[s->curvalue] );
664  }
665  else
666  {
667  strcpy( buffer, s->itemnames[s->curvalue] );
668  *strchr( buffer, '\n' ) = 0;
669  Menu_DrawString( RCOLUMN_OFFSET + s->generic.x + s->generic.parent->x, s->generic.y + s->generic.parent->y, buffer );
670  strcpy( buffer, strchr( s->itemnames[s->curvalue], '\n' ) + 1 );
671  Menu_DrawString( RCOLUMN_OFFSET + s->generic.x + s->generic.parent->x, s->generic.y + s->generic.parent->y + 10 * vid_hudscale->value, buffer );
672  }
673 }

Referenced by Menu_Draw().

Variable Documentation

◆ re

◆ vid_hudscale

◆ viddef

viddef_t viddef

Definition at line 54 of file vid_dll.c.

K_KP_ENTER
#define K_KP_ENTER
Definition: keys.h:70
K_INS
#define K_INS
Definition: keys.h:53
menuseparator_s
Definition: qmenu.h:118
height
GLsizei height
Definition: qgl_win.c:69
menufield_s::visible_offset
int visible_offset
Definition: qmenu.h:90
K_KP_RIGHTARROW
#define K_KP_RIGHTARROW
Definition: keys.h:66
RCOLUMN_OFFSET
#define RCOLUMN_OFFSET
Definition: qmenu.c:38
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
K_SPACE
#define K_SPACE
Definition: keys.h:28
Draw_Char
#define Draw_Char
Definition: qmenu.c:48
Field_DoEnter
qboolean Field_DoEnter(menufield_s *f)
Definition: qmenu.c:77
_tag_menuframework::items
void * items[64]
Definition: qmenu.h:56
VID_WIDTH
#define VID_WIDTH
Definition: qmenu.c:45
menufield_s::generic
menucommon_s generic
Definition: qmenu.h:84
menufield_s::visible_length
int visible_length
Definition: qmenu.h:89
keydown
qboolean keydown[256]
Definition: keys.c:45
menucommon_s::type
int type
Definition: qmenu.h:66
_tag_menuframework::y
int y
Definition: qmenu.h:51
menufield_s::length
int length
Definition: qmenu.h:88
SpinControl_Draw
static void SpinControl_Draw(menulist_s *s)
Definition: qmenu.c:651
MAXMENUITEMS
#define MAXMENUITEMS
Definition: qmenu.h:23
K_BACKSPACE
#define K_BACKSPACE
Definition: keys.h:32
K_KP_END
#define K_KP_END
Definition: keys.h:67
x
GLint GLenum GLint x
Definition: qgl_win.c:116
K_ENTER
#define K_ENTER
Definition: keys.h:26
K_KP_MINUS
#define K_KP_MINUS
Definition: keys.h:74
i
int i
Definition: q_shared.c:305
menucommon_s::flags
unsigned flags
Definition: qmenu.h:72
MenuList_Draw
static void MenuList_Draw(menulist_s *l)
Definition: qmenu.c:567
menucommon_s::x
int x
Definition: qmenu.h:68
buffer
GLenum GLfloat * buffer
Definition: qgl_win.c:151
QMF_LEFT_JUSTIFY
#define QMF_LEFT_JUSTIFY
Definition: qmenu.h:45
_tag_menuframework::statusbar
const char * statusbar
Definition: qmenu.h:58
menucommon_s::ownerdraw
void(* ownerdraw)(void *self)
Definition: qmenu.h:78
menuaction_s::generic
menucommon_s generic
Definition: qmenu.h:115
Menu_DrawStringR2L
void Menu_DrawStringR2L(int x, int y, const char *string)
Definition: qmenu.c:454
Menu_DrawStringDark
void Menu_DrawStringDark(int x, int y, const char *string)
Definition: qmenu.c:444
K_KP_PLUS
#define K_KP_PLUS
Definition: keys.h:75
K_CTRL
#define K_CTRL
Definition: keys.h:39
QMF_GRAYED
#define QMF_GRAYED
Definition: qmenu.h:46
Menu_DrawStringR2LDark
void Menu_DrawStringR2LDark(int x, int y, const char *string)
Definition: qmenu.c:464
Menu_DrawString
void Menu_DrawString(int x, int y, const char *string)
Definition: qmenu.c:434
menufield_s::cursor
int cursor
Definition: qmenu.h:87
vid_hudscale
cvar_t * vid_hudscale
Definition: vid_dll.c:48
K_KP_5
#define K_KP_5
Definition: keys.h:65
Action_DoEnter
static void Action_DoEnter(menuaction_s *a)
Definition: qmenu.c:51
edict_s::item
gitem_t * item
Definition: g_local.h:1110
K_KP_SLASH
#define K_KP_SLASH
Definition: keys.h:73
Draw_Fill
#define Draw_Fill
Definition: qmenu.c:49
menucommon_s::y
int y
Definition: qmenu.h:68
menucommon_s
Definition: qmenu.h:64
K_KP_INS
#define K_KP_INS
Definition: keys.h:71
menulist_s
Definition: qmenu.h:104
MTYPE_LIST
#define MTYPE_LIST
Definition: qmenu.h:26
Menu_ItemAtCursor
void * Menu_ItemAtCursor(menuframework_s *m)
Definition: qmenu.c:474
menucommon_s::callback
void(* callback)(void *self)
Definition: qmenu.h:76
K_LEFTARROW
#define K_LEFTARROW
Definition: keys.h:35
_tag_menuframework::cursordraw
void(* cursordraw)(struct _tag_menuframework *m)
Definition: qmenu.h:60
_tag_menuframework::cursor
int cursor
Definition: qmenu.h:52
cvar_s::value
float value
Definition: q_shared.h:331
K_KP_DEL
#define K_KP_DEL
Definition: keys.h:72
K_KP_UPARROW
#define K_KP_UPARROW
Definition: keys.h:62
K_KP_HOME
#define K_KP_HOME
Definition: keys.h:61
VID_HEIGHT
#define VID_HEIGHT
Definition: qmenu.c:46
MTYPE_ACTION
#define MTYPE_ACTION
Definition: qmenu.h:27
menuaction_s
Definition: qmenu.h:113
Slider_DoSlide
static void Slider_DoSlide(menuslider_s *s, int dir)
Definition: qmenu.c:592
SLIDER_RANGE
#define SLIDER_RANGE
Definition: qmenu.c:605
_tag_menuframework::nitems
int nitems
Definition: qmenu.h:54
menulist_s::curvalue
int curvalue
Definition: qmenu.h:108
s
static fixed16_t s
Definition: r_scan.c:30
y
GLint y
Definition: qgl_win.c:115
SpinControl_DoSlide
static void SpinControl_DoSlide(menulist_s *s, int dir)
Definition: qmenu.c:638
MTYPE_SLIDER
#define MTYPE_SLIDER
Definition: qmenu.h:25
Menu_DrawStatusBar
static void Menu_DrawStatusBar(const char *string)
Definition: qmenu.c:417
Field_Draw
void Field_Draw(menufield_s *f)
Definition: qmenu.c:87
LCOLUMN_OFFSET
#define LCOLUMN_OFFSET
Definition: qmenu.c:39
_tag_menuframework::x
int x
Definition: qmenu.h:51
menuslider_s
Definition: qmenu.h:93
menucommon_s::name
const char * name
Definition: qmenu.h:67
menufield_s
Definition: qmenu.h:82
menulist_s::itemnames
const char ** itemnames
Definition: qmenu.h:110
MTYPE_SPINCONTROL
#define MTYPE_SPINCONTROL
Definition: qmenu.h:28
K_DEL
#define K_DEL
Definition: keys.h:54
_tag_menuframework::nslots
int nslots
Definition: qmenu.h:55
MTYPE_FIELD
#define MTYPE_FIELD
Definition: qmenu.h:30
Separator_Draw
static void Separator_Draw(menuseparator_s *s)
Definition: qmenu.c:586
K_KP_PGUP
#define K_KP_PGUP
Definition: keys.h:63
K_KP_DOWNARROW
#define K_KP_DOWNARROW
Definition: keys.h:68
K_ESCAPE
#define K_ESCAPE
Definition: keys.h:27
K_TAB
#define K_TAB
Definition: keys.h:25
K_SHIFT
#define K_SHIFT
Definition: keys.h:40
Sys_Milliseconds
int Sys_Milliseconds(void)
Definition: q_shwin.c:120
K_KP_PGDN
#define K_KP_PGDN
Definition: keys.h:69
menulist_s::generic
menucommon_s generic
Definition: qmenu.h:106
Menu_TallySlots
int Menu_TallySlots(menuframework_s *menu)
Definition: qmenu.c:529
MTYPE_SEPARATOR
#define MTYPE_SEPARATOR
Definition: qmenu.h:29
Sys_GetClipboardData
char * Sys_GetClipboardData(void)
Definition: sys_win.c:431
gitem_s::flags
int flags
Definition: g_local.h:255
menucommon_s::parent
menuframework_s * parent
Definition: qmenu.h:69
menufield_s::buffer
char buffer[80]
Definition: qmenu.h:86
K_KP_LEFTARROW
#define K_KP_LEFTARROW
Definition: keys.h:64
QMF_NUMBERSONLY
#define QMF_NUMBERSONLY
Definition: qmenu.h:47
Action_Draw
static void Action_Draw(menuaction_s *a)
Definition: qmenu.c:57
Slider_Draw
static void Slider_Draw(menuslider_s *s)
Definition: qmenu.c:607