Don't draw crosshair if centerstring

Post tutorials on how to do certain tasks within game or engine code here.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Don't draw crosshair if centerstring

Post by Baker »

Quicky tutorial shows how to not draw a crosshair if there is centerprint that is going to print.

FitzQuake implementation: Add the yellow ...
gl_screen.c wrote:/*
==============
SCR_DrawCrosshair -- johnfitz
==============
*/
void SCR_DrawCrosshair (void)
{
qboolean will_draw_centerstring = !((scr_centertime_off - host_frametime <=0 && !cl.intermission) || key_dest != key_game || cl.paused);
if (will_draw_centerstring)
return; // Centerprint is going to print, so exit out and don't draw.


if (!crosshair.value)
return;

GL_SetCanvas (CANVAS_CROSSHAIR);
Draw_Character (-4, -4, '+'); //0,0 is center of viewport
}
Untested. Worst tutorial ever.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Don't draw crosshair if centerstring

Post by Spike »

if you use TF's statusbar (which is set up via centerprints) this will make you unable to aim.

in FTE, centerprints of 4 lines or less are shifted up by a small amount to keep the text away from the cursor. this at least resolves the common case, but won't help mods that put essays in there.
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Don't draw crosshair if centerstring

Post by Baker »

Great point. Anything that uses an improvised on-screen "QuakeC" Hud or indicator.

A single player example: Quoth's flashlight battery indicator.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Post Reply