Implement proof of concept for scripting capabilities

This commit is contained in:
Marcus Huderle
2020-04-26 19:38:20 -05:00
parent 37ab54019b
commit 267cd5e2cb
12 changed files with 154 additions and 25 deletions

31
include/scripting.h Normal file
View File

@@ -0,0 +1,31 @@
#ifndef SCRIPTING_H
#define SCRIPTING_H
#include "mainwindow.h"
#include "block.h"
#include <QStringList>
#include <QJSEngine>
enum CallbackType {
OnBlockChanged,
};
class Scripting
{
public:
Scripting(MainWindow *mainWindow);
QJSValue newBlockObject(Block block);
static void init(MainWindow *mainWindow);
static void cb_MetatileChanged(int x, int y, Block prevBlock, Block newBlock);
private:
QJSEngine *engine;
QStringList filepaths;
QList<QJSValue> modules;
void loadModules(QStringList moduleFiles);
void invokeCallback(CallbackType type, QJSValueList args);
};
#endif // SCRIPTING_H