Skip to content

Commit

Permalink
don't open weapon menu if there is no weapons
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaulwurff committed Jul 13, 2022
1 parent 6a65355 commit 0c57a72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ Inventory.AltHudIcon for your weapons! Tag property is also nice to have.
Zhs2 and Apollucas for feature suggestions.
- Thanks to Accensus, Proydoha, mamaluigisbagel, Ac!d, wildweasel,
Dark-Assassin, rparhkdtp, Samarai1000, Mr. Blazkowicz, lucker42, spectrefps,
Someone64, Lippeth, JMartinez9820 and generic name guy for bug reports.
Someone64, Lippeth, JMartinez9820, generic name guy and sebastianpanetta for
bug reports.
- See also [credits list](credits.md).
3 changes: 2 additions & 1 deletion zscript/gearbox/event_handler.zs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class gb_EventHandler : EventHandler
}
else
{
mSounds.playNope();
return false;
}

Expand Down Expand Up @@ -306,7 +307,7 @@ class gb_EventHandler : EventHandler
private ui
void openWeapons()
{
if (gb_Player.isDead())
if (gb_Player.isDead() || mWeaponMenu.isThereNoWeapons())
{
mSounds.playNope();
return;
Expand Down
11 changes: 11 additions & 0 deletions zscript/gearbox/weapon_menu.zs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ class gb_WeaponMenu
return oldIndex;
}

bool isThereNoWeapons() const
{
bool isNothingFound = true;
uint nWeapons = mWeapons.size();
for (uint i = 0; i < nWeapons; ++i)
{
if (isInInventory(i) && !isHidden(mWeapons[i].getClassName())) return false;
}
return isNothingFound;
}

// private: ////////////////////////////////////////////////////////////////////////////////////////

private
Expand Down

0 comments on commit 0c57a72

Please sign in to comment.