#include <client/announcer.qc>
#include <client/bgmscript.qc>
#include <client/csqcmodel_hooks.qc>
+#include <client/draw.qc>
#include <client/main.qc>
#include <client/mapvoting.qc>
-#include <client/miscfunctions.qc>
#include <client/player_skeleton.qc>
#include <client/resources.qc>
#include <client/shownames.qc>
#include <client/announcer.qh>
#include <client/bgmscript.qh>
#include <client/csqcmodel_hooks.qh>
+#include <client/draw.qh>
#include <client/main.qh>
#include <client/mapvoting.qh>
-#include <client/miscfunctions.qh>
#include <client/player_skeleton.qh>
#include <client/resources.qh>
#include <client/shownames.qh>
#include "cl_cmd.qh"
#include "../autocvars.qh"
+#include <client/draw.qh>
#include <client/hud/_mod.qh>
#include <client/hud/panel/quickmenu.qh>
#include <client/hud/panel/radar.qh>
#include <client/hud/panel/vote.qh>
#include "../main.qh"
#include "../mapvoting.qh"
-#include "../miscfunctions.qh"
#include <client/view.qh>
#include <client/mutators/_mod.qh>
+++ /dev/null
-#pragma once
-
-// Mask Constants (set .drawmask on entities; use R_AddEntities to add all entities based on mask)
-const int MASK_ENGINE = BIT(0);
-const int MASK_ENGINEVIEWMODELS = BIT(1);
-const int MASK_NORMAL = BIT(2);
-
-// Renderflag Constants (used for CSQC entities)
-const int RF_VIEWMODEL = BIT(0);
-const int RF_EXTERNALMODEL = BIT(1);
-const int RF_DEPTHHACK = BIT(2);
-const int RF_ADDITIVE = BIT(3);
-const int RF_USEAXIS = BIT(4);
-
-// Viewflag Constants (use with R_SetView)
-const int VF_MIN = 1; //(vector)
-const int VF_MIN_X = 2; //(float)
-const int VF_MIN_Y = 3; //(float)
-const int VF_SIZE = 4; //(vector) (viewport size)
-const int VF_SIZE_Y = 5; //(float)
-const int VF_SIZE_X = 6; //(float)
-const int VF_VIEWPORT = 7; //(vector, vector)
-const int VF_FOV = 8; //(vector)
-const int VF_FOVX = 9; //(float)
-const int VF_FOVY = 10; //(float)
-const int VF_ORIGIN = 11; //(vector)
-const int VF_ORIGIN_X = 12; //(float)
-const int VF_ORIGIN_Y = 13; //(float)
-const int VF_ORIGIN_Z = 14; //(float)
-const int VF_ANGLES = 15; //(vector)
-const int VF_ANGLES_X = 16; //(float)
-const int VF_ANGLES_Y = 17; //(float)
-const int VF_ANGLES_Z = 18; //(float)
-const int VF_DRAWWORLD = 19; //(float)
-const int VF_DRAWENGINEHUD = 20; //(float)
-const int VF_DRAWCROSSHAIR = 21; //(float)
-const int VF_PERSPECTIVE = 200; //(float)
-
-const int VF_CL_VIEWANGLES = 33; //(vector)
-const int VF_CL_VIEWANGLES_X = 34; //(float)
-const int VF_CL_VIEWANGLES_Y = 35; //(float)
-const int VF_CL_VIEWANGLES_Z = 36; //(float)
-
-// Quake-style Point Contents
-const int CONTENT_EMPTY = -1;
-const int CONTENT_SOLID = -2;
-const int CONTENT_WATER = -3;
-const int CONTENT_SLIME = -4;
-const int CONTENT_LAVA = -5;
-const int CONTENT_SKY = -6;
-
-// Vector / Hull Constants
-const vector VEC_1 = '1 1 1';
-const vector VEC_0 = '0 0 0';
-const vector VEC_M1 = '-1 -1 -1';
-
-const vector VEC_HULL_MIN = '-16 -16 -24';
-const vector VEC_HULL_MAX = '16 16 32';
-
-// Effect Constants
-const int EF_NODRAW = BIT(4);
-const int EF_ADDITIVE = BIT(5);
-const int EF_BLUE = BIT(6);
-const int EF_RED = BIT(7);
-const int EF_FULLBRIGHT = BIT(9);
-const int EF_FLAME = BIT(10);
-const int EF_STARDUST = BIT(11);
-const int EF_NOSHADOW = BIT(12);
-const int EF_NODEPTHTEST = BIT(13);
-
-// Quake Player Flag Constants
-const int PFL_ONGROUND = BIT(0);
-const int PFL_CROUCH = BIT(1);
-const int PFL_DEAD = BIT(2);
-const int PFL_GIBBED = BIT(3);
-
-// Quake Temporary Entity Constants
-const int TE_SPIKE = 0;
-const int TE_SUPERSPIKE = 1;
-const int TE_GUNSHOT = 2;
-const int TE_EXPLOSION = 3;
-const int TE_TAREXPLOSION = 4;
-const int TE_LIGHTNING1 = 5;
-const int TE_LIGHTNING2 = 6;
-const int TE_WIZSPIKE = 7;
-const int TE_KNIGHTSPIKE = 8;
-const int TE_LIGHTNING3 = 9;
-const int TE_LAVASPLASH = 10;
-const int TE_TELEPORT = 11;
-const int TE_EXPLOSION2 = 12;
-// Darkplaces Additions
-const int TE_EXPLOSIONRGB = 53;
-const int TE_GUNSHOTQUAD = 57;
-const int TE_EXPLOSIONQUAD = 70;
-
-// Math Constants
-const int EXTRA_LOW = -99999999;
-const int EXTRA_HIGH = 99999999;
-
-// Frik File Constants
-const int FILE_READ = 0;
-const int FILE_APPEND = 1;
-const int FILE_WRITE = 2;
-
-// Button values used by input_buttons
-const int BUTTON_ATTACK = BIT(0);
-const int BUTTON_JUMP = BIT(1);
-const int BUTTON_3 = BIT(2);
-const int BUTTON_4 = BIT(3);
-const int BUTTON_5 = BIT(4);
-const int BUTTON_6 = BIT(5);
-const int BUTTON7 = BIT(6);
-const int BUTTON8 = BIT(7);
-const int BUTTON_USE = BIT(8);
-const int BUTTON_CHAT = BIT(9);
-const int BUTTON_PRYDONCURSOR = BIT(10);
-const int BUTTON_9 = BIT(11);
-const int BUTTON_10 = BIT(12);
-const int BUTTON_11 = BIT(13);
-const int BUTTON_12 = BIT(14);
-const int BUTTON_13 = BIT(15);
-const int BUTTON_14 = BIT(16);
-const int BUTTON_15 = BIT(17);
-const int BUTTON_16 = BIT(18);
-
-const int SOLID_NOT = 0; // no interaction with other objects
-const int SOLID_TRIGGER = 1; // touch on edge, but not blocking
-const int SOLID_BBOX = 2; // touch on edge, block
-const int SOLID_SLIDEBOX = 3; // touch on edge, but not an onground
-const int SOLID_BSP = 4; // bsp clip, touch on edge, block
-const int SOLID_CORPSE = 5; // same as SOLID_BBOX, except it behaves as SOLID_NOT against SOLID_SLIDEBOX objects (players/monsters)
-
-const int MOVE_NORMAL = 0; // same as false
-const int MOVE_NOMONSTERS = 1; // same as true
-const int MOVE_MISSILE = 2; // save as movement with .move_movetype == MOVETYPE_FLYMISSILE
-const int MOVE_HITMODEL = 4;
-const int MOVE_WORLDONLY = 3;
-
-const int CAMERA_FREE = 1;
-const int CAMERA_CHASE = 2;
-
-const int EF_NOMODELFLAGS = BIT(23);
#include "csqcmodel_hooks.qh"
#include "autocvars.qh"
#include "main.qh"
-#include "miscfunctions.qh"
#include <client/mutators/_mod.qh>
#include <client/main.qh>
#include "player_skeleton.qh"
--- /dev/null
+#include "draw.qh"
+
+#include <client/hud/hud.qh>
+
+void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag)
+{
+ vector line_dim = '0 0 0';
+
+ // left and right lines
+ pos.x -= thickness;
+ line_dim.x = thickness;
+ line_dim.y = dim.y;
+ drawfill(pos, line_dim, color, theAlpha, drawflag);
+ drawfill(pos + (dim.x + thickness) * '1 0 0', line_dim, color, theAlpha, drawflag);
+
+ // upper and lower lines
+ pos.y -= thickness;
+ line_dim.x = dim.x + thickness * 2; // make upper and lower lines longer
+ line_dim.y = thickness;
+ drawfill(pos, line_dim, color, theAlpha, drawflag);
+ drawfill(pos + (dim.y + thickness) * '0 1 0', line_dim, color, theAlpha, drawflag);
+}
+
+void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag)
+{
+ pos = HUD_Shift(pos);
+ sz = HUD_Scale(sz);
+ area = HUD_Scale(area);
+
+ vector current_pos = '0 0 0', end_pos, new_size = '0 0 0', ratio = '0 0 0';
+ end_pos = pos + area;
+
+ current_pos.y = pos.y;
+ while (current_pos.y < end_pos.y)
+ {
+ current_pos.x = pos.x;
+ while (current_pos.x < end_pos.x)
+ {
+ new_size.x = min(sz.x, end_pos.x - current_pos.x);
+ new_size.y = min(sz.y, end_pos.y - current_pos.y);
+ ratio.x = new_size.x / sz.x;
+ ratio.y = new_size.y / sz.y;
+ drawsubpic(current_pos, new_size, pic, '0 0 0', ratio, color, theAlpha, drawflag);
+ current_pos.x += sz.x;
+ }
+ current_pos.y += sz.y;
+ }
+}
+
+float expandingbox_sizefactor_from_fadelerp(float fadelerp)
+{
+ return 1.2 / (1.2 - fadelerp);
+}
+
+vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor)
+{
+ boxsize.x *= boxxsizefactor; // easier interface for text
+ return boxsize * (0.5 * (1 - sz));
+}
+
+void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
+{
+ float sz;
+ sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
+
+ drawpic_aspect_skin(position + expandingbox_resize_centered_box_offset(sz, theScale, 1), pic, theScale * sz, rgb, theAlpha * (1 - fadelerp), flag);
+}
+
+void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
+{
+ drawpic_aspect_skin_expanding(position, pic, theScale, rgb, theAlpha, flag, fadelerp);
+ drawpic_skin(position, pic, theScale, rgb, theAlpha * fadelerp, flag);
+}
+
+float stringwidth(string text, float handleColors, vector sz)
+{
+ vector dfs = drawfontscale;
+ drawfontscale = '1 1 0';
+ float r = stringwidth_builtin(text, handleColors, sz);
+ drawfontscale = dfs;
+ return r;
+}
+
+#define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN \
+ float textaspect, oldsz; \
+ vector dfs = drawfontscale; \
+ drawfontscale = '1 1 0'; \
+ textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y; \
+ drawfontscale = dfs; \
+ if(sz.x/sz.y > textaspect) { \
+ oldsz = sz.x; \
+ sz.x = sz.y * textaspect; \
+ pos.x += (oldsz - sz.x) * 0.5; \
+ } else { \
+ oldsz = sz.y; \
+ sz.y = sz.x / textaspect; \
+ pos.y += (oldsz - sz.y) * 0.5; \
+ } \
+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) {
+ SET_POS_AND_SZ_Y_ASPECT(false);
+ drawstring(pos, text, '1 1 0' * sz.y, color, theAlpha, drawflag);
+}
+
+// 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 theAlpha, float drawflag) {
+ SET_POS_AND_SZ_Y_ASPECT(true);
+ drawcolorcodedstring(pos, text, '1 1 0' * sz.y, theAlpha, drawflag);
+}
+
+void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
+{
+ float sz;
+ sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
+
+ drawfontscale = hud_scale * sz;
+ vector dfs = drawfontscale;
+ drawfontscale = sz * '1 1 0';
+ float textaspect = stringwidth_builtin(text, false, theScale * (sz / drawfontscale.x)) / (theScale.x * sz);
+ drawfontscale = dfs;
+ drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, textaspect), text, HUD_Scale(theScale * (sz / drawfontscale.x)), rgb, theAlpha * (1 - fadelerp), flag);
+ // width parameter:
+ // (scale_x * sz / drawfontscale.x) * drawfontscale.x * SIZE1 / (scale_x * sz)
+ // SIZE1
+ drawfontscale = hud_scale;
+}
+
+// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
+void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp) {
+ SET_POS_AND_SZ_Y_ASPECT(false);
+ drawstring_expanding(pos, text, '1 1 0' * sz.y, color, theAlpha, drawflag, fadelerp);
+}
+
+void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp)
+{
+ float sz;
+ sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
+
+ drawfontscale = hud_scale * sz;
+ // eventually replace with drawcolorcodedstring
+ drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth_builtin(text, true, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
+ drawfontscale = hud_scale;
+}
+
+void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp) {
+ SET_POS_AND_SZ_Y_ASPECT(true);
+ drawcolorcodedstring_expanding(pos, text, '1 1 0' * sz.y, theAlpha, drawflag, fadelerp);
+}
+
+// this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
+float PolyDrawModelSurface(entity e, float i_s)
+{
+ float i_t;
+ float n_t;
+ vector tri;
+ string tex;
+ tex = getsurfacetexture(e, i_s);
+ if (!tex)
+ return 0; // this is beyond the last one
+ n_t = getsurfacenumtriangles(e, i_s);
+ for(i_t = 0; i_t < n_t; ++i_t)
+ {
+ tri = getsurfacetriangle(e, i_s, i_t);
+ R_BeginPolygon(tex, 0, false);
+ R_PolygonVertex(getsurfacepoint(e, i_s, tri.x), getsurfacepointattribute(e, i_s, tri.x, SPA_TEXCOORDS0), '1 1 1', 1);
+ R_PolygonVertex(getsurfacepoint(e, i_s, tri.y), getsurfacepointattribute(e, i_s, tri.y, SPA_TEXCOORDS0), '1 1 1', 1);
+ R_PolygonVertex(getsurfacepoint(e, i_s, tri.z), getsurfacepointattribute(e, i_s, tri.z, SPA_TEXCOORDS0), '1 1 1', 1);
+ R_EndPolygon();
+ }
+ return 1;
+}
+void PolyDrawModel(entity e)
+{
+ float i_s;
+ for(i_s = 0; ; ++i_s)
+ if(!PolyDrawModelSurface(e, i_s))
+ break;
+}
+
+void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag)
+{
+ vector ringsize, v, t;
+ ringsize = radi * '1 1 0';
+ centre = HUD_Shift(centre);
+ ringsize = HUD_Scale(ringsize);
+
+ if(f >= 1)
+ {
+ // draw full rectangle
+ R_BeginPolygon(pic, drawflag, true);
+ v = centre; t = '0.5 0.5 0';
+ v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.y += 0.5 * ringsize.y; t += '0.5 -0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.y -= 0.5 * ringsize.y; t -= '0.5 -0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+ R_EndPolygon();
+ return; // Complete rectangle, nothing more needed.
+ }
+
+ 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 > 0.75)
+ {
+ // draw upper half in full
+ R_BeginPolygon(pic, drawflag, true);
+ v = centre; t = '0.5 0.5 0';
+ v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.y += 0.5 * ringsize.y; t += '0.5 -0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+ R_EndPolygon();
+ // draw clipped lower half as a quad
+ R_BeginPolygon(pic, drawflag, true);
+ v = centre; t = '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.y -= 0.5 * ringsize.y; t -= '0.5 -0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+ }
+ else if(f > 0.5)
+ {
+ // draw upper half in full
+ R_BeginPolygon(pic, drawflag, true);
+ v = centre; t = '0.5 0.5 0';
+ v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.y += 0.5 * ringsize.y; t += '0.5 -0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+ R_EndPolygon();
+ // draw clipped lower half as a triangle
+ R_BeginPolygon(pic, drawflag, true);
+ v = centre; t = '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+ }
+ else if(f > 0.25)
+ {
+ // draw clipped lower half as a quad
+ R_BeginPolygon(pic, drawflag, true);
+ v = centre; t = '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.y += 0.5 * ringsize.y; t += '0.5 -0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+ }
+ else if (f > 0)
+ {
+ // draw clipped lower half as a triangle
+ R_BeginPolygon(pic, drawflag, true);
+ v = centre; t = '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+
+ v = centre; t = '0.5 0.5 0';
+ v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
+ R_PolygonVertex(v, t, rgb, a);
+ }
+ else
+ {
+ // Nothing to draw.
+ return;
+ }
+
+ // The last, moving vertex.
+ v = centre; t = '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();
+}
--- /dev/null
+#pragma once
+
+vector drawfontscale;
+#define draw_beginBoldFont() drawfont = FONT_USER + 2
+#define draw_endBoldFont() drawfont = FONT_USER + 1
+
+float expandingbox_sizefactor_from_fadelerp(float fadelerp);
+
+vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
+void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
+
+void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
+
+// The following functions / macros must be called from within
+// the panel HUD / scoreboard code so that pos and size are scaled
+// when the hud_dynamic code is running.
+// Make use of stringwidth_builtin and draw*_builtin everywhere else.
+
+float stringwidth(string text, float handleColors, vector sz);
+
+#define drawpic(position, pic, size, rgb, alpha, flag) \
+ drawpic_builtin(HUD_Shift(position), pic, HUD_Scale(size), rgb, alpha, flag)
+
+#define drawcharacter(position, character, scale, rgb, alpha, flag) \
+ drawcharacter_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
+
+#define drawstring(position, text, scale, rgb, alpha, flag) \
+ drawstring_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
+
+#define drawcolorcodedstring(position, text, scale, alpha, flag) \
+ drawcolorcodedstring_builtin(HUD_Shift(position), text, scale, alpha, flag)
+
+#define drawcolorcodedstring2(position, text, scale, rgb, alpha, flag) \
+ drawcolorcodedstring2_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
+
+#define drawfill(position, size, rgb, alpha, flag) \
+ drawfill_builtin(HUD_Shift(position), HUD_Scale(size), rgb, alpha, flag)
+
+#define drawsetcliparea(xposition, yposition, w, h) \
+ drawsetcliparea_builtin(HUD_ShiftX(xposition), HUD_ShiftY(yposition), HUD_ScaleX(w), HUD_ScaleY(h))
+
+// Since drawsubpic usually gets called multiple times from within an
+// utility function, instead of scaling pos and size in every call
+// we scale them once for all in the beginning of that utility function.
+// That's why drawsubpic isn't remapped.
+/*
+#define drawsubpic(position, size, pic, srcPosition, srcSize, rgb, alpha, flag) \
+ drawsubpic_builtin(HUD_Shift(position), HUD_Scale(size), pic, HUD_Shift(srcPosition), HUD_Scale(srcSize), rgb, alpha, flag)
+*/
+
+// drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
+float _drawpic_imgaspect;
+vector _drawpic_imgsize;
+vector _drawpic_sz;
+float _drawpic_oldsz;
+string _drawpic_picpath;
+#define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
+ MACRO_BEGIN \
+ _drawpic_imgsize = draw_getimagesize(pic);\
+ if(_drawpic_imgsize != '0 0 0') {\
+ _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\
+ _drawpic_sz = mySize;\
+ if(_drawpic_sz.x/_drawpic_sz.y > _drawpic_imgaspect) {\
+ _drawpic_oldsz = _drawpic_sz.x;\
+ _drawpic_sz.x = _drawpic_sz.y * _drawpic_imgaspect;\
+ if(_drawpic_sz.x)\
+ drawpic(pos + eX * 0.5 * (_drawpic_oldsz - _drawpic_sz.x), pic, _drawpic_sz, color, theAlpha, drawflag);\
+ } else {\
+ _drawpic_oldsz = _drawpic_sz.y;\
+ _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\
+ if(_drawpic_sz.y)\
+ drawpic(pos + eY * 0.5 * (_drawpic_oldsz - _drawpic_sz.y), pic, _drawpic_sz, color, theAlpha, drawflag);\
+ }\
+ }\
+ 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)\
+ 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;\
+ 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)\
+ 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;\
+ 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);
+
+// 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);
+
+// 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 theAlpha, float drawflag);
+
+void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
+
+// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
+void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp);
+
+void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
+
+void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
+// this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
+float PolyDrawModelSurface(entity e, float i_s);
+void PolyDrawModel(entity e);
+
+void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
#include "crosshair.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include <client/hud/panel/scoreboard.qh>
#include <client/view.qh>
#include "hud.qh"
+#include <client/draw.qh>
#include <client/items/items.qh>
-#include <client/miscfunctions.qh>
#include <client/view.qh>
#include "panel/scoreboard.qh"
#include "hud_config.qh"
}
}
+void HUD_Scale_Disable()
+{
+ hud_scale = '1 1 0';
+ hud_shift = '0 0 0';
+ drawfontscale = hud_scale;
+}
+
+void HUD_Scale_Enable()
+{
+ hud_scale = hud_scale_current;
+ hud_shift = hud_shift_current;
+ drawfontscale = hud_scale;
+}
+
+vector HUD_Scale(vector v)
+{
+ v.x = HUD_ScaleX(v.x);
+ v.y = HUD_ScaleY(v.y);
+ return v;
+}
+
+vector HUD_Shift(vector v)
+{
+ v.x = HUD_ShiftX(v.x);
+ v.y = HUD_ShiftY(v.y);
+ return v;
+}
+
+vector HUD_GetFontsize(string cvarname)
+{
+ vector v;
+ v = stov(cvar_string(cvarname));
+ if(v.x == 0)
+ v = '8 8 0';
+ if(v.y == 0)
+ v.y = v.x;
+ v.z = 0;
+ return v;
+}
+
vector HUD_Get_Num_Color(float hp, float maxvalue, bool blink)
{
const vector COLOR100 = '0 1 0'; // green
void draw_cursor_normal(vector pos, vector col, float a);
void LoadMenuSkinValues();
+void HUD_Scale_Disable();
+void HUD_Scale_Enable();
+
+#define HUD_ScaleX(f) (f * hud_scale.x)
+#define HUD_ScaleY(f) (f * hud_scale.y)
+#define HUD_ShiftX(f) (f + hud_shift.x + hud_shift.z * (f - hud_scale_center.x))
+#define HUD_ShiftY(f) (f + hud_shift.y + hud_shift.z * (f - hud_scale_center.y))
+vector HUD_Scale(vector v);
+vector HUD_Shift(vector v);
+
+vector HUD_GetFontsize(string cvarname);
+
void Hud_Dynamic_Frame();
bool HUD_Radar_Clickable();
#include "hud.qh"
#include "panel/scoreboard.qh"
#include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
#include <client/view.qh>
// Save the config
#include "ammo.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/items/items.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include <client/view.qh>
#include <common/wepent.qh>
#include <common/mutators/mutator/nades/nades.qh>
#include "scoreboard.qh"
#include <common/notifications/all.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
// CenterPrint (#16)
#include "chat.qh"
#include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
// Chat (#12)
#include "engineinfo.qh"
#include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
// Engine info (#13)
#include "healtharmor.qh"
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include <common/deathtypes/all.qh>
#include "infomessages.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include <common/ent_cs.qh>
#include "modicons.qh"
-#include <client/miscfunctions.qh>
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <common/mapinfo.qh>
#include <common/ent_cs.qh>
#include <common/scores.qh>
#include "notify.qh"
#include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
// Notifications (#4)
#include "physics.qh"
#include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
#include <client/main.qh>
#include <lib/csqcmodel/cl_player.qh>
#include "powerups.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include <common/items/_mod.qh>
#include <common/util.qh>
#include "pressedkeys.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
// Pressed keys (#11)
#include "quickmenu.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include <common/ent_cs.qh>
#include <common/minigames/cl_minigames.qh>
#include <client/hud/_mod.qh>
#include "racetimer.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
// Race timer (#8)
#include "radar.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include <common/ent_cs.qh>
#include <client/mapvoting.qh>
#include <client/resources.qh>
#include "score.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include "scoreboard.qh"
#include <common/ent_cs.qh>
#include <common/scores.qh>
#include "scoreboard.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include <client/hud/panel/racetimer.qh>
+#include <client/hud/panel/weapons.qh>
#include "quickmenu.qh"
#include <common/ent_cs.qh>
#include <common/constants.qh>
#include "timer.qh"
#include <client/autocvars.qh>
-#include <client/miscfunctions.qh>
+#include <client/draw.qh>
#include <client/view.qh>
// Timer (#5)
#include "vote.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
// Vote (#9)
#include "weapons.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <client/main.qh>
-#include <client/miscfunctions.qh>
#include <client/view.qh>
#include <common/wepent.qh>
HUD_Write_Cvar("hud_panel_weapons_selection_speed");
}
+void Accuracy_LoadLevels()
+{
+ if(autocvar_accuracy_color_levels != acc_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");
+
+ int i;
+ for(i = 0; i < acc_levels; ++i)
+ acc_lev[i] = stof(argv(i)) / 100.0;
+ }
+}
+
+void Accuracy_LoadColors()
+{
+ if(time > acc_col_loadtime)
+ if(acc_levels >= 2)
+ {
+ int i;
+ for(i = 0; i < acc_levels; ++i)
+ acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
+ acc_col_loadtime = time + 2;
+ }
+}
+
+vector Accuracy_GetColor(float accuracy)
+{
+ float factor;
+ vector color;
+ if(acc_levels < 2)
+ return '0 0 0'; // return black, can't determine the right color
+
+ // find the max level lower than acc
+ int j = acc_levels-1;
+ while(j && accuracy < acc_lev[j])
+ --j;
+
+ // inject color j+1 in color j, how much depending on how much accuracy is higher than level j
+ factor = (accuracy - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
+ color = acc_col[j];
+ color = color + factor * (acc_col[j+1] - color);
+ return color;
+}
+
entity weaponorder[REGISTRY_MAX(Weapons)];
void weaponorder_swap(int i, int j, entity pass)
{
#pragma once
#include "../panel.qh"
+
+const int MAX_ACCURACY_LEVELS = 10;
+float acc_lev[MAX_ACCURACY_LEVELS];
+vector acc_col[MAX_ACCURACY_LEVELS];
+float acc_col_loadtime;
+int acc_levels;
+string acc_color_levels;
+void Accuracy_LoadLevels();
+
+void Accuracy_LoadColors();
+
+vector Accuracy_GetColor(float accuracy);
#include "main.qh"
+#include <client/draw.qh>
#include <client/items/items.qh>
#include <common/ent_cs.qh>
-#include "miscfunctions.qh"
#include <common/effects/effect.qh>
#include <common/effects/qc/_mod.qh>
#include <common/effects/all.qh>
ReplicateVars(true); // destroy
}
+void AuditLists()
+{
+ entity e;
+ entity prev;
+
+ prev = players;
+ for(e = prev.sort_next; e; prev = e, e = e.sort_next)
+ {
+ if(prev != e.sort_prev)
+ error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
+ }
+
+ prev = teams;
+ for(e = prev.sort_next; e; prev = e, e = e.sort_next)
+ {
+ if(prev != e.sort_prev)
+ error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
+ }
+}
+
+float RegisterPlayer(entity player)
+{
+ entity pl;
+ AuditLists();
+ for(pl = players.sort_next; pl; pl = pl.sort_next)
+ if(pl == player)
+ error("Player already registered!");
+ player.sort_next = players.sort_next;
+ player.sort_prev = players;
+ if(players.sort_next)
+ players.sort_next.sort_prev = player;
+ players.sort_next = player;
+ AuditLists();
+ return true;
+}
+
+void RemovePlayer(entity player)
+{
+ entity pl, parent;
+ AuditLists();
+ parent = players;
+ for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
+ parent = pl;
+
+ if(!pl)
+ {
+ error("Trying to remove a player which is not in the playerlist!");
+ return;
+ }
+ parent.sort_next = player.sort_next;
+ if(player.sort_next)
+ player.sort_next.sort_prev = parent;
+ AuditLists();
+}
+
+void MoveToLast(entity e)
+{
+ AuditLists();
+ entity ent = e.sort_next;
+ while(ent)
+ {
+ SORT_SWAP(ent, e);
+ ent = e.sort_next;
+ }
+ AuditLists();
+}
+
+float RegisterTeam(entity Team)
+{
+ assert_once(Team.team, eprint(Team));
+ entity tm;
+ AuditLists();
+ for(tm = teams.sort_next; tm; tm = tm.sort_next)
+ if(tm == Team)
+ error("Team already registered!");
+ Team.sort_next = teams.sort_next;
+ Team.sort_prev = teams;
+ if(teams.sort_next)
+ teams.sort_next.sort_prev = Team;
+ teams.sort_next = Team;
+ if(Team.team && Team.team != NUM_SPECTATOR)
+ ++team_count;
+ AuditLists();
+ return true;
+}
+
+void RemoveTeam(entity Team)
+{
+ entity tm, parent;
+ AuditLists();
+ parent = teams;
+ for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
+ parent = tm;
+
+ if(!tm)
+ {
+ LOG_INFO(_("Trying to remove a team which is not in the teamlist!"));
+ return;
+ }
+ parent.sort_next = Team.sort_next;
+ if(Team.sort_next)
+ Team.sort_next.sort_prev = parent;
+ if(Team.team && Team.team != NUM_SPECTATOR)
+ --team_count;
+ AuditLists();
+}
+
+entity GetTeam(int Team, bool add)
+{
+ TC(int, Team); TC(bool, add);
+ int num = (Team == NUM_SPECTATOR) ? 16 : Team;
+ if(teamslots[num])
+ return teamslots[num];
+ if (!add)
+ return NULL;
+ entity tm = new_pure(team);
+ tm.team = Team;
+ teamslots[num] = tm;
+ RegisterTeam(tm);
+ return tm;
+}
+
.float has_team;
bool SetTeam(entity o, int Team)
{
else
return keys;
}
+
+/** engine callback */
+void URI_Get_Callback(int id, int status, string data)
+{
+ TC(int, id); TC(int, status);
+ if(url_URI_Get_Callback(id, status, data))
+ {
+ // handled
+ }
+ else if (id == URI_GET_DISCARD)
+ {
+ // discard
+ }
+ else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
+ {
+ // sv_cmd curl
+ Curl_URI_Get_Callback(id, status, data);
+ }
+ else
+ {
+ LOG_INFOF("Received HTTP request data for an invalid id %d.", id);
+ }
+}
void Gamemode_Init();
+entity players;
+entity teams;
+float team_count; // real teams
+
+void AuditLists();
+
+float RegisterPlayer(entity player);
+
+void RemovePlayer(entity player);
+
+void MoveToLast(entity e);
+
+float RegisterTeam(entity Team);
+
+void RemoveTeam(entity Team);
+
+entity GetTeam(int Team, bool add);
+
bool SetTeam(entity pl, int Team);
vector hud_fontsize;
#include "mapvoting.qh"
#include "autocvars.qh"
+#include <client/draw.qh>
#include "main.qh"
-#include "miscfunctions.qh"
#include "hud/_mod.qh"
#include "hud/panel/scoreboard.qh"
string ssdirs[NUM_SSDIRS];
int n_ssdirs;
+bool PreviewExists(string name)
+{
+ if(autocvar_cl_readpicture_force)
+ return false;
+
+ if (fexists(strcat(name, ".tga"))) return true;
+ if (fexists(strcat(name, ".png"))) return true;
+ if (fexists(strcat(name, ".jpg"))) return true;
+ if (fexists(strcat(name, ".pcx"))) return true;
+
+ return false;
+}
+
string MapVote_FormatMapItem(int id, string map, float _count, float maxwidth, vector fontsize)
{
TC(int, id);
#include <common/constants.qh>
void MapVote_Draw();
+bool PreviewExists(string name);
+
void Cmd_MapVote_MapDownload(int argc);
float MapVote_InputEvent(float bInputType, float nPrimary, float nSecondary);
+++ /dev/null
-#include "miscfunctions.qh"
-
-#include "autocvars.qh"
-#include "hud/_mod.qh"
-#include "main.qh"
-
-#include <common/command/_mod.qh>
-
-#include <common/teams.qh>
-
-#include <lib/csqcmodel/cl_model.qh>
-
-
-void AuditLists()
-{
- entity e;
- entity prev;
-
- prev = players;
- for(e = prev.sort_next; e; prev = e, e = e.sort_next)
- {
- if(prev != e.sort_prev)
- error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
- }
-
- prev = teams;
- for(e = prev.sort_next; e; prev = e, e = e.sort_next)
- {
- if(prev != e.sort_prev)
- error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
- }
-}
-
-
-float RegisterPlayer(entity player)
-{
- entity pl;
- AuditLists();
- for(pl = players.sort_next; pl; pl = pl.sort_next)
- if(pl == player)
- error("Player already registered!");
- player.sort_next = players.sort_next;
- player.sort_prev = players;
- if(players.sort_next)
- players.sort_next.sort_prev = player;
- players.sort_next = player;
- AuditLists();
- return true;
-}
-
-void RemovePlayer(entity player)
-{
- entity pl, parent;
- AuditLists();
- parent = players;
- for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
- parent = pl;
-
- if(!pl)
- {
- error("Trying to remove a player which is not in the playerlist!");
- return;
- }
- parent.sort_next = player.sort_next;
- if(player.sort_next)
- player.sort_next.sort_prev = parent;
- AuditLists();
-}
-
-void MoveToLast(entity e)
-{
- AuditLists();
- entity ent = e.sort_next;
- while(ent)
- {
- SORT_SWAP(ent, e);
- ent = e.sort_next;
- }
- AuditLists();
-}
-
-float RegisterTeam(entity Team)
-{
- assert_once(Team.team, eprint(Team));
- entity tm;
- AuditLists();
- for(tm = teams.sort_next; tm; tm = tm.sort_next)
- if(tm == Team)
- error("Team already registered!");
- Team.sort_next = teams.sort_next;
- Team.sort_prev = teams;
- if(teams.sort_next)
- teams.sort_next.sort_prev = Team;
- teams.sort_next = Team;
- if(Team.team && Team.team != NUM_SPECTATOR)
- ++team_count;
- AuditLists();
- return true;
-}
-
-void RemoveTeam(entity Team)
-{
- entity tm, parent;
- AuditLists();
- parent = teams;
- for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
- parent = tm;
-
- if(!tm)
- {
- LOG_INFO(_("Trying to remove a team which is not in the teamlist!"));
- return;
- }
- parent.sort_next = Team.sort_next;
- if(Team.sort_next)
- Team.sort_next.sort_prev = parent;
- if(Team.team && Team.team != NUM_SPECTATOR)
- --team_count;
- AuditLists();
-}
-
-entity GetTeam(int Team, bool add)
-{
- TC(int, Team); TC(bool, add);
- int num = (Team == NUM_SPECTATOR) ? 16 : Team;
- if(teamslots[num])
- return teamslots[num];
- if (!add)
- return NULL;
- entity tm = new_pure(team);
- tm.team = Team;
- teamslots[num] = tm;
- RegisterTeam(tm);
- return tm;
-}
-
-vector HUD_GetFontsize(string cvarname)
-{
- vector v;
- v = stov(cvar_string(cvarname));
- if(v.x == 0)
- v = '8 8 0';
- if(v.y == 0)
- v.y = v.x;
- v.z = 0;
- return v;
-}
-
-float PreviewExists(string name)
-{
- if(autocvar_cl_readpicture_force)
- return false;
-
- if (fexists(strcat(name, ".tga"))) return true;
- if (fexists(strcat(name, ".png"))) return true;
- if (fexists(strcat(name, ".jpg"))) return true;
- if (fexists(strcat(name, ".pcx"))) return true;
-
- return false;
-}
-
-float cvar_or(string cv, float v)
-{
- string s;
- s = cvar_string(cv);
- if(s == "")
- return v;
- else
- return stof(s);
-}
-
-vector project_3d_to_2d(vector vec)
-{
- vec = cs_project(vec);
- if(cs_project_is_b0rked > 0)
- {
- vec.x *= vid_conwidth / vid_width;
- vec.y *= vid_conheight / vid_height;
- }
- 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);
-}
-
-vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor)
-{
- boxsize.x *= boxxsizefactor; // easier interface for text
- return boxsize * (0.5 * (1 - sz));
-}
-
-// NOTE base is the central value
-// freq: circle frequency, = 2*pi*frequency in hertz
-// start_pos:
-// -1 start from the lower value
-// 0 start from the base value
-// 1 start from the higher value
-float blink_synced(float base, float range, float freq, float start_time, int start_pos)
-{
- // note:
- // RMS = sqrt(base^2 + 0.5 * range^2)
- // thus
- // base = sqrt(RMS^2 - 0.5 * range^2)
- // ensure RMS == 1
-
- return base + range * sin((time - start_time - (M_PI / 2) * start_pos) * freq);
-}
-
-float blink(float base, float range, float freq)
-{
- return blink_synced(base, range, freq, 0, 0);
-}
-
-void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag)
-{
- vector line_dim = '0 0 0';
-
- // left and right lines
- pos.x -= thickness;
- line_dim.x = thickness;
- line_dim.y = dim.y;
- drawfill(pos, line_dim, color, theAlpha, drawflag);
- drawfill(pos + (dim.x + thickness) * '1 0 0', line_dim, color, theAlpha, drawflag);
-
- // upper and lower lines
- pos.y -= thickness;
- line_dim.x = dim.x + thickness * 2; // make upper and lower lines longer
- line_dim.y = thickness;
- drawfill(pos, line_dim, color, theAlpha, drawflag);
- drawfill(pos + (dim.y + thickness) * '0 1 0', line_dim, color, theAlpha, drawflag);
-}
-
-void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag)
-{
- pos = HUD_Shift(pos);
- sz = HUD_Scale(sz);
- area = HUD_Scale(area);
-
- vector current_pos = '0 0 0', end_pos, new_size = '0 0 0', ratio = '0 0 0';
- end_pos = pos + area;
-
- current_pos.y = pos.y;
- while (current_pos.y < end_pos.y)
- {
- current_pos.x = pos.x;
- while (current_pos.x < end_pos.x)
- {
- new_size.x = min(sz.x, end_pos.x - current_pos.x);
- new_size.y = min(sz.y, end_pos.y - current_pos.y);
- ratio.x = new_size.x / sz.x;
- ratio.y = new_size.y / sz.y;
- drawsubpic(current_pos, new_size, pic, '0 0 0', ratio, color, theAlpha, drawflag);
- current_pos.x += sz.x;
- }
- current_pos.y += sz.y;
- }
-}
-
-void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
-{
- float sz;
- sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
-
- drawpic_aspect_skin(position + expandingbox_resize_centered_box_offset(sz, theScale, 1), pic, theScale * sz, rgb, theAlpha * (1 - fadelerp), flag);
-}
-
-void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
-{
- drawpic_aspect_skin_expanding(position, pic, theScale, rgb, theAlpha, flag, fadelerp);
- drawpic_skin(position, pic, theScale, rgb, theAlpha * fadelerp, flag);
-}
-
-void HUD_Scale_Disable()
-{
- hud_scale = '1 1 0';
- hud_shift = '0 0 0';
- drawfontscale = hud_scale;
-}
-
-void HUD_Scale_Enable()
-{
- hud_scale = hud_scale_current;
- hud_shift = hud_shift_current;
- drawfontscale = hud_scale;
-}
-
-vector HUD_Scale(vector v)
-{
- v.x = HUD_ScaleX(v.x);
- v.y = HUD_ScaleY(v.y);
- return v;
-}
-
-vector HUD_Shift(vector v)
-{
- v.x = HUD_ShiftX(v.x);
- v.y = HUD_ShiftY(v.y);
- return v;
-}
-
-float stringwidth(string text, float handleColors, vector sz)
-{
- vector dfs = drawfontscale;
- drawfontscale = '1 1 0';
- float r = stringwidth_builtin(text, handleColors, sz);
- drawfontscale = dfs;
- return r;
-}
-
-#define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN \
- float textaspect, oldsz; \
- vector dfs = drawfontscale; \
- drawfontscale = '1 1 0'; \
- textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y; \
- drawfontscale = dfs; \
- if(sz.x/sz.y > textaspect) { \
- oldsz = sz.x; \
- sz.x = sz.y * textaspect; \
- pos.x += (oldsz - sz.x) * 0.5; \
- } else { \
- oldsz = sz.y; \
- sz.y = sz.x / textaspect; \
- pos.y += (oldsz - sz.y) * 0.5; \
- } \
-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) {
- SET_POS_AND_SZ_Y_ASPECT(false);
- drawstring(pos, text, '1 1 0' * sz.y, color, theAlpha, drawflag);
-}
-
-// 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 theAlpha, float drawflag) {
- SET_POS_AND_SZ_Y_ASPECT(true);
- drawcolorcodedstring(pos, text, '1 1 0' * sz.y, theAlpha, drawflag);
-}
-
-void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
-{
- float sz;
- sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
-
- drawfontscale = hud_scale * sz;
- vector dfs = drawfontscale;
- drawfontscale = sz * '1 1 0';
- float textaspect = stringwidth_builtin(text, false, theScale * (sz / drawfontscale.x)) / (theScale.x * sz);
- drawfontscale = dfs;
- drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, textaspect), text, HUD_Scale(theScale * (sz / drawfontscale.x)), rgb, theAlpha * (1 - fadelerp), flag);
- // width parameter:
- // (scale_x * sz / drawfontscale.x) * drawfontscale.x * SIZE1 / (scale_x * sz)
- // SIZE1
- drawfontscale = hud_scale;
-}
-
-// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
-void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp) {
- SET_POS_AND_SZ_Y_ASPECT(false);
- drawstring_expanding(pos, text, '1 1 0' * sz.y, color, theAlpha, drawflag, fadelerp);
-}
-
-void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp)
-{
- float sz;
- sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
-
- drawfontscale = hud_scale * sz;
- // eventually replace with drawcolorcodedstring
- drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth_builtin(text, true, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
- drawfontscale = hud_scale;
-}
-
-void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp) {
- SET_POS_AND_SZ_Y_ASPECT(true);
- 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)
-{
- float i_t;
- float n_t;
- vector tri;
- string tex;
- tex = getsurfacetexture(e, i_s);
- if (!tex)
- return 0; // this is beyond the last one
- n_t = getsurfacenumtriangles(e, i_s);
- for(i_t = 0; i_t < n_t; ++i_t)
- {
- tri = getsurfacetriangle(e, i_s, i_t);
- R_BeginPolygon(tex, 0, false);
- R_PolygonVertex(getsurfacepoint(e, i_s, tri.x), getsurfacepointattribute(e, i_s, tri.x, SPA_TEXCOORDS0), '1 1 1', 1);
- R_PolygonVertex(getsurfacepoint(e, i_s, tri.y), getsurfacepointattribute(e, i_s, tri.y, SPA_TEXCOORDS0), '1 1 1', 1);
- R_PolygonVertex(getsurfacepoint(e, i_s, tri.z), getsurfacepointattribute(e, i_s, tri.z, SPA_TEXCOORDS0), '1 1 1', 1);
- R_EndPolygon();
- }
- return 1;
-}
-void PolyDrawModel(entity e)
-{
- float i_s;
- for(i_s = 0; ; ++i_s)
- if(!PolyDrawModelSurface(e, i_s))
- break;
-}
-
-void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag)
-{
- vector ringsize, v, t;
- ringsize = radi * '1 1 0';
- centre = HUD_Shift(centre);
- ringsize = HUD_Scale(ringsize);
-
- if(f >= 1)
- {
- // draw full rectangle
- R_BeginPolygon(pic, drawflag, true);
- v = centre; t = '0.5 0.5 0';
- v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.y += 0.5 * ringsize.y; t += '0.5 -0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.y -= 0.5 * ringsize.y; t -= '0.5 -0.5 0';
- R_PolygonVertex(v, t, rgb, a);
- R_EndPolygon();
- return; // Complete rectangle, nothing more needed.
- }
-
- 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 > 0.75)
- {
- // draw upper half in full
- R_BeginPolygon(pic, drawflag, true);
- v = centre; t = '0.5 0.5 0';
- v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.y += 0.5 * ringsize.y; t += '0.5 -0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
- R_EndPolygon();
- // draw clipped lower half as a quad
- R_BeginPolygon(pic, drawflag, true);
- v = centre; t = '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.y -= 0.5 * ringsize.y; t -= '0.5 -0.5 0';
- R_PolygonVertex(v, t, rgb, a);
- }
- else if(f > 0.5)
- {
- // draw upper half in full
- R_BeginPolygon(pic, drawflag, true);
- v = centre; t = '0.5 0.5 0';
- v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.y += 0.5 * ringsize.y; t += '0.5 -0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
- R_EndPolygon();
- // draw clipped lower half as a triangle
- R_BeginPolygon(pic, drawflag, true);
- v = centre; t = '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.x -= 0.5 * ringsize.x; t -= '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
- }
- else if(f > 0.25)
- {
- // draw clipped lower half as a quad
- R_BeginPolygon(pic, drawflag, true);
- v = centre; t = '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.y += 0.5 * ringsize.y; t += '0.5 -0.5 0';
- R_PolygonVertex(v, t, rgb, a);
- }
- else if (f > 0)
- {
- // draw clipped lower half as a triangle
- R_BeginPolygon(pic, drawflag, true);
- v = centre; t = '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
-
- v = centre; t = '0.5 0.5 0';
- v.x += 0.5 * ringsize.x; t += '0.5 0.5 0';
- R_PolygonVertex(v, t, rgb, a);
- }
- else
- {
- // Nothing to draw.
- return;
- }
-
- // The last, moving vertex.
- v = centre; t = '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)
-{
- TC(int, id); TC(int, status);
- if(url_URI_Get_Callback(id, status, data))
- {
- // handled
- }
- else if (id == URI_GET_DISCARD)
- {
- // discard
- }
- else if (id >= URI_GET_CURL && id <= URI_GET_CURL_END)
- {
- // sv_cmd curl
- Curl_URI_Get_Callback(id, status, data);
- }
- else
- {
- LOG_INFOF("Received HTTP request data for an invalid id %d.", id);
- }
-}
-
-void Accuracy_LoadLevels()
-{
- if(autocvar_accuracy_color_levels != acc_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");
-
- int i;
- for(i = 0; i < acc_levels; ++i)
- acc_lev[i] = stof(argv(i)) / 100.0;
- }
-}
-
-void Accuracy_LoadColors()
-{
- if(time > acc_col_loadtime)
- if(acc_levels >= 2)
- {
- int i;
- for(i = 0; i < acc_levels; ++i)
- acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i))));
- acc_col_loadtime = time + 2;
- }
-}
-
-vector Accuracy_GetColor(float accuracy)
-{
- float factor;
- vector color;
- if(acc_levels < 2)
- return '0 0 0'; // return black, can't determine the right color
-
- // find the max level lower than acc
- int j = acc_levels-1;
- while(j && accuracy < acc_lev[j])
- --j;
-
- // inject color j+1 in color j, how much depending on how much accuracy is higher than level j
- factor = (accuracy - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
- color = acc_col[j];
- color = color + factor * (acc_col[j+1] - color);
- return color;
-}
+++ /dev/null
-#pragma once
-
-entity players;
-entity teams;
-float team_count; // real teams
-
-const int INITPRIO_FIRST = 0;
-const int INITPRIO_GAMETYPE = 0;
-const int INITPRIO_GAMETYPE_FALLBACK = 1;
-const int INITPRIO_FINDTARGET = 10;
-const int INITPRIO_DROPTOFLOOR = 20;
-const int INITPRIO_SETLOCATION = 90;
-const int INITPRIO_LINKDOORS = 91;
-const int INITPRIO_LAST = 99;
-
-void AuditLists();
-
-float RegisterPlayer(entity player);
-
-void RemovePlayer(entity player);
-
-void MoveToLast(entity e);
-
-float RegisterTeam(entity Team);
-
-void RemoveTeam(entity Team);
-
-entity GetTeam(int Team, bool add);
-
-vector HUD_GetFontsize(string cvarname);
-
-float PreviewExists(string name);
-
-vector Rotate(vector v, float a);
-
-
-#define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : (GetResource((s), RES_HEALTH) <= 0))
-
-float cvar_or(string cv, float v);
-
-vector project_3d_to_2d(vector vec);
-
-vector drawfontscale;
-#define draw_beginBoldFont() drawfont = FONT_USER + 2
-#define draw_endBoldFont() drawfont = FONT_USER + 1
-
-float expandingbox_sizefactor_from_fadelerp(float fadelerp);
-
-vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
-
-float blink_synced(float base, float range, float freq, float start_time, int start_blink);
-float blink(float base, float range, float freq);
-
-void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
-
-void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
-
-void HUD_Scale_Disable();
-void HUD_Scale_Enable();
-
-#define HUD_ScaleX(f) (f * hud_scale.x)
-#define HUD_ScaleY(f) (f * hud_scale.y)
-#define HUD_ShiftX(f) (f + hud_shift.x + hud_shift.z * (f - hud_scale_center.x))
-#define HUD_ShiftY(f) (f + hud_shift.y + hud_shift.z * (f - hud_scale_center.y))
-vector HUD_Scale(vector v);
-vector HUD_Shift(vector v);
-
-// The following functions / macros must be called from within
-// the panel HUD / scoreboard code so that pos and size are scaled
-// when the hud_dynamic code is running.
-// Make use of stringwidth_builtin and draw*_builtin everywhere else.
-
-float stringwidth(string text, float handleColors, vector sz);
-
-#define drawpic(position, pic, size, rgb, alpha, flag) \
- drawpic_builtin(HUD_Shift(position), pic, HUD_Scale(size), rgb, alpha, flag)
-
-#define drawcharacter(position, character, scale, rgb, alpha, flag) \
- drawcharacter_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
-
-#define drawstring(position, text, scale, rgb, alpha, flag) \
- drawstring_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
-
-#define drawcolorcodedstring(position, text, scale, alpha, flag) \
- drawcolorcodedstring_builtin(HUD_Shift(position), text, scale, alpha, flag)
-
-#define drawcolorcodedstring2(position, text, scale, rgb, alpha, flag) \
- drawcolorcodedstring2_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
-
-#define drawfill(position, size, rgb, alpha, flag) \
- drawfill_builtin(HUD_Shift(position), HUD_Scale(size), rgb, alpha, flag)
-
-#define drawsetcliparea(xposition, yposition, w, h) \
- drawsetcliparea_builtin(HUD_ShiftX(xposition), HUD_ShiftY(yposition), HUD_ScaleX(w), HUD_ScaleY(h))
-
-// Since drawsubpic usually gets called multiple times from within an
-// utility function, instead of scaling pos and size in every call
-// we scale them once for all in the beginning of that utility function.
-// That's why drawsubpic isn't remapped.
-/*
-#define drawsubpic(position, size, pic, srcPosition, srcSize, rgb, alpha, flag) \
- drawsubpic_builtin(HUD_Shift(position), HUD_Scale(size), pic, HUD_Shift(srcPosition), HUD_Scale(srcSize), rgb, alpha, flag)
-*/
-
-// drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
-float _drawpic_imgaspect;
-vector _drawpic_imgsize;
-vector _drawpic_sz;
-float _drawpic_oldsz;
-string _drawpic_picpath;
-#define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
- MACRO_BEGIN \
- _drawpic_imgsize = draw_getimagesize(pic);\
- if(_drawpic_imgsize != '0 0 0') {\
- _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\
- _drawpic_sz = mySize;\
- if(_drawpic_sz.x/_drawpic_sz.y > _drawpic_imgaspect) {\
- _drawpic_oldsz = _drawpic_sz.x;\
- _drawpic_sz.x = _drawpic_sz.y * _drawpic_imgaspect;\
- if(_drawpic_sz.x)\
- drawpic(pos + eX * 0.5 * (_drawpic_oldsz - _drawpic_sz.x), pic, _drawpic_sz, color, theAlpha, drawflag);\
- } else {\
- _drawpic_oldsz = _drawpic_sz.y;\
- _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\
- if(_drawpic_sz.y)\
- drawpic(pos + eY * 0.5 * (_drawpic_oldsz - _drawpic_sz.y), pic, _drawpic_sz, color, theAlpha, drawflag);\
- }\
- }\
- 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)\
- 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;\
- 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)\
- 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;\
- 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);
-
-// 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);
-
-// 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 theAlpha, float drawflag);
-
-void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
-
-// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
-void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp);
-
-void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
-
-void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
-
-void update_mousepos();
-
-// this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
-float PolyDrawModelSurface(entity e, float i_s);
-void PolyDrawModel(entity e);
-
-void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
-
-const int MAX_ACCURACY_LEVELS = 10;
-float acc_lev[MAX_ACCURACY_LEVELS];
-vector acc_col[MAX_ACCURACY_LEVELS];
-float acc_col_loadtime;
-int acc_levels;
-string acc_color_levels;
-void Accuracy_LoadLevels();
-
-void Accuracy_LoadColors();
-
-vector Accuracy_GetColor(float accuracy);
#include "shownames.qh"
#include "autocvars.qh"
+#include <client/draw.qh>
#include "main.qh"
-#include "miscfunctions.qh"
#include "resources.qh"
+#include <client/view.qh>
#include "hud/_mod.qh"
#include <common/ent_cs.qh>
#include "view.qh"
#include "autocvars.qh"
-#include "miscfunctions.qh"
+#include <client/draw.qh>
#include "announcer.qh"
#include "hud/_mod.qh"
#include "main.qh"
viewmodels[slot] = new(viewmodel);
}
+vector project_3d_to_2d(vector vec)
+{
+ vec = cs_project(vec);
+ if(cs_project_is_b0rked > 0)
+ {
+ vec.x *= vid_conwidth / vid_width;
+ vec.y *= vid_conheight / vid_height;
+ }
+ 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;
+}
+
+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);
+}
+
float showfps_prevfps;
float showfps_prevfps_time;
int showfps_framecounter;
void calc_followmodel_ofs(entity view);
+vector project_3d_to_2d(vector vec);
+
+void update_mousepos();
+
void CSQC_Demo_Camera();
entity viewmodels[MAX_WEAPONSLOTS];
const int FL_PICKUPITEMS = BIT(17);
const int FL_DUCKED = BIT(18);
const int FL_ONSLICK = BIT(19);
+
+// initialization stages
+const int INITPRIO_FIRST = 0;
+const int INITPRIO_GAMETYPE = 0;
+const int INITPRIO_GAMETYPE_FALLBACK = 1;
+const int INITPRIO_FINDTARGET = 10;
+const int INITPRIO_DROPTOFLOOR = 20;
+const int INITPRIO_SETLOCATION = 90;
+const int INITPRIO_LINKDOORS = 91;
+const int INITPRIO_LAST = 99;
#endif
#if defined(SVQC)
#pragma once
#ifdef CSQC
+#include <client/draw.qh>
#include <client/resources.qh>
+#include <client/view.qh>
#endif
#include "cl_clanarena.qh"
+#include <client/draw.qh>
+
void HUD_Mod_CA_Export(int fh)
{
HUD_Write_Cvar("hud_panel_modicons_ca_layout");
#include "cl_ctf.qh"
#include <common/mutators/base.qh>
+#include <client/draw.qh>
#include <client/hud/panel/modicons.qh>
// CTF HUD modicon section
#include "cl_domination.qh"
+#include <client/draw.qh>
#include <client/hud/panel/modicons.qh>
void HUD_Mod_Dom_Export(int fh)
#include "cl_keepaway.qh"
+#include <client/draw.qh>
#include <client/hud/panel/modicons.qh>
// Keepaway HUD mod icon
#include "cl_race.qh"
+#include <client/draw.qh>
#include <common/mutators/base.qh>
// Race/CTS HUD mod icons
#include "cl_minigames_hud.qh"
#include <client/autocvars.qh>
+#include <client/draw.qh>
#include <common/ent_cs.qh>
#include "minigames.qh"
#include "nmm.qh"
-#ifdef CSQC
-#include <client/miscfunctions.qh>
-#endif
-
REGISTER_MINIGAME(nmm, _("Nine Men's Morris"));
const int NMM_TURN_PLACE = 0x0100; // player has to place a piece on the board
#define IS_CLIENT(s) (((s).isplayermodel & ISPLAYER_CLIENT) || (s) == csqcplayer)
#define IS_PLAYER(s) ((s).isplayermodel & ISPLAYER_PLAYER)
#define IS_NOT_A_CLIENT(s) (!(s).isplayermodel && (s) != csqcplayer)
+ #define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : (GetResource((s), RES_HEALTH) <= 0))
//float player_multijump;
//float player_jumpheight;
return trace_hits_box(start, end, thmi - ma, thma - mi);
}
#endif
+
+ERASEABLE
+float cvar_or(string cv, float v)
+{
+ string s = cvar_string(cv);
+ if(s == "")
+ return v;
+ else
+ return stof(s);
+}
+
+// NOTE base is the central value
+// freq: circle frequency, = 2*pi*frequency in hertz
+// start_pos:
+// -1 start from the lower value
+// 0 start from the base value
+// 1 start from the higher value
+ERASEABLE
+float blink_synced(float base, float range, float freq, float start_time, int start_pos)
+{
+ // note:
+ // RMS = sqrt(base^2 + 0.5 * range^2)
+ // thus
+ // base = sqrt(RMS^2 - 0.5 * range^2)
+ // ensure RMS == 1
+
+ return base + range * sin((time - start_time - (M_PI / 2) * start_pos) * freq);
+}
+
+ERASEABLE
+float blink(float base, float range, float freq)
+{
+ return blink_synced(base, range, freq, 0, 0);
+}
float tracebox_hits_box(vector start, vector mi, vector ma, vector end, vector thmi, vector thma);
#endif
+
+float cvar_or(string cv, float v);
+
+float blink_synced(float base, float range, float freq, float start_time, int start_blink);
+
+float blink(float base, float range, float freq);
bool sv_ready_restart_after_countdown;
-const int INITPRIO_FIRST = 0;
-const int INITPRIO_GAMETYPE = 0;
-const int INITPRIO_GAMETYPE_FALLBACK = 1;
-const int INITPRIO_FINDTARGET = 10;
-const int INITPRIO_DROPTOFLOOR = 20;
-const int INITPRIO_SETLOCATION = 90;
-const int INITPRIO_LINKDOORS = 91;
-const int INITPRIO_LAST = 99;
-
.void(entity this) initialize_entity;
.int initialize_entity_order;
.entity initialize_entity_next;