diff --git a/src/g_shared/sbar.h b/src/g_shared/sbar.h index 71dc66672..fd2758e65 100644 --- a/src/g_shared/sbar.h +++ b/src/g_shared/sbar.h @@ -386,4 +386,6 @@ void ST_LoadCrosshair(bool alwaysload=false); void ST_Clear(); extern FTexture *CrosshairImage; +FTextureID GetWeaponIcon(AWeapon *weapon); + #endif /* __SBAR_H__ */ diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index 62043a6a8..7124f8abd 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -41,6 +41,7 @@ // classes. //////////////////////////////////////////////////////////////////////////////// + class CommandDrawImage : public SBarInfoCommand { public: @@ -169,8 +170,17 @@ class CommandDrawImage : public SBarInfoCommand else if(type == WEAPONICON) { AWeapon *weapon = statusBar->CPlayer->ReadyWeapon; - if(weapon != NULL && weapon->Icon.isValid()) + if(weapon != NULL) { + FTextureID icon; + if (weapon->Icon.isValid()) + { + icon = weapon->Icon; + } + else + { + icon = GetWeaponIcon(weapon); + } texture = TexMan[weapon->Icon]; } } diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index db3b264c7..1c98b1808 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -594,25 +594,12 @@ static int DrawAmmo(player_t *CPlayer, int x, int y) // //--------------------------------------------------------------------------- -static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon) +FTextureID GetWeaponIcon(AWeapon *weapon) // This function is also used by SBARINFO { - int trans; - FTextureID picnum; - - // Powered up weapons and inherited sister weapons are not displayed. - if (weapon->WeaponFlags & WIF_POWERED_UP) return; - if (weapon->SisterWeapon && weapon->IsKindOf(RUNTIME_TYPE(weapon->SisterWeapon))) return; - - trans=0x6666; - if (CPlayer->ReadyWeapon) - { - if (weapon==CPlayer->ReadyWeapon || weapon==CPlayer->ReadyWeapon->SisterWeapon) trans=0xd999; - } - + FTextureID AltIcon = GetHUDIcon(weapon->GetClass()); FState * state=NULL, *ReadyState; - FTextureID AltIcon = GetHUDIcon(weapon->GetClass()); - picnum = !AltIcon.isNull()? AltIcon : weapon->Icon; + FTextureID picnum = !AltIcon.isNull()? AltIcon : weapon->Icon; if (picnum.isNull()) { @@ -625,7 +612,7 @@ static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon) { state = ReadyState; } - if (state && (unsigned)state->sprite < (unsigned)sprites.Size ()) + if (state && (unsigned)state->sprite < (unsigned)sprites.Size ()) { spritedef_t * sprdef = &sprites[state->sprite]; spriteframe_t * sprframe = &SpriteFrames[sprdef->spriteframes + state->GetFrame()]; @@ -633,6 +620,25 @@ static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon) picnum = sprframe->Texture[0]; } } + return picnum; +} + + +static void DrawOneWeapon(player_t * CPlayer, int x, int & y, AWeapon * weapon) +{ + int trans; + + // Powered up weapons and inherited sister weapons are not displayed. + if (weapon->WeaponFlags & WIF_POWERED_UP) return; + if (weapon->SisterWeapon && weapon->IsKindOf(RUNTIME_TYPE(weapon->SisterWeapon))) return; + + trans=0x6666; + if (CPlayer->ReadyWeapon) + { + if (weapon==CPlayer->ReadyWeapon || weapon==CPlayer->ReadyWeapon->SisterWeapon) trans=0xd999; + } + + FTextureID picnum = GetWeaponIcon(weapon); if (picnum.isValid()) {