Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include <KeyValues.h>
  8. #include <vgui/IScheme.h>
  9. #include <vgui/ISurface.h>
  10. #include <vgui/ISystem.h>
  11. #include <vgui_controls/AnimationController.h>
  12. #include <vgui_controls/EditablePanel.h>
  13. #include <vgui_controls/ImagePanel.h>
  14. #include "c_dod_team.h"
  15. #include "c_dod_playerresource.h"
  16. #include "c_dod_player.h"
  17. #include "weapon_dodbase.h"
  18. #include "dod_hud_playerstatus_weapon.h"
  19. float GetScale( int nIconWidth, int nIconHeight, int nWidth, int nHeight );
  20. //-----------------------------------------------------------------------------
  21. // Purpose:
  22. //-----------------------------------------------------------------------------
  23. void CDoDHudCurrentWeapon::Paint()
  24. {
  25. C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
  26. if ( pPlayer )
  27. {
  28. C_WeaponDODBase *pWeapon = pPlayer->GetActiveDODWeapon();
  29. if ( pWeapon )
  30. {
  31. const CHudTexture *pWpnSprite = pWeapon->GetSpriteActive();
  32. if ( pWpnSprite )
  33. {
  34. int x, y, w, h;
  35. GetBounds( x, y, w, h );
  36. int spriteWidth = pWpnSprite->Width(), spriteHeight = pWpnSprite->Height();
  37. float scale = GetScale( spriteWidth, spriteHeight, w, h );
  38. spriteWidth *= scale;
  39. spriteHeight *= scale;
  40. int xpos = ( w / 2.0f ) - ( spriteWidth / 2.0f );
  41. int ypos = ( h / 2.0f ) - ( spriteHeight / 2.0f );
  42. pWpnSprite->DrawSelf( xpos, ypos, spriteWidth, spriteHeight, Color( 255, 255, 255, 255 ) );
  43. }
  44. }
  45. }
  46. }