Xonotic
menu_cmd.qc File Reference
#include "menu_cmd.qh"
#include "../menu.qh"
#include "../item.qh"
#include <menu/mutators/_mod.qh>
#include <common/command/_mod.qh>
+ Include dependency graph for menu_cmd.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void _dumptree_close (entity pass, entity me)
 
void _dumptree_open (entity pass, entity me)
 
void GameCommand (string theCommand)
 
float updateConwidths (float width, float height, float pixelheight)
 

Variables

string _dumptree_space
 
entity firstChild
 
entity nextSibling
 

Function Documentation

◆ _dumptree_close()

void _dumptree_close ( entity  pass,
entity  me 
)

Definition at line 30 of file menu_cmd.qc.

References _dumptree_space, height, print(), strlen(), substring(), and updateConwidths().

Referenced by GameCommand().

31 {
32  if (me.firstChild)
33  {
35  print(_dumptree_space, "}\n");
36  }
37 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _dumptree_open()

void _dumptree_open ( entity  pass,
entity  me 
)

Definition at line 13 of file menu_cmd.qc.

References _dumptree_space, etos(), print(), and strcat().

Referenced by GameCommand().

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 }
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"))
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameCommand()

void GameCommand ( string  theCommand)

Definition at line 41 of file menu_cmd.qc.

References _dumptree_close(), _dumptree_open(), _dumptree_space, argv(), cvar(), depthfirst(), firstChild, FOREACH_ENTITY_ORDERED, GenericCommand(), GenericCommand_macro_help(), isdemo(), LOG_HELP, LOG_INFO, m_goto(), m_play_click_sound(), m_sync(), main, MENU_SOUND_OPEN, MUTATOR_CALLHOOK, nextSibling, NULL, parent, strcat(), string_null, tokenize_console, and updateConwidths().

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
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"))
#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
+ Here is the call graph for this function:

◆ updateConwidths()

float updateConwidths ( float  width,
float  height,
float  pixelheight 
)

Definition at line 8 of file slider_resolution.qc.

Referenced by _dumptree_close(), GameCommand(), and UpdateConWidthHeight().

9 {
10  vector r, c;
11  float minfactor, maxfactor;
12  float sz, f;
13 
14  sz = cvar("menu_vid_scale");
15  if (sz < -1)
16  return 0; // No recalculation.
17 
18  // Save off current settings.
19  cvar_set("_menu_vid_width", ftos(width));
20  cvar_set("_menu_vid_height", ftos(height));
21  cvar_set("_menu_vid_pixelheight", ftos(pixelheight));
22  cvar_set("_menu_vid_desktopfullscreen", cvar_string("vid_desktopfullscreen"));
23 
24  // engine is handling conwidth calculations!
25  if((cvar_type("vid_conwidthauto") & CVAR_TYPEFLAG_ENGINE) && cvar("vid_conwidthauto"))
26  {
27  if(vid_conwidth != cvar("vid_conwidth") || vid_conheight != cvar("vid_conheight"))
28  {
29  // Please reload resolutions list and such stuff.
31  vid_conwidth = cvar("vid_conwidth");
32  vid_conheight = cvar("vid_conheight");
33  return 1;
34  }
35  return 0; // No recalculation
36  }
37 
38  r_x = width;
39  r_y = height;
40  r_z = pixelheight;
41 
42  // calculate the base resolution
43  c_z = 0;
44  c_x = 800;
45  c_y = c.x * r.y * r.z / r.x;
46  if(c.y < 600)
47  {
48  c_y = 600;
49  c_x = c.y * r.x / (r.y * r.z);
50  }
51 
52  f = min(r.x / c.x, r.y / c.y);
53  if(f < 1)
54  c = c * f; // ensures that c_x <= r_x and c_y <= r_y
55 
56  minfactor = min(1, 640 / c.x); // can be > 1 only if c_x is <640
57  maxfactor = max(1, r.x / c.x, r.y / c.y); // can be < 1 only if r_x < c_x and r_y < c_y
58  LOG_TRACE("min factor: ", ftos(minfactor));
59  LOG_TRACE("max factor: ", ftos(maxfactor));
60 
61  if(sz < 0)
62  f = 1 - (maxfactor - 1) * sz;
63  else if(sz > 0)
64  f = 1 + (minfactor - 1) * sz;
65  else
66  f = 1;
67  c = c * f; // fteqcc fail
68 
69  c_x = rint(c.x);
70  c_y = rint(c.y);
71 
72  // Please reload resolutions list and such stuff.
74 
75  if (c.x != cvar("vid_conwidth") || c.y != cvar("vid_conheight"))
76  {
77  cvar_set("vid_conwidth", ftos(c.x));
78  cvar_set("vid_conheight", ftos(c.y));
79  return 1;
80  }
81  return 0;
82 }
float vid_conheight
float vid_conwidth
float height
Definition: jumppads.qh:12
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float CVAR_TYPEFLAG_ENGINE
#define LOG_TRACE(...)
Definition: log.qh:81
float XonoticResolutionSlider_DataHasChanged
+ Here is the caller graph for this function:

Variable Documentation

◆ _dumptree_space

string _dumptree_space

Definition at line 12 of file menu_cmd.qc.

Referenced by _dumptree_close(), _dumptree_open(), and GameCommand().

◆ firstChild

entity firstChild

Definition at line 10 of file menu_cmd.qc.

Referenced by GameCommand(), and getNewChildValue().

◆ nextSibling

entity nextSibling

Definition at line 10 of file menu_cmd.qc.

Referenced by GameCommand().