[Tutorial PSP/PC] - Adding a nohud Cvar.
Posted: Fri Jan 14, 2011 10:59 pm
It has been a while since I've made a tutorial, the effect of this one is simple, but it shows how to setup cvars, and what the return command does.
The code for this is my own, I implemented it in a different engine, thus it may require changes for stock Quake, but hey you never know.
Somewhere near the top of cl_main.c, where the other cvar_t lines are add this line of code:
Now in CL_init add this along with all of the other cvar register lines:
This is where it starts to get engine specific.
If your using the PSP open video_hardware_draw.cpp if your using another engine open the equivalent file, it may be gl_draw.c if I'm not mistaken.
Go to Draw_Crosshair.
And before this line:
Add this:
Now that was just a simple if statement, it used our cvar as the starting value, and used the .value as the line on the other side of the operator, if nohud is equal to anything except 0 it goes to the next line.
This line simply makes it not continue and return back.
Now, that was for the crosshair, this next part is for the actual hud.
Open sbar.c and near the top add this line:
This line tells the compiler that our cbar "nohud" is defined externally in another file.
Now find the Sbar_Draw function, and near the top add this:
That code acted just like the code we used before for the crosshair.
That is all.
This code I wrote for this tutorial was written a long time ago, and it probably has some improvements that could and should be made.
As usual post questions, comments, concerns, hate mail etc, at the bottom of this post.
Thank you.
Credits:
TeamXlink
The code for this is my own, I implemented it in a different engine, thus it may require changes for stock Quake, but hey you never know.
Somewhere near the top of cl_main.c, where the other cvar_t lines are add this line of code:
Code: Select all
cvar_t nohud = {"nohud", "0"}; //TeamXlink - nohud cvarNow in CL_init add this along with all of the other cvar register lines:
Code: Select all
Cvar_RegisterVariable (&nohud); //TeamXlink - nohud cvarThis is where it starts to get engine specific.
If your using the PSP open video_hardware_draw.cpp if your using another engine open the equivalent file, it may be gl_draw.c if I'm not mistaken.
Go to Draw_Crosshair.
And before this line:
Code: Select all
if (crosshair.value >= 2)Code: Select all
//TeamXlink - nohud cvar start
if ( nohud.value )
return;
//TeamXlink - nohud cvar endThis line simply makes it not continue and return back.
Now, that was for the crosshair, this next part is for the actual hud.
Open sbar.c and near the top add this line:
Code: Select all
extern cvar_t nohud; //TeamXlink - nohud cvarNow find the Sbar_Draw function, and near the top add this:
Code: Select all
//TeamXlink - nohud cvar start
if ( nohud.value )
return;
//TeamXlink - nohud cvar endThat is all.
This code I wrote for this tutorial was written a long time ago, and it probably has some improvements that could and should be made.
As usual post questions, comments, concerns, hate mail etc, at the bottom of this post.
Thank you.
Credits:
TeamXlink