예제 #1
0
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;
}
예제 #2
0
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;  
}
예제 #3
0
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;
  

  
 
 
}
예제 #4
0
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;
}
예제 #5
0
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();
      }
    }
예제 #6
0
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 );
    }
  }
}
예제 #7
0
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);
}
예제 #8
0
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();
    }
  }
}
예제 #9
0
파일: camera_native.c 프로젝트: CPFL/netim
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;
		}
	}

}
예제 #10
0
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
   
   
}
예제 #11
0
BigTempleMars::BigTempleMars() : ServiceBuilding(S_TEMPLE_MARS, B_BIG_TEMPLE_MARS, Size(3))
{
  setPicture( Picture::load( ResourceGroup::security, 52));
}
예제 #12
0
BigTempleNeptune::BigTempleNeptune() : ServiceBuilding(S_TEMPLE_NEPTUNE, B_BIG_TEMPLE_NEPTUNE, Size(3))
{
  setPicture(Picture::load( ResourceGroup::security, 48));
}
예제 #13
0
BigTempleCeres::BigTempleCeres() : ServiceBuilding(S_TEMPLE_CERES, B_BIG_TEMPLE_CERES, Size(3))
{
  setPicture( Picture::load( ResourceGroup::security, 46));
}
예제 #14
0
BuildingWell::BuildingWell() : ServiceBuilding(S_WELL, B_WELL, Size(1) )
{
   _fireIncrement = 0;
   _damageIncrement = 0;
   setPicture( Picture::load("utilitya", 1) );
}
예제 #15
0
Hospital::Hospital() : ServiceBuilding(S_HOSPITAL, B_HOSPITAL, Size(3 ) )
{
  setPicture( Picture::load( ResourceGroup::security, 44));
}
예제 #16
0
Barber::Barber() : ServiceBuilding(S_BARBER, B_BARBER, Size(1))
{
  setPicture( Picture::load( ResourceGroup::security, 19));
}
예제 #17
0
Library::Library() : ServiceBuilding(S_LIBRARY, B_LIBRARY, Size(2))
{
  setPicture( Picture::load( ResourceGroup::commerce, 84));
}
예제 #18
0
BigTempleMercure::BigTempleMercure() : ServiceBuilding(S_TEMPLE_MERCURE, B_BIG_TEMPLE_MERCURE, Size(3))
{
  setPicture(Picture::load( ResourceGroup::security, 50));
}
예제 #19
0
BigTempleVenus::BigTempleVenus() : ServiceBuilding(S_TEMPLE_VENUS, B_BIG_TEMPLE_VENUS, Size(3))
{
  setPicture(Picture::load( ResourceGroup::security, 54));
}
예제 #20
0
Road::Road()
{
  setType(B_ROAD);
  setPicture(PicLoader::instance().get_picture( rcRoadGroup, 44));  // default picture for build tool
}
예제 #21
0
TempleMercure::TempleMercure() : ServiceBuilding(S_TEMPLE_MERCURE, B_TEMPLE_MERCURE, Size(2))
{
  setPicture( Picture::load( ResourceGroup::security, 49));
}
예제 #22
0
SmallStatue::SmallStatue()
{
 setType(B_STATUE1);
  _size = 1;
  setPicture(PicLoader::instance().get_picture(rcGovernmentGroup, 1));
}
예제 #23
0
School::School() : ServiceBuilding(S_SCHOOL, B_SCHOOL, Size(2))
{
  setPicture( Picture::load( ResourceGroup::commerce, 83));
}
예제 #24
0
MediumStatue::MediumStatue()
{
 setType(B_STATUE2);
  _size = 2;
  setPicture(PicLoader::instance().get_picture(rcGovernmentGroup, 2));
}
예제 #25
0
College::College() : ServiceBuilding(S_COLLEGE, B_COLLEGE, Size(3))
{
  setPicture( Picture::load( ResourceGroup::commerce, 85));
}
예제 #26
0
BigStatue::BigStatue()
{
 setType(B_STATUE3);
  _size = 3;
  setPicture(PicLoader::instance().get_picture(rcGovernmentGroup, 3));
}
예제 #27
0
Doctor::Doctor() : ServiceBuilding(S_DOCTOR, B_DOCTOR, Size(1))
{
  setPicture( Picture::load( ResourceGroup::security, 20));
}
예제 #28
0
NativeCenter::NativeCenter()
{
  setType(B_NATIVE_CENTER);
  _size = 2;
  setPicture(PicLoader::instance().get_picture(rcHousingGroup, 51));
}
예제 #29
0
Forum::Forum() : ServiceBuilding(S_FORUM, B_FORUM, Size(2))
{
  setPicture( Picture::load( "govt", 10));
}
예제 #30
0
NativeField::NativeField()
{
  setType(B_NATIVE_FIELD);
  _size = 1;
  setPicture(PicLoader::instance().get_picture(ResourceGroup::commerce, 13));  
}