- Blood: Implement cl_showmagamt for the game's shotgun.

* Tile set for `kSBarNumberAmmo` does not include a slash. Hack put in place to get me a slash from a specific tile of a different font. It "works" and I don't think it looks too bad.
This commit is contained in:
Mitchell Richters 2020-08-28 11:38:56 +10:00 committed by Christoph Oelckers
parent 1617938d4f
commit c555540e24

View file

@ -169,6 +169,33 @@ private:
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void DrawCharArray(const char* string, int nTile, double x, double y, int nShade, int nPalette, unsigned int nStat = 0, int nScale = 65536, int align = 0)
{
double width = (tileWidth(nTile) + 1) * (nScale / 65536.);
x += 0.5;
y += 0.5; // This is needed because due to using floating point math, this code rounds slightly differently which for the numbers can be a problem.
for (unsigned int i = 0; string[i]; i++, x += width)
{
// Hackasaurus rex to give me a slash when drawing the weapon count of a reloadable gun.
if (string[i] == 47 && nTile == kSBarNumberAmmo)
{
DrawStatSprite(4207, x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent, align);
}
else
{
DrawStatSprite(nTile + string[i] - '0', x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent, align);
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void TileHGauge(int nTile, double x, double y, int nMult, int nDiv, int nStat = 0, int nScale = 65536) void TileHGauge(int nTile, double x, double y, int nMult, int nDiv, int nStat = 0, int nScale = 65536)
{ {
int bx = scale(mulscale16(tilesiz[nTile].x, nScale), nMult, nDiv) + x; int bx = scale(mulscale16(tilesiz[nTile].x, nScale), nMult, nDiv) + x;
@ -721,8 +748,23 @@ private:
if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles) if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles)
DrawStatMaskedSprite(gAmmoIcons[pPlayer->weaponAmmo].nTile, 304-320, -8 + gAmmoIcons[pPlayer->weaponAmmo].nYOffs, DrawStatMaskedSprite(gAmmoIcons[pPlayer->weaponAmmo].nTile, 304-320, -8 + gAmmoIcons[pPlayer->weaponAmmo].nYOffs,
0, 0, 512, gAmmoIcons[pPlayer->weaponAmmo].nScale); 0, 0, 512, gAmmoIcons[pPlayer->weaponAmmo].nScale);
if (pPlayer->curWeapon != 3 || (pPlayer->curWeapon == 3 && !cl_showmagamt))
{
DrawStatNumber("%3d", num, kSBarNumberAmmo, 267-320, 187 - 200, 0, 0, 512); DrawStatNumber("%3d", num, kSBarNumberAmmo, 267-320, 187 - 200, 0, 0, 512);
} }
else
{
FString format;
bool twoGuns = powerupCheck(pPlayer, kPwUpTwoGuns);
short reload = !twoGuns ? 1 : 6;
short capacity = !twoGuns ? 2 : 4;
short clip = CalcMagazineAmount(num, capacity, pPlayer->weaponState == reload);
format.Format("%d/%d", clip, num - clip);
DrawCharArray(format.GetChars(), kSBarNumberAmmo, 267-320, 187 - 200, 0, 0, 512);
}
}
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {