Skip to content

Commit

Permalink
Added: hud_longjump and hud_splash
Browse files Browse the repository at this point in the history
  • Loading branch information
Elinsrc committed Nov 2, 2024
1 parent aa64b53 commit 37608ee
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cl_dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ set (CLDLL_SOURCES
ui/hud/OpenAG/hud_suddendeath.cpp
ui/hud/OpenAG/hud_timeout.cpp
ui/hud/OpenAG/hud_vote.cpp
ui/hud/OpenAG/hud_splash.cpp
ui/hud/OpenAG/hud_longjump.cpp
cdll_int.cpp
com_weapons.cpp
demo.cpp
Expand Down
63 changes: 63 additions & 0 deletions cl_dll/ui/hud/OpenAG/hud_longjump.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//++ BulliT

#include "hud.h"
#include "cl_util.h"
#include <string.h>
#include <stdio.h>
#include <time.h>
#include "parsemsg.h"

DECLARE_MESSAGE(m_Longjump, Longjump )

int CHudLongjump::Init(void)
{
HOOK_MESSAGE( Longjump );

m_flTurnoff = 0;
m_iFlags = 0;

gHUD.AddHudElem(this);

return 1;
}

int CHudLongjump::VidInit(void)
{
return 1;
}

void CHudLongjump::Reset(void)
{
m_iFlags &= ~HUD_ACTIVE;
}

int CHudLongjump::Draw(float fTime)
{
if ( m_flTurnoff < gHUD.m_flTime || gHUD.m_iIntermission )
{
Reset();
return 1;
}

char szText[32];
int r, g, b;
UnpackRGB(r, g, b, gHUD.m_iDefaultHUDColor);
sprintf(szText,"Longjump %d",(int)(m_flTurnoff - gHUD.m_flTime));
gHUD.DrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight * 2, szText, r, g, b );

return 0;
}


int CHudLongjump::MsgFunc_Longjump(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );
int iTime = READ_BYTE();

m_flTurnoff = gHUD.m_flTime + iTime;
m_iFlags |= HUD_ACTIVE;

return 1;
}

//-- Martin Webrant
17 changes: 17 additions & 0 deletions cl_dll/ui/hud/OpenAG/hud_longjump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//++ BulliT
#pragma once

class CHudLongjump: public CHudBase
{
public:
int Init( void );
int VidInit( void );
int Draw(float flTime);
void Reset(void);
int MsgFunc_Longjump(const char *pszName, int iSize, void *pbuf);

private:
float m_flTurnoff;
};

//-- Martin Webrant
74 changes: 74 additions & 0 deletions cl_dll/ui/hud/OpenAG/hud_splash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//++ BulliT

#include "hud.h"
#include "cl_util.h"
#include <string.h>
#include <stdio.h>
#include <demo_api.h>
#include "parsemsg.h"

DECLARE_MESSAGE(m_Splash, Splash )

int CHudSplash::Init(void)
{
HOOK_MESSAGE( Splash );

m_flTurnoff = 0.0;
m_iFlags = 0;
gHUD.AddHudElem(this);

return 1;
}

int CHudSplash::VidInit(void)
{
m_hSprite = SPR_Load("sprites/ag_splash.spr");
return 1;
}

void CHudSplash::Reset(void)
{
m_iFlags &= ~HUD_ACTIVE;
}

#define RGB_WHITEISH 0x00FFFFFF //255,255,255

int CHudSplash::Draw(float fTime)
{
if (m_flTurnoff < gHUD.m_flTime || 0 == m_hSprite)
{
Reset();
return 1;
}

int r, g, b, x, y;

UnpackRGB(r,g,b, RGB_WHITEISH);
ScaleColors(r, g, b, 255);
SPR_Set(m_hSprite, r, g, b );

// This should show up to the top right corner
y = SPR_Height(m_hSprite,0);
x = ScreenWidth - SPR_Width(m_hSprite,0);
SPR_DrawHoles( 0, x, y, NULL);

return 0;
}

int CHudSplash::MsgFunc_Splash(const char *pszName, int iSize, void *pbuf)
{
BEGIN_READ( pbuf, iSize );

// update data
int iTime = READ_BYTE();
m_flTurnoff = gHUD.m_flTime + iTime;
m_iFlags |= HUD_ACTIVE;

if (iTime > 0)
m_iFlags |= HUD_ACTIVE;
else
m_iFlags &= ~HUD_ACTIVE;
return 1;
}

//-- Martin Webrant
18 changes: 18 additions & 0 deletions cl_dll/ui/hud/OpenAG/hud_splash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//++ BulliT
#pragma once

class CHudSplash: public CHudBase
{
public:
int Init( void );
int VidInit( void );
int Draw(float flTime);
void Reset(void);
int MsgFunc_Splash(const char *pszName, int iSize, void *pbuf);

private:
float m_flTurnoff;
HSPRITE m_hSprite;
};

//-- Martin Webrant
4 changes: 4 additions & 0 deletions cl_dll/ui/hud/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,8 @@ void CHud::Init( void )
m_SuddenDeath.Init();
m_Timeout.Init();
m_Vote.Init();
m_Splash.Init();
m_Longjump.Init();
#if USE_VGUI
GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort);
#endif
Expand Down Expand Up @@ -768,6 +770,8 @@ void CHud::VidInit( void )
m_SuddenDeath.VidInit();
m_Timeout.VidInit();
m_Vote.VidInit();
m_Splash.VidInit();
m_Longjump.VidInit();
#if USE_VGUI
GetClientVoiceMgr()->VidInit();
#endif
Expand Down
4 changes: 4 additions & 0 deletions cl_dll/ui/hud/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ struct HUDLIST
#include "hud_suddendeath.h"
#include "hud_timeout.h"
#include "hud_vote.h"
#include "hud_splash.h"
#include "hud_longjump.h"
//
//-----------------------------------------------------
//
Expand Down Expand Up @@ -686,6 +688,8 @@ class CHud
CHudSuddenDeath m_SuddenDeath;
CHudTimeout m_Timeout;
CHudVote m_Vote;
CHudSplash m_Splash;
CHudLongjump m_Longjump;
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
CHudScoreboard m_Scoreboard;
#endif
Expand Down

0 comments on commit 37608ee

Please sign in to comment.