예제 #1
0
void RandomFire::load(const VariantMap& stream)
{
  VariantList vl = stream.get( lc_population ).toList();
  _d->minPopulation = vl.get( 0, 0 ).toInt();
  _d->maxPopulation = vl.get( 1, 999999 ).toInt();
  _d->strong = stream.get( lc_strong, 10 );
}
예제 #2
0
 virtual void load(const VariantList& stream)
 {
   for (const auto& item : stream) {
     VariantList vl = item.toList();
     (*this)[ vl.get(0) ] = vl.get(1);
   }
 }
예제 #3
0
 void load( const VariantList& stream )
 {
   for( unsigned int i=0; i < stream.size(); i+=2 )
   {
     Service::Type type = Service::Type( stream.get( i ).toInt() );
     at( type )->set( stream.get( i+1 ).toFloat() ); //serviceValue
   }
 }
예제 #4
0
void Base::load(const VariantList& stream)
{
  type = (Type)stream.get( ftype ).toInt();
  date = stream.get( fdate ).toDateTime();
  objectName = stream.get( fname ).toString();
  message = stream.get( fmessage ).toString();
  location = stream.get( flocation ).toPoint();
}
예제 #5
0
void Addressable::onDeserialize(VariantList& variants) {
	if(variants.hasKey("class")) {
		addClasses(variants.get("class").asStringList());
	}
	if(variants.hasKey("id")) {
		setId(variants.get("id"));
	}
}
예제 #6
0
void RandomDamage::load(const VariantMap& stream)
{
  VariantList vl = stream.get( lc_population ).toList();
  _d->minPopulation = vl.get( 0, 0 ).toInt();
  _d->maxPopulation = vl.get( 1, 999999 ).toInt();
  VARIANT_LOAD_ANY_D( _d, strong, stream );
  VARIANT_LOAD_ANY_D( _d, priority, stream );

}
예제 #7
0
void PushButton::setupUI(const VariantMap &ui)
{
  Widget::setupUI( ui );

  __D_REF(_d,PushButton)

  Variant tmp;
  tmp = ui.get( "bgtype" );
  if( tmp.isValid() )
  {
    BackgroundStyleHelper helper;
    setBackgroundStyle( helper.findType( tmp.toString() ) );
  }

  setIsPushButton( (bool)ui.get( "pushbutton" ) );
  _d.text.offset = ui.get( "textOffset" );
  _d.text.offset = ui.get( "text.offset", _d.text.offset );
  setEnabled( (bool)ui.get( "enabled", true ) );

  Variant vFont = ui.get( "font" );
  if( vFont.isValid() ) { setFont( Font::create( vFont.toString() ) ); }

  VariantList vlist = ui.get( "normal" ).toList();
  if( !vlist.empty() ) setPicture( vlist.get( 0 ).toString(), vlist.get( 1 ).toInt(), stNormal );

  vlist = ui.get( "hovered" ).toList();
  if( !vlist.empty() ) setPicture( vlist.get( 0 ).toString(), vlist.get( 1 ).toInt(), stHovered  );

  vlist = ui.get( "pressed" ).toList();
  if( !vlist.empty() ) setPicture( vlist.get( 0 ).toString(), vlist.get( 1 ).toInt(), stPressed );

  vlist = ui.get( "disabled" ).toList();
  if( !vlist.empty() ) setPicture( vlist.get( 0 ).toString(), vlist.get( 1 ).toInt(), stDisabled );
}
예제 #8
0
void Stock::load( const VariantList& stream )
{
  if( stream.empty())
    return;

  _type = stream.get( 0 ).toInt();
  if( _type >= good::goodCount.toInt() )
  {
    Logger::warning( "GoodStock: wrong type of good %d", _type );
    _type = good::none.toInt();
  }

  _capacity = (int)stream.get( 1 );
  _qty = math::clamp( (int)stream.get( 2 ), 0, _capacity );
}
예제 #9
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 );
    }
  }
}
예제 #10
0
void PictureInfoBank::initialize(vfs::Path filename)
{
  Logger::warning( "PictureInfoBank: start load offsets from " + filename.toString() );
  VariantMap m = config::load( filename );

  foreach( it, m )
  {
    Variant v = it->second;
    Logger::warning( "Set offset for " + it->first );
    if( v.type() == Variant::Map )
    {
      VariantMap vm = v.toMap();
      int startIndex = vm[ "start" ];
      int stopIndex = vm[ "stop" ];
      std::string rc = vm[ "rc" ].toString();
      Point offset = vm[ "offset" ].toPoint();
      _d->setRange( rc.empty() ? it->first : rc, startIndex, stopIndex, offset );
    }
    else if( v.type() == Variant::List )
    {
      VariantList vl = v.toList();
      _d->setOne( it->first, vl.get( idxIndex ), vl.get( idxXOffset ), vl.get( idxYOffset ) );
    }
  }
void FestivalInfo::load(const VariantList& stream)
{
  date = stream.get( 0 ).toDateTime();
  divinity = stream.get( 1 ).toEnum<religion::RomeDivinityType>();
  size = stream.get( 2 ).toEnum<FestivalInfo::Type>();
}
예제 #12
0
 void load( const VariantList& stream )
 {
   lastYear = stream.get( 0 );
   thisYear = stream.get( 1 );
 }
예제 #13
0
 void load( const VariantList& stream )
 {
   minimum = stream.get( 0 );
   current = stream.get( 1 );
   maximum = stream.get( 2 );
 }