mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 13:05:25 -05:00
feat: Added cross-platform .NET scripts support (#1185)
This PR intends to add support for .NET scripts that can extend ImHex's functionality in a portable and cross-platform way. --------- Co-authored-by: Justus Garbe <55301990+Nowilltolife@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <loaders/loader.hpp>
|
||||
|
||||
#include <wolv/io/fs.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace hex::script::loader {
|
||||
|
||||
class DotNetLoader : public ScriptLoader {
|
||||
public:
|
||||
DotNetLoader() = default;
|
||||
~DotNetLoader() override = default;
|
||||
|
||||
bool initialize() override;
|
||||
bool loadAll() override;
|
||||
|
||||
private:
|
||||
std::function<bool(const std::fs::path&)> m_loadAssembly;
|
||||
};
|
||||
|
||||
}
|
||||
39
plugins/script_loader/include/loaders/loader.hpp
Normal file
39
plugins/script_loader/include/loaders/loader.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace hex::script::loader {
|
||||
|
||||
struct Script {
|
||||
std::string name;
|
||||
std::function<void()> entryPoint;
|
||||
};
|
||||
|
||||
class ScriptLoader {
|
||||
public:
|
||||
ScriptLoader() = default;
|
||||
virtual ~ScriptLoader() = default;
|
||||
|
||||
virtual bool initialize() = 0;
|
||||
virtual bool loadAll() = 0;
|
||||
|
||||
void addScript(std::string name, std::function<void()> entryPoint) {
|
||||
this->m_scripts.emplace_back(std::move(name), std::move(entryPoint));
|
||||
}
|
||||
|
||||
const auto& getScripts() const {
|
||||
return this->m_scripts;
|
||||
}
|
||||
|
||||
protected:
|
||||
void clearScripts() {
|
||||
this->m_scripts.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<Script> m_scripts;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user