示例#1
0
void PokeGeneral::load()
{
    loadMoves();
    loadTypes();
    loadAbilities();
    loadGenderAvail();
}
bool photo_camera_list::autodetect( GPContext* context )
{
  ssize_t port_count = 0;
 
  // Create a new list of cameras
  if( gp_list_new( &camera_list_ ) != GP_OK )
  {
    photo_reporter::error( "gp_list_new()" );
    return false;
  }

  // Load the low-level port drivers
  if( loadPortInfo( &port_count ) == false )
  {
    return false;
  }

  // Load the photo_camera drivers
  if( loadAbilities( context ) == false )
  {
    return false;
  }


  // Filter the list for USB cameras
  if( filterCameraList( context, "usb:" ) == false )
  {
    return false;
  }
  return true;
}
void EntityResourceManager::loadResource(const std::string filepath)
{
	//open up the file
	std::filebuf fb;
	fb.open(filepath, std::ios::in);

	//try to parse it
	Json::Value root;
	Json::Reader reader;
	bool parseSuccessful = reader.parse(std::istream(&fb), root);
	//now we have it parsed we can close it
	fb.close();

	if(!parseSuccessful)
	{
		std::cerr << "Unable to load entity: " << filepath << std::endl;
		std::cerr << reader.getFormattedErrorMessages() << std::endl;
		return;
	}

	Entity *entityPtr = loadType(root);
	if(entityPtr == NULL)
	{
		std::cerr << "Invalid type in entity file " << filepath << std::endl;
		return;
	}

	loadGenerics(*entityPtr, root);
	loadDamagingEntity(*entityPtr, root);
	loadCharacter(*entityPtr, root);

	std::string behaviour = root.get("behaviour", "").asString();
	if(!behaviour.empty())
	{
		loadBehaviour(*entityPtr, root);
	}

	Json::Value animations = root["animations"];
	if(animations.size() > 0)
	{
		loadAnimations(*entityPtr, root);
	}

	Json::Value abilities = root["abilities"];
	if(abilities.size() > 0)
	{
		loadAbilities(*entityPtr, root);
	}

	resourceMap[filepath] = entityPtr;
}