Skip to content

Commit

Permalink
update to the quantity bar stuff before I finish and commit the new c…
Browse files Browse the repository at this point in the history
…ustom HUD options. Fixed a few more little things, the equal padding now works properly (I hope). Need to commit some FF scheme stuff for this stuff to work properly.

Added some more customisations to the quantity bar but not made them available to use in game as I'll be doing away with cvars and using vdf files like with crosshairs.

# Conflicts:
#	cl_dll/client_scratch-2005.vcproj
#	cl_dll/client_scratch-2008.vcproj
#	cl_dll/ff/ff_hud_buildstate.cpp
#	cl_dll/ff/ff_hud_buildstate.h
  • Loading branch information
AdamWillden committed Oct 26, 2020
1 parent e39c056 commit f806499
Show file tree
Hide file tree
Showing 10 changed files with 653 additions and 441 deletions.
20 changes: 12 additions & 8 deletions cl_dll/client_scratch-2005.vcproj
Expand Up @@ -474,6 +474,14 @@
RelativePath=".\ff\vgui\ff_panel.h"
>
</File>
<File
RelativePath=".\ff\vgui\ff_quantitybar.cpp"
>
</File>
<File
RelativePath=".\ff\vgui\ff_quantitybar.h"
>
</File>
<File
RelativePath=".\ff\vgui\ff_quantitypanel.cpp"
>
Expand Down Expand Up @@ -622,6 +630,10 @@
RelativePath=".\ff\ff_hud_buildstate_sentry.cpp"
>
</File>
<File
RelativePath=".\ff\ff_hud_buildstate_sentry.h"
>
</File>
<File
RelativePath=".\ff\ff_hud_buildtimer.cpp"
>
Expand Down Expand Up @@ -742,14 +754,6 @@
RelativePath=".\ff\ff_hud_objectiveicon.cpp"
>
</File>
<File
RelativePath=".\ff\ff_hud_quantitybar.cpp"
>
</File>
<File
RelativePath=".\ff\ff_hud_quantitybar.h"
>
</File>
<File
RelativePath=".\ff\ff_hud_overpressure.cpp"
>
Expand Down
22 changes: 4 additions & 18 deletions cl_dll/ff/ff_hud_buildstate_base.cpp
Expand Up @@ -69,9 +69,9 @@ static ConVar hud_buildstate_shadow_icon( "hud_buildstate_shadow_icon", "0", FCV
static ConVar hud_buildstate_shadow_label( "hud_buildstate_shadow_label", "0", FCVAR_ARCHIVE, "Label Shadow (0 Off, 1 On)", true, 0, true, 1);
static ConVar hud_buildstate_shadow_amount( "hud_buildstate_shadow_amount", "0", FCVAR_ARCHIVE, "Amount Shadow (0 Off, 1 On)", true, 0, true, 1);

static ConVar hud_buildstate_size_icon( "hud_buildstate_size_icon", "2", FCVAR_ARCHIVE, "Icon Size (0-4)", true, 0, true, 4);
static ConVar hud_buildstate_size_label( "hud_buildstate_size_label", "2", FCVAR_ARCHIVE, "Label Shadow (0-4)", true, 0, true, 4);
static ConVar hud_buildstate_size_amount( "hud_buildstate_size_amount", "2", FCVAR_ARCHIVE, "Amount Shadow (0-4)", true, 0, true, 4);
static ConVar hud_buildstate_size_icon( "hud_buildstate_size_icon", "2", FCVAR_ARCHIVE, "Icon Size (0-9)", true, 0, true, 9);
static ConVar hud_buildstate_size_label( "hud_buildstate_size_label", "2", FCVAR_ARCHIVE, "Label Shadow (0-9)", true, 0, true, 9);
static ConVar hud_buildstate_size_amount( "hud_buildstate_size_amount", "2", FCVAR_ARCHIVE, "Amount Shadow (0-9)", true, 0, true, 9);

static ConVar hud_buildstate_colorMode_bar( "hud_buildstate_colorMode_bar", "2", FCVAR_ARCHIVE, "Bar color mode (0=Custom, 1=Stepped Intensity, 2=Faded Intensity, 3=Team Coloured)");
static ConVar hud_buildstate_colorMode_barBackground( "hud_buildstate_colorMode_barBackground", "2", FCVAR_ARCHIVE, "Bar Background color mode (0=Custom, 1=Stepped Intensity, 2=Faded Intensity, 3=Team Coloured)");
Expand Down Expand Up @@ -352,18 +352,4 @@ void CHudBuildStateBase::CheckCvars(bool updateBarPositions)

if(updateBarPositions)
UpdateQBPositions();
}

void CHudBuildStateBase::ApplySchemeSettings( vgui::IScheme *pScheme )
{
m_hfText = pScheme->GetFont( "QuantityPanel", IsProportional() );

SetPaintBackgroundType(2);
SetPaintBackgroundEnabled(false);
SetPaintBorderEnabled(false);
SetPaintEnabled(false);

UpdateQBPositions();
BaseClass::ApplySchemeSettings( pScheme );
}

}
16 changes: 2 additions & 14 deletions cl_dll/ff/ff_hud_buildstate_base.h
Expand Up @@ -3,26 +3,14 @@

//#include "c_ff_player.h" //required to cast base player

#include "iclientmode.h" //to set panel parent as the cliends viewport

class CHudBuildStateBase : public vgui::FFQuantityPanel
{
DECLARE_CLASS_SIMPLE( CHudBuildStateBase, vgui::FFQuantityPanel );

public:
CHudBuildStateBase(vgui::Panel* parent, const char *pElementName) : vgui::FFQuantityPanel(parent, pElementName)
{
SetParent(g_pClientMode->GetViewport());

m_flScale = 1.0f;
}
CHudBuildStateBase(vgui::Panel* parent, const char *pElementName) : vgui::FFQuantityPanel(parent, pElementName) {}

~CHudBuildStateBase( void ) {}

void CheckCvars(bool updateBarPositions = false);
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );

protected:

vgui::HFont m_hfText;
virtual void CheckCvars(bool updateBarPositions = false);
};
156 changes: 57 additions & 99 deletions cl_dll/ff/ff_hud_buildstate_sentry.cpp
@@ -1,114 +1,53 @@
#include "cbase.h"
#include "ff_hud_buildstate_base.h"
#include "ff_hud_buildstate_sentry.h"

#include "c_ff_player.h" //required to cast base player

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

static ConVar hud_buildstate_sg_override( "hud_buildstate_sg_overrideSettings", "1", FCVAR_ARCHIVE, "Whether positioning, alignment and columns should override standard buildstate settings", true, 0, true, 1);
static ConVar hud_buildstate_sg_x( "hud_buildstate_sg_x", "640", FCVAR_ARCHIVE, "Panel's X position on 640 480 Resolution", true, 0, true, 640);
static ConVar hud_buildstate_sg_y( "hud_buildstate_sg_y", "0", FCVAR_ARCHIVE, "Panel's Y Position on 640 480 Resolution", true, 0, true, 480);
static ConVar hud_buildstate_sg_align_horiz( "hud_buildstate_sg_align_horiz", "2", FCVAR_ARCHIVE, "Panel's horizontal alignment to the specified position (0=left, 1=center, 2=right", true, 0, true, 2);
static ConVar hud_buildstate_sg_align_vert( "hud_buildstate_sg_align_vert", "0", FCVAR_ARCHIVE, "Panel's vertical alignment to the specified position (0=top, 1=middle, 2=bottom", true, 0, true, 2);
static ConVar hud_buildstate_sg_columns( "hud_buildstate_sg_columns", "1", FCVAR_ARCHIVE, "Number of quantity bar columns", true, 1, true, 6);

class CHudBuildStateSentry : public CHudElement, public CHudBuildStateBase
CHudBuildStateSentry::CHudBuildStateSentry(const char *pElementName) : CHudElement(pElementName), BaseClass(NULL, "HudBuildStateSentry")
{
DECLARE_CLASS_SIMPLE( CHudBuildStateSentry, CHudBuildStateBase );

public:
CHudBuildStateSentry(const char *pElementName) : CHudElement(pElementName), CHudBuildStateBase(NULL, "HudBuildStateSentry")
{
SetParent(g_pClientMode->GetViewport());
SetHiddenBits( 0 );

m_bBuilt = false;

vgui::ivgui()->AddTickSignal(GetVPanel(), 500); //only update 2 times a second
}

~CHudBuildStateSentry( void ) {}

virtual void Init( void );
virtual void OnTick( void );
virtual void Paint( void );

void MsgFunc_SentryMsg(bf_read &msg);
SetParent(g_pClientMode->GetViewport());

protected:
virtual void CheckCvars();
private:
// could probably do this without these now
// but would need an alternative of selecting the one you want easily
FFQuantityBar *m_qbSentryHealth;
FFQuantityBar *m_qbSentryLevel;
// Hide when player is dead
SetHiddenBits( HIDEHUD_PLAYERDEAD );

bool m_bBuilt;
};

DECLARE_HUDELEMENT(CHudBuildStateSentry);
DECLARE_HUD_MESSAGE(CHudBuildStateSentry, SentryMsg);
m_bBuilt = false;
}

void CHudBuildStateSentry::CheckCvars()
CHudBuildStateSentry::~CHudBuildStateSentry()
{
bool updateBarPositions = false;

m_bChildOverride = hud_buildstate_sg_override.GetBool();

if(m_iX != hud_buildstate_sg_x.GetInt() || m_iY != hud_buildstate_sg_y.GetInt())
{
m_iX = hud_buildstate_sg_x.GetInt();
m_iY = hud_buildstate_sg_y.GetInt();
}

if(m_iHorizontalAlign != hud_buildstate_sg_align_horiz.GetInt())
m_iHorizontalAlign = hud_buildstate_sg_align_horiz.GetInt();

if(m_iVerticalAlign != hud_buildstate_sg_align_vert.GetInt())
m_iVerticalAlign = hud_buildstate_sg_align_vert.GetInt();

if(m_qb_iColumns != hud_buildstate_sg_columns.GetInt())
{
m_qb_iColumns = hud_buildstate_sg_columns.GetInt();
updateBarPositions = true;
}

BaseClass::CheckCvars(updateBarPositions);
}

void CHudBuildStateSentry::Init()
void CHudBuildStateSentry::VidInit()
{
HOOK_HUD_MESSAGE(CHudBuildStateSentry, SentryMsg);

wchar_t *tempString = vgui::localize()->Find("#FF_PLAYER_SENTRYGUN");

if (!tempString)
tempString = L"HEALTH";

m_qbSentryHealth = AddChild("BuildStateSentryHealth");
m_qbSentryLevel = AddChild("BuildStateSentryLevel");

SetHeaderText(tempString);
SetHeaderIconChar("R");

m_qbSentryHealth->SetLabelText("#FF_ITEM_HEALTH");
m_qbSentryHealth->SetIconChar(":");
m_qbSentryHealth->SetVisible(false);
m_qbSentryHealth->SetIntensityAmountScaled(true);//max changes (is not 100) so we need to scale to a percentage amount for calculation

m_qbSentryLevel->SetLabelText("#FF_ITEM_LEVEL");
m_qbSentryLevel->SetAmountMax(3);
m_qbSentryLevel->SetIntensityControl(1,2,2,3);
m_qbSentryLevel->SetIntensityValuesFixed(true);
m_qbSentryLevel->SetVisible(false);
}

void CHudBuildStateSentry::Init()
{
ivgui()->AddTickSignal(GetVPanel(), 500); //only update 2 times a second
HOOK_HUD_MESSAGE(CHudBuildStateSentry, SentryMsg);

m_qbSentryHealth = AddChild("BuildStateSentryHealth");
m_qbSentryLevel = AddChild("BuildStateSentryLevel");
}

void CHudBuildStateSentry::OnTick()
{
BaseClass::OnTick();


CheckCvars();

if (!engine->IsInGame())
Expand All @@ -121,23 +60,14 @@ void CHudBuildStateSentry::OnTick()
if (!pPlayer || pPlayer->GetClassSlot() != CLASS_ENGINEER)
//hide the panel
{
//TO-DO
//it should just be setvisible(false) to stop it from painting
//all children should follow and job done but for somereason it isn't
SetPaintBackgroundEnabled(false);
SetPaintBorderEnabled(false);
SetPaintEnabled(false);
m_qbSentryHealth->SetVisible(false);
m_qbSentryLevel->SetVisible(false);
SetVisible(false); //sits here for good measure.. does nothing :/
m_bDraw = false;
SetBarsVisible(false);
return; //return and don't continue
}
else
//show the panel
{
SetPaintBackgroundEnabled(true);
SetPaintBorderEnabled(true);
SetPaintEnabled(true);
m_bDraw = true;
}

m_bBuilt = pPlayer->GetSentryGun();
Expand All @@ -146,19 +76,20 @@ void CHudBuildStateSentry::OnTick()
if(!m_bBuilt)
//hide quantity bars
{
m_qbSentryHealth->SetVisible(false);
m_qbSentryLevel->SetVisible(false);
SetBarsVisible(false);
}
else
//show quantity bars
{
m_qbSentryHealth->SetVisible(true);
m_qbSentryLevel->SetVisible(true);
SetBarsVisible(true);
}
}

void CHudBuildStateSentry::Paint()
{
if(!m_bDraw)
return;

wchar_t* pText;

if(!m_bBuilt)
Expand All @@ -167,16 +98,43 @@ void CHudBuildStateSentry::Paint()
//paint "Not Built" message
//LOCALISE THIS
pText = L"Not Built"; // wide char text
vgui::surface()->DrawSetTextFont( m_hfText ); // set the font
vgui::surface()->DrawSetTextColor( m_ColorText );
vgui::surface()->DrawSetTextPos( m_qb_iPositionX * m_flScale, m_qb_iPositionY * m_flScale ); // x,y position
vgui::surface()->DrawPrintText( pText, wcslen(pText) ); // print text
surface()->DrawSetTextFont( m_hfText ); // set the font
surface()->DrawSetTextColor( m_ColorText );
surface()->DrawSetTextPos( (m_qb_iPositionX + m_qb_iBarMarginHorizontal) * m_flScale, (m_qb_iPositionY + m_qb_iBarMarginVertical) * m_flScale ); // x,y position
surface()->DrawPrintText( pText, wcslen(pText) ); // print text
}

//paint header
BaseClass::Paint();
}

void CHudBuildStateSentry::CheckCvars()
{
bool updateBarPositions = false;

m_bChildOverride = hud_buildstate_sg_override.GetBool();

if(m_iX != hud_buildstate_sg_x.GetInt() || m_iY != hud_buildstate_sg_y.GetInt())
{
m_iX = hud_buildstate_sg_x.GetInt();
m_iY = hud_buildstate_sg_y.GetInt();
}

if(m_iHorizontalAlign != hud_buildstate_sg_align_horiz.GetInt())
m_iHorizontalAlign = hud_buildstate_sg_align_horiz.GetInt();

if(m_iVerticalAlign != hud_buildstate_sg_align_vert.GetInt())
m_iVerticalAlign = hud_buildstate_sg_align_vert.GetInt();

if(m_qb_iColumns != hud_buildstate_sg_columns.GetInt())
{
m_qb_iColumns = hud_buildstate_sg_columns.GetInt();
updateBarPositions = true;
}

BaseClass::CheckCvars(updateBarPositions);
}

void CHudBuildStateSentry::MsgFunc_SentryMsg(bf_read &msg)
{
int iHealth = (int) msg.ReadByte();
Expand Down
49 changes: 49 additions & 0 deletions cl_dll/ff/ff_hud_buildstate_sentry.h
@@ -0,0 +1,49 @@
#include "cbase.h"

#include "ff_hud_buildstate_base.h"
#include "hudelement.h"

#include "hud_macros.h"

#include "iclientmode.h" //to set panel parent as the clients viewport
#include "c_ff_player.h" //required to cast base player

#include <vgui/ISurface.h>
#include <vgui/IVGui.h>
#include <vgui/ILocalize.h>

static ConVar hud_buildstate_sg_override( "hud_buildstate_sg_overrideSettings", "1", FCVAR_ARCHIVE, "Whether positioning, alignment and columns should override standard buildstate settings", true, 0, true, 1);
static ConVar hud_buildstate_sg_x( "hud_buildstate_sg_x", "640", FCVAR_ARCHIVE, "Panel's X position on 640 480 Resolution", true, 0, true, 640);
static ConVar hud_buildstate_sg_y( "hud_buildstate_sg_y", "0", FCVAR_ARCHIVE, "Panel's Y Position on 640 480 Resolution", true, 0, true, 480);
static ConVar hud_buildstate_sg_align_horiz( "hud_buildstate_sg_align_horiz", "2", FCVAR_ARCHIVE, "Panel's horizontal alignment to the specified position (0=left, 1=center, 2=right", true, 0, true, 2);
static ConVar hud_buildstate_sg_align_vert( "hud_buildstate_sg_align_vert", "0", FCVAR_ARCHIVE, "Panel's vertical alignment to the specified position (0=top, 1=middle, 2=bottom", true, 0, true, 2);
static ConVar hud_buildstate_sg_columns( "hud_buildstate_sg_columns", "1", FCVAR_ARCHIVE, "Number of quantity bar columns", true, 1, true, 6);

using namespace vgui;

class CHudBuildStateSentry : public CHudElement, public CHudBuildStateBase
{
private:
DECLARE_CLASS_SIMPLE( CHudBuildStateSentry, CHudBuildStateBase );

FFQuantityBar *m_qbSentryHealth;
FFQuantityBar *m_qbSentryLevel;

bool m_bBuilt;
public:
CHudBuildStateSentry(const char *pElementName);
~CHudBuildStateSentry();

void Init( void );
void VidInit( void );
void OnTick( void );
void Paint( void );

void MsgFunc_SentryMsg(bf_read &msg);

protected:
virtual void CheckCvars();
};

DECLARE_HUDELEMENT(CHudBuildStateSentry);
DECLARE_HUD_MESSAGE(CHudBuildStateSentry, SentryMsg);
2 changes: 2 additions & 0 deletions cl_dll/ff/vgui/ff_panel.cpp
Expand Up @@ -26,6 +26,8 @@

ConVar cl_teamcolourhud( "cl_teamcolourhud", "1", FCVAR_ARCHIVE );

extern ConVar cl_teamcolourhud;

extern C_PlayerResource *g_PR;

namespace vgui
Expand Down

0 comments on commit f806499

Please sign in to comment.