marrub
/
Lithia
Archived
1
0
Fork 0
This repository has been archived on 2023-06-17. You can view files and clone it, but cannot push or open issues/pull-requests.
Lithia/source/Main/u_headsupdisp.c

243 lines
5.7 KiB
C

// Copyright © 2016-2017 Graham Sanderson, all rights reserved.
#include "lith_upgrades_common.h"
#define UData UData_HeadsUpDisp(upgr)
// Static Functions ----------------------------------------------------------|
//
// HUD_IndicatorLine
//
static void HUD_IndicatorLine(struct player *p, __str image, int hid, int yadd)
{
int pos = (8 + p->ticks) % 57;
if(pos < 11)
yadd += 11 - (pos % 12);
DrawSpriteFade(image, hid, 88.1 - pos, 214.1 + yadd, 0.2, 0.7);
}
//
// HUD_Weapons
//
static void HUD_Weapons(struct player *p)
{
DrawSpritePlain(":HUD:Bar", hid_weaponbg, 279.2, 238.2, TS);
static int const ncolor[] = {
CR_UNTRANSLATED,
CR_LIGHTBLUE,
CR_BRICK
};
Lith_HUD_DrawWeaponSlots(p, ncolor, countof(ncolor), 'k', 282, 237);
}
//
// HUD_Ammo
//
static void HUD_Ammo(struct player *p)
{
invweapon_t const *wep = p->weapon.cur;
weaponinfo_t const *info = wep->info;
__str typegfx = null;
__str typebg;
int y;
if(p->getCVarI("lith_hud_showweapons")) {
typebg = ":HUD:SplitRight";
y = 14;
} else {
typebg = ":HUD:SplitFront";
y = 0;
}
if(wep->ammotype & AT_NMag)
{
int max = ACS_GetMaxInventory(0, wep->magclass);
int cur = ACS_CheckInventory(wep->magclass);
typegfx = ":HUD:MAG";
HudMessageF("LHUDFONT", "%i/%i", max - cur, max);
HudMessagePlain(hid_ammo1, 224.1, 229.0-y, TS);
}
if(wep->ammotype & AT_Ammo)
{
int x = 0;
if(wep->ammotype & AT_NMag) {
DrawSpritePlain(":HUD:BarBig", hid_ammobg2, 220.2, 238.2-y, TS);
x = -59;
}
typegfx = ":HUD:AMMO";
HudMessageF("LHUDFONT", "%i", ACS_CheckInventory(wep->ammoclass));
HudMessagePlain(hid_ammo2, x+224.1, 229.0-y, TS);
}
if(typegfx)
{
DrawSpritePlain(typebg, hid_ammotypebg, 320.2, 238.2, TS);
DrawSpritePlain(":HUD:BarBig", hid_ammobg1, 279.2, 238.2-y, TS);
DrawSpritePlain(typegfx, hid_ammotype, 282.1, 236.2, TS);
}
}
//
// HUD_Health
//
static void HUD_Health(struct player *p)
{
static __str weapongfx[SLOT_MAX] = {
[0] = ":HUD:H_D27",
[1] = ":HUD:H_D28",
[2] = ":HUD:H_D24",
[3] = ":HUD:H_D23",
[4] = ":HUD:H_D22",
[5] = ":HUD:H_D21",
[6] = ":HUD:H_D25",
[7] = ":HUD:H_D26"
};
DrawSpritePlain(
ACS_CheckInventory("PowerStrength") ? ":HUD:SplitBackRed" : ":HUD:SplitBack",
hid_healthbg, 0.1, 239.2, TS);
if(p->dead) HudMessageF("LHUDFONT", "---");
else HudMessageF("LHUDFONT", "%i", p->health);
HudMessagePlain(hid_health, 34.1, 231.0, TS);
DrawSpritePlain(":HUD:VIT", hid_healthtxt, 2.1, 237.2, TS);
if(!p->dead)
{
int cr = 0;
fixed ft;
if(p->health < p->oldhealth)
{
cr = CR_YELLOW;
ft = (p->oldhealth - p->health) / 30.0;
ft = minmax(ft, 0.1, 3.0);
}
else if(p->health > p->oldhealth)
{
cr = CR_PURPLE;
ft = 0.2;
}
if(cr)
{
HudMessageF("LHUDFONT", "%i", p->health);
HudMessageParams(HUDMSG_FADEOUT, hid_healthhit, cr, 34.1, 231.0, 0.1, ft);
}
}
HUD_IndicatorLine(p, weapongfx[p->weapon.cur->info->slot], hid_healthbg_fxS - (p->ticks % 32), 9);
}
//
// HUD_Score
//
static void HUD_Score(struct player *p)
{
HudMessageF("CNFONT", "%S\Cnscr", Lith_ScoreSep(p->score));
HudMessageParams(HUDMSG_PLAIN, hid_score, CR_WHITE, 320.2, 3.1, 0.1);
if(p->score > p->old.score)
{
HudMessageF("CNFONT", "%S\Cnscr", Lith_ScoreSep(p->score));
HudMessageParams(HUDMSG_FADEOUT, hid_scorehit, CR_ORANGE, 320.2, 3.1, 0.1, 0.2);
}
else if(p->score < p->old.score)
{
fixed ft = minmax((p->old.score - p->score) / 3000.0, 0.1, 3.0);
HudMessageF("CNFONT", "%S\Cnscr", Lith_ScoreSep(p->score));
HudMessageParams(HUDMSG_FADEOUT, hid_scorehit, CR_PURPLE, 320.2, 3.1, 0.1, ft);
}
if(p->scoreaccumtime > 0)
{
HudMessageF("CNFONT", "%+S", Lith_ScoreSep(p->scoreaccum));
HudMessageParams(HUDMSG_FADEOUT, hid_scoreaccum, CR_WHITE, 320.2, 13.1, 0.1, 0.4);
}
}
//
// HUD_KeyInd
//
static void HUD_KeyInd(struct player *p)
{
if(p->keys.ys) DrawSpriteAlpha(":HUD:H_KS2", hid_key_yellowskull, 310.2, 10.1, 0.1, 0.8);
if(p->keys.rs) DrawSpriteAlpha(":HUD:H_KS1", hid_key_redskull, 320.2, 10.1, 0.1, 0.8);
if(p->keys.bs) DrawSpriteAlpha(":HUD:H_KS3", hid_key_blueskull, 300.2, 10.1, 0.1, 0.8);
if(p->keys.rc) DrawSpriteAlpha(":HUD:H_KC1", hid_key_red, 290.2, 10.1, 0.1, 0.8);
if(p->keys.yc) DrawSpriteAlpha(":HUD:H_KC2", hid_key_yellow, 280.2, 10.1, 0.1, 0.8);
if(p->keys.bc) DrawSpriteAlpha(":HUD:H_KC3", hid_key_blue, 270.2, 10.1, 0.1, 0.8);
}
//
// HUD_Mode
//
static void HUD_Mode(struct player *p)
{
if(p->weapontype == weapon_rifle)
{
int addy = p->getUpgrActive(UPGR_RifleModes) ? 0 : 16;
DrawSpritePlain(":HUD:H_W3", hid_riflemodebg, 215.2, 240.2 + addy, TS);
DrawSpritePlain(StrParam(":HUD:H_W%i",
(rifle_firemode_max - p->riflefiremode) + 3),
hid_riflemode, 215.2, 208.2 + (p->riflefiremode * 16) + addy, TS);
}
}
// Extern Functions ----------------------------------------------------------|
//
// Activate
//
void Upgr_HeadsUpDisp_Activate(struct player *p, upgrade_t *upgr)
{
p->hudenabled = true;
}
//
// Disable
//
void Upgr_HeadsUpDisp_Deactivate(struct player *p, upgrade_t *upgr)
{
p->hudenabled = false;
}
//
// Render
//
void Upgr_HeadsUpDisp_Render(struct player *p, upgrade_t *upgr)
{
// Log
Lith_HUD_Log(p);
// Inventory
HUD_KeyInd(p);
if(p->getCVarI("lith_hud_showscore"))
HUD_Score(p);
if(p->getCVarI("lith_hud_showweapons"))
HUD_Weapons(p);
HUD_Mode(p);
// Status
HUD_Ammo(p);
HUD_Health(p);
}
// EOF