/* $Id: weaponindicator.cpp,v 1.5 2005/06/28 13:55:25 chfreund Exp $ */ #include "weaponindicator.hpp" #include "graphics.h" WeaponIndicator::WeaponIndicator( Uint32 width, Uint32 height ) { _width = width; _min_width = width; _height = height; _min_height = height; m_value = 0; m_empty_alpha = 100; } void WeaponIndicator::draw( SDL_Surface* surface ) { SDL_Rect destRect; getOffset( destRect.x, destRect.y ); destRect.h = _height; destRect.w = static_cast( _width * ( m_value / 100.0 ) ); if ( destRect.w > _width ) { destRect.w = _width; } Uint32 pixelColor = SDL_MapRGB( surface->format, _color.r, _color.g, _color.b ); SDL_FillRect( surface, &destRect, pixelColor ); destRect.x += destRect.w; destRect.w = _width - destRect.w; if ( destRect.w > 0 ) { SDLwidgets::Graphics::fillRectAlpha( surface, &destRect, _color, m_empty_alpha ); } }