Skip to content

Commit

Permalink
Merge pull request #20 from Elinsrc/novgui_voice_status
Browse files Browse the repository at this point in the history
Novgui voice status
  • Loading branch information
Elinsrc authored Nov 29, 2024
2 parents e65c8cc + b51ff71 commit 4cc4525
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 56 deletions.
4 changes: 2 additions & 2 deletions cl_dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ set (CLDLL_SOURCES
rendering/GameStudioModelRenderer.cpp
rendering/StudioModelRenderer.cpp
rendering/tri.cpp
ui/voice_status.cpp
ui/voice_banmgr.cpp
ui/hud/ammo.cpp
ui/hud/ammo_secondary.cpp
ui/hud/ammohistory.cpp
Expand Down Expand Up @@ -158,8 +160,6 @@ if (USE_VGUI)
ui/VGUI/vgui_TeamFortressViewport.cpp
ui/VGUI/vgui_SpectatorPanel.cpp
ui/VGUI/vgui_teammenu.cpp
ui/voice_status.cpp
ui/voice_banmgr.cpp
ui/VGUI/utils/vgui_checkbutton2.cpp
ui/VGUI/utils/vgui_grid.cpp
ui/VGUI/utils/vgui_helpers.cpp
Expand Down
6 changes: 2 additions & 4 deletions cl_dll/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,9 @@ void DLLEXPORT HUD_Frame( double time )
discord_integration::on_frame( );
#endif

#if USE_VGUI
GetClientVoiceMgr()->Frame(time);
#elif USE_FAKE_VGUI

#if USE_FAKE_VGUI
if (!gViewPort)
gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
#else
Expand All @@ -391,9 +391,7 @@ Called when a player starts or stops talking.

void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking )
{
#if USE_VGUI
GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
#endif
}

/*
Expand Down
6 changes: 4 additions & 2 deletions cl_dll/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "pmtrace.h"
#include "pm_shared.h"

#if !USE_VGUI
#include "voice_status.h"
#endif

#if BUILD_DISCORD_RPC
#include "discord_integration.h"
#endif
Expand Down Expand Up @@ -543,9 +547,7 @@ void DLLEXPORT HUD_CreateEntities( void )
// Add in any game specific objects
Game_AddObjects();

#if USE_VGUI
GetClientVoiceMgr()->CreateEntities();
#endif
}

/*
Expand Down
27 changes: 20 additions & 7 deletions cl_dll/ui/hud/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,22 @@ int g_iUser1 = 0;
int g_iUser2 = 0;
int g_iUser3 = 0;

#if !USE_VGUI
// Team Colors
int iNumberOfTeamColors = 5;
int iTeamColors[5][3] =
{
{ 255, 170, 0 }, // HL orange (default)
{ 125, 165, 210 }, // Blue
{ 200, 90, 70 }, // Red
{ 225, 205, 45 }, // Yellow
{ 145, 215, 140 }, // Green
};
#endif

#if USE_VGUI
#include "vgui_ScorePanel.h"

#endif
class CHLVoiceStatusHelper : public IVoiceStatusHelper
{
public:
Expand All @@ -68,27 +81,27 @@ class CHLVoiceStatusHelper : public IVoiceStatusHelper
color[2] = iTeamColors[iTeam][2];
}
}

#if USE_VGUI
virtual void UpdateCursorState()
{
gViewPort->UpdateCursorState();
}

#endif
virtual int GetAckIconHeight()
{
return ScreenHeight - gHUD.m_iFontHeight*3 - 6;
}

#if USE_VGUI
virtual bool CanShowSpeakerLabels()
{
if( gViewPort && gViewPort->m_pScoreBoard )
return !gViewPort->m_pScoreBoard->isVisible();
else
return false;
}
#endif
};
static CHLVoiceStatusHelper g_VoiceStatusHelper;
#endif

extern client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, int iRes, int iCount );

Expand Down Expand Up @@ -570,6 +583,8 @@ void CHud::Init( void )
m_Longjump.Init();
#if USE_VGUI
GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort);
#else
GetClientVoiceMgr()->Init(&g_VoiceStatusHelper);
#endif

#if !USE_VGUI || USE_NOVGUI_MOTD
Expand Down Expand Up @@ -776,9 +791,7 @@ void CHud::VidInit( void )
m_Vote.VidInit();
m_Splash.VidInit();
m_Longjump.VidInit();
#if USE_VGUI
GetClientVoiceMgr()->VidInit();
#endif
#if !USE_VGUI || USE_NOVGUI_MOTD
m_MOTD.VidInit();
#endif
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/ui/hud/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ struct HUDLIST

//
//-----------------------------------------------------
#if USE_VGUI
#include "voice_status.h" // base voice handling class
#endif
#include "hud_spectator.h"
#include "hud_speedometer.h"
#include "hud_jumpspeed.h"
Expand Down Expand Up @@ -279,6 +277,8 @@ class CHudScoreboard : public CHudBase
}icon_flagstatus_t;

icon_flagstatus_t m_IconFlagScore;

HSPRITE iVoiceSprite;
};
#endif

Expand Down
14 changes: 9 additions & 5 deletions cl_dll/ui/hud/scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ We have a minimum width of 1-320 - we could have the field widths scale with it?
#define PL_RANGE_MIN 315
#define PL_RANGE_MAX 375
#define MODEL_RANGE_MIN 0
#define LOSS_POSS 390
#define VOICE_POS 350

int SCOREBOARD_WIDTH = 320;

Expand All @@ -136,7 +136,7 @@ int CHudScoreboard::Draw( float fTime )

GetAllPlayersInfo();

SCOREBOARD_WIDTH = ( ScreenWidth >= 440 ) ? ( 320 - NAME_RANGE_MODIFIER ) : 320;
SCOREBOARD_WIDTH = ( ScreenWidth >= 520 ) ? ( 400 - NAME_RANGE_MODIFIER ) : 400;

// just sort the list on the fly
// list is sorted first by frags, then by deaths
Expand All @@ -147,7 +147,7 @@ int CHudScoreboard::Draw( float fTime )
int ypos = ROW_TOP + ROW_RANGE_MIN + ( list_slot * ROW_GAP );
int xpos = NAME_RANGE_MIN + xpos_rel;

FAR_RIGHT = PING_RANGE_MAX + 5;
FAR_RIGHT = VOICE_POS + 5;

if( ( ScreenWidth >= 440 ) || ( ScreenWidth >= 520 ) )
{
Expand All @@ -165,7 +165,7 @@ int CHudScoreboard::Draw( float fTime )
snprintf(ServerName,80,"%s",gHUD.m_szServerName );
gHUD.DrawHudStringWithColorTags( xpos, info_pos, ServerName, 255, 140, 0 );

int COUNT_PLAYERS_POS = 310;
int COUNT_PLAYERS_POS = 365;

char map[256];
char map_name[64];
Expand All @@ -189,6 +189,7 @@ int CHudScoreboard::Draw( float fTime )
gHUD.DrawHudString( DIVIDER_POS + xpos_rel, ypos, "/", 255, 140, 0 );
gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, CHudTextMessage::BufferedLocaliseTextString("#DEATHS"), 255, 140, 0 );
gHUD.DrawHudStringReverse( PING_RANGE_MAX + xpos_rel + 15, ypos, CHudTextMessage::BufferedLocaliseTextString("#LATENCY"), 255, 140, 0 );
gHUD.DrawHudStringReverse( VOICE_POS + xpos_rel + 15, ypos, CHudTextMessage::BufferedLocaliseTextString("#VOICE"), 255, 140, 0 );

list_slot += 1.2f;
ypos = ROW_TOP + ROW_RANGE_MIN + ( list_slot * ROW_GAP );
Expand Down Expand Up @@ -351,7 +352,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
{
int FAR_RIGHT;

FAR_RIGHT = PING_RANGE_MAX + 5;
FAR_RIGHT = VOICE_POS + 5;

if( ( ScreenWidth >= 440 ) || ( ScreenWidth >= 520 ) )
{
Expand Down Expand Up @@ -464,6 +465,9 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
xpos = ( ( PING_RANGE_MAX - PING_RANGE_MIN ) / 2 ) + PING_RANGE_MIN + xpos_rel + 40;
gHUD.DrawHudStringReverse( xpos, ypos, buf, r, g, b );

xpos = VOICE_POS + xpos_rel;
GetClientVoiceMgr()->DrawNoVguiSpeakerIcon( xpos - 20, ypos - 5, best_player);

pl_info->name = NULL; // set the name to be NULL, so this client won't get drawn again
list_slot++;
}
Expand Down
Loading

0 comments on commit 4cc4525

Please sign in to comment.