FortMounted::FortMounted() : Building( constants::building::B_FORT_MOUNTED, Size(3) ) { setPicture( ResourceGroup::security, 12 ); Picture logo = Picture::load(ResourceGroup::security, 15); logo.setOffset(80,10); _fgPicturesRef().resize(1); _fgPicturesRef().at( 0 ) = logo; }
FortLegionnaire::FortLegionnaire() : Building( building::B_FORT_LEGIONNAIRE, Size(3) ) { setPicture( ResourceGroup::security, 12 ); Picture logo = Picture::load(ResourceGroup::security, 16); logo.setOffset(80,10); _fgPicturesRef().resize(1); _fgPicturesRef().at( 0 ) = logo; }
FortMounted::FortMounted() : Building( B_FORT_MOUNTED, Size(3) ) { setPicture( Picture::load(ResourceGroup::security, 12)); Picture logo = Picture::load(ResourceGroup::security, 15); logo.setOffset(80,10); _fgPictures.resize(1); _fgPictures[ 0 ] = logo; }
FortLegionnaire::FortLegionnaire() : Building( B_FORT_LEGIONNAIRE, Size(3) ) { setPicture( Picture::load(ResourceGroup::security, 12)); Picture logo = Picture::load(ResourceGroup::security, 16); logo.setOffset(80,10); _fgPictures.resize(1); _fgPictures[ 0 ] = logo; }
FortJaveline::FortJaveline() : Building( building::B_FORT_JAVELIN, Size(3) ) { setPicture( ResourceGroup::security, 12 ); Picture logo = Picture::load(ResourceGroup::security, 14); //std::cout << logo->get_xoffset() << " " << logo->get_yoffset() << " " << logo->get_width() << " " << logo->get_height() << std::endl; logo.setOffset(80,10); _fgPicturesRef().resize(1); _fgPicturesRef().at( 0 ) = logo; }
void PictureBank::Impl::setPicture( const std::string &name, const Picture& pic ) { int dot_pos = name.find_last_of('.'); std::string rcname = name.substr(0, dot_pos); // first: we deallocate the current picture, if any unsigned int picId = Hash( rcname ); Picture* ptrPic = 0; Impl::ItPicture it = resources.find( picId ); if( it != resources.end() ) { //SDL_DestroyTexture( it->second.texture() ); if( it->second.texture() > 0 ) txCounters[ it->second.texture() ]--; ptrPic = &it->second; } else { resources[ picId ] = Picture(); ptrPic = &resources[ picId ]; } *ptrPic = pic; if( pic.texture() > 0 ) txCounters[ pic.texture() ]++; Point offset( 0, 0 ); // decode the picture name => to set the offset manually Point pic_info = PictureInfoBank::instance().getOffset( rcname ); if( pic_info == PictureInfoBank::instance().getDefaultOffset( PictureInfoBank::tileOffset ) ) { // this is a tiled picture=> automatic offset correction int cw = gfx::tilemap::cellSize().width() * 2; int ch = gfx::tilemap::cellSize().width() / 2; offset.setY( pic.height()-ch*( (pic.width()+2)/cw ) ); // (w+2)/60 is the size of the tile: (1x1, 2x2, 3x3, ...) } else if( pic_info == PictureInfoBank::instance().getDefaultOffset( PictureInfoBank::walkerOffset ) ) { // this is a walker picture=> automatic offset correction offset = Point( -pic.width()/2, int(pic.height()*3./4.) ); } else { offset = pic_info; } ptrPic->setOffset( offset ); ptrPic->setName( rcname ); }
foreach( Picture& pic, _pictures ) { pic.setOffset( offset ); }