Quake II RTX doxygen  1.0 dev
script.c File Reference
#include "ui.h"
#include "common/files.h"

Go to the source code of this file.

Macros

#define CHECK_NITEMS
 

Functions

static menuSound_t Activate (menuCommon_t *self)
 
static void Parse_Spin (menuFrameWork_t *menu, menuType_t type)
 
static void Parse_Pairs (menuFrameWork_t *menu)
 
static void Parse_Range (menuFrameWork_t *menu)
 
static void Parse_Action (menuFrameWork_t *menu)
 
static void Parse_Bitmap (menuFrameWork_t *menu)
 
static void Parse_Bind (menuFrameWork_t *menu)
 
static void Parse_Savegame (menuFrameWork_t *menu, menuType_t type)
 
static void Parse_Toggle (menuFrameWork_t *menu)
 
static void Parse_Field (menuFrameWork_t *menu)
 
static void Parse_Blank (menuFrameWork_t *menu)
 
static void Parse_Background (menuFrameWork_t *menu)
 
static void Parse_Style (menuFrameWork_t *menu)
 
static void Parse_Color (void)
 
static void Parse_Plaque (menuFrameWork_t *menu)
 
static void Parse_Banner (menuFrameWork_t *menu)
 
static void Parse_Footer (menuFrameWork_t *menu)
 
static void Parse_If (menuFrameWork_t *menu, qboolean equals)
 
static qboolean Parse_File (const char *path, int depth)
 
void UI_LoadScript (void)
 

Variables

static const cmd_option_t o_common []
 
static const cmd_option_t o_range []
 

Macro Definition Documentation

◆ CHECK_NITEMS

#define CHECK_NITEMS
Value:
if (menu->nitems >= MAXMENUITEMS) { \
Com_Printf("Too many items\n"); \
return; \
}

Definition at line 47 of file script.c.

Function Documentation

◆ Activate()

static menuSound_t Activate ( menuCommon_t self)
static

Definition at line 23 of file script.c.

24 {
25  switch (self->type) {
26  case MTYPE_ACTION:
27  if (strcmp(((menuAction_t *)self)->cmd, "_ignore")) {
28  Cbuf_AddText(&cmd_buffer, ((menuAction_t *)self)->cmd);
29  }
30  break;
31  case MTYPE_BITMAP:
32  Cbuf_AddText(&cmd_buffer, ((menuBitmap_t *)self)->cmd);
33  break;
34  case MTYPE_SAVEGAME:
35  Cbuf_AddText(&cmd_buffer, va("save \"%s\"; forcemenuoff\n", ((menuAction_t *)self)->cmd));
36  break;
37  case MTYPE_LOADGAME:
38  Cbuf_AddText(&cmd_buffer, va("load \"%s\"\n", ((menuAction_t *)self)->cmd));
39  break;
40  default:
41  break;
42  }
43 
44  return QMS_NOTHANDLED;
45 }

Referenced by Parse_Action(), Parse_Bitmap(), and Parse_Savegame().

◆ Parse_Action()

static void Parse_Action ( menuFrameWork_t menu)
static

Definition at line 192 of file script.c.

193 {
194  static const cmd_option_t o_action[] = {
195  { "a", "align" },
196  { "s:", "status" },
197  { NULL }
198  };
199  menuAction_t *a;
200  int uiFlags = UI_CENTER;
201  char *status = NULL;
202  int c;
203 
204  while ((c = Cmd_ParseOptions(o_action)) != -1) {
205  switch (c) {
206  case 'a':
207  uiFlags = UI_LEFT | UI_ALTCOLOR;
208  break;
209  case 's':
210  status = cmd_optarg;
211  break;
212  default:
213  return;
214  }
215  }
216 
217  if (Cmd_Argc() - cmd_optind < 2) {
218  Com_Printf("Usage: %s <name> <command>\n", Cmd_Argv(0));
219  return;
220  }
221 
223 
224  a = UI_Mallocz(sizeof(*a));
225  a->generic.type = MTYPE_ACTION;
226  a->generic.name = UI_CopyString(Cmd_Argv(cmd_optind));
227  a->generic.activate = Activate;
228  a->generic.uiFlags = uiFlags;
229  a->generic.status = UI_CopyString(status);
230  a->cmd = UI_CopyString(Cmd_ArgsFrom(cmd_optind + 1));
231 
232  Menu_AddItem(menu, a);
233 }

Referenced by Parse_File().

◆ Parse_Background()

static void Parse_Background ( menuFrameWork_t menu)
static

Definition at line 480 of file script.c.

481 {
482  char *s = Cmd_Argv(1);
483 
484  if (SCR_ParseColor(s, &menu->color)) {
485  menu->image = 0;
486  menu->transparent = menu->color.u8[3] != 255;
487  } else {
488  menu->image = R_RegisterPic(s);
489  menu->transparent = R_GetPicSize(NULL, NULL, menu->image);
490  }
491 }

Referenced by Parse_File().

◆ Parse_Banner()

static void Parse_Banner ( menuFrameWork_t menu)
static

Definition at line 571 of file script.c.

572 {
573  if (Cmd_Argc() < 2) {
574  Com_Printf("Usage: %s <banner>\n", Cmd_Argv(0));
575  return;
576  }
577 
578  menu->banner = R_RegisterPic(Cmd_Argv(1));
579  if (menu->banner) {
580  R_GetPicSize(&menu->banner_rc.width,
581  &menu->banner_rc.height, menu->banner);
582  }
583 }

Referenced by Parse_File().

◆ Parse_Bind()

static void Parse_Bind ( menuFrameWork_t menu)
static

Definition at line 281 of file script.c.

282 {
283  static const cmd_option_t o_bind[] = {
284  { "s:", "status" },
285  { "S:", "altstatus" },
286  { NULL }
287  };
288  menuKeybind_t *k;
289  char *status = "Press Enter to change, Backspace to clear";
290  char *altstatus = "Press the desired key, Escape to cancel";
291  int c;
292 
293  while ((c = Cmd_ParseOptions(o_bind)) != -1) {
294  switch (c) {
295  case 's':
296  status = cmd_optarg;
297  break;
298  case 'S':
299  altstatus = cmd_optarg;
300  break;
301  default:
302  return;
303  }
304  }
305 
306  if (Cmd_Argc() - cmd_optind < 2) {
307  Com_Printf("Usage: %s <name> <command>\n", Cmd_Argv(0));
308  return;
309  }
310 
312 
313  k = UI_Mallocz(sizeof(*k));
314  k->generic.type = MTYPE_KEYBIND;
315  k->generic.name = UI_CopyString(Cmd_Argv(cmd_optind));
316  k->generic.uiFlags = UI_CENTER;
317  k->generic.status = UI_CopyString(status);
318  k->cmd = UI_CopyString(Cmd_ArgsFrom(cmd_optind + 1));
319  k->altstatus = UI_CopyString(altstatus);
320 
321  Menu_AddItem(menu, k);
322 }

Referenced by Parse_File().

◆ Parse_Bitmap()

static void Parse_Bitmap ( menuFrameWork_t menu)
static

Definition at line 235 of file script.c.

236 {
237  static const cmd_option_t o_bitmap[] = {
238  { "s:", "status" },
239  { "N:", "altname" },
240  { NULL }
241  };
242  menuBitmap_t *b;
243  char *status = NULL, *altname = NULL;
244  int c;
245 
246  while ((c = Cmd_ParseOptions(o_bitmap)) != -1) {
247  switch (c) {
248  case 's':
249  status = cmd_optarg;
250  break;
251  case 'N':
252  altname = cmd_optarg;
253  break;
254  default:
255  return;
256  }
257  }
258 
259  if (Cmd_Argc() - cmd_optind < 2) {
260  Com_Printf("Usage: %s <name> <command>\n", Cmd_Argv(0));
261  return;
262  }
263 
265 
266  if (!altname)
267  altname = va("%s_sel", Cmd_Argv(cmd_optind));
268 
269  b = UI_Mallocz(sizeof(*b));
272  b->generic.status = UI_CopyString(status);
274  b->pics[0] = R_RegisterPic(Cmd_Argv(cmd_optind));
275  b->pics[1] = R_RegisterPic(altname);
276  R_GetPicSize(&b->generic.width, &b->generic.height, b->pics[0]);
277 
278  Menu_AddItem(menu, b);
279 }

Referenced by Parse_File().

◆ Parse_Blank()

static void Parse_Blank ( menuFrameWork_t menu)
static

Definition at line 468 of file script.c.

469 {
470  menuSeparator_t *s;
471 
473 
474  s = UI_Mallocz(sizeof(*s));
475  s->generic.type = MTYPE_SEPARATOR;
476 
477  Menu_AddItem(menu, s);
478 }

Referenced by Parse_File().

◆ Parse_Color()

static void Parse_Color ( void  )
static

Definition at line 524 of file script.c.

525 {
526  char *s, *c;
527 
528  if (Cmd_Argc() < 3) {
529  Com_Printf("Usage: %s <state> <color>\n", Cmd_Argv(0));
530  return;
531  }
532 
533  s = Cmd_Argv(1);
534  c = Cmd_Argv(2);
535 
536  if (!strcmp(s, "normal")) {
538  } else if (!strcmp(s, "active")) {
540  } else if (!strcmp(s, "selection")) {
542  } else if (!strcmp(s, "disabled")) {
544  } else {
545  Com_Printf("Unknown state '%s'\n", s);
546  }
547 }

Referenced by Parse_File().

◆ Parse_Field()

static void Parse_Field ( menuFrameWork_t menu)
static

Definition at line 414 of file script.c.

415 {
416  static const cmd_option_t o_field[] = {
417  { "c", "center" },
418  { "i", "integer" },
419  { "n", "numeric" },
420  { "s:", "status" },
421  { "w:", "width" },
422  { NULL }
423  };
424  menuField_t *f;
425  qboolean center = qfalse;
426  int flags = 0;
427  char *status = NULL;
428  int width = 16;
429  int c;
430 
431  while ((c = Cmd_ParseOptions(o_field)) != -1) {
432  switch (c) {
433  case 'c':
434  center = qtrue;
435  break;
436  case 'i':
437  case 'n':
438  flags |= QMF_NUMBERSONLY;
439  break;
440  case 's':
441  status = cmd_optarg;
442  break;
443  case 'w':
444  width = atoi(cmd_optarg);
445  if (width < 1 || width > 32) {
446  Com_Printf("Invalid width\n");
447  return;
448  }
449  break;
450  default:
451  return;
452  }
453  }
454 
456 
457  f = UI_Mallocz(sizeof(*f));
458  f->generic.type = MTYPE_FIELD;
459  f->generic.name = center ? NULL : UI_CopyString(Cmd_Argv(cmd_optind));
460  f->generic.status = UI_CopyString(status);
461  f->generic.flags = flags;
462  f->cvar = Cvar_WeakGet(Cmd_Argv(center ? cmd_optind : cmd_optind + 1));
463  f->width = width;
464 
465  Menu_AddItem(menu, f);
466 }

Referenced by Parse_File().

◆ Parse_File()

static qboolean Parse_File ( const char *  path,
int  depth 
)
static

Definition at line 624 of file script.c.

625 {
626  char *raw, *data, *p, *cmd;
627  int argc;
628  menuFrameWork_t *menu = NULL;
629  qerror_t ret;
630 
631  ret = FS_LoadFile(path, (void **)&raw);
632  if (!raw) {
633  if (ret != Q_ERR_NOENT || depth) {
634  Com_WPrintf("Couldn't %s %s: %s\n", depth ? "include" : "load",
635  path, Q_ErrorString(ret));
636  }
637  return qfalse;
638  }
639 
640  data = raw;
641  COM_Compress(data);
642 
643  while (*data) {
644  p = strchr(data, '\n');
645  if (p) {
646  *p = 0;
647  }
648 
649  Cmd_TokenizeString(data, qtrue);
650 
651  argc = Cmd_Argc();
652  if (argc) {
653  cmd = Cmd_Argv(0);
654  if (menu) {
655  if (!strcmp(cmd, "end")) {
656  menu->current_condition.cvar = NULL;
657  if (menu->nitems) {
658  List_Append(&ui_menus, &menu->entry);
659  } else {
660  Com_WPrintf("Menu entry without items\n");
661  menu->free(menu);
662  }
663  menu = NULL;
664  } else if (!strcmp(cmd, "title")) {
665  if (menu->title) {
666  Z_Free(menu->title);
667  }
668  menu->title = UI_CopyString(Cmd_Argv(1));
669  } else if (!strcmp(cmd, "plaque")) {
670  Parse_Plaque(menu);
671  } else if (!strcmp(cmd, "banner")) {
672  Parse_Banner(menu);
673  } else if (!strcmp(cmd, "footer")) {
674  Parse_Footer(menu);
675  } else if (!strcmp(cmd, "background")) {
676  Parse_Background(menu);
677  } else if (!strcmp(cmd, "style")) {
678  Parse_Style(menu);
679  } else if (!strcmp(cmd, "values")) {
681  } else if (!strcmp(cmd, "strings")) {
682  Parse_Spin(menu, MTYPE_STRINGS);
683  } else if (!strcmp(cmd, "pairs")) {
684  Parse_Pairs(menu);
685  } else if (!strcmp(cmd, "range")) {
686  Parse_Range(menu);
687  } else if (!strcmp(cmd, "action")) {
688  Parse_Action(menu);
689  } else if (!strcmp(cmd, "bitmap")) {
690  Parse_Bitmap(menu);
691  } else if (!strcmp(cmd, "bind")) {
692  Parse_Bind(menu);
693  } else if (!strcmp(cmd, "savegame")) {
695  } else if (!strcmp(cmd, "loadgame")) {
697  } else if (!strcmp(cmd, "toggle")) {
698  Parse_Toggle(menu);
699  } else if (!strcmp(cmd, "field")) {
700  Parse_Field(menu);
701  } else if (!strcmp(cmd, "blank")) {
702  Parse_Blank(menu);
703  } else if (!strcmp(cmd, "ifeq")) {
704  Parse_If(menu, qtrue);
705  } else if (!strcmp(cmd, "ifneq")) {
706  Parse_If(menu, qfalse);
707  } else if (!strcmp(cmd, "endif")) {
708  menu->current_condition.cvar = NULL;
709  } else {
710  Com_WPrintf("Unknown keyword '%s'\n", cmd);
711  }
712  } else {
713  if (!strcmp(cmd, "begin")) {
714  char *s = Cmd_Argv(1);
715  if (!*s) {
716  Com_WPrintf("Expected menu name after '%s'\n", cmd);
717  break;
718  }
719  menu = UI_FindMenu(s);
720  if (menu) {
721  if (menu->free) {
722  menu->free(menu);
723  }
724  List_Remove(&menu->entry);
725  }
726  menu = UI_Mallocz(sizeof(*menu));
727  menu->name = UI_CopyString(s);
728  menu->push = Menu_Push;
729  menu->pop = Menu_Pop;
730  menu->free = Menu_Free;
731  menu->image = uis.backgroundHandle;
732  menu->color.u32 = uis.color.background.u32;
733  menu->transparent = uis.transparent;
734  } else if (!strcmp(cmd, "include")) {
735  char *s = Cmd_Argv(1);
736  if (!*s) {
737  Com_WPrintf("Expected file name after '%s'\n", cmd);
738  break;
739  }
740  if (depth == 16) {
741  Com_WPrintf("Includes too deeply nested\n");
742  } else {
743  Parse_File(s, depth + 1);
744  }
745  } else if (!strcmp(cmd, "color")) {
746  Parse_Color();
747  } else if (!strcmp(cmd, "background")) {
748  char *s = Cmd_Argv(1);
749 
750  if (SCR_ParseColor(s, &uis.color.background)) {
751  uis.backgroundHandle = 0;
752  uis.transparent = uis.color.background.u8[3] != 255;
753  } else {
754  uis.backgroundHandle = R_RegisterPic(s);
756  }
757  } else if (!strcmp(cmd, "font")) {
758  uis.fontHandle = R_RegisterFont(Cmd_Argv(1));
759  } else if (!strcmp(cmd, "cursor")) {
760  uis.cursorHandle = R_RegisterPic(Cmd_Argv(1));
763  } else if (!strcmp(cmd, "weapon")) {
765  } else {
766  Com_WPrintf("Unknown keyword '%s'\n", cmd);
767  break;
768  }
769  }
770  }
771 
772  if (!p) {
773  break;
774  }
775 
776  data = p + 1;
777  }
778 
779  FS_FreeFile(raw);
780 
781  if (menu) {
782  Com_WPrintf("Menu entry without 'end' terminator\n");
783  menu->free(menu);
784  }
785 
786  return qtrue;
787 }

Referenced by UI_LoadScript().

◆ Parse_Footer()

static void Parse_Footer ( menuFrameWork_t menu)
static

Definition at line 585 of file script.c.

586 {
587  if (Cmd_Argc() < 2) {
588  Com_Printf("Usage: %s <footer>\n", Cmd_Argv(0));
589  return;
590  }
591 
592  menu->footer = R_RegisterPic(Cmd_Argv(1));
593  if (menu->footer) {
594  R_GetPicSize(&menu->footer_rc.width,
595  &menu->footer_rc.height, menu->footer);
596 
597  if (Cmd_Argc() >= 3)
598  {
599  double scale = atof(Cmd_Argv(2));
600  menu->footer_rc.width = (int)(menu->footer_rc.width * scale);
601  menu->footer_rc.height = (int)(menu->footer_rc.height * scale);
602  }
603  }
604 }

Referenced by Parse_File().

◆ Parse_If()

static void Parse_If ( menuFrameWork_t menu,
qboolean  equals 
)
static

Definition at line 606 of file script.c.

607 {
608  if (Cmd_Argc() != 3) {
609  Com_Printf("Usage: %s <cvar> <value>]\n", Cmd_Argv(0));
610  return;
611  }
612 
613  if (menu->current_condition.cvar)
614  {
615  Com_Printf("Nested ifeq or ifneq are not supported\n");
616  return;
617  }
618 
620  menu->current_condition.value = atoi(Cmd_Argv(2));
621  menu->current_condition.equals = equals;
622 }

Referenced by Parse_File().

◆ Parse_Pairs()

static void Parse_Pairs ( menuFrameWork_t menu)
static

Definition at line 96 of file script.c.

97 {
99  int c, i, numItems;
100  char *status = NULL;
101 
102  while ((c = Cmd_ParseOptions(o_common)) != -1) {
103  switch (c) {
104  case 's':
105  status = cmd_optarg;
106  break;
107  default:
108  return;
109  }
110  }
111 
112  numItems = Cmd_Argc() - (cmd_optind + 2);
113  if (numItems < 2 || (numItems & 1)) {
114  Com_Printf("Usage: %s <name> <cvar> <desc1> <value1> [...]\n", Cmd_Argv(0));
115  return;
116  }
117 
119 
120  s = UI_Mallocz(sizeof(*s));
121  s->generic.type = MTYPE_PAIRS;
122  s->generic.name = UI_CopyString(Cmd_Argv(cmd_optind));
123  s->generic.status = UI_CopyString(status);
124  s->cvar = Cvar_WeakGet(Cmd_Argv(cmd_optind + 1));
125  numItems /= 2;
126  s->itemnames = UI_Mallocz(sizeof(char *) * (numItems + 1));
127  s->itemvalues = UI_Mallocz(sizeof(char *) * (numItems + 1));
128  for (i = 0; i < numItems; i++) {
129  s->itemnames[i] = UI_CopyString(Cmd_Argv(cmd_optind + 2 + i * 2));
130  s->itemvalues[i] = UI_CopyString(Cmd_Argv(cmd_optind + 3 + i * 2));
131  }
132  s->numItems = numItems;
133 
134  Menu_AddItem(menu, s);
135 }

Referenced by Parse_File().

◆ Parse_Plaque()

static void Parse_Plaque ( menuFrameWork_t menu)
static

Definition at line 549 of file script.c.

550 {
551  if (Cmd_Argc() < 2) {
552  Com_Printf("Usage: %s <plaque> [logo]\n", Cmd_Argv(0));
553  return;
554  }
555 
556  menu->plaque = R_RegisterPic(Cmd_Argv(1));
557  if (menu->plaque) {
558  R_GetPicSize(&menu->plaque_rc.width,
559  &menu->plaque_rc.height, menu->plaque);
560  }
561 
562  if (Cmd_Argc() > 2) {
563  menu->logo = R_RegisterPic(Cmd_Argv(2));
564  if (menu->logo) {
565  R_GetPicSize(&menu->logo_rc.width,
566  &menu->logo_rc.height, menu->logo);
567  }
568  }
569 }

Referenced by Parse_File().

◆ Parse_Range()

static void Parse_Range ( menuFrameWork_t menu)
static

Definition at line 143 of file script.c.

144 {
145  menuSlider_t *s;
146  char *status = NULL;
147  char *format = NULL;
148  qboolean percentage = qfalse;
149  int c;
150 
151  while ((c = Cmd_ParseOptions(o_range)) != -1) {
152  switch (c) {
153  case 's':
154  status = cmd_optarg;
155  break;
156  case 'f':
157  format = cmd_optarg;
158  break;
159  case 'p':
160  percentage = qtrue;
161  break;
162  default:
163  return;
164  }
165  }
166 
167  if (Cmd_Argc() - cmd_optind < 4) {
168  Com_Printf("Usage: %s <name> <cvar> <min> <max> [step]\n", Cmd_Argv(0));
169  return;
170  }
171 
173 
174  s = UI_Mallocz(sizeof(*s));
175  s->generic.type = MTYPE_SLIDER;
176  s->generic.name = UI_CopyString(Cmd_Argv(cmd_optind));
177  s->generic.status = UI_CopyString(status);
178  s->cvar = Cvar_WeakGet(Cmd_Argv(cmd_optind + 1));
179  s->minvalue = atof(Cmd_Argv(cmd_optind + 2));
180  s->maxvalue = atof(Cmd_Argv(cmd_optind + 3));
181  if (Cmd_Argc() - cmd_optind > 4) {
182  s->step = atof(Cmd_Argv(cmd_optind + 4));
183  } else {
184  s->step = (s->maxvalue - s->minvalue) / SLIDER_RANGE;
185  }
186  s->format = UI_CopyString(format);
187  s->percentage = percentage;
188 
189  Menu_AddItem(menu, s);
190 }

Referenced by Parse_File().

◆ Parse_Savegame()

static void Parse_Savegame ( menuFrameWork_t menu,
menuType_t  type 
)
static

Definition at line 324 of file script.c.

325 {
326  menuAction_t *a;
327  char *status = NULL;
328  int c;
329 
330  while ((c = Cmd_ParseOptions(o_common)) != -1) {
331  switch (c) {
332  case 's':
333  status = cmd_optarg;
334  break;
335  default:
336  return;
337  }
338  }
339 
340  if (Cmd_Argc() - cmd_optind < 1) {
341  Com_Printf("Usage: %s <dir>\n", Cmd_Argv(0));
342  return;
343  }
344 
346 
347  a = UI_Mallocz(sizeof(*a));
348  a->generic.type = type;
349  a->generic.name = UI_CopyString("<EMPTY>");
350  a->generic.activate = Activate;
351  a->generic.uiFlags = UI_CENTER;
352  a->generic.status = UI_CopyString(status);
353  a->cmd = UI_CopyString(Cmd_Argv(cmd_optind));
354 
355  if (type == MTYPE_LOADGAME)
356  a->generic.flags |= QMF_GRAYED;
357 
358  Menu_AddItem(menu, a);
359 }

Referenced by Parse_File().

◆ Parse_Spin()

static void Parse_Spin ( menuFrameWork_t menu,
menuType_t  type 
)
static

Definition at line 58 of file script.c.

59 {
61  int c, i, numItems;
62  char *status = NULL;
63 
64  while ((c = Cmd_ParseOptions(o_common)) != -1) {
65  switch (c) {
66  case 's':
67  status = cmd_optarg;
68  break;
69  default:
70  return;
71  }
72  }
73 
74  numItems = Cmd_Argc() - (cmd_optind + 2);
75  if (numItems < 1) {
76  Com_Printf("Usage: %s <name> <cvar> <desc1> [...]\n", Cmd_Argv(0));
77  return;
78  }
79 
81 
82  s = UI_Mallocz(sizeof(*s));
83  s->generic.type = type;
84  s->generic.name = UI_CopyString(Cmd_Argv(cmd_optind));
85  s->generic.status = UI_CopyString(status);
86  s->cvar = Cvar_WeakGet(Cmd_Argv(cmd_optind + 1));
87  s->itemnames = UI_Mallocz(sizeof(char *) * (numItems + 1));
88  for (i = 0; i < numItems; i++) {
89  s->itemnames[i] = UI_CopyString(Cmd_Argv(cmd_optind + 2 + i));
90  }
91  s->numItems = numItems;
92 
93  Menu_AddItem(menu, s);
94 }

Referenced by Parse_File().

◆ Parse_Style()

static void Parse_Style ( menuFrameWork_t menu)
static

Definition at line 493 of file script.c.

494 {
495  static const cmd_option_t o_style[] = {
496  { "c", "compact" },
497  { "C", "no-compact" },
498  { "t", "transparent" },
499  { "T", "no-transparent" },
500  { NULL }
501  };
502  int c;
503 
504  while ((c = Cmd_ParseOptions(o_style)) != -1) {
505  switch (c) {
506  case 'c':
507  menu->compact = qtrue;
508  break;
509  case 'C':
510  menu->compact = qfalse;
511  break;
512  case 't':
513  menu->transparent = qtrue;
514  break;
515  case 'T':
516  menu->transparent = qfalse;
517  break;
518  default:
519  return;
520  }
521  }
522 }

Referenced by Parse_File().

◆ Parse_Toggle()

static void Parse_Toggle ( menuFrameWork_t menu)
static

Definition at line 361 of file script.c.

362 {
363  static const char *yes_no_names[] = { "no", "yes", NULL };
365  qboolean negate = qfalse;
366  menuType_t type = MTYPE_TOGGLE;
367  int c, bit = 0;
368  char *b, *status = NULL;
369 
370  while ((c = Cmd_ParseOptions(o_common)) != -1) {
371  switch (c) {
372  case 's':
373  status = cmd_optarg;
374  break;
375  default:
376  return;
377  }
378  }
379 
380  if (Cmd_Argc() - cmd_optind < 2) {
381  Com_Printf("Usage: %s <name> <cvar> [~][bit]\n", Cmd_Argv(0));
382  return;
383  }
384 
385  b = Cmd_Argv(cmd_optind + 2);
386  if (*b == '~') {
387  negate = qtrue;
388  b++;
389  }
390  if (*b) {
391  bit = atoi(b);
392  if (bit < 0 || bit >= 32) {
393  Com_Printf("Invalid bit number: %d\n", bit);
394  return;
395  }
396  type = MTYPE_BITFIELD;
397  }
398 
400 
401  s = UI_Mallocz(sizeof(*s));
402  s->generic.type = type;
403  s->generic.name = UI_CopyString(Cmd_Argv(cmd_optind));
404  s->generic.status = UI_CopyString(status);
405  s->cvar = Cvar_WeakGet(Cmd_Argv(cmd_optind + 1));
406  s->itemnames = (char **)yes_no_names;
407  s->numItems = 2;
408  s->negate = negate;
409  s->mask = 1 << bit;
410 
411  Menu_AddItem(menu, s);
412 }

Referenced by Parse_File().

◆ UI_LoadScript()

void UI_LoadScript ( void  )

Definition at line 789 of file script.c.

790 {
791  Parse_File("q2rtx.menu", 0);
792 }

Referenced by UI_Init().

Variable Documentation

◆ o_common

const cmd_option_t o_common[]
static
Initial value:
= {
{ "s:", "status" },
{ NULL }
}

Definition at line 53 of file script.c.

Referenced by Parse_Pairs(), Parse_Savegame(), Parse_Spin(), and Parse_Toggle().

◆ o_range

const cmd_option_t o_range[]
static
Initial value:
= {
{ "s:", "status" },
{ "f:", "format" },
{ "p", "percentage" },
{ NULL }
}

Definition at line 137 of file script.c.

Referenced by Parse_Range().

menuCondition_s::value
int value
Definition: ui.h:94
MTYPE_TOGGLE
@ MTYPE_TOGGLE
Definition: ui.h:51
menuFrameWork_s::title
char * title
Definition: ui.h:101
uiStatic_s::transparent
qboolean transparent
Definition: ui.h:301
uiStatic_s::fontHandle
qhandle_t fontHandle
Definition: ui.h:307
QMS_NOTHANDLED
@ QMS_NOTHANDLED
Definition: ui.h:68
Parse_Toggle
static void Parse_Toggle(menuFrameWork_t *menu)
Definition: script.c:361
MTYPE_SEPARATOR
@ MTYPE_SEPARATOR
Definition: ui.h:45
Parse_Field
static void Parse_Field(menuFrameWork_t *menu)
Definition: script.c:414
menuCommon_s::type
menuType_t type
Definition: ui.h:141
cmd_optarg
char * cmd_optarg
Definition: cmd.c:848
menuFrameWork_s::name
char * name
Definition: ui.h:101
Parse_If
static void Parse_If(menuFrameWork_t *menu, qboolean equals)
Definition: script.c:606
MTYPE_STRINGS
@ MTYPE_STRINGS
Definition: ui.h:49
menuCondition_s::cvar
cvar_t * cvar
Definition: ui.h:93
MTYPE_KEYBIND
@ MTYPE_KEYBIND
Definition: ui.h:53
menuCommon_s::activate
menuSound_t(* activate)(struct menuCommon_s *)
Definition: ui.h:157
menuCommon_s::height
int height
Definition: ui.h:150
Parse_Bitmap
static void Parse_Bitmap(menuFrameWork_t *menu)
Definition: script.c:235
Q_ErrorString
const char * Q_ErrorString(qerror_t error)
Definition: error.c:51
menuFrameWork_s::logo_rc
vrect_t logo_rc
Definition: ui.h:124
menuFrameWork_s::free
void(* free)(struct menuFrameWork_s *)
Definition: ui.h:136
menuFrameWork_s::push
qboolean(* push)(struct menuFrameWork_s *)
Definition: ui.h:131
menuType_t
menuType_t
Definition: ui.h:39
menuKeybind_s
Definition: ui.h:262
menuFrameWork_s::logo
qhandle_t logo
Definition: ui.h:123
MTYPE_SAVEGAME
@ MTYPE_SAVEGAME
Definition: ui.h:55
o_common
static const cmd_option_t o_common[]
Definition: script.c:53
menuFrameWork_s::image
qhandle_t image
Definition: ui.h:110
cmd_optind
int cmd_optind
Definition: cmd.c:847
Parse_Pairs
static void Parse_Pairs(menuFrameWork_t *menu)
Definition: script.c:96
menuFrameWork_s::footer_rc
vrect_t footer_rc
Definition: ui.h:127
menuFrameWork_s
Definition: ui.h:98
Cmd_TokenizeString
void Cmd_TokenizeString(const char *text, qboolean macroExpand)
Definition: cmd.c:1399
menuFrameWork_s::banner
qhandle_t banner
Definition: ui.h:117
menuFrameWork_s::nitems
int nitems
Definition: ui.h:103
UI_Mallocz
#define UI_Mallocz(s)
Definition: ui.h:34
MTYPE_BITMAP
@ MTYPE_BITMAP
Definition: ui.h:54
menuBitmap_s::pics
qhandle_t pics[2]
Definition: ui.h:258
Menu_Pop
void Menu_Pop(menuFrameWork_t *menu)
Definition: menu.c:2547
Cmd_Argv
char * Cmd_Argv(int arg)
Definition: cmd.c:899
menuAction_s
Definition: ui.h:242
Cmd_Argc
int Cmd_Argc(void)
Definition: cmd.c:889
MTYPE_SPINCONTROL
@ MTYPE_SPINCONTROL
Definition: ui.h:44
width
static int width
Definition: physical_sky.c:38
menuCommon_s::width
int width
Definition: ui.h:150
cmd_buffer
cmdbuf_t cmd_buffer
Definition: cmd.c:49
uis
uiStatic_t uis
Definition: ui.c:24
Cmd_ArgsFrom
char * Cmd_ArgsFrom(int from)
Definition: cmd.c:981
Parse_Footer
static void Parse_Footer(menuFrameWork_t *menu)
Definition: script.c:585
Parse_Banner
static void Parse_Banner(menuFrameWork_t *menu)
Definition: script.c:571
Cmd_ParseOptions
int Cmd_ParseOptions(const cmd_option_t *opt)
Definition: cmd.c:1057
Cbuf_AddText
void Cbuf_AddText(cmdbuf_t *buf, const char *text)
Definition: cmd.c:95
va
char * va(const char *format,...)
Definition: shared.c:429
Z_Free
void Z_Free(void *ptr)
Definition: zone.c:147
Parse_Bind
static void Parse_Bind(menuFrameWork_t *menu)
Definition: script.c:281
uiStatic_s::cursorHandle
qhandle_t cursorHandle
Definition: ui.h:308
uiStatic_s::weaponModel
char weaponModel[32]
Definition: ui.h:304
UI_CopyString
#define UI_CopyString(s)
Definition: ui.h:35
MTYPE_ACTION
@ MTYPE_ACTION
Definition: ui.h:43
Parse_Spin
static void Parse_Spin(menuFrameWork_t *menu, menuType_t type)
Definition: script.c:58
QMF_NUMBERSONLY
#define QMF_NUMBERSONLY
Definition: ui.h:61
Parse_Action
static void Parse_Action(menuFrameWork_t *menu)
Definition: script.c:192
menuFrameWork_s::footer
qhandle_t footer
Definition: ui.h:126
menuFrameWork_s::compact
qboolean compact
Definition: ui.h:106
menuFrameWork_s::plaque_rc
vrect_t plaque_rc
Definition: ui.h:121
menuFrameWork_s::plaque
qhandle_t plaque
Definition: ui.h:120
Parse_Color
static void Parse_Color(void)
Definition: script.c:524
Menu_AddItem
void Menu_AddItem(menuFrameWork_t *menu, void *item)
Definition: menu.c:1785
COM_Compress
size_t COM_Compress(char *data)
Definition: shared.c:543
MTYPE_PAIRS
@ MTYPE_PAIRS
Definition: ui.h:48
MAXMENUITEMS
#define MAXMENUITEMS
Definition: ui.h:37
menuCondition_s::equals
qboolean equals
Definition: ui.h:95
menuSeparator_s
Definition: ui.h:247
ui_menus
list_t ui_menus
Parse_Plaque
static void Parse_Plaque(menuFrameWork_t *menu)
Definition: script.c:549
Cvar_WeakGet
cvar_t * Cvar_WeakGet(const char *var_name)
Definition: cvar.c:324
Parse_Range
static void Parse_Range(menuFrameWork_t *menu)
Definition: script.c:143
menuFrameWork_s::color
color_t color
Definition: ui.h:111
uiStatic_s::selection
color_t selection
Definition: ui.h:317
MTYPE_LOADGAME
@ MTYPE_LOADGAME
Definition: ui.h:56
c
statCounters_t c
Definition: main.c:30
menuSpinControl_s
Definition: ui.h:229
uiStatic_s::color
struct uiStatic_s::@9 color
R_GetPicSize
qboolean R_GetPicSize(int *w, int *h, qhandle_t pic)
Definition: images.c:1289
uiStatic_s::disabled
color_t disabled
Definition: ui.h:318
CHECK_NITEMS
#define CHECK_NITEMS
Definition: script.c:47
Activate
static menuSound_t Activate(menuCommon_t *self)
Definition: script.c:23
Parse_Savegame
static void Parse_Savegame(menuFrameWork_t *menu, menuType_t type)
Definition: script.c:324
o_range
static const cmd_option_t o_range[]
Definition: script.c:137
uiStatic_s::normal
color_t normal
Definition: ui.h:315
menuFrameWork_s::banner_rc
vrect_t banner_rc
Definition: ui.h:118
uiStatic_s::background
color_t background
Definition: ui.h:314
Menu_Free
void Menu_Free(menuFrameWork_t *menu)
Definition: menu.c:2586
uiStatic_s::active
color_t active
Definition: ui.h:316
Parse_Style
static void Parse_Style(menuFrameWork_t *menu)
Definition: script.c:493
Cmd_ArgvBuffer
size_t Cmd_ArgvBuffer(int arg, char *buffer, size_t size)
Definition: cmd.c:912
UI_FindMenu
menuFrameWork_t * UI_FindMenu(const char *name)
Definition: ui.c:190
MTYPE_FIELD
@ MTYPE_FIELD
Definition: ui.h:46
uiStatic_s::backgroundHandle
qhandle_t backgroundHandle
Definition: ui.h:306
Parse_File
static qboolean Parse_File(const char *path, int depth)
Definition: script.c:624
menuFrameWork_s::entry
list_t entry
Definition: ui.h:99
Menu_Push
qboolean Menu_Push(menuFrameWork_t *menu)
Definition: menu.c:2503
uiStatic_s::cursorWidth
int cursorWidth
Definition: ui.h:309
menuSlider_s
Definition: ui.h:172
menuBitmap_s::generic
menuCommon_t generic
Definition: ui.h:257
menuFrameWork_s::current_condition
menuCondition_t current_condition
Definition: ui.h:129
uiStatic_s::cursorHeight
int cursorHeight
Definition: ui.h:309
MTYPE_BITFIELD
@ MTYPE_BITFIELD
Definition: ui.h:47
menuCommon_s::status
char * status
Definition: ui.h:147
SCR_ParseColor
qboolean SCR_ParseColor(const char *s, color_t *color)
Definition: screen.c:215
int
CONST PIXELFORMATDESCRIPTOR int
Definition: wgl.c:26
menuBitmap_s
Definition: ui.h:256
Parse_Blank
static void Parse_Blank(menuFrameWork_t *menu)
Definition: script.c:468
menuFrameWork_s::pop
void(* pop)(struct menuFrameWork_s *)
Definition: ui.h:132
MTYPE_SLIDER
@ MTYPE_SLIDER
Definition: ui.h:41
menuFrameWork_s::transparent
qboolean transparent
Definition: ui.h:107
Parse_Background
static void Parse_Background(menuFrameWork_t *menu)
Definition: script.c:480
QMF_GRAYED
#define QMF_GRAYED
Definition: ui.h:60
SLIDER_RANGE
#define SLIDER_RANGE
Definition: ui.h:170
menuBitmap_s::cmd
char * cmd
Definition: ui.h:259
menuField_s
Definition: ui.h:163