2023-06-06 21:35:13 +02:00
|
|
|
#include <hex/api/content_registry.hpp>
|
|
|
|
#include <hex/api/project_file_manager.hpp>
|
2024-06-22 10:44:55 +02:00
|
|
|
|
|
|
|
#include <hex/helpers/default_paths.hpp>
|
|
|
|
|
2024-02-21 00:06:52 +01:00
|
|
|
#include <toasts/toast_notification.hpp>
|
2023-06-06 21:35:13 +02:00
|
|
|
|
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
|
|
|
void registerFileHandlers() {
|
|
|
|
|
|
|
|
ContentRegistry::FileHandler::add({ ".hexproj" }, [](const std::fs::path &path) {
|
|
|
|
return ProjectFile::load(path);
|
|
|
|
});
|
|
|
|
|
|
|
|
ContentRegistry::FileHandler::add({ ".hexlyt" }, [](const std::fs::path &path) {
|
2024-06-22 10:44:55 +02:00
|
|
|
for (const auto &folder : paths::Layouts.write()) {
|
2023-06-06 21:35:13 +02:00
|
|
|
if (wolv::io::fs::copyFile(path, folder / path.filename()))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2024-02-21 00:06:52 +01:00
|
|
|
|
|
|
|
ContentRegistry::FileHandler::add({ ".mgc" }, [](const auto &path) {
|
2024-06-22 10:44:55 +02:00
|
|
|
for (const auto &destPath : paths::Magic.write()) {
|
2024-02-21 00:06:52 +01:00
|
|
|
if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
|
|
|
|
ui::ToastInfo::open("hex.builtin.view.information.magic_db_added"_lang);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2023-06-06 21:35:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|