source-engine/game/client/vgui_avatarimage.h

135 lines
3.4 KiB
C
Raw Normal View History

2023-10-03 17:23:56 +03:00
//====== Copyright 1996-2005, Valve Corporation, All rights reserved. =======
2020-04-22 12:56:21 -04:00
//
2023-10-03 17:23:56 +03:00
// Purpose:
2020-04-22 12:56:21 -04:00
//
//=============================================================================
#ifndef VGUI_AVATARIMAGE_H
#define VGUI_AVATARIMAGE_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui_controls/Image.h>
#include <vgui_controls/ImagePanel.h>
#include "steam/steam_api.h"
#include "c_baseplayer.h"
2023-10-03 17:23:56 +03:00
// Avatar images, and avatar images with friends, don't scale with resolution.
#define AVATAR_INDENT_X (22)
#define AVATAR_INDENT_Y (1)
#define AVATAR_POSTDENT_X (1)
#define AVATAR_POSTDENT_Y (1)
2020-04-22 12:56:21 -04:00
//-----------------------------------------------------------------------------
2023-10-03 17:23:56 +03:00
// Purpose:
2020-04-22 12:56:21 -04:00
//-----------------------------------------------------------------------------
class CAvatarImage : public vgui::IImage
{
public:
CAvatarImage( void );
// Call this to set the steam ID associated with the avatar
2023-10-03 17:23:56 +03:00
bool SetAvatarSteamID( CSteamID steamIDUser );
2020-04-22 12:56:21 -04:00
void UpdateFriendStatus( void );
void ClearAvatarSteamID( void );
// Call to Paint the image
// Image will draw within the current panel context at the specified position
virtual void Paint( void );
// Set the position of the image
virtual void SetPos(int x, int y)
{
m_nX = x;
m_nY = y;
}
// Gets the size of the content
virtual void GetContentSize(int &wide, int &tall)
{
2023-10-03 17:23:56 +03:00
wide = m_nWide;
tall = m_nTall;
2020-04-22 12:56:21 -04:00
}
// Get the size the image will actually draw in (usually defaults to the content size)
virtual void GetSize(int &wide, int &tall)
{
GetContentSize( wide, tall );
}
// Sets the size of the image
2023-10-03 17:23:56 +03:00
virtual void SetSize(int wide, int tall)
{
m_nWide = wide;
m_nTall = tall;
}
2020-04-22 12:56:21 -04:00
2023-10-03 17:23:56 +03:00
void SetAvatarSize(int wide, int tall)
2020-04-22 12:56:21 -04:00
{
2023-10-03 17:23:56 +03:00
m_iAvatarWidth = wide;
m_iAvatarHeight = tall;
SetSize( wide + AVATAR_INDENT_X + AVATAR_POSTDENT_X, tall + AVATAR_INDENT_Y + AVATAR_POSTDENT_Y );
2020-04-22 12:56:21 -04:00
}
2023-10-03 17:23:56 +03:00
// Set the draw color
virtual void SetColor(Color col)
{
m_Color = col;
}
2020-04-22 12:56:21 -04:00
2023-10-03 17:23:56 +03:00
void SetAvatarSize( EAvatarSize size )
{
m_SourceArtSize = size;
}
2020-04-22 12:56:21 -04:00
2023-10-03 17:23:56 +03:00
bool IsValid( void ) { return m_bValid; }
2020-04-22 12:56:21 -04:00
2023-10-03 17:23:56 +03:00
virtual bool Evict() { return false; }
virtual int GetNumFrames() { return 0; }
virtual void SetFrame( int nFrame ) {}
virtual vgui::HTexture GetID() { return m_iTextureID; }
2020-04-22 12:56:21 -04:00
virtual void SetRotation( int iRotation ) { return; }
2023-10-03 17:23:56 +03:00
int GetWide( void ) { return m_nWide; }
2020-04-22 12:56:21 -04:00
protected:
2023-10-03 17:23:56 +03:00
void InitFromRGBA( const byte *rgba, int width, int height );
2020-04-22 12:56:21 -04:00
private:
2023-10-03 17:23:56 +03:00
CSteamID m_steamIDUser;
2020-04-22 12:56:21 -04:00
Color m_Color;
int m_iTextureID;
2023-10-03 17:23:56 +03:00
int m_nX, m_nY, m_nWide, m_nTall;
2020-04-22 12:56:21 -04:00
bool m_bValid;
bool m_bFriend;
CHudTexture *m_pFriendIcon;
2023-10-03 17:23:56 +03:00
int m_iAvatarWidth;
int m_iAvatarHeight;
2020-04-22 12:56:21 -04:00
CSteamID m_SteamID;
2023-10-03 17:23:56 +03:00
EAvatarSize m_SourceArtSize;
2020-04-22 12:56:21 -04:00
};
//-----------------------------------------------------------------------------
2023-10-03 17:23:56 +03:00
// Purpose:
2020-04-22 12:56:21 -04:00
//-----------------------------------------------------------------------------
2023-10-03 17:23:56 +03:00
class CAvatarImagePanel : public vgui::ImagePanel
2020-04-22 12:56:21 -04:00
{
public:
2023-10-03 17:23:56 +03:00
DECLARE_CLASS_SIMPLE( CAvatarImagePanel, vgui::ImagePanel );
2020-04-22 12:56:21 -04:00
CAvatarImagePanel( vgui::Panel *parent, const char *name );
// Set the player that this Avatar should display for
2023-10-03 17:23:56 +03:00
void SetPlayer( C_BasePlayer *pPlayer );
void SetPlayerByIndex( int iIndex );
void SetAvatarBySteamID( CSteamID *friendsID );
2020-04-22 12:56:21 -04:00
2023-10-03 17:23:56 +03:00
virtual void PaintBackground( void );
bool IsValid( void ) { return (GetImage() && ((CAvatarImage*)GetImage())->IsValid()); }
2020-04-22 12:56:21 -04:00
protected:
CPanelAnimationVar( Color, m_clrOutline, "color_outline", "Black" );
};
#endif // VGUI_AVATARIMAGE_H