]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/miscfunctions.qc
Merge branch 'master' into mirceakitsune/nex_reticle
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / miscfunctions.qc
index e97b3fd7595ddb05629ecbe0ac5bedfaf97e5ee4..0e3e58f49607542917a34d1ebfa154cd20962e22 100644 (file)
@@ -304,8 +304,8 @@ entity GetTeam(float Team, float add)
 
 void CSQC_CheckEngine()
 {
-       sbar_font = FONT_USER+1;
-       sbar_bigfont = FONT_USER+2;
+       hud_font = FONT_USER+1;
+       hud_bigfont = FONT_USER+2;
 }
 
 vector HUD_GetFontsize(string cvarname)
@@ -323,7 +323,7 @@ vector HUD_GetFontsize(string cvarname)
 float HUD_GetWidth(float teamcolumnwidth)
 {
        float f;
-       f = cvar("sbar_width");
+       f = cvar("hud_width");
        if(f == 0)
                f = 640;
        if(f < 320)
@@ -482,6 +482,28 @@ void drawpic_expanding_two(vector position, string pic, vector scale, vector rgb
        drawpic(position, pic, scale, rgb, alpha * fadelerp, flag);
 }
 
+// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
+void drawstring_aspect(vector pos, string text, vector sz, float fontsize, vector color, float alpha, float drawflag) {
+       vector textsize;
+       textsize = eX * stringwidth(text, FALSE, '1 1 0' * fontsize) + eY * fontsize;
+       
+       float textaspect;
+       textaspect = textsize_x/textsize_y;
+
+       vector oldsz;
+       oldsz = sz;
+       float aspect;
+       aspect = sz_x/sz_y;
+
+       if(aspect > textaspect) {
+               sz_x = sz_y * textaspect;
+               drawstring(pos + eX * (oldsz_x - sz_x) * 0.5, text, '1 1 0' * sz_y, color, alpha, drawflag);
+       } else {
+               sz_y = sz_x / textaspect; 
+               drawstring(pos + eY * (oldsz_y - sz_y) * 0.5, text, '1 1 0' * sz_y, color, alpha, drawflag);
+       }
+}
+
 vector drawfontscale;
 void drawstring_expanding(vector position, string text, vector scale, vector rgb, float alpha, float flag, float fadelerp)
 {