- Duke: Implement cl_showmagamt for the RR's pistol and shotgun.

This commit is contained in:
Mitchell Richters 2020-08-27 22:44:37 +10:00 committed by Christoph Oelckers
parent 161647ed5b
commit eb3a21e677

View file

@ -141,10 +141,29 @@ public:
int weapon = p->curr_weapon; int weapon = p->curr_weapon;
if (weapon == HANDREMOTE_WEAPON) weapon = DYNAMITE_WEAPON; if (weapon == HANDREMOTE_WEAPON) weapon = DYNAMITE_WEAPON;
int wicon = ammo_sprites[p->curr_weapon]; int wicon = ammo_sprites[weapon];
if (wicon > 0) if (wicon > 0)
{ {
format.Format("%d", p->ammo_amount[weapon]); int ammo = p->ammo_amount[weapon];
bool reloadableWeapon = weapon == PISTOL_WEAPON || weapon == SHOTGUN_WEAPON;
if (!reloadableWeapon || (reloadableWeapon && !cl_showmagamt))
{
format.Format("%d", ammo);
}
else
{
short clip;
switch (weapon)
{
case PISTOL_WEAPON:
clip = CalcMagazineAmount(ammo, 6, p->kickback_pic >= 1);
break;
case SHOTGUN_WEAPON:
clip = CalcMagazineAmount(ammo, 2, p->kickback_pic >= 4);
break;
}
format.Format("%d/%d", clip, ammo - clip);
}
img = tileGetTexture(wicon); img = tileGetTexture(wicon);
imgScale = baseScale / img->GetDisplayHeight(); imgScale = baseScale / img->GetDisplayHeight();
auto imgX = 22.5; auto imgX = 22.5;
@ -155,7 +174,7 @@ public:
imgX += (imgX * 0.755) * (strlen - 1); imgX += (imgX * 0.755) * (strlen - 1);
} }
if (p->curr_weapon != KNEE_WEAPON && p->curr_weapon != SLINGBLADE_WEAPON && (!althud_flashing || gameclock & 32 || p->ammo_amount[weapon] > (max_ammo_amount[weapon] / 10))) if (weapon != KNEE_WEAPON && weapon != SLINGBLADE_WEAPON && (!althud_flashing || gameclock & 32 || ammo > (max_ammo_amount[weapon] / 10)))
{ {
SBar_DrawString(this, &numberFont, format, -1, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); SBar_DrawString(this, &numberFont, format, -1, -numberFont.mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale);
} }