Xonotic
slider_resolution.qh File Reference
#include "textslider.qh"
+ Include dependency graph for slider_resolution.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  XonoticResolutionSlider
 

Functions

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

Function Documentation

◆ makeXonoticResolutionSlider()

entity makeXonoticResolutionSlider ( )

Definition at line 83 of file slider_resolution.qc.

References entity(), and NEW.

84 {
85  entity me;
87  me.configureXonoticResolutionSlider(me);
88  return me;
89 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ 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.

References cvar(), cvar_set(), cvar_string(), CVAR_TYPEFLAG_ENGINE, ftos(), height, LOG_TRACE, max(), min(), rint(), vector(), vid_conheight, vid_conwidth, and XonoticResolutionSlider_DataHasChanged.

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 call graph for this function: