Picture& PictureBank::getPicture(const std::string &name) { const unsigned int hash = Hash( name ); //Logger::warning( "PictureBank getpic " + name ); Impl::ItPicture it = _d->resources.find( hash ); if( it == _d->resources.end() ) { //can't find image in valid resources, try load from hdd Picture pic = _d->tryLoadPicture( name ); if( pic.isValid() ) { setPicture( name, pic ); } else{ _d->resources[ hash ] = pic; } return _d->resources[ hash ]; } return it->second; }
Granary::Granary() : WorkingBuilding( constants::building::granary, Size(3) ), _d( new Impl ) { _d->goodStore.granary = this; setPicture( ResourceGroup::commerce, 140 ); _fgPicturesRef().resize(6); // 1 upper level + 4 windows + animation _animationRef().load(ResourceGroup::commerce, 146, 7, Animation::straight); // do the animation in reverse _animationRef().load(ResourceGroup::commerce, 151, 6, Animation::reverse); _animationRef().setDelay( 4 ); _fgPicturesRef().at(0) = Picture::load( ResourceGroup::commerce, 141); _fgPicturesRef().at(5) = _animationRef().getFrame(); computePictures(); _d->devastateThis = false; }
BuildingHippodrome::BuildingHippodrome() : EntertainmentBuilding(S_HIPPODROME) { setType(B_HIPPODROME); _size = 5; setPicture(PicLoader::instance().get_picture("circus", 5)); getPicture().set_offset(0,106); Picture* logo = &PicLoader::instance().get_picture("circus", 3); Picture* logo1 = &PicLoader::instance().get_picture("circus", 1); logo -> set_offset(150,181); logo1 -> set_offset(300,310); _fgPictures.resize(5); _fgPictures.at(0) = logo; _fgPictures.at(1) = logo1; }
bool QLabel::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: setText((const QString&)static_QUType_QString.get(_o+1)); break; case 1: setPixmap((const QPixmap&)*((const QPixmap*)static_QUType_ptr.get(_o+1))); break; case 2: setPicture((const QPicture&)*((const QPicture*)static_QUType_ptr.get(_o+1))); break; case 3: setMovie((const QMovie&)*((const QMovie*)static_QUType_ptr.get(_o+1))); break; case 4: setNum((int)static_QUType_int.get(_o+1)); break; case 5: setNum((double)static_QUType_double.get(_o+1)); break; case 6: clear(); break; case 7: acceleratorSlot(); break; case 8: buddyDied(); break; case 9: movieUpdated((const QRect&)*((const QRect*)static_QUType_ptr.get(_o+1))); break; case 10: movieResized((const QSize&)*((const QSize*)static_QUType_ptr.get(_o+1))); break; default: return QFrame::qt_invoke( _id, _o ); } return TRUE; }
void Garden::build( CityPtr city, const TilePos& pos ) { // this is the same arrangement of garden tiles as existed in C3 int theGrid[2][2] = {{113, 110}, {112, 111}}; Construction::build( city, pos ); setPicture( ResourceGroup::entertaiment, theGrid[pos.getI() % 2][pos.getJ() % 2] ); if( getSize().getArea() == 1 ) { TilemapTiles tilesAround = city->getTilemap().getRectangle( getTilePos() - TilePos( 1, 1), getTilePos() + TilePos( 1, 1 ) ); foreach( Tile* tile, tilesAround ) { GardenPtr garden = tile->getOverlay().as<Garden>(); if( garden.isValid() ) { garden->update(); } }
void PictureBank::Impl::loadAtlas(const vfs::Path& filePath) { if( !filePath.exist() ) { Logger::warning( "PictureBank: cant find atlas " + filePath.toString() ); return; } VariantMap info = config::load( filePath ); vfs::Path texturePath = info.get( "texture" ).toString(); vfs::NFile file = vfs::NFile::open( texturePath ); Picture mainTexture; if( file.isOpen() ) { mainTexture = PictureLoader::instance().load( file ); } else { Logger::warning( "PictureBank: load atlas failed for texture" + texturePath.toString() ); mainTexture = Picture::getInvalid(); } //SizeF mainRectSize = mainTexture.size().toSizeF(); if( !info.empty() ) { VariantMap items = info.get( framesSection ).toMap(); for( auto& i : items ) { VariantList rInfo = i.second.toList(); Picture pic = mainTexture; Point start( rInfo.get( 0 ).toInt(), rInfo.get( 1 ).toInt() ); Size size( rInfo.get( 2 ).toInt(), rInfo.get( 3 ).toInt() ); pic.setOriginRect( Rect( start, size ) ); setPicture( i.first, pic ); } } }
Market::Market() : ServiceBuilding(S_MARKET) { setType(B_MARKET); setMaxWorkers(5); setWorkers(0); _marketBuyer = NULL; _buyerDelay = 10; _size = 2; // _name = _("Marche"); setPicture(PicLoader::instance().get_picture("commerce", 1)); _fgPictures.resize(1); // animation _goodStore.setMaxQty(5000); _goodStore.setMaxQty(G_WHEAT, 400); _goodStore.setMaxQty(G_POTTERY, 300); _goodStore.setCurrentQty(G_WHEAT, 200); AnimLoader animLoader(PicLoader::instance()); animLoader.fill_animation(_animation, "commerce", 2, 10); }
void Road::build(const TilePos& pos ) { Tilemap& tilemap = Scenario::instance().getCity().getTilemap(); LandOverlay* saveOverlay = tilemap.at( pos ).get_terrain().getOverlay(); Construction::build( pos ); setPicture(computePicture()); if( Aqueduct* aqua = safety_cast< Aqueduct* >( saveOverlay ) ) { aqua->build( pos ); return; } // update adjacent roads for (std::list<Tile*>::iterator itTile = _accessRoads.begin(); itTile != _accessRoads.end(); ++itTile) { Road* road = safety_cast< Road* >( (*itTile)->get_terrain().getOverlay() ); // let's think: may here different type screw up whole program? if( road ) { road->computeAccessRoads(); road->setPicture(road->computePicture()); } } // NOTE: also we need to update accessRoads for adjacent building // how to detect them if MaxDistance2Road can be any // so let's recompute accessRoads for every _building_ std::list<LandOverlay*> list = Scenario::instance().getCity().getOverlayList(); // it looks terrible!!!! for (std::list<LandOverlay*>::iterator itOverlay = list.begin(); itOverlay!=list.end(); ++itOverlay) { LandOverlay *overlay = *itOverlay; Building *construction = dynamic_cast<Building*>(overlay); if (construction != NULL) // if NULL then it ISN'T building { construction->computeAccessRoads(); } } }
void getPicture(int sock){ int size = 0; unsigned int file_size = 555555; int sum = 0; int image_size; //save image data static unsigned char buf[200000]; memset(buf, 0, sizeof(buf)); size = recv(sock, &image_size, 4, 0); while(1){ //recieve image data size = recv(sock1, buf+sum, image_size-sum, 0); sum += size; if(sum == image_size){ setPicture(buf,sum); break; } } }
BuildingFountain::BuildingFountain() : ServiceBuilding(S_FOUNTAIN) { setType(B_FOUNTAIN); _size = 1; int id; std::srand(std::time(NULL)); id = std::rand() % 4; std::cout << id << std::endl; setPicture(PicLoader::instance().get_picture("utilitya", 26)); AnimLoader animLoader(PicLoader::instance()); animLoader.fill_animation(_animation, "utilitya", 27, 7); //animLoader.fill_animation_reverse(_animation, "utilitya", 25, 7); animLoader.change_offset(_animation, 14, 26); _fgPictures.resize(1); //2 10 18 26 // utilitya 10 - empty // utilitya 11 - 17 - working fontain // the first fountain's (10) ofsets ~ 11, 23 /*AnimLoader animLoader(PicLoader::instance()); animLoader.fill_animation(_animation, "utilitya", 11, 7); animLoader.change_offset(_animation, 11, 23); _fgPictures.resize(1);*/ // the second (2) ~ 8, 42 // the third (18) ~ 8, 24 // the 4rd (26) ~14, 26 }
BigTempleMars::BigTempleMars() : ServiceBuilding(S_TEMPLE_MARS, B_BIG_TEMPLE_MARS, Size(3)) { setPicture( Picture::load( ResourceGroup::security, 52)); }
BigTempleNeptune::BigTempleNeptune() : ServiceBuilding(S_TEMPLE_NEPTUNE, B_BIG_TEMPLE_NEPTUNE, Size(3)) { setPicture(Picture::load( ResourceGroup::security, 48)); }
BigTempleCeres::BigTempleCeres() : ServiceBuilding(S_TEMPLE_CERES, B_BIG_TEMPLE_CERES, Size(3)) { setPicture( Picture::load( ResourceGroup::security, 46)); }
BuildingWell::BuildingWell() : ServiceBuilding(S_WELL, B_WELL, Size(1) ) { _fireIncrement = 0; _damageIncrement = 0; setPicture( Picture::load("utilitya", 1) ); }
Hospital::Hospital() : ServiceBuilding(S_HOSPITAL, B_HOSPITAL, Size(3 ) ) { setPicture( Picture::load( ResourceGroup::security, 44)); }
Barber::Barber() : ServiceBuilding(S_BARBER, B_BARBER, Size(1)) { setPicture( Picture::load( ResourceGroup::security, 19)); }
Library::Library() : ServiceBuilding(S_LIBRARY, B_LIBRARY, Size(2)) { setPicture( Picture::load( ResourceGroup::commerce, 84)); }
BigTempleMercure::BigTempleMercure() : ServiceBuilding(S_TEMPLE_MERCURE, B_BIG_TEMPLE_MERCURE, Size(3)) { setPicture(Picture::load( ResourceGroup::security, 50)); }
BigTempleVenus::BigTempleVenus() : ServiceBuilding(S_TEMPLE_VENUS, B_BIG_TEMPLE_VENUS, Size(3)) { setPicture(Picture::load( ResourceGroup::security, 54)); }
Road::Road() { setType(B_ROAD); setPicture(PicLoader::instance().get_picture( rcRoadGroup, 44)); // default picture for build tool }
TempleMercure::TempleMercure() : ServiceBuilding(S_TEMPLE_MERCURE, B_TEMPLE_MERCURE, Size(2)) { setPicture( Picture::load( ResourceGroup::security, 49)); }
SmallStatue::SmallStatue() { setType(B_STATUE1); _size = 1; setPicture(PicLoader::instance().get_picture(rcGovernmentGroup, 1)); }
School::School() : ServiceBuilding(S_SCHOOL, B_SCHOOL, Size(2)) { setPicture( Picture::load( ResourceGroup::commerce, 83)); }
MediumStatue::MediumStatue() { setType(B_STATUE2); _size = 2; setPicture(PicLoader::instance().get_picture(rcGovernmentGroup, 2)); }
College::College() : ServiceBuilding(S_COLLEGE, B_COLLEGE, Size(3)) { setPicture( Picture::load( ResourceGroup::commerce, 85)); }
BigStatue::BigStatue() { setType(B_STATUE3); _size = 3; setPicture(PicLoader::instance().get_picture(rcGovernmentGroup, 3)); }
Doctor::Doctor() : ServiceBuilding(S_DOCTOR, B_DOCTOR, Size(1)) { setPicture( Picture::load( ResourceGroup::security, 20)); }
NativeCenter::NativeCenter() { setType(B_NATIVE_CENTER); _size = 2; setPicture(PicLoader::instance().get_picture(rcHousingGroup, 51)); }
Forum::Forum() : ServiceBuilding(S_FORUM, B_FORUM, Size(2)) { setPicture( Picture::load( "govt", 10)); }
NativeField::NativeField() { setType(B_NATIVE_FIELD); _size = 1; setPicture(PicLoader::instance().get_picture(ResourceGroup::commerce, 13)); }