fix: Don't unload background .NET scripts

This commit is contained in:
WerWolv
2024-06-07 21:27:01 +02:00
parent af59b9d2ca
commit 8531a67519
3 changed files with 34 additions and 10 deletions

View File

@@ -15,6 +15,7 @@ namespace hex::script::loader {
bool initialize() override;
bool loadAll() override;
void clearScripts() override;
private:
std::function<int(const std::string &, bool, const std::fs::path&)> m_runMethod;

View File

@@ -17,6 +17,8 @@ namespace hex::script::loader {
struct Script {
std::string name;
std::fs::path path;
bool background;
std::function<void()> entryPoint;
const ScriptLoader *loader;
@@ -29,9 +31,10 @@ namespace hex::script::loader {
virtual bool initialize() = 0;
virtual bool loadAll() = 0;
virtual void clearScripts() = 0;
void addScript(std::string name, bool background, std::function<void()> entryPoint) {
m_scripts.emplace_back(std::move(name), background, std::move(entryPoint), this);
void addScript(std::string name, std::fs::path path, bool background, std::function<void()> entryPoint) {
m_scripts.emplace_back(std::move(name), std::move(path), background, std::move(entryPoint), this);
}
const auto& getScripts() const {
@@ -43,8 +46,8 @@ namespace hex::script::loader {
}
protected:
void clearScripts() {
m_scripts.clear();
auto& getScripts() {
return m_scripts;
}
private: