mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Display background scripts in about page
This commit is contained in:
@@ -262,13 +262,15 @@ namespace hex::script::loader {
|
||||
continue;
|
||||
|
||||
if (m_methodExists("Main", scriptPath)) {
|
||||
this->addScript(entry.path().stem().string(), [this, scriptPath] {
|
||||
this->addScript(entry.path().stem().string(), false, [this, scriptPath] {
|
||||
hex::unused(m_runMethod("Main", false, scriptPath));
|
||||
});
|
||||
}
|
||||
|
||||
if (m_methodExists("OnLoad", scriptPath)) {
|
||||
hex::unused(m_runMethod("OnLoad", true, scriptPath));
|
||||
this->addScript(entry.path().stem().string(), true, [this, scriptPath] {
|
||||
hex::unused(m_runMethod("OnLoad", true, scriptPath));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <fonts/codicons_font.h>
|
||||
#include <hex/plugin.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/task_manager.hpp>
|
||||
@@ -20,6 +21,8 @@ using ScriptLoaders = std::tuple<
|
||||
#endif
|
||||
>;
|
||||
|
||||
IMHEX_DEFINE_PLUGIN_FEATURES(){ };
|
||||
|
||||
namespace {
|
||||
|
||||
ScriptLoaders s_loaders;
|
||||
@@ -32,17 +35,29 @@ namespace {
|
||||
}
|
||||
|
||||
std::vector<const Script*> loadAllScripts() {
|
||||
std::vector<const Script*> plugins;
|
||||
std::vector<const Script*> scripts;
|
||||
|
||||
try {
|
||||
std::apply([&plugins](auto&&... args) {
|
||||
(loadScript(plugins, args), ...);
|
||||
std::apply([&scripts](auto&&... args) {
|
||||
(loadScript(scripts, args), ...);
|
||||
}, s_loaders);
|
||||
} catch (const std::exception &e) {
|
||||
log::error("Error when loading scripts: {}", e.what());
|
||||
}
|
||||
|
||||
return plugins;
|
||||
{
|
||||
std::vector<hex::Feature> features;
|
||||
for (const auto &script : scripts) {
|
||||
if (!script->background)
|
||||
continue;
|
||||
|
||||
features.emplace_back(script->name, true);
|
||||
}
|
||||
|
||||
IMHEX_PLUGIN_FEATURES = features;
|
||||
}
|
||||
|
||||
return scripts;
|
||||
}
|
||||
|
||||
void initializeLoader(u32 &count, auto &loader) {
|
||||
@@ -74,7 +89,7 @@ namespace {
|
||||
hex::ContentRegistry::Interface::addMenuItemSubMenu({ "hex.builtin.menu.extras" }, 5000, [] {
|
||||
static bool menuJustOpened = true;
|
||||
|
||||
if (ImGui::BeginMenu("hex.script_loader.menu.run_script"_lang)) {
|
||||
if (ImGui::BeginMenuEx("hex.script_loader.menu.run_script"_lang, ICON_VS_LIBRARY)) {
|
||||
if (menuJustOpened) {
|
||||
menuJustOpened = false;
|
||||
if (!updaterTask.isRunning()) {
|
||||
@@ -91,7 +106,9 @@ namespace {
|
||||
}
|
||||
|
||||
for (const auto &script : scripts) {
|
||||
const auto &[name, entryPoint] = *script;
|
||||
const auto &[name, background, entryPoint] = *script;
|
||||
if (background)
|
||||
continue;
|
||||
|
||||
if (ImGui::MenuItem(name.c_str())) {
|
||||
runnerTask = TaskManager::createTask("Running script...", TaskManager::NoProgress, [entryPoint](auto&) {
|
||||
|
||||
Reference in New Issue
Block a user