Ejemplo n.º 1
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);
}
Ejemplo n.º 2
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));
}
Ejemplo n.º 3
0
	void serialize(Lumix::JsonSerializer& serializer)
	{
		serializer.serialize("path", m_mesh_path.c_str());
		serializer.beginArray("pos");
		serializer.serializeArrayItem(m_position.x);
		serializer.serializeArrayItem(m_position.y);
		serializer.serializeArrayItem(m_position.z);
		serializer.endArray();
	}
Ejemplo n.º 4
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();
}