X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fmiscfunctions.qh;h=a2fa4edced358d7d6812ce5b5b7c38e7b4177eb2;hp=9ac46340dd45a40ec01982bd9961d25ac5baec6b;hb=1b178ce6d0a16f1df280bc596237e877061d7455;hpb=1556aa4ea70b3b275afb1cb4587e555fb44f71c3 diff --git a/qcsrc/client/miscfunctions.qh b/qcsrc/client/miscfunctions.qh index 9ac46340d..a2fa4edce 100644 --- a/qcsrc/client/miscfunctions.qh +++ b/qcsrc/client/miscfunctions.qh @@ -1,5 +1,5 @@ -#ifndef MISCFUNCTIONS_H -#define MISCFUNCTIONS_H +#ifndef CLIENT_MISCFUNCTIONS_H +#define CLIENT_MISCFUNCTIONS_H entity players; entity teams; @@ -35,7 +35,8 @@ float PreviewExists(string name); vector rotate(vector v, float a); -string ColorTranslateRGB(string s); +#define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : ((s).health <= 0)) + // decolorizes and team colors the player name when needed string playername(string thename, float teamid); @@ -44,7 +45,8 @@ float cvar_or(string cv, float v); vector project_3d_to_2d(vector vec); -void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8); +#define draw_beginBoldFont() MACRO_BEGIN { drawfont = FONT_USER + 2; } MACRO_END +#define draw_endBoldFont() MACRO_BEGIN { drawfont = FONT_USER + 1; } MACRO_END float expandingbox_sizefactor_from_fadelerp(float fadelerp); @@ -61,7 +63,7 @@ vector _drawpic_sz; float _drawpic_oldsz; string _drawpic_picpath; #define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\ - do {\ + MACRO_BEGIN {\ _drawpic_imgsize = draw_getimagesize(pic);\ if(_drawpic_imgsize != '0 0 0') {\ _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\ @@ -78,35 +80,35 @@ string _drawpic_picpath; drawpic(pos + eY * (_drawpic_oldsz - _drawpic_sz.y) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\ }\ }\ - } while(0) + } MACRO_END // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga #define drawpic_aspect_skin(pos,pic,sz,color,theAlpha,drawflag)\ - do{\ + MACRO_BEGIN {\ _drawpic_picpath = strcat(hud_skin_path, "/", pic);\ if(precache_pic(_drawpic_picpath) == "") {\ _drawpic_picpath = strcat("gfx/hud/default/", pic);\ }\ drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\ _drawpic_picpath = string_null;\ - } while(0) + } MACRO_END // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga #define drawpic_skin(pos,pic,sz,color,theAlpha,drawflag)\ - do{\ + MACRO_BEGIN {\ _drawpic_picpath = strcat(hud_skin_path, "/", pic);\ if(precache_pic(_drawpic_picpath) == "") {\ _drawpic_picpath = strcat("gfx/hud/default/", pic);\ }\ drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\ _drawpic_picpath = string_null;\ - } while(0) + } MACRO_END void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp); void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp); -#define SET_POS_AND_SZ_Y_ASPECT(allow_colors) do { \ +#define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN { \ float textaspect, oldsz; \ textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y; \ if(sz.x/sz.y > textaspect) { \ @@ -118,7 +120,7 @@ void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theSc sz.y = sz.x / textaspect; \ pos.y += (oldsz - sz.y) * 0.5; \ } \ -} while(0) +} MACRO_END // 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, vector color, float theAlpha, float drawflag); @@ -142,22 +144,6 @@ void PolyDrawModel(entity e); void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag); -const vector GETPLAYERORIGIN_ERROR = '1123581321 2357111317 3141592653'; // way out of bounds for anything on the map -vector getplayerorigin(int pl); - -float getplayeralpha(float pl); - -vector getcsqcplayercolor(float pl); - -float getplayerisdead(float pl); - -void URI_Get_Callback(int id, float status, string data); - -void draw_beginBoldFont(); - -void draw_endBoldFont(); - - const int MAX_ACCURACY_LEVELS = 10; float acc_lev[MAX_ACCURACY_LEVELS]; vector acc_col[MAX_ACCURACY_LEVELS];