X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fmiscfunctions.qc;h=23f88868bcb5600a7decd1eaf03ae89b3efd57ef;hp=0e3e58f49607542917a34d1ebfa154cd20962e22;hb=7384810428bebf9ad462bf62421fa4c75ed5be91;hpb=85ff31f9ec26adf70f835d95184f6dded9d0c785 diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 0e3e58f49..23f88868b 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -483,9 +483,9 @@ void drawpic_expanding_two(vector position, string pic, vector scale, vector rgb } // 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) { +void drawstring_aspect(vector pos, string text, vector sz, vector color, float alpha, float drawflag) { vector textsize; - textsize = eX * stringwidth(text, FALSE, '1 1 0' * fontsize) + eY * fontsize; + textsize = eX * stringwidth(text, FALSE, '1 1 1' * sz_y) + eY * sz_y; float textaspect; textaspect = textsize_x/textsize_y; @@ -504,24 +504,41 @@ void drawstring_aspect(vector pos, string text, vector sz, float fontsize, vecto } } +// drawstring wrapper to draw a colorcodedstring as large as possible with preserved aspect ratio into a box +void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float alpha, float drawflag) { + vector textsize; + textsize = eX * stringwidth(text, TRUE, '1 1 1' * sz_y) + eY * sz_y; + + 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; + drawcolorcodedstring(pos + eX * (oldsz_x - sz_x) * 0.5, text, '1 1 0' * sz_y, alpha, drawflag); + } else { + sz_y = sz_x / textaspect; + drawcolorcodedstring(pos + eY * (oldsz_y - sz_y) * 0.5, text, '1 1 0' * sz_y, alpha, drawflag); + } +} + vector drawfontscale; void drawstring_expanding(vector position, string text, vector scale, vector rgb, float alpha, float flag, float fadelerp) { float sz; sz = expandingbox_sizefactor_from_fadelerp(fadelerp); - if(cvar("menu_font_size_snapping_fix")) - drawfontscale = sz * '1 1 0'; - else - drawfontscale = '1 1 0'; + drawfontscale = sz * '1 1 0'; dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); drawstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, FALSE, scale * (sz / drawfontscale_x)) / (scale_x * sz)), text, scale * (sz / drawfontscale_x), rgb, alpha * (1 - fadelerp), flag); // width parameter: // (scale_x * sz / drawfontscale_x) * drawfontscale_x * SIZE1 / (scale_x * sz) // SIZE1 - - if(cvar("menu_font_size_snapping_fix")) - drawfontscale = '1 1 0'; + drawfontscale = '1 1 0'; } void drawcolorcodedstring_expanding(vector position, string text, vector scale, float alpha, float flag, float fadelerp) @@ -529,15 +546,10 @@ void drawcolorcodedstring_expanding(vector position, string text, vector scale, float sz; sz = expandingbox_sizefactor_from_fadelerp(fadelerp); - if(cvar("menu_font_size_snapping_fix")) - drawfontscale = sz * '1 1 0'; - else - drawfontscale = '1 1 0'; + drawfontscale = sz * '1 1 0'; dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, TRUE, scale * (sz / drawfontscale_x)) / (scale_x * sz)), text, scale * (sz / drawfontscale_x), alpha * (1 - fadelerp), flag); - - if(cvar("menu_font_size_snapping_fix")) - drawfontscale = '1 1 0'; + drawfontscale = '1 1 0'; } // this draws the triangles of a model DIRECTLY. Don't expect high performance, really...