X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fmiscfunctions.qc;h=ec76692e584474829181bb7fe9dcd93008ad082a;hb=refs%2Fheads%2FTimePath%2Fdefault-eraseable;hp=33fd015cce8f8724a5403d6024b3ea7f79a1f379;hpb=4ee2807b2d8f808928ef14b3e814945b3edb4350;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 33fd015cc..ec76692e5 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -1,5 +1,7 @@ #include "miscfunctions.qh" +#include "autocvars.qh" +#include "defs.qh" #include "hud/_mod.qh" #include @@ -192,6 +194,15 @@ vector project_3d_to_2d(vector vec) return vec; } +bool projected_on_screen(vector screen_pos) +{ + return screen_pos.z >= 0 + && screen_pos.x >= 0 + && screen_pos.y >= 0 + && screen_pos.x < vid_conwidth + && screen_pos.y < vid_conheight; +} + float expandingbox_sizefactor_from_fadelerp(float fadelerp) { return 1.2 / (1.2 - fadelerp); @@ -350,6 +361,13 @@ void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, f drawcolorcodedstring_expanding(pos, text, '1 1 0' * sz.y, theAlpha, drawflag, fadelerp); } +void update_mousepos() +{ + mousepos += getmousepos() * autocvar_menu_mouse_speed; + mousepos.x = bound(0, mousepos.x, vid_conwidth); + mousepos.y = bound(0, mousepos.y, vid_conheight); +} + // this draws the triangles of a model DIRECTLY. Don't expect high performance, really... float PolyDrawModelSurface(entity e, float i_s) { @@ -382,15 +400,17 @@ void PolyDrawModel(entity e) void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag) { - float x, y, q, d; + float d; vector ringsize, v, t; ringsize = radi * '1 1 0'; + centre = HUD_Shift(centre); + ringsize = HUD_Scale(ringsize); - x = cos(f * 2 * M_PI); - y = sin(f * 2 * M_PI); - q = fabs(x) + fabs(y); - x /= q; - y /= q; + float co = cos(f * 2 * M_PI); + float si = sin(f * 2 * M_PI); + float q = fabs(co) + fabs(si); + co /= q; + si /= q; if(f >= 1) { @@ -523,15 +543,15 @@ void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector if(d > 0) { v = centre; t = '0.5 0.5 0'; - v.x += x * 0.5 * ringsize.x; t += x * '0.5 0.5 0'; - v.y += y * 0.5 * ringsize.y; t += y * '0.5 -0.5 0'; + v.x += co * 0.5 * ringsize.x; t += co * '0.5 0.5 0'; + v.y += si * 0.5 * ringsize.y; t += si * '0.5 -0.5 0'; R_PolygonVertex(v, t, rgb, a); R_EndPolygon(); } } /** engine callback */ -void URI_Get_Callback(int id, int status, string data) +EXPORT void URI_Get_Callback(int id, int status, string data) { TC(int, id); TC(int, status); if(url_URI_Get_Callback(id, status, data)) @@ -549,7 +569,7 @@ void URI_Get_Callback(int id, int status, string data) } else { - LOG_INFOF("Received HTTP request data for an invalid id %d.\n", id); + LOG_INFOF("Received HTTP request data for an invalid id %d.", id); } } @@ -557,14 +577,12 @@ void Accuracy_LoadLevels() { if(autocvar_accuracy_color_levels != acc_color_levels) { - if(acc_color_levels) - strunzone(acc_color_levels); - acc_color_levels = strzone(autocvar_accuracy_color_levels); + strcpy(acc_color_levels, autocvar_accuracy_color_levels); acc_levels = tokenize_console(acc_color_levels); if(acc_levels > MAX_ACCURACY_LEVELS) acc_levels = MAX_ACCURACY_LEVELS; if(acc_levels < 2) - LOG_INFO("Warning: accuracy_color_levels must contain at least 2 values\n"); + LOG_INFO("Warning: accuracy_color_levels must contain at least 2 values"); int i; for(i = 0; i < acc_levels; ++i) @@ -602,4 +620,3 @@ vector Accuracy_GetColor(float accuracy) color = color + factor * (acc_col[j+1] - color); return color; } -