Forum

Don't draw crosshair if centerstring

Post tutorials on how to do certain tasks within game or engine code here.

Moderator: InsideQC Admins

Don't draw crosshair if centerstring

Postby Baker » Mon Jun 23, 2014 6:03 am

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 ..
User avatar
Baker
 
Posts: 3662
Joined: Tue Mar 14, 2006 5:15 am

Re: Don't draw crosshair if centerstring

Postby Spike » Mon Jun 23, 2014 6:36 am

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.
Spike
 
Posts: 2881
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Don't draw crosshair if centerstring

Postby Baker » Mon Jun 23, 2014 7:43 am

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 ..
User avatar
Baker
 
Posts: 3662
Joined: Tue Mar 14, 2006 5:15 am


Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest