1
0
mirror of synced 2024-11-25 08:10:24 +01:00

impr: Disable some Import... options when the provider isn't writable

This commit is contained in:
WerWolv 2023-05-20 21:23:15 +02:00
parent 3219ba68de
commit 87621e9337

View File

@ -35,6 +35,10 @@ namespace hex::plugin::builtin {
return noRunningTasks() && ImHexApi::Provider::isValid();
}
bool noRunningTaskAndWritableProvider() {
return noRunningTasks() && ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isWritable();
}
}
namespace {
@ -340,7 +344,7 @@ namespace hex::plugin::builtin {
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.base64" }, 2050,
Shortcut::None,
importBase64,
noRunningTasks);
noRunningTaskAndWritableProvider);
ContentRegistry::Interface::addMenuItemSeparator({ "hex.builtin.menu.file", "hex.builtin.menu.file.import" }, 2100);
@ -348,19 +352,19 @@ namespace hex::plugin::builtin {
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.ips"}, 2150,
Shortcut::None,
importIPSPatch,
ImHexApi::Provider::isValid);
noRunningTaskAndWritableProvider);
/* IPS32 */
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.ips32"}, 2200,
Shortcut::None,
importIPS32Patch,
ImHexApi::Provider::isValid);
noRunningTaskAndWritableProvider);
/* Modified File */
ContentRegistry::Interface::addMenuItem({ "hex.builtin.menu.file", "hex.builtin.menu.file.import", "hex.builtin.menu.file.import.modified_file" }, 2300,
Shortcut::None,
importModifiedFile,
[&] { return noRunningTaskAndValidProvider() && ImHexApi::Provider::get()->isWritable(); });
noRunningTaskAndWritableProvider);
}
/* Export */