Skip to content

Commit

Permalink
Add hud_watermark command
Browse files Browse the repository at this point in the history
hud_watermark <0|1> (1 by default)

Controls whether the watermark & server-settings will display or not. The update disclaimer will display regardless, but only for 5 seconds if hud_watermark is set to 0.

Co-Authored-By: Ivan Molodetskikh <[email protected]>
  • Loading branch information
sabianroberts and YaLTeR committed Nov 14, 2024
1 parent 7c35c77 commit 793f88a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
3 changes: 3 additions & 0 deletions cl_dll/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ cvar_t *cl_righthand = nullptr;
cvar_t *cl_viewrollangle;
cvar_t *cl_viewrollspeed;
cvar_t *cl_bob_angled;
cvar_t *hud_watermark;

void ShutdownInput (void);

Expand Down Expand Up @@ -500,6 +501,8 @@ void CHud :: Init( void )
cl_viewrollspeed = CVAR_CREATE ( "cl_viewrollspeed", "300", FCVAR_CLIENTDLL | FCVAR_ARCHIVE );
cl_bob_angled = CVAR_CREATE ( "cl_bob_angled", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE );

hud_watermark = CVAR_CREATE ( "hud_watermark", "1", FCVAR_CLIENTDLL | FCVAR_ARCHIVE );

HOOK_MESSAGE( CheatCheck );
HOOK_MESSAGE( WhString );
HOOK_MESSAGE( SpikeCheck );
Expand Down
47 changes: 25 additions & 22 deletions cl_dll/hud_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,39 @@ int CHudSettings::Draw(float time)

char str[32];

sprintf(str, "AG version %s", ag_version);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);

gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), gamemode, r, g, b);

sprintf(str, "Time limit: %hhd", time_limit);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight / 2 * 3), str, r, g, b);

sprintf(str, "Frag limit: %hhd", frag_limit);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);
extern cvar_t* hud_watermark;
if (hud_watermark->value == 1) {
sprintf(str, "AG version %s", ag_version);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);

sprintf(str, "Friendly fire: %s", friendly_fire ? "On" : "Off");
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), gamemode, r, g, b);

sprintf(str, "Weaponstay: %s", weapon_stay ? "On" : "Off");
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);
sprintf(str, "Time limit: %hhd", time_limit);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight / 2 * 3), str, r, g, b);

if (wallgauss[0]) {
sprintf(str, "Wallgauss: %sx (1)", wallgauss);
sprintf(str, "Frag limit: %hhd", frag_limit);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);
}

if (headshot[0]) {
sprintf(str, "Headshot: %sx (3)", headshot);
sprintf(str, "Friendly fire: %s", friendly_fire ? "On" : "Off");
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);
}

if (blast_radius[0]) {
sprintf(str, "Blast radius: %sx (1)", blast_radius);
sprintf(str, "Weaponstay: %s", weapon_stay ? "On" : "Off");
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);

if (wallgauss[0]) {
sprintf(str, "Wallgauss: %sx (1)", wallgauss);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);
}

if (headshot[0]) {
sprintf(str, "Headshot: %sx (3)", headshot);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);
}

if (blast_radius[0]) {
sprintf(str, "Blast radius: %sx (1)", blast_radius);
gEngfuncs.pfnDrawString(x, (y += gHUD.m_scrinfo.iCharHeight), str, r, g, b);
}
}

if (match_is_on) {
Expand Down
16 changes: 12 additions & 4 deletions cl_dll/hud_watermark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "parsemsg.h"
#include "update_checker.h"

extern cvar_t* hud_watermark;

int CHudWatermark::Init()
{
m_iFlags = 0;
Expand All @@ -22,9 +24,13 @@ int CHudWatermark::VidInit()

int CHudWatermark::Draw(float time)
{
if (refresh_draw_until || (draw_until > gHUD.m_flTime + 15.0f)) {
float duration = 15.0f;
if (hud_watermark->value != 1)
duration = 5.0f;

if (refresh_draw_until || (draw_until > gHUD.m_flTime + duration)) {
refresh_draw_until = false;
draw_until = gHUD.m_flTime + 15.0f;
draw_until = gHUD.m_flTime + duration;
}

if (gHUD.m_flTime >= draw_until) {
Expand All @@ -35,8 +41,10 @@ int CHudWatermark::Draw(float time)
int r, g, b;
UnpackRGB(r, g, b, gHUD.m_iDefaultHUDColor);

gEngfuncs.pfnDrawString(ScreenWidth / 20, gHUD.m_scrinfo.iCharHeight, "OpenAG client build " __DATE__, r, g, b);
gEngfuncs.pfnDrawString(ScreenWidth / 20, gHUD.m_scrinfo.iCharHeight * 2, "j.mp/OpenAG", r, g, b);
if (hud_watermark->value != 0) {
gEngfuncs.pfnDrawString(ScreenWidth / 20, gHUD.m_scrinfo.iCharHeight, "OpenAG client build " __DATE__, r, g, b);
gEngfuncs.pfnDrawString(ScreenWidth / 20, gHUD.m_scrinfo.iCharHeight * 2, "j.mp/OpenAG", r, g, b);
}

if (update_is_available)
gEngfuncs.pfnDrawString(ScreenWidth / 20, gHUD.m_scrinfo.iCharHeight / 2 * 7, "An update is available.", r, g, b);
Expand Down

0 comments on commit 793f88a

Please sign in to comment.