Offset<TimeLineTextureFrame> FlatBuffersSerialize::createTimeLineTextureFrame(const tinyxml2::XMLElement *objectData)
{
    int frameIndex = 0;
    bool tween = true;
    
    std::string path = "";
    std::string plistFile = "";
    int resourceType = 0;
    
    const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
    while (attribute)
    {
        std::string attriname = attribute->Name();
        std::string value = attribute->Value();
        
        if (attriname == "FrameIndex")
        {
            frameIndex = atoi(value.c_str());
        }
        else if (attriname == "Tween")
        {
            tween = (value == "True") ? true : false;
        }
        
        attribute = attribute->Next();
    }
    
    const tinyxml2::XMLElement* child = objectData->FirstChildElement();
    while (child)
    {
        attribute = child->FirstAttribute();
        while (attribute)
        {
            std::string attriname = attribute->Name();
            std::string value = attribute->Value();
            
            if (attriname == "Path")
            {
                path = value;
            }
            else if (attriname == "Type")
            {
                resourceType = getResourceType(value);
            }
            else if (attriname == "Plist")
            {
                plistFile = value;
            }
            
            attribute = attribute->Next();
        }
        
        child = child->NextSiblingElement();
    }
    
    return CreateTimeLineTextureFrame(*_builder,
                                      frameIndex,
                                      tween,
                                      _builder->CreateString(path));
}
Пример #2
0
ResourceTreeItem::ResourceTreeItem(Aurora::Archive *archive, const QString &archivePath,
                                   const Aurora::Archive::Resource &resource) :
	_name(QString::fromUtf8(TypeMan.setFileType(resource.name, resource.type).c_str())),
	_source(kSourceArchiveFile) {

	Common::UString resName = resource.name;
	if (resName.empty())
		resName = Common::composeString(resource.hash);

	resName = TypeMan.setFileType(resName, resource.type);
	_name = QString::fromUtf8(resName.c_str());

	_archive.owner = archive;
	_archive.index = resource.index;

	_path = archivePath + "/" + _name;

	_size = archive->getResourceSize(resource.index);

	if (_source != kSourceDirectory) {
		_fileType = TypeMan.getFileType(_name.toStdString());
		_resourceType = TypeMan.getResourceType(_name.toStdString());
	}

	_triedDuration = getResourceType() != Aurora::kResourceSound;
}
Пример #3
0
::LabrestAPI::ResourceTypeList
LabrestAPI::LabrestDB::getAllResourceTypes()
{ 
    int s;
    
    ::LabrestAPI::ResourceTypeList resource_types;
    
 //   ::std::cout << "LabrestDB::getAllResourceTypes() called" << ::std::endl;
    
    sqlite3_stmt * ppStmt;
    
    sqlite3_exec(db, "BEGIN", 0, 0, 0);

    sqlite3_prepare(db,"select id from resource_type;",-1,&ppStmt,0);

    s = sqlite3_step(ppStmt);
    
    while (s == SQLITE_ROW)
    {
        ::LabrestAPI::ResourceType temp_resource_type = getResourceType(sqlite3_column_int(ppStmt, 0));
        
        resource_types.push_back(temp_resource_type);

        s = sqlite3_step(ppStmt);
    }
    sqlite3_finalize(ppStmt);

    sqlite3_exec(db, "COMMIT", 0, 0, 0);

    return resource_types;
    
}
Пример #4
0
void AssetBrowser::onGUIResource()
{
	if (!m_selected_resource) return;

	const char* path = m_selected_resource->getPath().c_str();
	ImGui::Separator();
	ImGui::LabelText("Selected resource", "%s", path);
	ImGui::Separator();

	if (!m_selected_resource->isReady() && !m_selected_resource->isFailure())
	{
		ImGui::Text("Not ready");
		return;
	}

	char source[Lumix::MAX_PATH_LENGTH];
	if (m_metadata.getString(m_selected_resource->getPath().getHash(), SOURCE_HASH, source, Lumix::lengthOf(source)))
	{
		ImGui::LabelText("Source", "%s", source);
	}

	auto resource_type = getResourceType(path);
	for (auto* plugin : m_plugins)
	{
		if (plugin->onGUI(m_selected_resource, resource_type)) return;
	}
	ASSERT(resource_type == UNIVERSE_HASH); // unimplemented resource
}
// Called on ALooper thread.
void MediaResourceManagerService::onMessageReceived(const sp<AMessage> &msg)
{
  Mutex::Autolock autoLock(mLock);
  ResourceType type = static_cast<ResourceType>(getResourceType(msg));

  // Note: a message is sent both for "I added an entry to the queue"
  // (which may succeed, typically if the queue is empty), and for "I gave
  // up the resource", in which case it's "give to the next waiting client,
  // or no one".

  // Exit if no resource is available, but leave the client in the waiting
  // list.
  int found = mResources.findAvailableResource(type);
  if (found == NAME_NOT_FOUND) {
    return;
  }

  // Exit if no request.
  if (!mResources.hasRequest(type)) {
    return;
  }

  sp<IBinder> req = mResources.nextRequest(type);
  mResources.aquireResource(req, type, found);
  // Notify resource assignment to the client.
  sp<IMediaResourceManagerClient> client = interface_cast<IMediaResourceManagerClient>(req);
  client->statusChanged(MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED);
  mResources.dequeueRequest(type);
}
Пример #6
0
void AssetBrowser::onFileChanged(const char* path)
{
	Lumix::uint32 resource_type = getResourceType(path);
	if (resource_type == 0) return;

	Lumix::MT::SpinLock lock(m_changed_files_mutex);
	m_changed_files.push(Lumix::Path(path));
}
Пример #7
0
void AssetBrowser::update()
{
	PROFILE_FUNCTION();
	if (!m_is_update_enabled) return;
	bool is_empty;
	{
		Lumix::MT::SpinLock lock(m_changed_files_mutex);
		is_empty = m_changed_files.empty();
	}

	while (!is_empty)
	{
		Lumix::Path path;
		{
			Lumix::MT::SpinLock lock(m_changed_files_mutex);
			
			path = m_changed_files.back();
			m_changed_files.pop();
			is_empty = m_changed_files.empty();
		}

		char ext[10];
		Lumix::PathUtils::getExtension(ext, Lumix::lengthOf(ext), path.c_str());
		m_on_resource_changed.invoke(path, ext);

		Lumix::uint32 resource_type = getResourceType(path.c_str());
		if (resource_type == 0) continue;

		if (m_autoreload_changed_resource) m_editor.getEngine().getResourceManager().reload(path);

		char tmp_path[Lumix::MAX_PATH_LENGTH];
		if (m_editor.getEngine().getPatchFileDevice())
		{
			Lumix::copyString(tmp_path, m_editor.getEngine().getPatchFileDevice()->getBasePath());
			Lumix::catString(tmp_path, path.c_str());
		}

		if (!m_editor.getEngine().getPatchFileDevice() || !PlatformInterface::fileExists(tmp_path))
		{
			Lumix::copyString(tmp_path, m_editor.getEngine().getDiskFileDevice()->getBasePath());
			Lumix::catString(tmp_path, path.c_str());

			if (!PlatformInterface::fileExists(tmp_path))
			{
				int index = getTypeIndexFromManagerType(resource_type);
				m_resources[index].eraseItemFast(path);
				continue;
			}
		}

		char dir[Lumix::MAX_PATH_LENGTH];
		char filename[Lumix::MAX_PATH_LENGTH];
		Lumix::PathUtils::getDir(dir, sizeof(dir), path.c_str());
		Lumix::PathUtils::getFilename(filename, sizeof(filename), path.c_str());
		addResource(dir, filename);
	}
	m_changed_files.clear();
}
Пример #8
0
void AssetBrowser::selectResource(const Lumix::Path& resource, bool record_history)
{
	m_activate = true;
	char ext[30];
	Lumix::PathUtils::getExtension(ext, Lumix::lengthOf(ext), resource.c_str());

	auto& manager = m_editor.getEngine().getResourceManager();
	auto* resource_manager = manager.get(getResourceType(resource.c_str()));
	if (resource_manager) selectResource(resource_manager->load(resource), record_history);
}
Пример #9
0
 //--------------------------------------------------------------------------
 FLevelFile::FLevelFile( Ogre::ResourceManager *creator
              ,const String &name, Ogre::ResourceHandle handle
              ,const String &group, bool isManual
              ,Ogre::ManualResourceLoader *loader ) :
     Resource( creator, name, handle, group, isManual, loader )
    ,m_background_texture_loader( NULL )
    ,m_background_2d_loader( NULL )
 {
     createParamDictionary( getResourceType() );
 }
Пример #10
0
void AssetBrowser::selectResource(const Lumix::Path& resource)
{
	m_activate = true;
	char ext[30];
	Lumix::PathUtils::getExtension(ext, Lumix::lengthOf(ext), resource.c_str());
	if (Lumix::compareString(ext, "unv") == 0) return;

	auto& manager = m_editor.getEngine().getResourceManager();
	auto* resource_manager = manager.get(getResourceType(resource.c_str()));
	if (resource_manager) selectResource(resource_manager->load(resource));
}
Пример #11
0
void AssetBrowser::unloadResource()
{
	if (!m_selected_resource) return;

	for (auto* plugin : m_plugins)
	{
		plugin->onResourceUnloaded(m_selected_resource);
	}
	m_selected_resource->getResourceManager()
		.get(getResourceType(m_selected_resource->getPath().c_str()))
		->unload(*m_selected_resource);

	m_selected_resource = nullptr;
}
Пример #12
0
ResourceTreeItem::ResourceTreeItem(const Common::FileTree::Entry &entry) :
	_name(QString::fromUtf8(entry.name.c_str())),
	_source(entry.isDirectory() ? kSourceDirectory : kSourceFile) {

	_path = QString::fromUtf8(entry.path.string().c_str());

	if (_source == kSourceFile)
		_size = Common::FilePath::getFileSize(entry.path.generic_string().c_str());

	if (_source != kSourceDirectory) {
		_fileType = TypeMan.getFileType(_name.toStdString());
		_resourceType = TypeMan.getResourceType(_name.toStdString());
	}

	_triedDuration = getResourceType() != Aurora::kResourceSound;
}
Пример #13
0
Images::Decoder *ResourceTreeItem::getImage() const {
	if (getResourceType() != Aurora::kResourceImage)
		throw Common::Exception("\"%s\" is not an image resource", getName().toStdString().c_str());

	std::unique_ptr<Common::SeekableReadStream> res(getResourceData());

	Images::Decoder *img = nullptr;
	try {
		img = getImage(*res, _fileType);
	} catch (Common::Exception &e) {
		e.add("Failed to get image from \"%s\"", getName().toStdString().c_str());
		throw;
	}

	return img;
}
Пример #14
0
const char *MADSResourceManager::getResourceFilename(const char *resourceName) {
	static char outputFilename[64];

	ResourceType resType = getResourceType(resourceName);

	strcpy(outputFilename, "GLOBAL.HAG");

	if ((resType == RESTYPE_ROOM) || (resType == RESTYPE_SC)) {
		int value = atoi(resourceName + 2);
		int hagFileNum = (resType == RESTYPE_ROOM) ? value / 100 : value;

		if (hagFileNum > 0)
			sprintf(outputFilename, "SECTION%d.HAG", hagFileNum);
	}

	if (resType == RESTYPE_SPEECH)
		strcpy(outputFilename, "SPEECH.HAG");

	return outputFilename;
}
Пример #15
0
::LabrestAPI::Resource 
LabrestAPI::LabrestDB::getResource(int id)
{
    int s;
    
    ::LabrestAPI::Resource resource;
    
//    ::std::cout << "LabrestDB::getResource() called" << ::std::endl;
    
    sqlite3_stmt * ppStmt;

    sqlite3_prepare(db,"select * from resource where id = ? ;",-1,&ppStmt,0);
    
    sqlite3_bind_int(ppStmt, 1, id);

    s = sqlite3_step(ppStmt);
    
    if  (s == SQLITE_ROW)
    {
        resource.id = sqlite3_column_int(ppStmt, 0);
        
        resource.name = (reinterpret_cast<const char *>(sqlite3_column_text(ppStmt, 1)));
        
        resource.description = (reinterpret_cast<const char *>(sqlite3_column_text(ppStmt, 2)));
        
        resource.resLockStatus = getLockStatus(sqlite3_column_int(ppStmt, 3));
        
        resource.type = getResourceType(sqlite3_column_int_or_null(ppStmt, 4));
        
        resource.parentId = sqlite3_column_int_or_null(ppStmt, 5);    
  
    }
    sqlite3_finalize(ppStmt);

    return resource;
}
Пример #16
0
ResourceType FileTypeManager::getResourceType(const Common::UString &path) {
	return getResourceType(getFileType(path));
}
Пример #17
0
void TradeCommand::subDesc(const Faction *faction, TradeDescriptor *callback, const ResourceType *rt) const {
    Lang &lang = g_lang;
    callback->addElement("Trade: ");
    callback->addItem(rt, getResourceType()->getName());
}
Пример #18
0
ResourceType FileTypeManager::getResourceType(Common::HashAlgo algo, uint64 hashedExtension) {
	return getResourceType(getFileType(algo, hashedExtension));
}