Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion engine/includes/adapters/handlers/defaultfilehandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ class DefaultFileHandler : public FileHandler {

bool remove(const char *path) override {
try {
return std::filesystem::remove(path);
if(isDir(path)) {
return std::filesystem::remove_all(path);
} else {
return std::filesystem::remove(path);
}
} catch (const std::filesystem::filesystem_error &) {
return false;
}
Expand Down
35 changes: 16 additions & 19 deletions engine/includes/editor/baseassetprovider.h
Original file line number Diff line number Diff line change
@@ -1,40 +1,37 @@
#ifndef BASEASSETPROVIDER_H
#define BASEASSETPROVIDER_H

#include <QObject>

#include <engine.h>

class QFileSystemWatcher;
class FileSystemWatcher;

class ENGINE_EXPORT BaseAssetProvider : public Object {
A_OBJECT(BaseAssetProvider, Object, Core)

A_METHODS(
A_SLOT(BaseAssetProvider::onFileChanged),
A_SLOT(BaseAssetProvider::onDirectoryChanged)
)

class ENGINE_EXPORT BaseAssetProvider : public QObject {
Q_OBJECT
public:
BaseAssetProvider();

~BaseAssetProvider();

void init();
void init(bool force);

void renameResource(const TString &source, const TString &destination);
void removeResource(const TString &source);
void duplicateResource(const TString &source);

void cleanupBundle();

protected:
bool copyRecursively(const TString &sourceFolder, const TString &destFolder);

public slots:
void onFileChanged(const QString &path);
void onFileChangedForce(const QString &path, bool force = false);
public: // slots
void onFileChanged(const TString &path);
void onFileChangedForce(const TString &path, bool force = false);

void onDirectoryChanged(const QString &path);
void onDirectoryChangedForce(const QString &path, bool force = false);
void onDirectoryChanged(const TString &path);
void onDirectoryChangedForce(const TString &path, bool force = false);

private:
QFileSystemWatcher *m_dirWatcher;
QFileSystemWatcher *m_fileWatcher;
FileSystemWatcher *m_dirWatcher;

};

Expand Down
26 changes: 9 additions & 17 deletions engine/src/editor/assetmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ void AssetManager::rescan() {

TString target = m_projectManager->targetPath();
if(target.isEmpty()) {

bool update = m_projectManager->projectSdk() != SDK_VERSION;
if(update) {
getChangedUUIDs();
Expand All @@ -128,24 +127,11 @@ void AssetManager::rescan() {
Engine::resourceSystem()->unloadBundle(TString());
m_force |= !Engine::resourceSystem()->loadBundle(TString());
m_force |= update;

m_assetProvider->init();
} else {
m_force = true;
}

m_assetProvider->onDirectoryChangedForce((m_projectManager->resourcePath() + "/engine/materials").data(),m_force);
m_assetProvider->onDirectoryChangedForce((m_projectManager->resourcePath() + "/engine/textures").data(), m_force);
m_assetProvider->onDirectoryChangedForce((m_projectManager->resourcePath() + "/engine/meshes").data(), m_force);
m_assetProvider->onDirectoryChangedForce((m_projectManager->resourcePath() + "/engine/pipelines").data(),m_force);
m_assetProvider->onDirectoryChangedForce((m_projectManager->resourcePath() + "/engine/fonts").data(), m_force);
#ifndef BUILDER
m_assetProvider->onDirectoryChangedForce((m_projectManager->resourcePath() + "/editor/materials").data(),m_force);
m_assetProvider->onDirectoryChangedForce((m_projectManager->resourcePath() + "/editor/gizmos").data(), m_force);
m_assetProvider->onDirectoryChangedForce((m_projectManager->resourcePath() + "/editor/meshes").data(), m_force);
m_assetProvider->onDirectoryChangedForce((m_projectManager->resourcePath() + "/editor/textures").data(), m_force);
#endif
m_assetProvider->onDirectoryChangedForce(m_projectManager->contentPath().data(), m_force);
m_assetProvider->init(m_force);

Engine::resourceSystem()->setCleanImport(m_force);

Expand Down Expand Up @@ -175,7 +161,7 @@ TString AssetManager::assetTypeName(const TString &source) {
}

bool AssetManager::pushToImport(const TString &source) {
m_assetProvider->onFileChangedForce(source.data(), true);
m_assetProvider->onFileChangedForce(source, true);
return true;
}

Expand Down Expand Up @@ -601,7 +587,13 @@ void AssetManager::onPerform() {
}
}

m_assetProvider->cleanupBundle();
// Cleanup bundle
for(auto &path : File::list(ProjectSettings::instance()->importPath())) {
TString fileName(Url(path).name());
if(!File::isDir(path) && fileName != gIndex && uuidToPath(fileName).isEmpty()) {
File::remove(path);
}
}

auto tmp = m_indices;
for(auto &index : tmp) {
Expand Down
Loading
Loading