Skip to content

Commit

Permalink
manually merge "Option to enable retro MSC HUD"
Browse files Browse the repository at this point in the history
thanks git for being stupid.
  • Loading branch information
SaintWish committed Oct 11, 2023
1 parent 5a15368 commit 5b793d6
Show file tree
Hide file tree
Showing 7 changed files with 368 additions and 78 deletions.
3 changes: 2 additions & 1 deletion game/client/client.vpc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ $Project "Client"
$File "ui\ms\vgui_containerlist.cpp"
$File "ui\ms\vgui_eventconsole.h"
$File "ui\ms\vgui_health.h"
$File "ui\ms\vgui_health2.h"
$File "ui\ms\vgui_hud.cpp"
$File "ui\ms\vgui_id.h"
$File "ui\ms\vgui_infowin.h"
Expand Down Expand Up @@ -421,4 +422,4 @@ $Project "Client"
$ImpLib steam_api
$ImpLib fmod_vc
}
}
}
4 changes: 3 additions & 1 deletion game/client/ms/hudmisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ int CHudMisc::Init(void)
HOOK_COMMAND("accept", Accept);
//HOOK_COMMAND("listskills", ListSkills);

CVAR_CREATE("cl_retrohud", "0", FCVAR_ARCHIVE);

CVAR_CREATE("cl_crosshair_draw", "1", FCVAR_ARCHIVE);
CVAR_CREATE("cl_crosshair_type", "0", FCVAR_ARCHIVE);

Expand Down Expand Up @@ -385,4 +387,4 @@ void CHudMisc ::UserCmd_Accept(void)
//if( player.Class && player.Class->id == CLASS_ROGUE )
// gHUD.m_Menu->ShowMenu( 1, "Use skill:\n\n1. Shadow Stealth\n", MENU_LISTSKILLS );
}*/
}*/
69 changes: 31 additions & 38 deletions game/client/ui/ms/vgui_health.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,24 @@

#include <vector>

static COLOR Color_Text_LowHealth(250, 0, 0, 10),
Color_Charge_Lvl1(128, 128, 128, 128), Color_Charge_Lvl2(255, 100, 100, 128),
Color_Charge_Lvl3(100, 230, 30, 128),
Color_Charge_BG(128, 128, 128, 100);
static COLOR HighColor(0, 255, 0, 128), MedColor(255, 255, 0, 128), LowColor(255, 0, 0, 128);

//Scales flasks down to only 40% wide of the screen if sprites are too big
#define FLASK_SCALE (1.0f - ((730 - (ScreenWidth * 0.40f)) / ScreenWidth))
#define BAR_SCALE (1.0f - ((730 - (ScreenWidth * 0.40f)) / ScreenWidth))

//Dimensions of the "Flask" sprites
#define FLASK_W (320 * FLASK_SCALE)
#define FLASK_H (40 * FLASK_SCALE)
//Dimensions of the "Bar" sprites
#define BAR_W (320 * BAR_SCALE)
#define BAR_H (40 * BAR_SCALE)

#define EMBLEM_SIZE (90 * FLASK_SCALE)
#define EMBLEM_SIZE (90 * BAR_SCALE)

class VGUI_Flask : public Panel
class VGUI_Bar : public Panel
{
public:
VGUI_Image3D m_Image;
MSLabel *m_Label;
int m_Type;
float m_CurrentAmt;

VGUI_Flask(Panel *pParent, int Type, int x, int y) : Panel(x, y, FLASK_W, FLASK_H)
VGUI_Bar(Panel *pParent, int Type, int x, int y) : Panel(x, y, BAR_W, BAR_H)
{
setParent(pParent);
setBgColor(0, 0, 0, 255);
Expand Down Expand Up @@ -60,16 +54,20 @@ class VGUI_Flask : public Panel
float Amt, MaxAmt;

switch (m_Type) {
case 0: Amt = player.m_HP;
case 0:
Amt = player.m_HP;
MaxAmt = player.MaxHP();
break;
case 1: Amt = player.m_MP;
case 1:
Amt = player.m_MP;
MaxAmt = player.MaxMP();
break;
case 2: Amt = player.Weight();
case 2:
Amt = player.Weight();
MaxAmt = player.Volume();
break;
case 3: Amt = player.Stamina;
case 3:
Amt = player.Stamina;
MaxAmt = player.MaxStamina();
break;
}
Expand Down Expand Up @@ -109,10 +107,13 @@ class VGUI_Flask : public Panel
m_Image.SetFrame(frame);

m_Label->setText(UTIL_VarArgs("%i/%i ", (int)m_CurrentAmt, (int)MaxAmt)); //the space is intentional
if (m_CurrentAmt > MaxAmt / 4.0f)
m_Label->SetFGColorRGB(Color_Text_White);
else
m_Label->SetFGColorRGB(Color_Text_LowHealth);
m_Label->SetFGColorRGB(COLOR(255, 255, 255, 10));
if (m_Type != 2) {
if (m_CurrentAmt > MaxAmt / 4.0f)
m_Label->SetFGColorRGB(COLOR(255, 255, 255, 10));
else
m_Label->SetFGColorRGB(COLOR(250, 0, 0, 10));
}

setVisible(ShowHealth());
}
Expand All @@ -128,7 +129,7 @@ class VGUI_Health : public Panel, public IHUD_Interface
int vCurChargeLevel = 0;

public:
class VGUI_Flask *m_Flask[4];
class VGUI_Bar *m_Bar[4];

CStatusBar *m_Charge[2];
MSLabel *m_ChargeLbl[2];
Expand All @@ -139,66 +140,59 @@ class VGUI_Health : public Panel, public IHUD_Interface
//Main HUD Image
VGUI_Health(Panel* pParent) : Panel(0, 0, ScreenWidth, ScreenHeight)
{
startdbg;
dbg("Begin");
setParent(pParent);
SetBGColorRGB(Color_Transparent);



//Point defines where status bars are positioned relative to and the max screen space its allowed to take before scaling
float coords[2];

coords[0] = 10; //x
coords[1] = (ScreenHeight - (2 * FLASK_H) - 10); //y, from the bottom of the screen, as high as the sprites are
coords[1] = (ScreenHeight - (2 * BAR_H) - 10); //y, from the bottom of the screen, as high as the sprites are

// Status Bars

//Health bar
m_Flask[0] = new VGUI_Flask(this, 0, coords[0], coords[1]);
m_Bar[0] = new VGUI_Bar(this, 0, coords[0], coords[1]);

//weight bar
m_Flask[2] = new VGUI_Flask(this, 2, coords[0], coords[1] + FLASK_H);
m_Bar[2] = new VGUI_Bar(this, 2, coords[0], coords[1] + BAR_H);

//Mana bar
m_Flask[1] = new VGUI_Flask(this, 1, coords[0] + FLASK_W + EMBLEM_SIZE - 1, coords[1]);
m_Bar[1] = new VGUI_Bar(this, 1, coords[0] + BAR_W + EMBLEM_SIZE - 1, coords[1]);

//stam bar
m_Flask[3] = new VGUI_Flask(this, 3, coords[0] + FLASK_W + EMBLEM_SIZE - 1, coords[1] + FLASK_H);
m_Bar[3] = new VGUI_Bar(this, 3, coords[0] + BAR_W + EMBLEM_SIZE - 1, coords[1] + BAR_H);

m_HUDImage.setParent(this);
m_HUDImage.LoadImg("hud_main", true, false);
m_HUDImage.setSize(EMBLEM_SIZE, EMBLEM_SIZE);
m_HUDImage.setPos(coords[0] + FLASK_W, coords[1] - (7 * FLASK_SCALE));
m_HUDImage.setPos(coords[0] + BAR_W, coords[1] - (7 * BAR_SCALE));

//Charge system
#define CHARGE_W XRES(30)
#define CHARGE_H YRES(6)
#define CHARGE_SPACER_W XRES(2)
//#define CHARGE_X XRES(320) - CHARGE_W/2

dbg("Setup m_Charge[0] & m_Charge[1]");
for (int i = 0; i < 2; i++)
{
int Multiplier = (i == 0) ? -1 : 1;
float OffsetW = CHARGE_SPACER_W + (i == 0) ? CHARGE_W : 0;
m_Charge[i] = new CStatusBar(this, XRES(304) + OffsetW * Multiplier, YRES(408), CHARGE_W, CHARGE_H);
m_Charge[i]->SetBGColorRGB(Color_Charge_BG);
m_Charge[i]->SetBGColorRGB(COLOR(128, 128, 128, 100));
//m_Charge[i]->m_fBorder = false;
m_Charge[i]->setVisible(false);
m_ChargeLbl[i] = new MSLabel(this, "0/0", XRES(304) + OffsetW * Multiplier, YRES(408), CHARGE_W, CHARGE_H, MSLabel::a_center);
m_ChargeLbl[i]->setVisible(false);
}

enddbg;
}

//MiB NOV2007a - Moar Charge Colors!
void Update()
{
//Update flasks
for (int i = 0; i < 4; i++)
m_Flask[i]->Update();
m_Bar[i]->Update();

bool bShowHealth = ShowHealth();

Expand Down Expand Up @@ -239,7 +233,6 @@ class VGUI_Health : public Panel, public IHUD_Interface

if (Item->Attack_IsCharging() && (vCurChargeAmt = Item->Attack_Charge()) > 0)
{

ChargeBar.setVisible(bShowHealth);
bool notDone = true;

Expand Down
Loading

0 comments on commit 5b793d6

Please sign in to comment.