mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add callEveryWithArgs
This commit is contained in:
parent
c5688dd033
commit
f5f0a3301f
2 changed files with 20 additions and 0 deletions
|
@ -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 <memory>
|
||||
#include <utility>
|
||||
|
@ -70,6 +74,18 @@ void PluginController::callEvery(const QString &functionName)
|
|||
}
|
||||
}
|
||||
|
||||
void PluginController::callEveryWithArgs(
|
||||
const QString &functionName, int count,
|
||||
std::function<void(const std::unique_ptr<Plugin> &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;
|
||||
|
||||
|
|
|
@ -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<void(const std::unique_ptr<Plugin> &pl, lua_State *L)>
|
||||
argCb);
|
||||
|
||||
private:
|
||||
void load(QFileInfo index, QDir pluginDir);
|
||||
|
|
Loading…
Reference in a new issue