Quake II RTX doxygen  1.0 dev
menu.c File Reference
#include "ui.h"
#include "server/server.h"

Go to the source code of this file.

Functions

static void Action_Free (menuAction_t *a)
 
static void Action_Init (menuAction_t *a)
 
static void Action_Draw (menuAction_t *a)
 
static void Static_Init (menuStatic_t *s)
 
static void Static_Draw (menuStatic_t *s)
 
static void Bitmap_Free (menuBitmap_t *b)
 
static void Bitmap_Init (menuBitmap_t *b)
 
static void Bitmap_Draw (menuBitmap_t *b)
 
static void Keybind_Free (menuKeybind_t *k)
 
static void Keybind_Init (menuKeybind_t *k)
 
static void Keybind_Draw (menuKeybind_t *k)
 
static void Keybind_Push (menuKeybind_t *k)
 
static void Keybind_Pop (menuKeybind_t *k)
 
static void Keybind_Update (menuFrameWork_t *menu)
 
static void Keybind_Remove (const char *cmd)
 
static qboolean keybind_cb (void *arg, int key)
 
static menuSound_t Keybind_DoEnter (menuKeybind_t *k)
 
static menuSound_t Keybind_Key (menuKeybind_t *k, int key)
 
static void Field_Push (menuField_t *f)
 
static void Field_Pop (menuField_t *f)
 
static void Field_Free (menuField_t *f)
 
static void Field_Init (menuField_t *f)
 
static void Field_Draw (menuField_t *f)
 
static qboolean Field_TestKey (menuField_t *f, int key)
 
static int Field_Key (menuField_t *f, int key)
 
static int Field_Char (menuField_t *f, int key)
 
static void SpinControl_Push (menuSpinControl_t *s)
 
static void SpinControl_Pop (menuSpinControl_t *s)
 
static void SpinControl_Free (menuSpinControl_t *s)
 
void SpinControl_Init (menuSpinControl_t *s)
 
static int SpinControl_DoEnter (menuSpinControl_t *s)
 
static int SpinControl_DoSlide (menuSpinControl_t *s, int dir)
 
static void SpinControl_Draw (menuSpinControl_t *s)
 
static void BitField_Push (menuSpinControl_t *s)
 
static void BitField_Pop (menuSpinControl_t *s)
 
static void BitField_Free (menuSpinControl_t *s)
 
static void Pairs_Push (menuSpinControl_t *s)
 
static void Pairs_Pop (menuSpinControl_t *s)
 
static void Pairs_Free (menuSpinControl_t *s)
 
static void Strings_Push (menuSpinControl_t *s)
 
static void Strings_Pop (menuSpinControl_t *s)
 
static void Toggle_Push (menuSpinControl_t *s)
 
static void Toggle_Pop (menuSpinControl_t *s)
 
static void MenuList_ValidatePrestep (menuList_t *l)
 
static void MenuList_AdjustPrestep (menuList_t *l)
 
void MenuList_Init (menuList_t *l)
 
void MenuList_SetValue (menuList_t *l, int value)
 
static menuSound_t MenuList_SetColumn (menuList_t *l, int value)
 
static menuSound_t MenuList_FindColumn (menuList_t *l, int rel)
 
static menuSound_t MenuList_PrevColumn (menuList_t *l)
 
static menuSound_t MenuList_NextColumn (menuList_t *l)
 
static menuSound_t MenuList_Click (menuList_t *l)
 
static menuSound_t MenuList_Key (menuList_t *l, int key)
 
static menuSound_t MenuList_MouseMove (menuList_t *l)
 
static void MenuList_DrawString (int x, int y, int flags, menuListColumn_t *column, const char *string)
 
static void MenuList_Draw (menuList_t *l)
 
void MenuList_Sort (menuList_t *l, int offset, int(*cmpfunc)(const void *, const void *))
 
static menuSound_t Slider_DoSlide (menuSlider_t *s, int dir)
 
static void Slider_Push (menuSlider_t *s)
 
static void Slider_Pop (menuSlider_t *s)
 
static void Slider_Free (menuSlider_t *s)
 
static void Slider_Init (menuSlider_t *s)
 
static menuSound_t Slider_Click (menuSlider_t *s)
 
static menuSound_t Slider_MouseMove (menuSlider_t *s)
 
static menuSound_t Slider_Key (menuSlider_t *s, int key)
 
static void Slider_Draw (menuSlider_t *s)
 
static void Separator_Init (menuSeparator_t *s)
 
static void Separator_Draw (menuSeparator_t *s)
 
static void Savegame_Push (menuAction_t *a)
 
static int Common_DoEnter (menuCommon_t *item)
 
void Menu_AddItem (menuFrameWork_t *menu, void *item)
 
static void UI_ClearBounds (int mins[2], int maxs[2])
 
static void UI_AddRectToBounds (const vrect_t *rc, int mins[2], int maxs[2])
 
void Menu_Init (menuFrameWork_t *menu)
 
void Menu_Size (menuFrameWork_t *menu)
 
menuCommon_tMenu_ItemAtCursor (menuFrameWork_t *m)
 
void Menu_SetFocus (menuCommon_t *focus)
 
menuSound_t Menu_AdjustCursor (menuFrameWork_t *m, int dir)
 
static void Menu_DrawStatus (menuFrameWork_t *menu)
 
void Menu_Draw (menuFrameWork_t *menu)
 
menuSound_t Menu_SelectItem (menuFrameWork_t *s)
 
menuSound_t Menu_SlideItem (menuFrameWork_t *s, int dir)
 
menuSound_t Menu_KeyEvent (menuCommon_t *item, int key)
 
menuSound_t Menu_CharEvent (menuCommon_t *item, int key)
 
menuSound_t Menu_MouseMove (menuCommon_t *item)
 
static menuSound_t Menu_DefaultKey (menuFrameWork_t *m, int key)
 
menuSound_t Menu_Keydown (menuFrameWork_t *menu, int key)
 
menuCommon_tMenu_HitTest (menuFrameWork_t *menu)
 
qboolean Menu_Push (menuFrameWork_t *menu)
 
void Menu_Pop (menuFrameWork_t *menu)
 
void Menu_Free (menuFrameWork_t *menu)
 

Function Documentation

◆ Action_Draw()

static void Action_Draw ( menuAction_t a)
static

Definition at line 65 of file menu.c.

66 {
67  int flags;
68 
69  flags = a->generic.uiFlags;
70  if (a->generic.flags & QMF_HASFOCUS) {
71  if ((a->generic.uiFlags & UI_CENTER) != UI_CENTER) {
72  if ((uis.realtime >> 8) & 1) {
73  UI_DrawChar(a->generic.x - RCOLUMN_OFFSET / 2, a->generic.y, a->generic.uiFlags | UI_RIGHT, 13);
74  }
75  } else {
76  flags |= UI_ALTCOLOR;
77  if ((uis.realtime >> 8) & 1) {
78  UI_DrawChar(a->generic.x - strlen(a->generic.name) * CHAR_WIDTH / 2 - CHAR_WIDTH, a->generic.y, flags, 13);
79  }
80  }
81  }
82 
83  if (a->generic.flags & QMF_GRAYED) {
85  }
86  UI_DrawString(a->generic.x, a->generic.y, flags, a->generic.name);
87  if (a->generic.flags & QMF_GRAYED) {
88  R_ClearColor();
89  }
90 }

Referenced by Menu_Draw().

◆ Action_Free()

static void Action_Free ( menuAction_t a)
static

Definition at line 31 of file menu.c.

32 {
33  Z_Free(a->generic.name);
34  Z_Free(a->generic.status);
35  Z_Free(a->cmd);
36  Z_Free(a);
37 }

Referenced by Menu_Free().

◆ Action_Init()

static void Action_Init ( menuAction_t a)
static

Definition at line 44 of file menu.c.

45 {
46  if (!a->generic.name) {
47  Com_Error(ERR_FATAL, "Action_Init: NULL a->generic.name");
48  }
49 
50  if ((a->generic.uiFlags & UI_CENTER) != UI_CENTER) {
51  a->generic.x += RCOLUMN_OFFSET;
52  }
53 
54  a->generic.rect.x = a->generic.x;
55  a->generic.rect.y = a->generic.y;
57 }

Referenced by Menu_Init().

◆ BitField_Free()

static void BitField_Free ( menuSpinControl_t s)
static

Definition at line 677 of file menu.c.

678 {
679  Z_Free(s->generic.name);
680  Z_Free(s->generic.status);
681  Z_Free(s);
682 }

Referenced by Menu_Free().

◆ BitField_Pop()

static void BitField_Pop ( menuSpinControl_t s)
static

Definition at line 665 of file menu.c.

666 {
667  int val = s->cvar->integer;
668 
669  if (s->curvalue ^ s->negate) {
670  val |= s->mask;
671  } else {
672  val &= ~s->mask;
673  }
674  Cvar_SetInteger(s->cvar, val, FROM_MENU);
675 }

Referenced by Menu_Pop().

◆ BitField_Push()

static void BitField_Push ( menuSpinControl_t s)
static

Definition at line 656 of file menu.c.

657 {
658  if (s->cvar->integer & s->mask) {
659  s->curvalue = 1 ^ s->negate;
660  } else {
661  s->curvalue = 0 ^ s->negate;
662  }
663 }

Referenced by Menu_Push().

◆ Bitmap_Draw()

static void Bitmap_Draw ( menuBitmap_t b)
static

Definition at line 161 of file menu.c.

162 {
163  if (b->generic.flags & QMF_HASFOCUS) {
164  unsigned frame = (uis.realtime / 100) % NUM_CURSOR_FRAMES;
166  R_DrawPic(b->generic.x, b->generic.y, b->pics[1]);
167  } else {
168  R_DrawPic(b->generic.x, b->generic.y, b->pics[0]);
169  }
170 }

Referenced by Menu_Draw().

◆ Bitmap_Free()

static void Bitmap_Free ( menuBitmap_t b)
static

Definition at line 146 of file menu.c.

147 {
148  Z_Free(b->generic.status);
149  Z_Free(b->cmd);
150  Z_Free(b);
151 }

Referenced by Menu_Free().

◆ Bitmap_Init()

static void Bitmap_Init ( menuBitmap_t b)
static

Definition at line 153 of file menu.c.

154 {
155  b->generic.rect.x = b->generic.x;
156  b->generic.rect.y = b->generic.y;
157  b->generic.rect.width = b->generic.width;
158  b->generic.rect.height = b->generic.height;
159 }

Referenced by Menu_Init().

◆ Common_DoEnter()

static int Common_DoEnter ( menuCommon_t item)
static

Definition at line 1767 of file menu.c.

1768 {
1769  if (item->activate) {
1770  menuSound_t sound = item->activate(item);
1771  if (sound != QMS_NOTHANDLED) {
1772  return sound;
1773  }
1774  }
1775 
1776  return QMS_IN;
1777 }

Referenced by Menu_SelectItem().

◆ Field_Char()

static int Field_Char ( menuField_t f,
int  key 
)
static

Definition at line 484 of file menu.c.

485 {
486  qboolean ret;
487 
488  if (!Field_TestKey(f, key)) {
489  return QMS_BEEP;
490  }
491 
492  ret = IF_CharEvent(&f->field, key);
493  if (f->generic.change) {
494  f->generic.change(&f->generic);
495  }
496 
497  return ret ? QMS_SILENT : QMS_NOTHANDLED;
498 }

Referenced by Menu_CharEvent().

◆ Field_Draw()

static void Field_Draw ( menuField_t f)
static

Definition at line 424 of file menu.c.

425 {
426  int flags = f->generic.uiFlags;
427  uint32_t color = uis.color.normal.u32;
428 
429  if (f->generic.flags & QMF_HASFOCUS) {
430  flags |= UI_DRAWCURSOR;
431  color = uis.color.active.u32;
432  }
433 
434  if (f->generic.name) {
436  f->generic.uiFlags | UI_RIGHT | UI_ALTCOLOR, f->generic.name);
437 
439  f->field.visibleChars * CHAR_WIDTH, CHAR_HEIGHT + 2, color);
440 
441  IF_Draw(&f->field, f->generic.x + RCOLUMN_OFFSET, f->generic.y,
442  flags, uis.fontHandle);
443  } else {
444  R_DrawFill32(f->generic.rect.x, f->generic.rect.y - 1,
445  f->generic.rect.width, CHAR_HEIGHT + 2, color);
446 
447  IF_Draw(&f->field, f->generic.rect.x, f->generic.rect.y,
448  flags, uis.fontHandle);
449  }
450 }

Referenced by Menu_Draw().

◆ Field_Free()

static void Field_Free ( menuField_t f)
static

Definition at line 386 of file menu.c.

387 {
388  Z_Free(f->generic.name);
389  Z_Free(f->generic.status);
390  Z_Free(f);
391 }

Referenced by Menu_Free().

◆ Field_Init()

static void Field_Init ( menuField_t f)
static

Definition at line 398 of file menu.c.

399 {
400  int w = f->width * CHAR_WIDTH;
401 
402  f->generic.uiFlags &= ~(UI_LEFT | UI_RIGHT);
403 
404  if (f->generic.name) {
405  f->generic.rect.x = f->generic.x + LCOLUMN_OFFSET;
406  f->generic.rect.y = f->generic.y;
408  f->generic.uiFlags | UI_RIGHT, f->generic.name);
409  f->generic.rect.width += (RCOLUMN_OFFSET - LCOLUMN_OFFSET) + w;
410  } else {
411  f->generic.rect.x = f->generic.x - w / 2;
412  f->generic.rect.y = f->generic.y;
413  f->generic.rect.width = w;
414  f->generic.rect.height = CHAR_HEIGHT;
415  }
416 }

Referenced by Menu_Init().

◆ Field_Key()

static int Field_Key ( menuField_t f,
int  key 
)
static

Definition at line 466 of file menu.c.

467 {
468  if (IF_KeyEvent(&f->field, key)) {
469  return QMS_SILENT;
470  }
471 
472  if (Field_TestKey(f, key)) {
473  return QMS_SILENT;
474  }
475 
476  return QMS_NOTHANDLED;
477 }

Referenced by Menu_KeyEvent().

◆ Field_Pop()

static void Field_Pop ( menuField_t f)
static

Definition at line 381 of file menu.c.

382 {
383  Cvar_SetByVar(f->cvar, f->field.text, FROM_MENU);
384 }

Referenced by Menu_Pop().

◆ Field_Push()

static void Field_Push ( menuField_t f)
static

Definition at line 375 of file menu.c.

376 {
377  IF_Init(&f->field, f->width, f->width);
378  IF_Replace(&f->field, f->cvar->string);
379 }

Referenced by Menu_Push().

◆ Field_TestKey()

static qboolean Field_TestKey ( menuField_t f,
int  key 
)
static

Definition at line 452 of file menu.c.

453 {
454  if (f->generic.flags & QMF_NUMBERSONLY) {
455  return Q_isdigit(key) || key == '+' || key == '-' || key == '.';
456  }
457 
458  return Q_isprint(key);
459 }

Referenced by Field_Char(), and Field_Key().

◆ keybind_cb()

static qboolean keybind_cb ( void arg,
int  key 
)
static

Definition at line 310 of file menu.c.

311 {
312  menuKeybind_t *k = arg;
313  menuFrameWork_t *menu = k->generic.parent;
314 
315  // console key is hardcoded
316  if (key == '`') {
318  return qfalse;
319  }
320 
321  // menu key is hardcoded
322  if (key != K_ESCAPE) {
323  if (k->altbinding[0]) {
324  Keybind_Remove(k->cmd);
325  }
326  Key_SetBinding(key, k->cmd);
327  }
328 
329  Keybind_Update(menu);
330 
331  menu->keywait = qfalse;
332  menu->status = k->generic.status;
333  Key_WaitKey(NULL, NULL);
334 
336  return qfalse;
337 }

Referenced by Keybind_DoEnter().

◆ Keybind_DoEnter()

static menuSound_t Keybind_DoEnter ( menuKeybind_t k)
static

Definition at line 339 of file menu.c.

340 {
341  menuFrameWork_t *menu = k->generic.parent;
342 
343  menu->keywait = qtrue;
344  menu->status = k->altstatus;
346  return QMS_IN;
347 }

Referenced by Menu_SelectItem().

◆ Keybind_Draw()

static void Keybind_Draw ( menuKeybind_t k)
static

Definition at line 226 of file menu.c.

227 {
228  char string[MAX_STRING_CHARS];
229  int flags;
230 
231  flags = UI_ALTCOLOR;
232  if (k->generic.flags & QMF_HASFOCUS) {
233  /*if(k->generic.parent->keywait) {
234  UI_DrawChar(k->generic.x + RCOLUMN_OFFSET / 2, k->generic.y, k->generic.uiFlags | UI_RIGHT, '=');
235  } else*/ if ((uis.realtime >> 8) & 1) {
236  UI_DrawChar(k->generic.x + RCOLUMN_OFFSET / 2, k->generic.y, k->generic.uiFlags | UI_RIGHT, 13);
237  }
238  } else {
239  if (k->generic.parent->keywait) {
241  flags = 0;
242  }
243  }
244 
246  k->generic.uiFlags | UI_RIGHT | flags, k->generic.name);
247 
248  if (k->altbinding[0]) {
249  Q_concat(string, sizeof(string), k->binding, " or ", k->altbinding, NULL);
250  } else if (k->binding[0]) {
251  strcpy(string, k->binding);
252  } else {
253  strcpy(string, "???");
254  }
255 
257  k->generic.uiFlags | UI_LEFT, string);
258 
259  R_ClearColor();
260 }

Referenced by Menu_Draw().

◆ Keybind_Free()

static void Keybind_Free ( menuKeybind_t k)
static

Definition at line 180 of file menu.c.

181 {
182  Z_Free(k->generic.name);
183  Z_Free(k->generic.status);
184  Z_Free(k->cmd);
185  Z_Free(k->altstatus);
186  Z_Free(k);
187 }

Referenced by Menu_Free().

◆ Keybind_Init()

static void Keybind_Init ( menuKeybind_t k)
static

Definition at line 194 of file menu.c.

195 {
196  size_t len;
197 
198  if (!k->generic.name) {
199  Com_Error(ERR_FATAL, "Keybind_Init: NULL k->generic.name");
200  }
201 
202  k->generic.uiFlags &= ~(UI_LEFT | UI_RIGHT);
203 
204  k->generic.rect.x = k->generic.x + LCOLUMN_OFFSET;
205  k->generic.rect.y = k->generic.y;
206 
208  k->generic.uiFlags | UI_RIGHT, k->generic.name);
209 
210  if (k->altbinding[0]) {
211  len = strlen(k->binding) + 4 + strlen(k->altbinding);
212  } else if (k->binding[0]) {
213  len = strlen(k->binding);
214  } else {
215  len = 3;
216  }
217 
218  k->generic.rect.width += (RCOLUMN_OFFSET - LCOLUMN_OFFSET) + len * CHAR_WIDTH;
219 }

Referenced by Keybind_Update(), and Menu_Init().

◆ Keybind_Key()

static menuSound_t Keybind_Key ( menuKeybind_t k,
int  key 
)
static

Definition at line 349 of file menu.c.

350 {
351  menuFrameWork_t *menu = k->generic.parent;
352 
353  if (menu->keywait) {
354  return QMS_OUT; // never gets there
355  }
356 
357  if (key == K_BACKSPACE || key == K_DEL) {
358  Keybind_Remove(k->cmd);
359  Keybind_Update(menu);
360  return QMS_IN;
361  }
362 
363  return QMS_NOTHANDLED;
364 }

Referenced by Menu_KeyEvent().

◆ Keybind_Pop()

static void Keybind_Pop ( menuKeybind_t k)
static

Definition at line 278 of file menu.c.

279 {
280  Key_WaitKey(NULL, NULL);
281 }

Referenced by Menu_Pop().

◆ Keybind_Push()

static void Keybind_Push ( menuKeybind_t k)
static

Definition at line 262 of file menu.c.

263 {
264  int key = Key_EnumBindings(0, k->cmd);
265 
266  k->altbinding[0] = 0;
267  if (key == -1) {
268  strcpy(k->binding, "???");
269  } else {
270  strcpy(k->binding, Key_KeynumToString(key));
271  key = Key_EnumBindings(key + 1, k->cmd);
272  if (key != -1) {
273  strcpy(k->altbinding, Key_KeynumToString(key));
274  }
275  }
276 }

Referenced by Keybind_Update(), and Menu_Push().

◆ Keybind_Remove()

static void Keybind_Remove ( const char *  cmd)
static

Definition at line 297 of file menu.c.

298 {
299  int key;
300 
301  for (key = 0; ; key++) {
302  key = Key_EnumBindings(key, cmd);
303  if (key == -1) {
304  break;
305  }
306  Key_SetBinding(key, NULL);
307  }
308 }

Referenced by keybind_cb(), and Keybind_Key().

◆ Keybind_Update()

static void Keybind_Update ( menuFrameWork_t menu)
static

Definition at line 283 of file menu.c.

284 {
285  menuKeybind_t *k;
286  int i;
287 
288  for (i = 0; i < menu->nitems; i++) {
289  k = menu->items[i];
290  if (k->generic.type == MTYPE_KEYBIND) {
291  Keybind_Push(k);
292  Keybind_Init(k);
293  }
294  }
295 }

Referenced by keybind_cb(), and Keybind_Key().

◆ Menu_AddItem()

void Menu_AddItem ( menuFrameWork_t menu,
void item 
)

Definition at line 1785 of file menu.c.

1786 {
1787  if (menu->nitems >= MAXMENUITEMS) {
1788  Com_Error(ERR_FATAL, "Menu_AddItem: too many items");
1789  }
1790 
1791  menu->items[menu->nitems++] = item;
1792  ((menuCommon_t *)item)->parent = menu;
1793  ((menuCommon_t *)item)->condition = menu->current_condition;
1794 }

Referenced by M_Menu_Demos(), M_Menu_PlayerConfig(), M_Menu_Servers(), Parse_Action(), Parse_Bind(), Parse_Bitmap(), Parse_Blank(), Parse_Field(), Parse_Pairs(), Parse_Range(), Parse_Savegame(), Parse_Spin(), and Parse_Toggle().

◆ Menu_AdjustCursor()

menuSound_t Menu_AdjustCursor ( menuFrameWork_t m,
int  dir 
)

Definition at line 2101 of file menu.c.

2102 {
2103  menuCommon_t *item;
2104  int cursor, pos;
2105  int i;
2106 
2107  pos = 0;
2108  for (i = 0; i < m->nitems; i++) {
2109  item = (menuCommon_t *)m->items[i];
2110 
2111  if (item->flags & QMF_HASFOCUS) {
2112  pos = i;
2113  break;
2114  }
2115  }
2116 
2117  /*
2118  ** crawl in the direction indicated until we find a valid spot
2119  */
2120  cursor = pos;
2121  if (dir == 1) {
2122  do {
2123  cursor++;
2124  if (cursor >= m->nitems)
2125  cursor = 0;
2126 
2127  item = (menuCommon_t *)m->items[cursor];
2128  if (UI_IsItemSelectable(item))
2129  break;
2130  } while (cursor != pos);
2131  } else {
2132  do {
2133  cursor--;
2134  if (cursor < 0)
2135  cursor = m->nitems - 1;
2136 
2137  item = (menuCommon_t *)m->items[cursor];
2138  if (UI_IsItemSelectable(item))
2139  break;
2140  } while (cursor != pos);
2141  }
2142 
2143  Menu_SetFocus(item);
2144 
2145  return QMS_MOVE;
2146 }

Referenced by Menu_DefaultKey().

◆ Menu_CharEvent()

menuSound_t Menu_CharEvent ( menuCommon_t item,
int  key 
)

Definition at line 2376 of file menu.c.

2377 {
2378  switch (item->type) {
2379  case MTYPE_FIELD:
2380  return Field_Char((menuField_t *)item, key);
2381  default:
2382  return QMS_NOTHANDLED;
2383  }
2384 }

Referenced by UI_CharEvent().

◆ Menu_DefaultKey()

static menuSound_t Menu_DefaultKey ( menuFrameWork_t m,
int  key 
)
static

Definition at line 2398 of file menu.c.

2399 {
2400  menuCommon_t *item;
2401 
2402  switch (key) {
2403  case K_ESCAPE:
2404  case K_MOUSE2:
2405  UI_PopMenu();
2406  return QMS_OUT;
2407 
2408  case K_KP_UPARROW:
2409  case K_UPARROW:
2410  case 'k':
2411  return Menu_AdjustCursor(m, -1);
2412 
2413  case K_KP_DOWNARROW:
2414  case K_DOWNARROW:
2415  case K_TAB:
2416  case 'j':
2417  return Menu_AdjustCursor(m, 1);
2418 
2419  case K_KP_LEFTARROW:
2420  case K_LEFTARROW:
2421  case K_MWHEELDOWN:
2422  case 'h':
2423  return Menu_SlideItem(m, -1);
2424 
2425  case K_KP_RIGHTARROW:
2426  case K_RIGHTARROW:
2427  case K_MWHEELUP:
2428  case 'l':
2429  return Menu_SlideItem(m, 1);
2430 
2431  case K_MOUSE1:
2432  //case K_MOUSE2:
2433  case K_MOUSE3:
2434  item = Menu_HitTest(m);
2435  if (!item) {
2436  return QMS_NOTHANDLED;
2437  }
2438 
2439  if (!(item->flags & QMF_HASFOCUS)) {
2440  return QMS_NOTHANDLED;
2441  }
2442  // fall through
2443 
2444  case K_KP_ENTER:
2445  case K_ENTER:
2446  return Menu_SelectItem(m);
2447  }
2448 
2449  return QMS_NOTHANDLED;
2450 }

Referenced by Menu_Keydown().

◆ Menu_Draw()

void Menu_Draw ( menuFrameWork_t menu)

Definition at line 2196 of file menu.c.

2197 {
2198  void *item;
2199  int i;
2200 
2201 //
2202 // draw background
2203 //
2204  if (menu->image) {
2205  R_DrawStretchPic(0, menu->y1, uis.width,
2206  menu->y2 - menu->y1, menu->image);
2207  } else {
2208  R_DrawFill32(0, menu->y1, uis.width,
2209  menu->y2 - menu->y1, menu->color.u32);
2210  }
2211 
2212 //
2213 // draw title bar
2214 //
2215  if (menu->title) {
2216  UI_DrawString(uis.width / 2, menu->y1,
2217  UI_CENTER | UI_ALTCOLOR, menu->title);
2218  }
2219 
2220 //
2221 // draw banner, plaque and logo
2222 //
2223  if (menu->banner) {
2224  R_DrawPic(menu->banner_rc.x, menu->banner_rc.y, menu->banner);
2225  }
2226  if (menu->plaque) {
2227  R_DrawPic(menu->plaque_rc.x, menu->plaque_rc.y, menu->plaque);
2228  }
2229  if (menu->logo) {
2230  R_DrawPic(menu->logo_rc.x, menu->logo_rc.y, menu->logo);
2231  }
2232  if (menu->footer) {
2233  R_DrawStretchPic(menu->footer_rc.x, menu->footer_rc.y, menu->footer_rc.width, menu->footer_rc.height, menu->footer);
2234  }
2235 
2236 //
2237 // draw contents
2238 //
2239  for (i = 0; i < menu->nitems; i++) {
2240  item = menu->items[i];
2241  if (((menuCommon_t *)item)->flags & QMF_HIDDEN) {
2242  continue;
2243  }
2244 
2245  switch (((menuCommon_t *)item)->type) {
2246  case MTYPE_FIELD:
2247  Field_Draw(item);
2248  break;
2249  case MTYPE_SLIDER:
2250  Slider_Draw(item);
2251  break;
2252  case MTYPE_LIST:
2253  MenuList_Draw(item);
2254  break;
2255  case MTYPE_SPINCONTROL:
2256  case MTYPE_BITFIELD:
2257  case MTYPE_PAIRS:
2258  case MTYPE_VALUES:
2259  case MTYPE_STRINGS:
2260  case MTYPE_TOGGLE:
2261  SpinControl_Draw(item);
2262  break;
2263  case MTYPE_ACTION:
2264  case MTYPE_SAVEGAME:
2265  case MTYPE_LOADGAME:
2266  Action_Draw(item);
2267  break;
2268  case MTYPE_SEPARATOR:
2269  Separator_Draw(item);
2270  break;
2271  case MTYPE_STATIC:
2272  Static_Draw(item);
2273  break;
2274  case MTYPE_KEYBIND:
2275  Keybind_Draw(item);
2276  break;
2277  case MTYPE_BITMAP:
2278  Bitmap_Draw(item);
2279  break;
2280  default:
2281  Com_Error(ERR_FATAL, "Menu_Draw: unknown item type");
2282  break;
2283  }
2284 
2285  if (ui_debug->integer) {
2286  UI_DrawRect8(&((menuCommon_t *)item)->rect, 1, 223);
2287  }
2288  }
2289 
2290 //
2291 // draw status bar
2292 //
2293  if (menu->status) {
2294  Menu_DrawStatus(menu);
2295  }
2296 }

Referenced by Draw(), and UI_Draw().

◆ Menu_DrawStatus()

static void Menu_DrawStatus ( menuFrameWork_t menu)
static

Definition at line 2148 of file menu.c.

2149 {
2150  int linewidth = uis.width / CHAR_WIDTH;
2151  int x, y, l, count;
2152  char *txt, *p;
2153  int lens[8];
2154  char *ptrs[8];
2155 
2156  txt = menu->status;
2157  x = 0;
2158 
2159  count = 0;
2160  ptrs[0] = txt;
2161 
2162  while (*txt) {
2163  // count word length
2164  for (p = txt; *p > 32; p++)
2165  ;
2166  l = p - txt;
2167 
2168  // word wrap
2169  if ((l < linewidth && x + l > linewidth) || (x == linewidth)) {
2170  if (count == 7)
2171  break;
2172  lens[count++] = x;
2173  ptrs[count] = txt;
2174  x = 0;
2175  }
2176 
2177  // display character and advance
2178  txt++;
2179  x++;
2180  }
2181 
2182  lens[count++] = x;
2183 
2184  for (l = 0; l < count; l++) {
2185  x = (uis.width - lens[l] * CHAR_WIDTH) / 2;
2186  y = menu->y2 - (count - l) * CHAR_HEIGHT;
2187  R_DrawString(x, y, 0, lens[l], ptrs[l], uis.fontHandle);
2188  }
2189 }

Referenced by Menu_Draw().

◆ Menu_Free()

void Menu_Free ( menuFrameWork_t menu)

Definition at line 2586 of file menu.c.

2587 {
2588  void *item;
2589  int i;
2590 
2591  for (i = 0; i < menu->nitems; i++) {
2592  item = menu->items[i];
2593 
2594  switch (((menuCommon_t *)item)->type) {
2595  case MTYPE_ACTION:
2596  case MTYPE_SAVEGAME:
2597  case MTYPE_LOADGAME:
2598  Action_Free(item);
2599  break;
2600  case MTYPE_SLIDER:
2601  Slider_Free(item);
2602  break;
2603  case MTYPE_BITFIELD:
2604  case MTYPE_TOGGLE:
2605  BitField_Free(item);
2606  break;
2607  case MTYPE_PAIRS:
2608  Pairs_Free(item);
2609  break;
2610  case MTYPE_SPINCONTROL:
2611  case MTYPE_STRINGS:
2612  SpinControl_Free(item);
2613  break;
2614  case MTYPE_KEYBIND:
2615  Keybind_Free(item);
2616  break;
2617  case MTYPE_FIELD:
2618  Field_Free(item);
2619  break;
2620  case MTYPE_SEPARATOR:
2621  Z_Free(item);
2622  break;
2623  case MTYPE_BITMAP:
2624  Bitmap_Free(item);
2625  break;
2626  default:
2627  break;
2628  }
2629  }
2630 
2631  Z_Free(menu->title);
2632  Z_Free(menu->name);
2633  Z_Free(menu);
2634 }

Referenced by Parse_File().

◆ Menu_HitTest()

menuCommon_t* Menu_HitTest ( menuFrameWork_t menu)

Definition at line 2480 of file menu.c.

2481 {
2482  int i;
2483  menuCommon_t *item;
2484 
2485  if (menu->keywait) {
2486  return NULL;
2487  }
2488 
2489  for (i = 0; i < menu->nitems; i++) {
2490  item = menu->items[i];
2491  if (item->flags & QMF_HIDDEN) {
2492  continue;
2493  }
2494 
2495  if (UI_CursorInRect(&item->rect)) {
2496  return item;
2497  }
2498  }
2499 
2500  return NULL;
2501 }

Referenced by Menu_DefaultKey(), and UI_DoHitTest().

◆ Menu_Init()

void Menu_Init ( menuFrameWork_t menu)

Definition at line 1817 of file menu.c.

1818 {
1819  void *item;
1820  int i;
1821  int focus = 0;
1822  vrect_t *rc;
1823 
1824  menu->y1 = 0;
1825  menu->y2 = uis.height;
1826 
1827  for (i = 0; i < menu->nitems; i++) {
1828  item = menu->items[i];
1829 
1830  menuCondition_t *condition = &((menuCommon_t*)item)->condition;
1831  if (condition->cvar)
1832  {
1833  qboolean equals = condition->cvar->integer == condition->value;
1834  if (equals == condition->equals)
1835  ((menuCommon_t *)item)->flags &= ~QMF_HIDDEN;
1836  else
1837  ((menuCommon_t *)item)->flags |= QMF_HIDDEN;
1838  }
1839  }
1840 
1841  if (!menu->size) {
1842  menu->size = Menu_Size;
1843  }
1844  menu->size(menu);
1845 
1846  for (i = 0; i < menu->nitems; i++) {
1847  item = menu->items[i];
1848 
1849  focus |= ((menuCommon_t *)item)->flags & QMF_HASFOCUS;
1850  switch (((menuCommon_t *)item)->type) {
1851  case MTYPE_FIELD:
1852  Field_Init(item);
1853  break;
1854  case MTYPE_SLIDER:
1855  Slider_Init(item);
1856  break;
1857  case MTYPE_LIST:
1858  MenuList_Init(item);
1859  break;
1860  case MTYPE_SPINCONTROL:
1861  case MTYPE_BITFIELD:
1862  case MTYPE_PAIRS:
1863  case MTYPE_VALUES:
1864  case MTYPE_STRINGS:
1865  case MTYPE_TOGGLE:
1866  SpinControl_Init(item);
1867  break;
1868  case MTYPE_ACTION:
1869  case MTYPE_SAVEGAME:
1870  case MTYPE_LOADGAME:
1871  Action_Init(item);
1872  break;
1873  case MTYPE_SEPARATOR:
1874  Separator_Init(item);
1875  break;
1876  case MTYPE_STATIC:
1877  Static_Init(item);
1878  break;
1879  case MTYPE_KEYBIND:
1880  Keybind_Init(item);
1881  break;
1882  case MTYPE_BITMAP:
1883  Bitmap_Init(item);
1884  break;
1885  default:
1886  Com_Error(ERR_FATAL, "Menu_Init: unknown item type");
1887  break;
1888  }
1889  }
1890 
1891  // set focus to the first non-hidden item by default
1892  if (!focus && menu->nitems) {
1893  for (i = 0; i < menu->nitems; i++) {
1894  item = menu->items[i];
1895  if (!(((menuCommon_t *)item)->flags & QMF_HIDDEN) && (((menuCommon_t *)item)->type != MTYPE_SEPARATOR)) {
1896  ((menuCommon_t *)item)->flags |= QMF_HASFOCUS;
1897  if (((menuCommon_t *)item)->status) {
1898  menu->status = ((menuCommon_t *)item)->status;
1899  }
1900  break;
1901  }
1902  }
1903  }
1904 
1905  // calc menu bounding box
1906  UI_ClearBounds(menu->mins, menu->maxs);
1907 
1908  for (i = 0; i < menu->nitems; i++) {
1909  item = menu->items[i];
1910  rc = &((menuCommon_t *)item)->rect;
1911 
1912  UI_AddRectToBounds(rc, menu->mins, menu->maxs);
1913  }
1914 
1915  // expand
1916  menu->mins[0] -= MENU_SPACING;
1917  menu->mins[1] -= MENU_SPACING;
1918  menu->maxs[0] += MENU_SPACING;
1919  menu->maxs[1] += MENU_SPACING;
1920 
1921  // clamp
1922  if (menu->mins[0] < 0) menu->mins[0] = 0;
1923  if (menu->mins[1] < 0) menu->mins[1] = 0;
1924  if (menu->maxs[0] > uis.width) menu->maxs[0] = uis.width;
1925  if (menu->maxs[1] > uis.height) menu->maxs[1] = uis.height;
1926 }

Referenced by UI_PushMenu(), and UI_Resize().

◆ Menu_ItemAtCursor()

menuCommon_t* Menu_ItemAtCursor ( menuFrameWork_t m)

Definition at line 2042 of file menu.c.

2043 {
2044  menuCommon_t *item;
2045  int i;
2046 
2047  for (i = 0; i < m->nitems; i++) {
2048  item = m->items[i];
2049  if (item->flags & QMF_HASFOCUS) {
2050  return item;
2051  }
2052  }
2053 
2054  return NULL;
2055 }

Referenced by Menu_Keydown(), Menu_SelectItem(), Menu_SlideItem(), and UI_CharEvent().

◆ Menu_Keydown()

menuSound_t Menu_Keydown ( menuFrameWork_t menu,
int  key 
)

Definition at line 2452 of file menu.c.

2453 {
2454  menuCommon_t *item;
2455  menuSound_t sound;
2456 
2457  if (menu->keywait) {
2458  }
2459 
2460  if (menu->keydown) {
2461  sound = menu->keydown(menu, key);
2462  if (sound != QMS_NOTHANDLED) {
2463  return sound;
2464  }
2465  }
2466 
2467  item = Menu_ItemAtCursor(menu);
2468  if (item) {
2469  sound = Menu_KeyEvent(item, key);
2470  if (sound != QMS_NOTHANDLED) {
2471  return sound;
2472  }
2473  }
2474 
2475  sound = Menu_DefaultKey(menu, key);
2476  return sound;
2477 }

Referenced by UI_KeyEvent().

◆ Menu_KeyEvent()

menuSound_t Menu_KeyEvent ( menuCommon_t item,
int  key 
)

Definition at line 2353 of file menu.c.

2354 {
2355  if (item->keydown) {
2356  menuSound_t sound = item->keydown(item, key);
2357  if (sound != QMS_NOTHANDLED) {
2358  return sound;
2359  }
2360  }
2361 
2362  switch (item->type) {
2363  case MTYPE_FIELD:
2364  return Field_Key((menuField_t *)item, key);
2365  case MTYPE_LIST:
2366  return MenuList_Key((menuList_t *)item, key);
2367  case MTYPE_SLIDER:
2368  return Slider_Key((menuSlider_t *)item, key);
2369  case MTYPE_KEYBIND:
2370  return Keybind_Key((menuKeybind_t *)item, key);
2371  default:
2372  return QMS_NOTHANDLED;
2373  }
2374 }

Referenced by Menu_Keydown().

◆ Menu_MouseMove()

menuSound_t Menu_MouseMove ( menuCommon_t item)

Definition at line 2386 of file menu.c.

2387 {
2388  switch (item->type) {
2389  case MTYPE_LIST:
2390  return MenuList_MouseMove((menuList_t *)item);
2391  case MTYPE_SLIDER:
2392  return Slider_MouseMove((menuSlider_t *)item);
2393  default:
2394  return QMS_NOTHANDLED;
2395  }
2396 }

Referenced by UI_DoHitTest().

◆ Menu_Pop()

void Menu_Pop ( menuFrameWork_t menu)

Definition at line 2547 of file menu.c.

2548 {
2549  void *item;
2550  int i;
2551 
2552  for (i = 0; i < menu->nitems; i++) {
2553  item = menu->items[i];
2554 
2555  switch (((menuCommon_t *)item)->type) {
2556  case MTYPE_SLIDER:
2557  Slider_Pop(item);
2558  break;
2559  case MTYPE_BITFIELD:
2560  BitField_Pop(item);
2561  break;
2562  case MTYPE_PAIRS:
2563  Pairs_Pop(item);
2564  break;
2565  case MTYPE_STRINGS:
2566  Strings_Pop(item);
2567  break;
2568  case MTYPE_SPINCONTROL:
2569  SpinControl_Pop(item);
2570  break;
2571  case MTYPE_TOGGLE:
2572  Toggle_Pop(item);
2573  break;
2574  case MTYPE_KEYBIND:
2575  Keybind_Pop(item);
2576  break;
2577  case MTYPE_FIELD:
2578  Field_Pop(item);
2579  break;
2580  default:
2581  break;
2582  }
2583  }
2584 }

Referenced by Parse_File().

◆ Menu_Push()

qboolean Menu_Push ( menuFrameWork_t menu)

Definition at line 2503 of file menu.c.

2504 {
2505  void *item;
2506  int i;
2507 
2508  for (i = 0; i < menu->nitems; i++) {
2509  item = menu->items[i];
2510 
2511  switch (((menuCommon_t *)item)->type) {
2512  case MTYPE_SLIDER:
2513  Slider_Push(item);
2514  break;
2515  case MTYPE_BITFIELD:
2516  BitField_Push(item);
2517  break;
2518  case MTYPE_PAIRS:
2519  Pairs_Push(item);
2520  break;
2521  case MTYPE_STRINGS:
2522  Strings_Push(item);
2523  break;
2524  case MTYPE_SPINCONTROL:
2525  SpinControl_Push(item);
2526  break;
2527  case MTYPE_TOGGLE:
2528  Toggle_Push(item);
2529  break;
2530  case MTYPE_KEYBIND:
2531  Keybind_Push(item);
2532  break;
2533  case MTYPE_FIELD:
2534  Field_Push(item);
2535  break;
2536  case MTYPE_SAVEGAME:
2537  case MTYPE_LOADGAME:
2538  Savegame_Push(item);
2539  break;
2540  default:
2541  break;
2542  }
2543  }
2544  return qtrue;
2545 }

Referenced by Parse_File().

◆ Menu_SelectItem()

menuSound_t Menu_SelectItem ( menuFrameWork_t s)

Definition at line 2298 of file menu.c.

2299 {
2300  menuCommon_t *item;
2301 
2302  if (!(item = Menu_ItemAtCursor(s))) {
2303  return QMS_NOTHANDLED;
2304  }
2305 
2306  switch (item->type) {
2307  //case MTYPE_SLIDER:
2308  // return Slider_DoSlide((menuSlider_t *)item, 1);
2309  case MTYPE_SPINCONTROL:
2310  case MTYPE_BITFIELD:
2311  case MTYPE_PAIRS:
2312  case MTYPE_VALUES:
2313  case MTYPE_STRINGS:
2314  case MTYPE_TOGGLE:
2315  return SpinControl_DoEnter((menuSpinControl_t *)item);
2316  case MTYPE_KEYBIND:
2317  return Keybind_DoEnter((menuKeybind_t *)item);
2318  case MTYPE_FIELD:
2319  case MTYPE_ACTION:
2320  case MTYPE_LIST:
2321  case MTYPE_BITMAP:
2322  case MTYPE_SAVEGAME:
2323  case MTYPE_LOADGAME:
2324  return Common_DoEnter(item);
2325  default:
2326  return QMS_NOTHANDLED;
2327  }
2328 }

Referenced by Menu_DefaultKey().

◆ Menu_SetFocus()

void Menu_SetFocus ( menuCommon_t focus)

Definition at line 2057 of file menu.c.

2058 {
2059  menuFrameWork_t *menu;
2060  menuCommon_t *item;
2061  int i;
2062 
2063  if (focus->flags & QMF_HASFOCUS) {
2064  return;
2065  }
2066 
2067  menu = focus->parent;
2068 
2069  for (i = 0; i < menu->nitems; i++) {
2070  item = (menuCommon_t *)menu->items[i];
2071 
2072  if (item == focus) {
2073  item->flags |= QMF_HASFOCUS;
2074  if (item->focus) {
2075  item->focus(item, qtrue);
2076  } else if (item->status) {
2077  menu->status = item->status;
2078  }
2079  } else if (item->flags & QMF_HASFOCUS) {
2080  item->flags &= ~QMF_HASFOCUS;
2081  if (item->focus) {
2082  item->focus(item, qfalse);
2083  } else if (menu->status == item->status
2084  && menu->status != focus->status) {
2085  menu->status = NULL;
2086  }
2087  }
2088  }
2089 
2090 }

Referenced by Menu_AdjustCursor(), and UI_DoHitTest().

◆ Menu_Size()

void Menu_Size ( menuFrameWork_t menu)

Definition at line 1928 of file menu.c.

1929 {
1930  menuCommon_t *item;
1931  int x, y, w, h;
1932  int i, widest = -1;
1933 
1934  // count visible items
1935  for (i = 0, h = 0; i < menu->nitems; i++) {
1936  item = menu->items[i];
1937  if (item->flags & QMF_HIDDEN) {
1938  continue;
1939  }
1940  if (item->type == MTYPE_BITMAP) {
1941  h += GENERIC_SPACING(item->height);
1942  if (widest < item->width) {
1943  widest = item->width;
1944  }
1945  } else {
1946  h += MENU_SPACING;
1947  }
1948  }
1949 
1950  // account for banner
1951  if (menu->banner) {
1952  h += GENERIC_SPACING(menu->banner_rc.height);
1953  }
1954 
1955  // set menu top/bottom
1956  if (menu->compact) {
1957  menu->y1 = (uis.height - h) / 2 - MENU_SPACING;
1958  menu->y2 = (uis.height + h) / 2 + MENU_SPACING;
1959  } else {
1960  menu->y1 = 0;
1961  menu->y2 = uis.height;
1962  }
1963 
1964  // set menu horizontal base
1965  if (widest == -1) {
1966  x = uis.width / 2;
1967  } else {
1968  // if menu has bitmaps, it is expected to have plaque and logo
1969  // align them horizontally to avoid going off screen on small resolution
1970  w = widest + CURSOR_WIDTH;
1971  if (menu->plaque_rc.width > menu->logo_rc.width) {
1972  w += menu->plaque_rc.width;
1973  } else {
1974  w += menu->logo_rc.width;
1975  }
1976  x = (uis.width + w) / 2 - widest;
1977  }
1978 
1979  // set menu vertical base
1980  y = (uis.height - h) / 2;
1981 
1982  // banner is horizontally centered and
1983  // positioned on top of all menu items
1984  if (menu->banner) {
1985  menu->banner_rc.x = (uis.width - menu->banner_rc.width) / 2;
1986  menu->banner_rc.y = y;
1987  y += GENERIC_SPACING(menu->banner_rc.height);
1988  }
1989 
1990  // plaque and logo are vertically centered and
1991  // positioned to the left of bitmaps and cursor
1992  h = 0;
1993  if (menu->plaque) {
1994  h += menu->plaque_rc.height;
1995  }
1996  if (menu->logo) {
1997  h += menu->logo_rc.height + 5;
1998  }
1999 
2000  if (menu->plaque) {
2001  menu->plaque_rc.x = x - CURSOR_WIDTH - menu->plaque_rc.width;
2002  menu->plaque_rc.y = (uis.height - h) / 2;
2003  }
2004 
2005  if (menu->logo) {
2006  menu->logo_rc.x = x - CURSOR_WIDTH - menu->logo_rc.width;
2007  menu->logo_rc.y = (uis.height + h) / 2 - menu->logo_rc.height;
2008  }
2009 
2010  // align items
2011  for (i = 0; i < menu->nitems; i++) {
2012  item = menu->items[i];
2013  if (item->flags & QMF_HIDDEN) {
2014  continue;
2015  }
2016  item->x = x;
2017  item->y = y;
2018  if (item->type == MTYPE_BITMAP) {
2019  y += GENERIC_SPACING(item->height);
2020  } else {
2021  y += MENU_SPACING;
2022  }
2023  }
2024 
2025  // footer is horizontally centered and
2026  // positioned below all menu items
2027  if (menu->footer) {
2028  menu->footer_rc.x = (uis.width - menu->footer_rc.width) / 2;
2029 
2030  menu->footer_rc.y = y;
2031 
2032  if (menu->plaque)
2033  menu->footer_rc.y = max(menu->footer_rc.y, menu->plaque_rc.y + menu->plaque_rc.height);
2034 
2035  if (menu->logo)
2036  menu->footer_rc.y = max(menu->footer_rc.y, menu->logo_rc.y + menu->logo_rc.height);
2037 
2038  menu->footer_rc.y += menu->footer_rc.height;
2039  }
2040 }

Referenced by Menu_Init().

◆ Menu_SlideItem()

menuSound_t Menu_SlideItem ( menuFrameWork_t s,
int  dir 
)

Definition at line 2330 of file menu.c.

2331 {
2332  menuCommon_t *item;
2333 
2334  if (!(item = Menu_ItemAtCursor(s))) {
2335  return QMS_NOTHANDLED;
2336  }
2337 
2338  switch (item->type) {
2339  case MTYPE_SLIDER:
2340  return Slider_DoSlide((menuSlider_t *)item, dir);
2341  case MTYPE_SPINCONTROL:
2342  case MTYPE_BITFIELD:
2343  case MTYPE_PAIRS:
2344  case MTYPE_VALUES:
2345  case MTYPE_STRINGS:
2346  case MTYPE_TOGGLE:
2347  return SpinControl_DoSlide((menuSpinControl_t *)item, dir);
2348  default:
2349  return QMS_NOTHANDLED;
2350  }
2351 }

Referenced by Menu_DefaultKey().

◆ MenuList_AdjustPrestep()

static void MenuList_AdjustPrestep ( menuList_t l)
static

Definition at line 802 of file menu.c.

803 {
804  if (l->numItems > l->maxItems && l->curvalue > 0) {
805  if (l->prestep > l->curvalue) {
806  l->prestep = l->curvalue;
807  } else if (l->prestep < l->curvalue - l->maxItems + 1) {
808  l->prestep = l->curvalue - l->maxItems + 1;
809  }
810  } else {
811  l->prestep = 0;
812  }
813 }

Referenced by MenuList_Key(), MenuList_SetValue(), and MenuList_Sort().

◆ MenuList_Click()

static menuSound_t MenuList_Click ( menuList_t l)
static

Definition at line 967 of file menu.c.

968 {
969  int i, j;
970  vrect_t rect;
971 
972  if (!l->items) {
973  return QMS_SILENT;
974  }
975 
976  // click on scroll bar
977  if ((l->mlFlags & MLF_SCROLLBAR) && l->numItems > l->maxItems) {
978  int x = l->generic.rect.x + l->generic.rect.width - MLIST_SCROLLBAR_WIDTH;
979  int y = l->generic.rect.y + MLIST_SPACING;
980  int h = l->generic.height;
981  int barHeight, pageHeight, prestepHeight;
982  float pageFrac, prestepFrac;
983 
984  if (l->mlFlags & MLF_HEADER) {
985  y += MLIST_SPACING;
986  h -= MLIST_SPACING;
987  }
988 
989  barHeight = h - MLIST_SPACING * 2;
990  pageFrac = (float)l->maxItems / l->numItems;
991  prestepFrac = (float)l->prestep / l->numItems;
992 
993  pageHeight = Q_rint(barHeight * pageFrac);
994  prestepHeight = Q_rint(barHeight * prestepFrac);
995 
996  // click above thumb
997  rect.x = x;
998  rect.y = y;
999  rect.width = MLIST_SCROLLBAR_WIDTH;
1000  rect.height = prestepHeight;
1001  if (UI_CursorInRect(&rect)) {
1002  l->prestep -= l->maxItems;
1004  return QMS_MOVE;
1005  }
1006 
1007  // click on thumb
1008  rect.y = y + prestepHeight;
1009  rect.height = pageHeight;
1010  if (UI_CursorInRect(&rect)) {
1011  l->drag_y = uis.mouseCoords[1] - rect.y;
1012  uis.mouseTracker = &l->generic;
1013  return QMS_SILENT;
1014  }
1015 
1016  // click below thumb
1017  rect.y = y + prestepHeight + pageHeight;
1018  rect.height = barHeight - prestepHeight - pageHeight;
1019  if (UI_CursorInRect(&rect)) {
1020  l->prestep += l->maxItems;
1022  return QMS_MOVE;
1023  }
1024 
1025  // click above scrollbar
1026  rect.y = y - MLIST_SPACING;
1027  rect.height = MLIST_SPACING;
1028  if (UI_CursorInRect(&rect)) {
1029  l->prestep--;
1031  return QMS_MOVE;
1032  }
1033 
1034  // click below scrollbar
1035  rect.y = l->generic.rect.y + l->generic.height - MLIST_SPACING;
1036  rect.height = MLIST_SPACING;
1037  if (UI_CursorInRect(&rect)) {
1038  l->prestep++;
1040  return QMS_MOVE;
1041  }
1042  }
1043 
1044  rect.x = l->generic.rect.x;
1045  rect.y = l->generic.rect.y;
1046  rect.width = l->generic.rect.width;
1047  rect.height = MLIST_SPACING;
1048 
1049  if (l->mlFlags & MLF_SCROLLBAR) {
1050  rect.width -= MLIST_SCROLLBAR_WIDTH;
1051  }
1052 
1053  // click on header
1054  if (l->mlFlags & MLF_HEADER) {
1055  if (l->sortdir && UI_CursorInRect(&rect)) {
1056  for (j = 0; j < l->numcolumns; j++) {
1057  if (!l->columns[j].width) {
1058  continue;
1059  }
1060  rect.width = l->columns[j].width;
1061  if (UI_CursorInRect(&rect)) {
1062  return MenuList_SetColumn(l, j);
1063  }
1064  rect.x += rect.width;
1065  }
1066  return QMS_SILENT;
1067  }
1068  rect.y += MLIST_SPACING;
1069  }
1070 
1071  // click on item
1072  j = min(l->numItems, l->prestep + l->maxItems);
1073  for (i = l->prestep; i < j; i++) {
1074  if (UI_CursorInRect(&rect)) {
1075  if (l->curvalue == i && uis.realtime -
1077  if (l->generic.activate) {
1078  return l->generic.activate(&l->generic);
1079  }
1080  return QMS_SILENT;
1081  }
1082  l->clickTime = uis.realtime;
1083  l->curvalue = i;
1084  if (l->generic.change) {
1085  return l->generic.change(&l->generic);
1086  }
1087  return QMS_SILENT;
1088  }
1089  rect.y += MLIST_SPACING;
1090  }
1091 
1092  return QMS_SILENT;
1093 }

Referenced by MenuList_Key().

◆ MenuList_Draw()

static void MenuList_Draw ( menuList_t l)
static

Definition at line 1333 of file menu.c.

1334 {
1335  char *s;
1336  int x, y, xx, yy;
1337  int i, j, k;
1338  int width, height;
1339  float pageFrac, prestepFrac;
1340  int barHeight;
1341 
1342  x = l->generic.rect.x;
1343  y = l->generic.rect.y;
1344  width = l->generic.rect.width;
1345  height = l->generic.rect.height;
1346 
1347  // draw header
1348  if (l->mlFlags & MLF_HEADER) {
1349  xx = x;
1350  for (j = 0; j < l->numcolumns; j++) {
1351  int flags = UI_ALTCOLOR;
1352  uint32_t color = uis.color.normal.u32;
1353 
1354  if (!l->columns[j].width) {
1355  continue;
1356  }
1357 
1358  if (l->sortcol == j && l->sortdir) {
1359  flags = 0;
1360  if (l->generic.flags & QMF_HASFOCUS) {
1361  color = uis.color.active.u32;
1362  }
1363  }
1364  R_DrawFill32(xx, y, l->columns[j].width - 1,
1365  MLIST_SPACING - 1, color);
1366 
1367  if (l->columns[j].name) {
1368  MenuList_DrawString(xx, y, flags,
1369  &l->columns[j], l->columns[j].name);
1370  }
1371  xx += l->columns[j].width;
1372  }
1373  y += MLIST_SPACING;
1374  height -= MLIST_SPACING;
1375  }
1376 
1377  if (l->mlFlags & MLF_SCROLLBAR) {
1378  barHeight = height - MLIST_SPACING * 2;
1379  yy = y + MLIST_SPACING;
1380 
1381  // draw scrollbar background
1383  MLIST_SCROLLBAR_WIDTH - 1, barHeight,
1384  uis.color.normal.u32);
1385 
1386  if (l->numItems > l->maxItems) {
1387  pageFrac = (float)l->maxItems / l->numItems;
1388  prestepFrac = (float)l->prestep / l->numItems;
1389  } else {
1390  pageFrac = 1;
1391  prestepFrac = 0;
1392  }
1393 
1394  // draw scrollbar thumb
1396  yy + Q_rint(barHeight * prestepFrac),
1398  Q_rint(barHeight * pageFrac),
1399  uis.color.selection.u32);
1400  }
1401 
1402  // draw background
1403  xx = x;
1404  for (j = 0; j < l->numcolumns; j++) {
1405  uint32_t color = uis.color.normal.u32;
1406 
1407  if (!l->columns[j].width) {
1408  continue;
1409  }
1410 
1411  if (l->sortcol == j && l->sortdir) {
1412  if (l->generic.flags & QMF_HASFOCUS) {
1413  color = uis.color.active.u32;
1414  }
1415  }
1416  R_DrawFill32(xx, y, l->columns[j].width - 1,
1417  height, color);
1418 
1419  xx += l->columns[j].width;
1420  }
1421 
1422  yy = y;
1423  k = min(l->numItems, l->prestep + l->maxItems);
1424  for (i = l->prestep; i < k; i++) {
1425  // draw selection
1426  if (!(l->generic.flags & QMF_DISABLED) && i == l->curvalue) {
1427  xx = x;
1428  for (j = 0; j < l->numcolumns; j++) {
1429  if (!l->columns[j].width) {
1430  continue;
1431  }
1432  R_DrawFill32(xx, yy, l->columns[j].width - 1,
1434  xx += l->columns[j].width;
1435  }
1436  }
1437 
1438  // draw contents
1439  s = (char *)l->items[i] + l->extrasize;
1440  if (l->mlFlags & MLF_COLOR) {
1441  R_SetColor(*((uint32_t *)(s - 4)));
1442  }
1443 
1444  xx = x;
1445  for (j = 0; j < l->numcolumns; j++) {
1446  if (!*s) {
1447  break;
1448  }
1449 
1450  if (l->columns[j].width) {
1451  MenuList_DrawString(xx, yy, 0, &l->columns[j], s);
1452  xx += l->columns[j].width;
1453  }
1454  s += strlen(s) + 1;
1455  }
1456 
1457  yy += MLIST_SPACING;
1458  }
1459 
1460  if (l->mlFlags & MLF_COLOR) {
1461  R_SetColor(U32_WHITE);
1462  }
1463 }

Referenced by Menu_Draw().

◆ MenuList_DrawString()

static void MenuList_DrawString ( int  x,
int  y,
int  flags,
menuListColumn_t column,
const char *  string 
)
static

Definition at line 1304 of file menu.c.

1307 {
1308  clipRect_t rc;
1309 
1310  rc.left = x;
1311  rc.right = x + column->width - 1;
1312  rc.top = y + 1;
1313  rc.bottom = y + CHAR_HEIGHT + 1;
1314 
1315  if ((column->uiFlags & UI_CENTER) == UI_CENTER) {
1316  x += column->width / 2 - 1;
1317  } else if (column->uiFlags & UI_RIGHT) {
1318  x += column->width - MLIST_PRESTEP;
1319  } else {
1320  x += MLIST_PRESTEP;
1321  }
1322 
1323  R_SetClipRect(&rc);
1324  UI_DrawString(x, y + 1, column->uiFlags | flags, string);
1325  R_SetClipRect(NULL);
1326 }

Referenced by MenuList_Draw().

◆ MenuList_FindColumn()

static menuSound_t MenuList_FindColumn ( menuList_t l,
int  rel 
)
static

Definition at line 892 of file menu.c.

893 {
894  int i, j;
895 
896  if (!l->sortdir)
897  return QMS_NOTHANDLED;
898 
899  for (i = 0, j = 0; i < l->numcolumns; i++) {
900  if (!l->columns[i].width)
901  continue;
902 
903  if (++j == rel)
904  return MenuList_SetColumn(l, i);
905  }
906 
907  return QMS_NOTHANDLED;
908 }

Referenced by MenuList_Key(), MenuList_NextColumn(), and MenuList_PrevColumn().

◆ MenuList_Init()

void MenuList_Init ( menuList_t l)

Definition at line 820 of file menu.c.

821 {
822  int height;
823  int i;
824 
825  height = l->generic.height;
826  if (l->mlFlags & MLF_HEADER) {
828  }
829 
831 
832  //clamp(l->curvalue, 0, l->numItems - 1);
833 
835 
836  l->generic.rect.x = l->generic.x;
837  l->generic.rect.y = l->generic.y;
838 
839  l->generic.rect.width = 0;
840  for (i = 0; i < l->numcolumns; i++) {
841  l->generic.rect.width += l->columns[i].width;
842  }
843 
844  if (l->mlFlags & MLF_SCROLLBAR) {
845  l->generic.rect.width += MLIST_SCROLLBAR_WIDTH;
846  }
847 
848  l->generic.rect.height = l->generic.height;
849 
850  if (l->sortdir && l->sort) {
851  l->sort(l);
852  }
853 }

Referenced by EnterDirectory(), LeaveDirectory(), and Menu_Init().

◆ MenuList_Key()

static menuSound_t MenuList_Key ( menuList_t l,
int  key 
)
static

Definition at line 1100 of file menu.c.

1101 {
1102  //int i;
1103 
1104  if (!l->items) {
1105  return QMS_NOTHANDLED;
1106  }
1107 
1108  if (Key_IsDown(K_ALT) && Q_isdigit(key)) {
1109  return MenuList_FindColumn(l, key - '0');
1110  }
1111 
1112 #if 0
1113  if (key > 32 && key < 127) {
1114  if (uis.realtime > l->scratchTime + 1300) {
1115  l->scratchCount = 0;
1116  l->scratchTime = uis.realtime;
1117  }
1118 
1119  if (l->scratchCount >= sizeof(l->scratch) - 1) {
1120  return QMS_NOTHANDLED;
1121  }
1122 
1123  l->scratch[l->scratchCount++] = key;
1124  l->scratch[l->scratchCount] = 0;
1125 
1126  //l->scratchTime = uis.realtime;
1127 
1128  if (!Q_stricmpn(UI_GetColumn((char *)l->items[l->curvalue] + l->extrasize, l->sortcol),
1129  l->scratch, l->scratchCount)) {
1130  return QMS_NOTHANDLED;
1131  }
1132 
1133  for (i = 0; i < l->numItems; i++) {
1134  if (!Q_stricmpn(UI_GetColumn((char *)l->items[i] + l->extrasize, l->sortcol), l->scratch, l->scratchCount)) {
1135  MenuList_SetValue(l, i);
1136  return QMS_SILENT;
1137  }
1138  i++;
1139  }
1140 
1141  return QMS_NOTHANDLED;
1142  }
1143 #endif
1144 
1145  l->scratchCount = 0;
1146 
1147  switch (key) {
1148  case K_LEFTARROW:
1149  case 'h':
1150  return MenuList_PrevColumn(l);
1151 
1152  case K_RIGHTARROW:
1153  case 'l':
1154  return MenuList_NextColumn(l);
1155 
1156  case K_UPARROW:
1157  case K_KP_UPARROW:
1158  case 'k':
1159  if (l->curvalue < 0) {
1160  goto home;
1161  }
1162  if (l->curvalue > 0) {
1163  l->curvalue--;
1164  if (l->generic.change) {
1165  l->generic.change(&l->generic);
1166  }
1168  return QMS_MOVE;
1169  }
1170  return QMS_BEEP;
1171 
1172  case K_DOWNARROW:
1173  case K_KP_DOWNARROW:
1174  case 'j':
1175  if (l->curvalue < 0) {
1176  goto home;
1177  }
1178  if (l->curvalue < l->numItems - 1) {
1179  l->curvalue++;
1180  if (l->generic.change) {
1181  l->generic.change(&l->generic);
1182  }
1184  return QMS_MOVE;
1185  }
1186  return QMS_BEEP;
1187 
1188  case K_HOME:
1189  case K_KP_HOME:
1190  home:
1191  l->prestep = 0;
1192  l->curvalue = 0;
1193  if (l->generic.change) {
1194  l->generic.change(&l->generic);
1195  }
1196  return QMS_MOVE;
1197 
1198  case K_END:
1199  case K_KP_END:
1200  if (!l->numItems) {
1201  goto home;
1202  }
1203  if (l->numItems > l->maxItems) {
1204  l->prestep = l->numItems - l->maxItems;
1205  }
1206  l->curvalue = l->numItems - 1;
1207  if (l->generic.change) {
1208  l->generic.change(&l->generic);
1209  }
1210  return QMS_MOVE;
1211 
1212  case K_MWHEELUP:
1213  if (Key_IsDown(K_CTRL)) {
1214  l->prestep -= 4;
1215  } else {
1216  l->prestep -= 2;
1217  }
1219  return QMS_SILENT;
1220 
1221  case K_MWHEELDOWN:
1222  if (Key_IsDown(K_CTRL)) {
1223  l->prestep += 4;
1224  } else {
1225  l->prestep += 2;
1226  }
1228  return QMS_SILENT;
1229 
1230  case K_PGUP:
1231  case K_KP_PGUP:
1232  if (l->curvalue < 0) {
1233  goto home;
1234  }
1235  if (l->curvalue > 0) {
1236  l->curvalue -= l->maxItems - 1;
1237  if (l->curvalue < 0) {
1238  l->curvalue = 0;
1239  }
1240  if (l->generic.change) {
1241  l->generic.change(&l->generic);
1242  }
1244  return QMS_MOVE;
1245  }
1246  return QMS_BEEP;
1247 
1248  case K_PGDN:
1249  case K_KP_PGDN:
1250  if (l->curvalue < 0) {
1251  goto home;
1252  }
1253  if (l->curvalue < l->numItems - 1) {
1254  l->curvalue += l->maxItems - 1;
1255  if (l->curvalue > l->numItems - 1) {
1256  l->curvalue = l->numItems - 1;
1257  }
1258  if (l->generic.change) {
1259  l->generic.change(&l->generic);
1260  }
1262  return QMS_MOVE;
1263  }
1264  return QMS_BEEP;
1265 
1266  case K_MOUSE1:
1267  //case K_MOUSE2:
1268  //case K_MOUSE3:
1269  return MenuList_Click(l);
1270  }
1271 
1272  return QMS_NOTHANDLED;
1273 }

Referenced by Menu_KeyEvent().

◆ MenuList_MouseMove()

static menuSound_t MenuList_MouseMove ( menuList_t l)
static

Definition at line 1275 of file menu.c.

1276 {
1277  int y, h, barHeight;
1278 
1279  if (uis.mouseTracker != &l->generic)
1280  return QMS_NOTHANDLED;
1281 
1282  y = l->generic.y + MLIST_SPACING;
1283  h = l->generic.height;
1284 
1285  if (l->mlFlags & MLF_HEADER) {
1286  y += MLIST_SPACING;
1287  h -= MLIST_SPACING;
1288  }
1289 
1290  barHeight = h - MLIST_SPACING * 2;
1291  if (barHeight > 0) {
1292  l->prestep = (uis.mouseCoords[1] - y - l->drag_y) * l->numItems / barHeight;
1294  }
1295 
1296  return QMS_SILENT;
1297 }

Referenced by Menu_MouseMove().

◆ MenuList_NextColumn()

static menuSound_t MenuList_NextColumn ( menuList_t l)
static

Definition at line 936 of file menu.c.

937 {
938  int col;
939 
940  if (!l->sortdir || !l->numcolumns) {
941  return QMS_NOTHANDLED;
942  }
943 
944  col = l->sortcol;
945  if (col < 0)
946  return MenuList_FindColumn(l, 1);
947 
948  do {
949  if (col == l->numcolumns - 1) {
950  col = 0;
951  } else {
952  col++;
953  }
954  if (col == l->sortcol) {
955  return QMS_SILENT;
956  }
957  } while (!l->columns[col].width);
958 
959  return MenuList_SetColumn(l, col);
960 }

Referenced by MenuList_Key().

◆ MenuList_PrevColumn()

static menuSound_t MenuList_PrevColumn ( menuList_t l)
static

Definition at line 910 of file menu.c.

911 {
912  int col;
913 
914  if (!l->sortdir || !l->numcolumns) {
915  return QMS_NOTHANDLED;
916  }
917 
918  col = l->sortcol;
919  if (col < 0)
920  return MenuList_FindColumn(l, 1);
921 
922  do {
923  if (col < 0) {
924  col = l->numcolumns - 1;
925  } else {
926  col--;
927  }
928  if (col == l->sortcol) {
929  return QMS_SILENT;
930  }
931  } while (!l->columns[col].width);
932 
933  return MenuList_SetColumn(l, col);
934 }

Referenced by MenuList_Key().

◆ MenuList_SetColumn()

static menuSound_t MenuList_SetColumn ( menuList_t l,
int  value 
)
static

Definition at line 877 of file menu.c.

878 {
879  if (l->sortcol == value) {
880  l->sortdir = -l->sortdir;
881  } else {
882  l->sortcol = value;
883  l->sortdir = 1;
884  }
885  if (l->sort) {
886  l->sort(l);
887  }
888  return QMS_SILENT;
889 }

Referenced by MenuList_Click(), MenuList_FindColumn(), MenuList_NextColumn(), and MenuList_PrevColumn().

◆ MenuList_SetValue()

void MenuList_SetValue ( menuList_t l,
int  value 
)

Definition at line 860 of file menu.c.

861 {
862  if (value > l->numItems - 1)
863  value = l->numItems - 1;
864  if (value < 0)
865  value = 0;
866 
867  if (value != l->curvalue) {
868  l->curvalue = value;
869  if (l->generic.change) {
870  l->generic.change(&l->generic);
871  }
872  }
873 
875 }

Referenced by Expose(), LeaveDirectory(), and MenuList_Key().

◆ MenuList_Sort()

void MenuList_Sort ( menuList_t l,
int  offset,
int(*)(const void *, const void *)  cmpfunc 
)

Definition at line 1465 of file menu.c.

1466 {
1467  void *n;
1468  int i;
1469 
1470  if (!l->items)
1471  return;
1472 
1473  if (offset >= l->numItems)
1474  return;
1475 
1476  if (l->sortcol < 0 || l->sortcol >= l->numcolumns)
1477  return;
1478 
1479  if (l->curvalue < 0 || l->curvalue >= l->numItems)
1480  n = NULL;
1481  else
1482  n = l->items[l->curvalue];
1483 
1484  qsort(l->items + offset, l->numItems - offset, sizeof(char *), cmpfunc);
1485 
1486  for (i = 0; i < l->numItems; i++) {
1487  if (l->items[i] == n) {
1488  l->curvalue = i;
1489  break;
1490  }
1491  }
1492 
1493  if (n)
1495 }

Referenced by Sort().

◆ MenuList_ValidatePrestep()

static void MenuList_ValidatePrestep ( menuList_t l)
static

Definition at line 792 of file menu.c.

793 {
794  if (l->prestep > l->numItems - l->maxItems) {
795  l->prestep = l->numItems - l->maxItems;
796  }
797  if (l->prestep < 0) {
798  l->prestep = 0;
799  }
800 }

Referenced by MenuList_Click(), MenuList_Init(), MenuList_Key(), and MenuList_MouseMove().

◆ Pairs_Free()

static void Pairs_Free ( menuSpinControl_t s)
static

Definition at line 712 of file menu.c.

713 {
714  int i;
715 
716  Z_Free(s->generic.name);
717  Z_Free(s->generic.status);
718  for (i = 0; i < s->numItems; i++) {
719  Z_Free(s->itemnames[i]);
720  Z_Free(s->itemvalues[i]);
721  }
722  Z_Free(s->itemnames);
723  Z_Free(s->itemvalues);
724  Z_Free(s);
725 }

Referenced by Menu_Free().

◆ Pairs_Pop()

static void Pairs_Pop ( menuSpinControl_t s)
static

Definition at line 706 of file menu.c.

707 {
708  if (s->curvalue >= 0 && s->curvalue < s->numItems)
709  Cvar_SetByVar(s->cvar, s->itemvalues[s->curvalue], FROM_MENU);
710 }

Referenced by Menu_Pop().

◆ Pairs_Push()

static void Pairs_Push ( menuSpinControl_t s)
static

Definition at line 692 of file menu.c.

693 {
694  int i;
695 
696  for (i = 0; i < s->numItems; i++) {
697  if (!Q_stricmp(s->itemvalues[i], s->cvar->string)) {
698  s->curvalue = i;
699  return;
700  }
701  }
702 
703  s->curvalue = -1;
704 }

Referenced by Menu_Push().

◆ Savegame_Push()

static void Savegame_Push ( menuAction_t a)
static

Definition at line 1726 of file menu.c.

1727 {
1728  char *info;
1729 
1730  Z_Free(a->generic.name);
1731 
1732  info = SV_GetSaveInfo(a->cmd);
1733  if (info) {
1734  a->generic.name = info;
1735  a->generic.flags &= ~QMF_GRAYED;
1736  } else {
1737  a->generic.name = UI_CopyString("<EMPTY>");
1738  if (a->generic.type == MTYPE_LOADGAME)
1739  a->generic.flags |= QMF_GRAYED;
1740  }
1741 
1742  qboolean is_auto_save = strcmp(a->cmd, "save0") == 0;
1743  qboolean is_quick_save = strcmp(a->cmd, "quick") == 0;
1744  if (is_auto_save || is_quick_save)
1745  {
1746  char *new_name = va("%s - %s", a->generic.name, is_auto_save ? "Auto Save" : "Quick Save");
1747  Z_Free(a->generic.name);
1748  a->generic.name = Z_CopyString(new_name);
1749  }
1750 
1752 }

Referenced by Menu_Push().

◆ Separator_Draw()

static void Separator_Draw ( menuSeparator_t s)
static

Definition at line 1712 of file menu.c.

1713 {
1714  if (s->generic.name)
1715  UI_DrawString(s->generic.x, s->generic.y, UI_RIGHT, s->generic.name);
1716 }

Referenced by Menu_Draw().

◆ Separator_Init()

static void Separator_Init ( menuSeparator_t s)
static

Definition at line 1701 of file menu.c.

1702 {
1703  s->generic.rect.x = s->generic.rect.y = 999999;
1704  s->generic.rect.width = s->generic.rect.height = -999999;
1705 }

Referenced by Menu_Init().

◆ Slider_Click()

static menuSound_t Slider_Click ( menuSlider_t s)
static

Definition at line 1542 of file menu.c.

1543 {
1544  vrect_t rect;
1545  float pos;
1546  int x;
1547 
1548  pos = (s->curvalue - s->minvalue) / (s->maxvalue - s->minvalue);
1549  clamp(pos, 0, 1);
1550 
1551  x = CHAR_WIDTH + (SLIDER_RANGE - 1) * CHAR_WIDTH * pos;
1552 
1553  // click left of thumb
1554  rect.x = s->generic.x + RCOLUMN_OFFSET;
1555  rect.y = s->generic.y;
1556  rect.width = x;
1557  rect.height = CHAR_HEIGHT;
1558  if (UI_CursorInRect(&rect))
1559  return Slider_DoSlide(s, -1);
1560 
1561  // click on thumb
1562  rect.x = s->generic.x + RCOLUMN_OFFSET + x;
1563  rect.y = s->generic.y;
1564  rect.width = CHAR_WIDTH;
1565  rect.height = CHAR_HEIGHT;
1566  if (UI_CursorInRect(&rect)) {
1567  uis.mouseTracker = &s->generic;
1568  return QMS_SILENT;
1569  }
1570 
1571  // click right of thumb
1572  rect.x = s->generic.x + RCOLUMN_OFFSET + x + CHAR_WIDTH;
1573  rect.y = s->generic.y;
1574  rect.width = (SLIDER_RANGE + 1) * CHAR_WIDTH - x;
1575  rect.height = CHAR_HEIGHT;
1576  if (UI_CursorInRect(&rect))
1577  return Slider_DoSlide(s, 1);
1578 
1579  return QMS_SILENT;
1580 }

Referenced by Slider_Key().

◆ Slider_DoSlide()

static menuSound_t Slider_DoSlide ( menuSlider_t s,
int  dir 
)
static

Definition at line 1625 of file menu.c.

1626 {
1627  s->modified = qtrue;
1628  s->curvalue += dir * s->step;
1629 
1630  cclamp(s->curvalue, s->minvalue, s->maxvalue);
1631 
1632  if (s->generic.change) {
1633  menuSound_t sound = s->generic.change(&s->generic);
1634  if (sound != QMS_NOTHANDLED) {
1635  return sound;
1636  }
1637  }
1638 
1639  return QMS_SILENT;
1640 }

Referenced by Menu_SlideItem(), and Slider_Click().

◆ Slider_Draw()

static void Slider_Draw ( menuSlider_t s)
static

Definition at line 1647 of file menu.c.

1648 {
1649  int i, flags;
1650  float pos;
1651 
1652  flags = s->generic.uiFlags & ~(UI_LEFT | UI_RIGHT);
1653 
1654  if (s->generic.flags & QMF_HASFOCUS) {
1655  if ((uis.realtime >> 8) & 1) {
1656  UI_DrawChar(s->generic.x + RCOLUMN_OFFSET / 2, s->generic.y, s->generic.uiFlags | UI_RIGHT, 13);
1657  }
1658  }
1659 
1661  flags | UI_RIGHT | UI_ALTCOLOR, s->generic.name);
1662 
1663  UI_DrawChar(s->generic.x + RCOLUMN_OFFSET, s->generic.y, flags | UI_LEFT, 128);
1664 
1665  for (i = 0; i < SLIDER_RANGE; i++)
1666  UI_DrawChar(RCOLUMN_OFFSET + s->generic.x + i * CHAR_WIDTH + CHAR_WIDTH, s->generic.y, flags | UI_LEFT, 129);
1667 
1668  UI_DrawChar(RCOLUMN_OFFSET + s->generic.x + i * CHAR_WIDTH + CHAR_WIDTH, s->generic.y, flags | UI_LEFT, 130);
1669 
1670  pos = (s->curvalue - s->minvalue) / (s->maxvalue - s->minvalue);
1671  clamp(pos, 0, 1);
1672 
1673  UI_DrawChar(CHAR_WIDTH + RCOLUMN_OFFSET + s->generic.x + (SLIDER_RANGE - 1) * CHAR_WIDTH * pos, s->generic.y, flags | UI_LEFT, 131);
1674 
1675  float display_value = s->curvalue;
1676  if (s->percentage)
1677  display_value *= 100.f;
1678 
1679  char sbuf[16];
1680  if (s->format)
1681  snprintf(sbuf, sizeof(sbuf), s->format, display_value);
1682  else
1683  snprintf(sbuf, sizeof(sbuf), "%.1f", display_value);
1684 
1685  UI_DrawString(s->generic.x + RCOLUMN_OFFSET + CHAR_WIDTH * (SLIDER_RANGE + 3), s->generic.y, flags | UI_LEFT, sbuf);
1686 }

Referenced by Menu_Draw().

◆ Slider_Free()

static void Slider_Free ( menuSlider_t s)
static

Definition at line 1522 of file menu.c.

1523 {
1524  Z_Free(s->generic.name);
1525  Z_Free(s->generic.status);
1526  Z_Free(s->format);
1527  Z_Free(s);
1528 }

Referenced by Menu_Free().

◆ Slider_Init()

static void Slider_Init ( menuSlider_t s)
static

Definition at line 1530 of file menu.c.

1531 {
1532  int len = strlen(s->generic.name) * CHAR_WIDTH;
1533 
1534  s->generic.rect.x = s->generic.x + LCOLUMN_OFFSET - len;
1535  s->generic.rect.y = s->generic.y;
1536 
1537  s->generic.rect.width = (RCOLUMN_OFFSET - LCOLUMN_OFFSET) +
1538  len + (SLIDER_RANGE + 2) * CHAR_WIDTH;
1539  s->generic.rect.height = CHAR_HEIGHT;
1540 }

Referenced by Menu_Init().

◆ Slider_Key()

static menuSound_t Slider_Key ( menuSlider_t s,
int  key 
)
static

Definition at line 1601 of file menu.c.

1602 {
1603  switch (key) {
1604  case K_END:
1605  s->modified = qtrue;
1606  s->curvalue = s->maxvalue;
1607  return QMS_MOVE;
1608  case K_HOME:
1609  s->modified = qtrue;
1610  s->curvalue = s->minvalue;
1611  return QMS_MOVE;
1612  case K_MOUSE1:
1613  return Slider_Click(s);
1614  }
1615 
1616  return QMS_NOTHANDLED;
1617 }

Referenced by Menu_KeyEvent().

◆ Slider_MouseMove()

static menuSound_t Slider_MouseMove ( menuSlider_t s)
static

Definition at line 1582 of file menu.c.

1583 {
1584  float pos, value;
1585  int steps;
1586 
1587  if (uis.mouseTracker != &s->generic)
1588  return QMS_NOTHANDLED;
1589 
1590  pos = (uis.mouseCoords[0] - (s->generic.x + RCOLUMN_OFFSET + CHAR_WIDTH)) * (1.0f / (SLIDER_RANGE * CHAR_WIDTH));
1591  clamp(pos, 0, 1);
1592 
1593  value = pos * (s->maxvalue - s->minvalue);
1594  steps = Q_rint(value / s->step);
1595 
1596  s->modified = qtrue;
1597  s->curvalue = s->minvalue + steps * s->step;
1598  return QMS_SILENT;
1599 }

Referenced by Menu_MouseMove().

◆ Slider_Pop()

static void Slider_Pop ( menuSlider_t s)
static

Definition at line 1514 of file menu.c.

1515 {
1516  if (s->modified) {
1517  cclamp(s->curvalue, s->minvalue, s->maxvalue);
1518  Cvar_SetValue(s->cvar, s->curvalue, FROM_MENU);
1519  }
1520 }

Referenced by Menu_Pop().

◆ Slider_Push()

static void Slider_Push ( menuSlider_t s)
static

Definition at line 1507 of file menu.c.

1508 {
1509  s->modified = qfalse;
1510  s->curvalue = s->cvar->value;
1511  cclamp(s->curvalue, s->minvalue, s->maxvalue);
1512 }

Referenced by Menu_Push().

◆ SpinControl_DoEnter()

static int SpinControl_DoEnter ( menuSpinControl_t s)
static

Definition at line 578 of file menu.c.

579 {
580  if (!s->numItems)
581  return QMS_BEEP;
582 
583  s->curvalue++;
584 
585  if (s->curvalue >= s->numItems)
586  s->curvalue = 0;
587 
588  if (s->generic.change) {
589  s->generic.change(&s->generic);
590  }
591 
592  return QMS_MOVE;
593 }

Referenced by Menu_SelectItem().

◆ SpinControl_DoSlide()

static int SpinControl_DoSlide ( menuSpinControl_t s,
int  dir 
)
static

Definition at line 600 of file menu.c.

601 {
602  if (!s->numItems)
603  return QMS_BEEP;
604 
605  s->curvalue += dir;
606 
607  if (s->curvalue < 0) {
608  s->curvalue = s->numItems - 1;
609  } else if (s->curvalue >= s->numItems) {
610  s->curvalue = 0;
611  }
612 
613  if (s->generic.change) {
614  s->generic.change(&s->generic);
615  }
616 
617  return QMS_MOVE;
618 }

Referenced by Menu_SlideItem().

◆ SpinControl_Draw()

static void SpinControl_Draw ( menuSpinControl_t s)
static

Definition at line 625 of file menu.c.

626 {
627  char *name;
628 
630  s->generic.uiFlags | UI_RIGHT | UI_ALTCOLOR, s->generic.name);
631 
632  if (s->generic.flags & QMF_HASFOCUS) {
633  if ((uis.realtime >> 8) & 1) {
635  s->generic.uiFlags | UI_RIGHT, 13);
636  }
637  }
638 
639  if (s->curvalue < 0 || s->curvalue >= s->numItems)
640  name = "???";
641  else
642  name = s->itemnames[s->curvalue];
643 
645  s->generic.uiFlags, name);
646 }

Referenced by Menu_Draw().

◆ SpinControl_Free()

static void SpinControl_Free ( menuSpinControl_t s)
static

Definition at line 524 of file menu.c.

525 {
526  int i;
527 
528  Z_Free(s->generic.name);
529  Z_Free(s->generic.status);
530  for (i = 0; i < s->numItems; i++) {
531  Z_Free(s->itemnames[i]);
532  }
533  Z_Free(s->itemnames);
534  Z_Free(s);
535 }

Referenced by Menu_Free().

◆ SpinControl_Init()

void SpinControl_Init ( menuSpinControl_t s)

Definition at line 543 of file menu.c.

544 {
545  char **n;
546  int maxLength, length;
547 
548  s->generic.uiFlags &= ~(UI_LEFT | UI_RIGHT);
549 
550  s->generic.rect.x = s->generic.x + LCOLUMN_OFFSET;
551  s->generic.rect.y = s->generic.y;
552 
554  s->generic.uiFlags | UI_RIGHT, s->generic.name);
555 
556  maxLength = 0;
557  s->numItems = 0;
558  n = s->itemnames;
559  while (*n) {
560  length = strlen(*n);
561 
562  if (maxLength < length) {
563  maxLength = length;
564  }
565  s->numItems++;
566  n++;
567  }
568 
569  s->generic.rect.width += (RCOLUMN_OFFSET - LCOLUMN_OFFSET) +
570  maxLength * CHAR_WIDTH;
571 }

Referenced by Change(), and Menu_Init().

◆ SpinControl_Pop()

static void SpinControl_Pop ( menuSpinControl_t s)
static

Definition at line 518 of file menu.c.

519 {
520  if (s->curvalue >= 0 && s->curvalue < s->numItems)
521  Cvar_SetInteger(s->cvar, s->curvalue, FROM_MENU);
522 }

Referenced by Menu_Pop().

◆ SpinControl_Push()

static void SpinControl_Push ( menuSpinControl_t s)
static

Definition at line 508 of file menu.c.

509 {
510  int val = s->cvar->integer;
511 
512  if (val < 0 || val >= s->numItems)
513  s->curvalue = -1;
514  else
515  s->curvalue = val;
516 }

Referenced by Menu_Push().

◆ Static_Draw()

static void Static_Draw ( menuStatic_t s)
static

Definition at line 127 of file menu.c.

128 {
129  if (s->generic.flags & QMF_CUSTOM_COLOR) {
130  R_SetColor(s->generic.color.u32);
131  }
133  if (s->generic.flags & QMF_CUSTOM_COLOR) {
134  R_ClearColor();
135  }
136 }

Referenced by Menu_Draw().

◆ Static_Init()

static void Static_Init ( menuStatic_t s)
static

Definition at line 105 of file menu.c.

106 {
107  if (!s->generic.name) {
108  Com_Error(ERR_FATAL, "Static_Init: NULL s->generic.name");
109  }
110 
111  if (!s->maxChars) {
112  s->maxChars = MAX_STRING_CHARS;
113  }
114 
115  s->generic.rect.x = s->generic.x;
116  s->generic.rect.y = s->generic.y;
117 
119  s->generic.uiFlags, s->generic.name);
120 }

Referenced by Menu_Init().

◆ Strings_Pop()

static void Strings_Pop ( menuSpinControl_t s)
static

Definition at line 749 of file menu.c.

750 {
751  if (s->curvalue >= 0 && s->curvalue < s->numItems)
752  Cvar_SetByVar(s->cvar, s->itemnames[s->curvalue], FROM_MENU);
753 }

Referenced by Menu_Pop().

◆ Strings_Push()

static void Strings_Push ( menuSpinControl_t s)
static

Definition at line 735 of file menu.c.

736 {
737  int i;
738 
739  for (i = 0; i < s->numItems; i++) {
740  if (!Q_stricmp(s->itemnames[i], s->cvar->string)) {
741  s->curvalue = i;
742  return;
743  }
744  }
745 
746  s->curvalue = -1;
747 }

Referenced by Menu_Push().

◆ Toggle_Pop()

static void Toggle_Pop ( menuSpinControl_t s)
static

Definition at line 773 of file menu.c.

774 {
775  if (s->curvalue == 0 || s->curvalue == 1)
776  Cvar_SetInteger(s->cvar, s->curvalue ^ s->negate, FROM_MENU);
777 }

Referenced by Menu_Pop().

◆ Toggle_Push()

static void Toggle_Push ( menuSpinControl_t s)
static

Definition at line 763 of file menu.c.

764 {
765  int val = s->cvar->integer;
766 
767  if (val == 0 || val == 1)
768  s->curvalue = val ^ s->negate;
769  else
770  s->curvalue = -1;
771 }

Referenced by Menu_Push().

◆ UI_AddRectToBounds()

static void UI_AddRectToBounds ( const vrect_t *  rc,
int  mins[2],
int  maxs[2] 
)
static

Definition at line 1802 of file menu.c.

1803 {
1804  if (mins[0] > rc->x) {
1805  mins[0] = rc->x;
1806  } else if (maxs[0] < rc->x + rc->width) {
1807  maxs[0] = rc->x + rc->width;
1808  }
1809 
1810  if (mins[1] > rc->y) {
1811  mins[1] = rc->y;
1812  } else if (maxs[1] < rc->y + rc->height) {
1813  maxs[1] = rc->y + rc->height;
1814  }
1815 }

Referenced by Menu_Init().

◆ UI_ClearBounds()

static void UI_ClearBounds ( int  mins[2],
int  maxs[2] 
)
static

Definition at line 1796 of file menu.c.

1797 {
1798  mins[0] = mins[1] = 9999;
1799  maxs[0] = maxs[1] = -9999;
1800 }

Referenced by Menu_Init().

menuCondition_s::value
int value
Definition: ui.h:94
menuList_s::sortcol
int sortcol
Definition: ui.h:224
menuCommon_s
Definition: ui.h:140
MTYPE_TOGGLE
@ MTYPE_TOGGLE
Definition: ui.h:51
menuFrameWork_s::title
char * title
Definition: ui.h:101
menuList_s::columns
menuListColumn_t columns[MAX_COLUMNS]
Definition: ui.h:222
Strings_Pop
static void Strings_Pop(menuSpinControl_t *s)
Definition: menu.c:749
R_SetColor
void(* R_SetColor)(uint32_t color)
Definition: refresh.c:413
uiStatic_s::fontHandle
qhandle_t fontHandle
Definition: ui.h:307
QMS_NOTHANDLED
@ QMS_NOTHANDLED
Definition: ui.h:68
menuFrameWork_s::mins
int mins[2]
Definition: ui.h:114
menuCommon_s::change
menuSound_t(* change)(struct menuCommon_s *)
Definition: ui.h:158
uiStatic_s::mouseTracker
menuCommon_t * mouseTracker
Definition: ui.h:297
menuFrameWork_s::status
char * status
Definition: ui.h:101
MenuList_Key
static menuSound_t MenuList_Key(menuList_t *l, int key)
Definition: menu.c:1100
MTYPE_SEPARATOR
@ MTYPE_SEPARATOR
Definition: ui.h:45
Slider_Free
static void Slider_Free(menuSlider_t *s)
Definition: menu.c:1522
menuCommon_s::type
menuType_t type
Definition: ui.h:141
menuCommon_s::keydown
menuSound_t(* keydown)(struct menuCommon_s *, int key)
Definition: ui.h:159
menuCommon_s::focus
menuSound_t(* focus)(struct menuCommon_s *, qboolean gain)
Definition: ui.h:160
menuKeybind_s::cmd
char * cmd
Definition: ui.h:266
menuFrameWork_s::name
char * name
Definition: ui.h:101
menuAction_s::cmd
char * cmd
Definition: ui.h:244
height
static int height
Definition: physical_sky.c:39
MenuList_NextColumn
static menuSound_t MenuList_NextColumn(menuList_t *l)
Definition: menu.c:936
MenuList_SetColumn
static menuSound_t MenuList_SetColumn(menuList_t *l, int value)
Definition: menu.c:877
Slider_Key
static menuSound_t Slider_Key(menuSlider_t *s, int key)
Definition: menu.c:1601
MTYPE_STRINGS
@ MTYPE_STRINGS
Definition: ui.h:49
CURSOR_OFFSET
#define CURSOR_OFFSET
Definition: ui.h:285
menuCondition_s::cvar
cvar_t * cvar
Definition: ui.h:93
menuList_s::generic
menuCommon_t generic
Definition: ui.h:204
MTYPE_VALUES
@ MTYPE_VALUES
Definition: ui.h:50
SpinControl_Pop
static void SpinControl_Pop(menuSpinControl_t *s)
Definition: menu.c:518
MTYPE_KEYBIND
@ MTYPE_KEYBIND
Definition: ui.h:53
menuFrameWork_s::size
void(* size)(struct menuFrameWork_s *)
Definition: ui.h:135
Action_Draw
static void Action_Draw(menuAction_t *a)
Definition: menu.c:65
menuCommon_s::activate
menuSound_t(* activate)(struct menuCommon_s *)
Definition: ui.h:157
menuCommon_s::height
int height
Definition: ui.h:150
menuSlider_s::modified
qboolean modified
Definition: ui.h:175
menuSpinControl_s::cvar
cvar_t * cvar
Definition: ui.h:231
MenuList_Draw
static void MenuList_Draw(menuList_t *l)
Definition: menu.c:1333
Keybind_Remove
static void Keybind_Remove(const char *cmd)
Definition: menu.c:297
SpinControl_DoEnter
static int SpinControl_DoEnter(menuSpinControl_t *s)
Definition: menu.c:578
menuFrameWork_s::logo_rc
vrect_t logo_rc
Definition: ui.h:124
Action_Init
static void Action_Init(menuAction_t *a)
Definition: menu.c:44
R_ClearColor
void(* R_ClearColor)(void)
Definition: refresh.c:410
Slider_Pop
static void Slider_Pop(menuSlider_t *s)
Definition: menu.c:1514
Slider_Push
static void Slider_Push(menuSlider_t *s)
Definition: menu.c:1507
uiStatic_s::height
int height
Definition: ui.h:292
DOUBLE_CLICK_DELAY
#define DOUBLE_CLICK_DELAY
Definition: ui.h:83
menuKeybind_s
Definition: ui.h:262
menuList_s::numcolumns
int numcolumns
Definition: ui.h:223
menuFrameWork_s::logo
qhandle_t logo
Definition: ui.h:123
MTYPE_SAVEGAME
@ MTYPE_SAVEGAME
Definition: ui.h:55
MenuList_AdjustPrestep
static void MenuList_AdjustPrestep(menuList_t *l)
Definition: menu.c:802
menuField_s::generic
menuCommon_t generic
Definition: ui.h:164
BitField_Push
static void BitField_Push(menuSpinControl_t *s)
Definition: menu.c:656
menuAction_s::generic
menuCommon_t generic
Definition: ui.h:243
BitField_Free
static void BitField_Free(menuSpinControl_t *s)
Definition: menu.c:677
Keybind_Init
static void Keybind_Init(menuKeybind_t *k)
Definition: menu.c:194
Pairs_Push
static void Pairs_Push(menuSpinControl_t *s)
Definition: menu.c:692
UI_DrawChar
void UI_DrawChar(int x, int y, int flags, int ch)
Definition: ui.c:325
Menu_SelectItem
menuSound_t Menu_SelectItem(menuFrameWork_t *s)
Definition: menu.c:2298
menuFrameWork_s::image
qhandle_t image
Definition: ui.h:110
menuField_s::cvar
cvar_t * cvar
Definition: ui.h:166
menuCommon_s::parent
menuFrameWork_t * parent
Definition: ui.h:144
menuSlider_s::minvalue
float minvalue
Definition: ui.h:177
menuKeybind_s::altstatus
char * altstatus
Definition: ui.h:267
Field_Draw
static void Field_Draw(menuField_t *f)
Definition: menu.c:424
QMS_SILENT
@ QMS_SILENT
Definition: ui.h:69
menuKeybind_s::altbinding
char altbinding[32]
Definition: ui.h:265
Slider_Click
static menuSound_t Slider_Click(menuSlider_t *s)
Definition: menu.c:1542
Keybind_Update
static void Keybind_Update(menuFrameWork_t *menu)
Definition: menu.c:283
menuSlider_s::cvar
cvar_t * cvar
Definition: ui.h:174
Key_EnumBindings
int Key_EnumBindings(int key, const char *binding)
Definition: keys.c:320
SpinControl_Draw
static void SpinControl_Draw(menuSpinControl_t *s)
Definition: menu.c:625
MenuList_PrevColumn
static menuSound_t MenuList_PrevColumn(menuList_t *l)
Definition: menu.c:910
menuCommon_s::rect
vrect_t rect
Definition: ui.h:146
UI_GetColumn
char * UI_GetColumn(char *s, int n)
Definition: ui.c:281
menuFrameWork_s::footer_rc
vrect_t footer_rc
Definition: ui.h:127
UI_ClearBounds
static void UI_ClearBounds(int mins[2], int maxs[2])
Definition: menu.c:1796
menuFrameWork_s
Definition: ui.h:98
Menu_SetFocus
void Menu_SetFocus(menuCommon_t *focus)
Definition: menu.c:2057
menuFrameWork_s::banner
qhandle_t banner
Definition: ui.h:117
menuFrameWork_s::nitems
int nitems
Definition: ui.h:103
menuList_s::maxItems
int maxItems
Definition: ui.h:208
menuList_s::mlFlags
int mlFlags
Definition: ui.h:209
Static_Init
static void Static_Init(menuStatic_t *s)
Definition: menu.c:105
Strings_Push
static void Strings_Push(menuSpinControl_t *s)
Definition: menu.c:735
MTYPE_BITMAP
@ MTYPE_BITMAP
Definition: ui.h:54
menuList_s::items
void ** items
Definition: ui.h:206
menuBitmap_s::pics
qhandle_t pics[2]
Definition: ui.h:258
MTYPE_STATIC
@ MTYPE_STATIC
Definition: ui.h:52
menuSlider_s::format
char * format
Definition: ui.h:181
Keybind_Key
static menuSound_t Keybind_Key(menuKeybind_t *k, int key)
Definition: menu.c:349
Savegame_Push
static void Savegame_Push(menuAction_t *a)
Definition: menu.c:1726
UI_AddRectToBounds
static void UI_AddRectToBounds(const vrect_t *rc, int mins[2], int maxs[2])
Definition: menu.c:1802
Keybind_DoEnter
static menuSound_t Keybind_DoEnter(menuKeybind_t *k)
Definition: menu.c:339
Bitmap_Init
static void Bitmap_Init(menuBitmap_t *b)
Definition: menu.c:153
Keybind_Draw
static void Keybind_Draw(menuKeybind_t *k)
Definition: menu.c:226
GENERIC_SPACING
#define GENERIC_SPACING(x)
Definition: ui.h:79
MTYPE_SPINCONTROL
@ MTYPE_SPINCONTROL
Definition: ui.h:44
Menu_HitTest
menuCommon_t * Menu_HitTest(menuFrameWork_t *menu)
Definition: menu.c:2480
uiStatic_s::bitmapCursors
qhandle_t bitmapCursors[NUM_CURSOR_FRAMES]
Definition: ui.h:311
UI_PopMenu
void UI_PopMenu(void)
Definition: ui.c:143
menuFrameWork_s::maxs
int maxs[2]
Definition: ui.h:115
Field_Push
static void Field_Push(menuField_t *f)
Definition: menu.c:375
MLIST_SCROLLBAR_WIDTH
#define MLIST_SCROLLBAR_WIDTH
Definition: ui.h:189
width
static int width
Definition: physical_sky.c:38
menuCommon_s::width
int width
Definition: ui.h:150
RCOLUMN_OFFSET
#define RCOLUMN_OFFSET
Definition: ui.h:76
QMS_MOVE
@ QMS_MOVE
Definition: ui.h:71
menuStatic_s::maxChars
int maxChars
Definition: ui.h:253
uis
uiStatic_t uis
Definition: ui.c:24
menuListColumn_s::uiFlags
int uiFlags
Definition: ui.h:200
Menu_DrawStatus
static void Menu_DrawStatus(menuFrameWork_t *menu)
Definition: menu.c:2148
Com_Error
void Com_Error(error_type_t type, const char *fmt,...)
Definition: g_main.c:258
menuCondition_s
Definition: ui.h:92
Bitmap_Draw
static void Bitmap_Draw(menuBitmap_t *b)
Definition: menu.c:161
menuListColumn_s::width
int width
Definition: ui.h:199
Slider_Draw
static void Slider_Draw(menuSlider_t *s)
Definition: menu.c:1647
QMF_HASFOCUS
#define QMF_HASFOCUS
Definition: ui.h:62
menuSlider_s::step
float step
Definition: ui.h:180
menuList_s::clickTime
int clickTime
Definition: ui.h:214
menuList_s::sort
menuSound_t(* sort)(struct menuList_s *)
Definition: ui.h:226
SpinControl_Free
static void SpinControl_Free(menuSpinControl_t *s)
Definition: menu.c:524
ui_debug
cvar_t * ui_debug
Definition: ui.c:28
menuList_s::drag_y
int drag_y
Definition: ui.h:220
Action_Free
static void Action_Free(menuAction_t *a)
Definition: menu.c:31
UI_StartSound
void UI_StartSound(menuSound_t sound)
Definition: ui.c:478
menuSlider_s::curvalue
float curvalue
Definition: ui.h:179
Cvar_SetValue
void Cvar_SetValue(cvar_t *var, float value, from_t from)
Definition: cvar.c:487
menuCommon_s::x
int x
Definition: ui.h:149
va
char * va(const char *format,...)
Definition: shared.c:429
UI_StringDimensions
void UI_StringDimensions(vrect_t *rc, int flags, const char *string)
Definition: ui.c:330
Z_Free
void Z_Free(void *ptr)
Definition: zone.c:147
Toggle_Pop
static void Toggle_Pop(menuSpinControl_t *s)
Definition: menu.c:773
R_DrawPic
void(* R_DrawPic)(int x, int y, qhandle_t pic)
Definition: refresh.c:419
Field_Free
static void Field_Free(menuField_t *f)
Definition: menu.c:386
menuList_s::sortdir
int sortdir
Definition: ui.h:224
Menu_DefaultKey
static menuSound_t Menu_DefaultKey(menuFrameWork_t *m, int key)
Definition: menu.c:2398
UI_CopyString
#define UI_CopyString(s)
Definition: ui.h:35
Key_IsDown
int Key_IsDown(int key)
Definition: keys.c:204
m
static struct mdfour * m
Definition: mdfour.c:32
QMS_OUT
@ QMS_OUT
Definition: ui.h:72
Keybind_Free
static void Keybind_Free(menuKeybind_t *k)
Definition: menu.c:180
Key_SetBinding
void Key_SetBinding(int keynum, const char *binding)
Definition: keys.c:341
MTYPE_ACTION
@ MTYPE_ACTION
Definition: ui.h:43
UI_DrawString
void UI_DrawString(int x, int y, int flags, const char *string)
Definition: ui.c:314
R_DrawString
int(* R_DrawString)(int x, int y, int flags, size_t maxChars, const char *string, qhandle_t font)
Definition: refresh.c:417
QMF_NUMBERSONLY
#define QMF_NUMBERSONLY
Definition: ui.h:61
Field_Char
static int Field_Char(menuField_t *f, int key)
Definition: menu.c:484
Field_Init
static void Field_Init(menuField_t *f)
Definition: menu.c:398
menuFrameWork_s::footer
qhandle_t footer
Definition: ui.h:126
menuSlider_s::generic
menuCommon_t generic
Definition: ui.h:173
menuSpinControl_s::generic
menuCommon_t generic
Definition: ui.h:230
menuField_s::width
int width
Definition: ui.h:167
menuFrameWork_s::compact
qboolean compact
Definition: ui.h:106
menuSound_t
menuSound_t
Definition: ui.h:67
menuList_s::scratch
char scratch[8]
Definition: ui.h:216
Menu_SlideItem
menuSound_t Menu_SlideItem(menuFrameWork_t *s, int dir)
Definition: menu.c:2330
Cvar_SetByVar
void Cvar_SetByVar(cvar_t *var, const char *value, from_t from)
Definition: cvar.c:345
menuFrameWork_s::plaque_rc
vrect_t plaque_rc
Definition: ui.h:121
menuFrameWork_s::plaque
qhandle_t plaque
Definition: ui.h:120
menuList_s::numItems
int numItems
Definition: ui.h:207
menuList_s::scratchCount
int scratchCount
Definition: ui.h:217
Key_KeynumToString
char * Key_KeynumToString(int keynum)
Definition: keys.c:259
UI_DrawRect8
void UI_DrawRect8(const vrect_t *rc, int border, int c)
Definition: ui.c:342
QMF_DISABLED
#define QMF_DISABLED
Definition: ui.h:64
MTYPE_PAIRS
@ MTYPE_PAIRS
Definition: ui.h:48
MAXMENUITEMS
#define MAXMENUITEMS
Definition: ui.h:37
Cvar_SetInteger
void Cvar_SetInteger(cvar_t *var, int value, from_t from)
Definition: cvar.c:509
menuList_s::extrasize
int extrasize
Definition: ui.h:210
R_DrawFill32
void(* R_DrawFill32)(int x, int y, int w, int h, uint32_t color)
Definition: refresh.c:423
Menu_Size
void Menu_Size(menuFrameWork_t *menu)
Definition: menu.c:1928
menuCondition_s::equals
qboolean equals
Definition: ui.h:95
MenuList_DrawString
static void MenuList_DrawString(int x, int y, int flags, menuListColumn_t *column, const char *string)
Definition: menu.c:1304
menuSpinControl_s::itemnames
char ** itemnames
Definition: ui.h:233
menuSpinControl_s::itemvalues
char ** itemvalues
Definition: ui.h:234
menuKeybind_s::binding
char binding[32]
Definition: ui.h:264
IF_Replace
void IF_Replace(inputField_t *field, const char *text)
Definition: field.c:67
Menu_AdjustCursor
menuSound_t Menu_AdjustCursor(menuFrameWork_t *m, int dir)
Definition: menu.c:2101
MLF_SCROLLBAR
#define MLF_SCROLLBAR
Definition: ui.h:194
menuCommon_s::y
int y
Definition: ui.h:149
menuFrameWork_s::color
color_t color
Definition: ui.h:111
MLF_HEADER
#define MLF_HEADER
Definition: ui.h:193
QMS_BEEP
@ QMS_BEEP
Definition: ui.h:73
LCOLUMN_OFFSET
#define LCOLUMN_OFFSET
Definition: ui.h:77
uiStatic_s::selection
color_t selection
Definition: ui.h:317
MenuList_ValidatePrestep
static void MenuList_ValidatePrestep(menuList_t *l)
Definition: menu.c:792
menuKeybind_s::generic
menuCommon_t generic
Definition: ui.h:263
MTYPE_LOADGAME
@ MTYPE_LOADGAME
Definition: ui.h:56
QMF_CUSTOM_COLOR
#define QMF_CUSTOM_COLOR
Definition: ui.h:65
MLIST_PRESTEP
#define MLIST_PRESTEP
Definition: ui.h:190
Keybind_Push
static void Keybind_Push(menuKeybind_t *k)
Definition: menu.c:262
menuSpinControl_s
Definition: ui.h:229
Slider_Init
static void Slider_Init(menuSlider_t *s)
Definition: menu.c:1530
uiStatic_s::color
struct uiStatic_s::@9 color
SpinControl_DoSlide
static int SpinControl_DoSlide(menuSpinControl_t *s, int dir)
Definition: menu.c:600
menuCommon_s::flags
int flags
Definition: ui.h:152
menuFrameWork_s::y1
int y1
Definition: ui.h:112
MLIST_SPACING
#define MLIST_SPACING
Definition: ui.h:187
uiStatic_s::disabled
color_t disabled
Definition: ui.h:318
uiStatic_s::mouseCoords
int mouseCoords[2]
Definition: ui.h:298
Field_TestKey
static qboolean Field_TestKey(menuField_t *f, int key)
Definition: menu.c:452
menuListColumn_s::name
char * name
Definition: ui.h:198
menuCommon_s::name
char * name
Definition: ui.h:143
menuSlider_s::percentage
qboolean percentage
Definition: ui.h:182
uiStatic_s::normal
color_t normal
Definition: ui.h:315
Separator_Draw
static void Separator_Draw(menuSeparator_t *s)
Definition: menu.c:1712
menuFrameWork_s::banner_rc
vrect_t banner_rc
Definition: ui.h:118
uiStatic_s::width
int width
Definition: ui.h:292
menuFrameWork_s::items
void * items[MAXMENUITEMS]
Definition: ui.h:104
menuList_s
Definition: ui.h:203
R_SetClipRect
void(* R_SetClipRect)(const clipRect_t *clip)
Definition: refresh.c:414
uiStatic_s::active
color_t active
Definition: ui.h:316
uiStatic_s::realtime
int realtime
Definition: ui.h:291
R_DrawStretchPic
void(* R_DrawStretchPic)(int x, int y, int w, int h, qhandle_t pic)
Definition: refresh.c:420
QMF_HIDDEN
#define QMF_HIDDEN
Definition: ui.h:63
MTYPE_FIELD
@ MTYPE_FIELD
Definition: ui.h:46
Field_Pop
static void Field_Pop(menuField_t *f)
Definition: menu.c:381
Pairs_Pop
static void Pairs_Pop(menuSpinControl_t *s)
Definition: menu.c:706
UI_CursorInRect
qboolean UI_CursorInRect(vrect_t *rect)
Definition: ui.c:297
Common_DoEnter
static int Common_DoEnter(menuCommon_t *item)
Definition: menu.c:1767
menuSpinControl_s::numItems
int numItems
Definition: ui.h:235
QMS_IN
@ QMS_IN
Definition: ui.h:70
UI_IsItemSelectable
#define UI_IsItemSelectable(item)
Definition: ui.h:85
MLF_COLOR
#define MLF_COLOR
Definition: ui.h:195
MTYPE_LIST
@ MTYPE_LIST
Definition: ui.h:42
Separator_Init
static void Separator_Init(menuSeparator_t *s)
Definition: menu.c:1701
NUM_CURSOR_FRAMES
#define NUM_CURSOR_FRAMES
Definition: ui.h:287
menuSlider_s
Definition: ui.h:172
menuBitmap_s::generic
menuCommon_t generic
Definition: ui.h:257
color
static vec4_t color
Definition: mesh.c:33
SV_GetSaveInfo
char * SV_GetSaveInfo(const char *dir)
Definition: save.c:260
menuFrameWork_s::current_condition
menuCondition_t current_condition
Definition: ui.h:129
Menu_ItemAtCursor
menuCommon_t * Menu_ItemAtCursor(menuFrameWork_t *m)
Definition: menu.c:2042
Toggle_Push
static void Toggle_Push(menuSpinControl_t *s)
Definition: menu.c:763
Slider_DoSlide
static menuSound_t Slider_DoSlide(menuSlider_t *s, int dir)
Definition: menu.c:1625
Q_concat
size_t Q_concat(char *dest, size_t size,...)
Definition: shared.c:758
menuSeparator_s::generic
menuCommon_t generic
Definition: ui.h:248
Pairs_Free
static void Pairs_Free(menuSpinControl_t *s)
Definition: menu.c:712
MTYPE_BITFIELD
@ MTYPE_BITFIELD
Definition: ui.h:47
menuCommon_s::status
char * status
Definition: ui.h:147
Field_Key
static int Field_Key(menuField_t *f, int key)
Definition: menu.c:466
menuList_s::prestep
int prestep
Definition: ui.h:212
MenuList_SetValue
void MenuList_SetValue(menuList_t *l, int value)
Definition: menu.c:860
menuSpinControl_s::mask
int mask
Definition: ui.h:238
SpinControl_Push
static void SpinControl_Push(menuSpinControl_t *s)
Definition: menu.c:508
MenuList_MouseMove
static menuSound_t MenuList_MouseMove(menuList_t *l)
Definition: menu.c:1275
keybind_cb
static qboolean keybind_cb(void *arg, int key)
Definition: menu.c:310
MTYPE_SLIDER
@ MTYPE_SLIDER
Definition: ui.h:41
Key_WaitKey
void Key_WaitKey(keywaitcb_t wait, void *arg)
Definition: keys.c:899
menuFrameWork_s::y2
int y2
Definition: ui.h:112
CURSOR_WIDTH
#define CURSOR_WIDTH
Definition: ui.h:284
IF_Init
void IF_Init(inputField_t *field, size_t visibleChars, size_t maxChars)
Definition: field.c:36
menuCommon_s::color
color_t color
Definition: ui.h:145
Slider_MouseMove
static menuSound_t Slider_MouseMove(menuSlider_t *s)
Definition: menu.c:1582
menuCommon_s::uiFlags
int uiFlags
Definition: ui.h:153
menuSlider_s::maxvalue
float maxvalue
Definition: ui.h:178
BitField_Pop
static void BitField_Pop(menuSpinControl_t *s)
Definition: menu.c:665
menuSpinControl_s::curvalue
int curvalue
Definition: ui.h:236
Keybind_Pop
static void Keybind_Pop(menuKeybind_t *k)
Definition: menu.c:278
MenuList_Init
void MenuList_Init(menuList_t *l)
Definition: menu.c:820
QMF_GRAYED
#define QMF_GRAYED
Definition: ui.h:60
Menu_KeyEvent
menuSound_t Menu_KeyEvent(menuCommon_t *item, int key)
Definition: menu.c:2353
MenuList_Click
static menuSound_t MenuList_Click(menuList_t *l)
Definition: menu.c:967
SLIDER_RANGE
#define SLIDER_RANGE
Definition: ui.h:170
SpinControl_Init
void SpinControl_Init(menuSpinControl_t *s)
Definition: menu.c:543
menuList_s::scratchTime
int scratchTime
Definition: ui.h:218
menuFrameWork_s::keydown
menuSound_t(* keydown)(struct menuFrameWork_s *, int)
Definition: ui.h:137
menuList_s::curvalue
int curvalue
Definition: ui.h:213
menuBitmap_s::cmd
char * cmd
Definition: ui.h:259
menuFrameWork_s::keywait
qboolean keywait
Definition: ui.h:108
Bitmap_Free
static void Bitmap_Free(menuBitmap_t *b)
Definition: menu.c:146
menuStatic_s::generic
menuCommon_t generic
Definition: ui.h:252
menuSpinControl_s::negate
qboolean negate
Definition: ui.h:239
menuField_s
Definition: ui.h:163
menuField_s::field
inputField_t field
Definition: ui.h:165
Static_Draw
static void Static_Draw(menuStatic_t *s)
Definition: menu.c:127
MENU_SPACING
#define MENU_SPACING
Definition: ui.h:81
MenuList_FindColumn
static menuSound_t MenuList_FindColumn(menuList_t *l, int rel)
Definition: menu.c:892