From b2e5e15d3cdca153e2eb0fec0c4a830862597ff4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 22 Apr 2012 09:41:06 +0000 Subject: [PATCH] - changed icon lookup for weapons in SBARINFO so that it uses the alternative HUD's method if the weapon does not have an icon defined. SVN r3587 (trunk) --- src/g_shared/sbar.h | 2 ++ src/g_shared/sbarinfo_commands.cpp | 12 ++++++++- src/g_shared/shared_hud.cpp | 40 +++++++++++++++++------------- 3 files changed, 36 insertions(+), 18 deletions(-) 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()) {