@@ -29,18 +29,15 @@ Variable cl_crosshair_t("cl_crosshair_t", "0",
2929 " Removes the top line from the crosshair :"
3030 " 0: normal crosshair,"
3131 " 1: crosshair without top.\n " );
32- Variable cl_crosshairgap (" cl_crosshairgap" , " 5 " , 0 , " Changes the distance of the crosshair lines from the center of screen.\n " );
33- Variable cl_crosshaircolor_r (" cl_crosshaircolor_r" , " 0 " , 0 , 255 , " Changes the color of the crosshair.\n " );
32+ Variable cl_crosshairgap (" cl_crosshairgap" , " 9 " , 0 , " Changes the distance of the crosshair lines from the center of screen.\n " );
33+ Variable cl_crosshaircolor_r (" cl_crosshaircolor_r" , " 255 " , 0 , 255 , " Changes the color of the crosshair.\n " );
3434Variable cl_crosshaircolor_g (" cl_crosshaircolor_g" , " 255" , 0 , 255 , " Changes the color of the crosshair.\n " );
35- Variable cl_crosshaircolor_b (" cl_crosshaircolor_b" , " 0 " , 0 , 255 , " Changes the color of the crosshair.\n " );
36- Variable cl_crosshairsize (" cl_crosshairsize" , " 5 " , -100 , " Changes the size of the crosshair.\n " );
35+ Variable cl_crosshaircolor_b (" cl_crosshaircolor_b" , " 255 " , 0 , 255 , " Changes the color of the crosshair.\n " );
36+ Variable cl_crosshairsize (" cl_crosshairsize" , " 1 " , -100 , " Changes the size of the crosshair.\n " );
3737Variable cl_crosshairthickness (" cl_crosshairthickness" , " 0" , 0 , " Changes the thinkness of the crosshair lines.\n " );
3838Variable cl_crosshairalpha (" cl_crosshairalpha" , " 255" , 0 , 255 , " Change the amount of transparency.\n " );
3939Variable cl_crosshairdot (" cl_crosshairdot" , " 1" , " Decides if there is a dot in the middle of the crosshair\n " );
4040
41- Variable cl_quickhud_x (" sar_quickhud_x" , " 45" , -1000 , " Horizontal distance of the custom quickhud.\n " );
42- Variable cl_quickhud_y (" sar_quickhud_y" , " 0" , -1000 , " Vertical distance of the custom quickhud.\n " );
43- Variable cl_quickhud_size (" sar_quickhud_size" , " 15" , -100 , " Size of the custom quickhud.\n " );
4441Variable cl_quickhudleftcolor_r (" cl_quickhudleftcolor_r" , " 255" , 0 , 255 , " Changes the color of the left quickhud.\n " );
4542Variable cl_quickhudleftcolor_g (" cl_quickhudleftcolor_g" , " 184" , 0 , 255 , " Changes the color of the left quickhud.\n " );
4643Variable cl_quickhudleftcolor_b (" cl_quickhudleftcolor_b" , " 86" , 0 , 255 , " Changes the color of the left quickhud.\n " );
@@ -52,7 +49,7 @@ Variable cl_quickhud_alpha("cl_quickhud_alpha", "255", 0, 255, "Change the amoun
5249Crosshair crosshair;
5350
5451Crosshair::Crosshair ()
55- : Hud(HudType_InGame, true )
52+ : Hud(HudType_InGame, false )
5653 , crosshairTextureID(0 )
5754 , quickhudTextureID{-1 , -1 , -1 , -1 }
5855 , isCustomCrosshairReady(false )
@@ -109,7 +106,9 @@ bool Crosshair::IsSurfacePortalable() {
109106
110107int Crosshair::GetPortalUpgradeState () {
111108 if (server->portalGun != nullptr ) {
112- return SE (server->portalGun )->field <bool >(" m_bCanFirePortal1" ) + SE (server->portalGun )->field <bool >(" m_bCanFirePortal2" );
109+ bool prim = SE (server->portalGun )->field <bool >(" m_bCanFirePortal1" );
110+ bool sec = SE (server->portalGun )->field <bool >(" m_bCanFirePortal2" );
111+ return prim | (sec << 1 );
113112 }
114113
115114 return 0 ;
@@ -167,8 +166,6 @@ void Crosshair::Paint(int slot) {
167166 return ;
168167 }
169168
170- surface->StartDrawing (surface->matsurface ->ThisPtr ());
171-
172169 int xScreen, yScreen, xCenter, yCenter;
173170 engine->GetScreenSize (nullptr , xScreen, yScreen);
174171
@@ -224,18 +221,18 @@ void Crosshair::Paint(int slot) {
224221 Color cl (cl_quickhudleftcolor_r.GetInt (), cl_quickhudleftcolor_g.GetInt (), cl_quickhudleftcolor_b.GetInt (), cl_quickhud_alpha.GetInt ());
225222 Color cr (cl_quickhudrightcolor_r.GetInt (), cl_quickhudrightcolor_g.GetInt (), cl_quickhudrightcolor_b.GetInt (), cl_quickhud_alpha.GetInt ());
226223
227- int x1 = xCenter - cl_quickhud_x.GetInt ();
228- int x2 = xCenter + cl_quickhud_x.GetInt ();
229- int y1 = yCenter + cl_quickhud_y.GetInt ();
230- int size = cl_quickhud_size.GetInt ();
224+ int x1 = xCenter - 0 ; // cl_quickhud_x.GetInt();
225+ int x2 = xCenter + 0 ; // cl_quickhud_x.GetInt();
226+ int y1 = yCenter + 0 ; // cl_quickhud_y.GetInt();
227+ int size = 10 ; // cl_quickhud_size.GetInt();
231228
232229 if (bluePortalState) {
233230 surface->DrawFilledCircle (x1, y1, size, cr);
234231 } else {
235232 surface->DrawCircle (x1, y1, size, cr);
236233 }
237234
238- if (portalGunUpgradeState == 2 ) {
235+ if (portalGunUpgradeState & 2 ) {
239236 if (orangePortalState) {
240237 surface->DrawFilledCircle (x2, y1, size, cl);
241238 } else {
@@ -244,22 +241,34 @@ void Crosshair::Paint(int slot) {
244241 }
245242
246243 } else if ((sar_quickhud_mode.GetInt () == 2 || sar_crosshair_P1.GetBool ()) && this ->isCustomQuickHudReady && portalGunUpgradeState) { // Quickhud from .png
244+ int width, height;
247245
248- surface->DrawSetColor (surface->matsurface ->ThisPtr (), 255 , 255 , 255 , cl_quickhud_alpha.GetInt ());
249- int halfSize = cl_quickhud_size.GetInt () / 2 ;
250- int xOffset = cl_quickhud_x.GetInt ();
251- int yOffset = cl_quickhud_y.GetInt ();
246+ Color blue { 111 , 184 , 255 };
247+ Color orange { 255 , 184 , 86 };
248+ Color atlas_prim { 32 , 128 , 210 };
249+ Color atlas_sec { 16 , 0 , 210 };
250+ Color pbody_prim { 255 , 180 , 32 };
251+ Color pbody_sec { 58 , 3 , 3 };
252252
253- surface-> DrawSetTexture (surface-> matsurface -> ThisPtr (), this -> quickhudTextureID [bluePortalState]); // Blue
254- surface-> DrawTexturedRect (surface-> matsurface -> ThisPtr (), xCenter - halfSize * 2 - xOffset, yCenter - halfSize - yOffset, xCenter - xOffset, yCenter + halfSize - yOffset) ;
253+ Color real_prim = engine-> IsOrange () ? pbody_prim : engine-> IsCoop () ? atlas_prim : blue;
254+ Color real_sec = engine-> IsOrange () ? pbody_sec : engine-> IsCoop () ? atlas_sec : orange ;
255255
256- if (portalGunUpgradeState) {
257- surface->DrawSetTexture (surface->matsurface ->ThisPtr (), this ->quickhudTextureID [orangePortalState + 2 ]); // Orange
258- surface->DrawTexturedRect (surface->matsurface ->ThisPtr (), xCenter + xOffset, yCenter - halfSize - yOffset, xCenter + halfSize * 2 + xOffset, yCenter + halfSize - yOffset);
259- }
260- }
256+ Color prim = (portalGunUpgradeState & 1 ) ? real_prim : real_sec;
257+ Color sec = (portalGunUpgradeState & 2 ) ? real_sec : real_prim;
261258
262- surface->FinishDrawing ();
259+ bool prim_state = (portalGunUpgradeState & 1 ) ? bluePortalState : orangePortalState;
260+ bool sec_state = (portalGunUpgradeState & 2 ) ? orangePortalState : bluePortalState;
261+
262+ surface->DrawGetTextureSize (surface->matsurface ->ThisPtr (), this ->quickhudTextureID [prim_state], width, height);
263+ surface->DrawSetTexture (surface->matsurface ->ThisPtr (), this ->quickhudTextureID [prim_state]);
264+ surface->DrawSetColor (surface->matsurface ->ThisPtr (), prim.r , prim.g , prim.b , cl_quickhud_alpha.GetInt ());
265+ surface->DrawTexturedRect (surface->matsurface ->ThisPtr (), xCenter - width/2 , yCenter - height/2 , xCenter + width/2 , yCenter + height/2 );
266+
267+ surface->DrawGetTextureSize (surface->matsurface ->ThisPtr (), this ->quickhudTextureID [sec_state + 2 ], width, height);
268+ surface->DrawSetTexture (surface->matsurface ->ThisPtr (), this ->quickhudTextureID [sec_state + 2 ]);
269+ surface->DrawSetColor (surface->matsurface ->ThisPtr (), sec.r , sec.g , sec.b , cl_quickhud_alpha.GetInt ());
270+ surface->DrawTexturedRect (surface->matsurface ->ThisPtr (), xCenter - width/2 , yCenter - height/2 , xCenter + width/2 , yCenter + height/2 );
271+ }
263272}
264273
265274int Crosshair::SetCrosshairTexture (const std::string filename) {
0 commit comments