Xonotic
menu_cmd.qc
Go to the documentation of this file.
1 #include "menu_cmd.qh"
2 
3 #include "../menu.qh"
4 #include "../item.qh"
5 
6 #include <menu/mutators/_mod.qh>
7 
8 #include <common/command/_mod.qh>
9 
11 
14 {
15  string s;
16  s = me.toString(me);
17  if (s == "") s = me.classname;
18  else s = strcat(me.classname, ": ", s);
19  print(_dumptree_space, etos(me), " (", s, ")");
20  if (me.firstChild)
21  {
22  print(" {\n");
24  }
25  else
26  {
27  print("\n");
28  }
29 }
31 {
32  if (me.firstChild)
33  {
35  print(_dumptree_space, "}\n");
36  }
37 }
38 
39 float updateConwidths(float width, float height, float pixelheight);
40 
41 void GameCommand(string theCommand)
42 {
43  int argc = tokenize_console(theCommand);
44  string ss = strtolower(argv(0));
45 
46  // TODO port these commands to the command system
47  if (argv(0) == "help" || argc == 0)
48  {
49  LOG_HELP("Usage:^3 menu_cmd <command> [<item>], where possible commands are:");
50  LOG_HELP(" 'sync' reloads all cvars on the current menu page");
51  LOG_HELP(" 'directmenu' shows the menu window named <item> (or the menu window containing an item named <item>)");
52  LOG_HELP(" if <item> is not specified it shows the list of available items in the console");
53  LOG_HELP(" 'dumptree' dumps the state of the menu as a tree to the console");
54 
55  LOG_HELP("\nGeneric commands shared by all programs:");
57 
58  return;
59  }
60 
61  if (GenericCommand(theCommand)) return;
62 
63  if (argv(0) == "sync")
64  {
65  m_sync();
66  return;
67  }
68 
69  if (argv(0) == "update_conwidths_before_vid_restart")
70  {
71  updateConwidths(cvar("vid_width"), cvar("vid_height"), cvar("vid_pixelheight"));
72  return;
73  }
74 
75  if (argv(0) == "directmenu" || argv(0) == "directpanelhudmenu")
76  {
77  string filter = string_null;
78  if (argv(0) == "directpanelhudmenu") filter = "HUD";
79 
80  if (argc == 1)
81  {
82  LOG_HELP("Available items:");
83 
84  FOREACH_ENTITY_ORDERED(it.name != "", {
85  if (it.classname == "vtbl") continue;
86  string s = it.name;
87  if (filter)
88  {
89  if (!startsWith(s, filter)) continue;
90  s = substring(s, strlen(filter), strlen(s) - strlen(filter));
91  }
92  LOG_HELP(" ", s);
93  });
94  }
95  else if (argc == 2 && !isdemo()) // don't allow this command in demos
96  {
98  m_goto(strcat(filter, argv(1))); // switch to a menu item
99  }
100  return;
101  }
102 
103  if (argv(0) == "skinselect")
104  {
105  m_goto("skinselector");
106  return;
107  }
108 
109  if (argv(0) == "languageselect")
110  {
111  m_goto("languageselector");
112  return;
113  }
114 
115  if (argv(0) == "videosettings")
116  {
117  m_goto("videosettings");
118  return;
119  }
120 
121  if (argv(0) == "dumptree")
122  {
123  _dumptree_space = "";
125  return;
126  }
127 
128  if(MUTATOR_CALLHOOK(Menu_ConsoleCommand, ss, argc, theCommand)) // handled by a mutator
129  return;
130 
131  LOG_INFO("Invalid command. For a list of supported commands, try menu_cmd help.");
132 }
string string_null
Definition: nil.qh:9
entity parent
Definition: animhost.qc:7
entity() spawn
float GenericCommand(string command)
Definition: generic.qc:582
void depthfirst(entity start,.entity up,.entity downleft,.entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass)
Definition: util.qc:281
#define LOG_HELP(...)
Definition: log.qh:95
#define FOREACH_ENTITY_ORDERED(cond, body)
Definition: iter.qh:138
void GenericCommand_macro_help()
Definition: generic.qc:546
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
float height
Definition: jumppads.qh:12
#define NULL
Definition: post.qh:17
#define LOG_INFO(...)
Definition: log.qh:70
#define tokenize_console
Definition: dpextensions.qh:24
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
#define pass(name, colormin, colormax)