diff --git a/src/controllers/plugins/PluginController.cpp b/src/controllers/plugins/PluginController.cpp index f63f81fa8..2aa45aa75 100644 --- a/src/controllers/plugins/PluginController.cpp +++ b/src/controllers/plugins/PluginController.cpp @@ -4,6 +4,10 @@ #include "common/QLogging.hpp" #include "messages/MessageBuilder.hpp" #include "providers/twitch/TwitchIrcServer.hpp" +#include "singletons/WindowManager.hpp" +#include "widgets/Notebook.hpp" +#include "widgets/splits/Split.hpp" +#include "widgets/Window.hpp" #include #include @@ -70,6 +74,18 @@ void PluginController::callEvery(const QString &functionName) } } +void PluginController::callEveryWithArgs( + const QString &functionName, int count, + std::function &pl, lua_State *L)> argCb) +{ + for (const auto &[name, plugin] : this->plugins) + { + lua_getglobal(plugin->state_, functionName.toStdString().c_str()); + argCb(plugin, plugin->state_); + lua_pcall(plugin->state_, count, 0, 0); + } +} + constexpr int C_FALSE = 0; constexpr int C_TRUE = 1; diff --git a/src/controllers/plugins/PluginController.hpp b/src/controllers/plugins/PluginController.hpp index 3014c9f2b..33e593c37 100644 --- a/src/controllers/plugins/PluginController.hpp +++ b/src/controllers/plugins/PluginController.hpp @@ -50,6 +50,10 @@ public: void initialize(Settings &settings, Paths &paths) override; void save() override{}; void callEvery(const QString &functionName); + void callEveryWithArgs( + const QString &functionName, int count, + std::function &pl, lua_State *L)> + argCb); private: void load(QFileInfo index, QDir pluginDir);