1
0
mirror of synced 2025-01-31 03:53:44 +01:00

impr: Open .hexproj files as projects when opened though the Open File option (#1061)

This commit is contained in:
iTrooz 2023-05-11 12:38:22 +02:00 committed by GitHub
parent 688471fd61
commit 2e73d74cea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,7 +84,23 @@ namespace hex::plugin::builtin {
else
EventManager::post<EventProviderOpened>(newProvider);
} else if (name == "Open File") {
ImHexApi::Provider::createProvider("hex.builtin.provider.file");
fs::openFileBrowser(fs::DialogMode::Open, { }, [](const auto &path) {
if(path.extension() == ".hexproj"){
if (!ProjectFile::load(path)) {
PopupError::open("hex.builtin.popup.error.project.load"_lang);
}
}else{
FileProvider* newProvider = static_cast<FileProvider*>(
ImHexApi::Provider::createProvider("hex.builtin.provider.file", true)
);
newProvider->setPath(path);
newProvider->open();
if (newProvider != nullptr && !newProvider->open())
hex::ImHexApi::Provider::remove(newProvider);
else
EventManager::post<EventProviderOpened>(newProvider);
}
});
} else if (name == "Open Project") {
fs::openFileBrowser(fs::DialogMode::Open, { {"Project File", "hexproj"} },
[](const auto &path) {