Add onLayoutOpened API callback

This commit is contained in:
GriffinR
2025-03-14 23:24:17 -04:00
parent 4b1332609e
commit e6f4e64aa4
8 changed files with 82 additions and 46 deletions

View File

@@ -9,6 +9,8 @@
#include <QStringList>
#include <QJSEngine>
// !! New callback functions or changes to existing callback function names/arguments
// should be synced to resources/text/script_template.txt and docsrc/manual/scripting-capabilities.rst
enum CallbackType {
OnProjectOpened,
OnProjectClosed,
@@ -17,6 +19,7 @@ enum CallbackType {
OnBlockHoverChanged,
OnBlockHoverCleared,
OnMapOpened,
OnLayoutOpened,
OnMapResized,
OnBorderResized,
OnMapShifted,
@@ -43,6 +46,7 @@ public:
static void cb_BlockHoverChanged(int x, int y);
static void cb_BlockHoverCleared();
static void cb_MapOpened(QString mapName);
static void cb_LayoutOpened(QString layoutName);
static void cb_MapResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
static void cb_BorderResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
static void cb_MapShifted(int xDelta, int yDelta);

View File

@@ -70,11 +70,13 @@ public:
Q_INVOKABLE void addTileImage(int x, int y, QJSValue tileObj, bool setTransparency = false, int layer = 0);
Q_INVOKABLE void addMetatileImage(int x, int y, int metatileId, bool setTransparency = false, int layer = 0);
private:
QMap<int, Overlay*> overlayMap;
protected:
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
virtual void keyPressEvent(QKeyEvent*) override;
private:
QMap<int, Overlay*> overlayMap;
void updateScene();
};
#endif // GRAPHICSVIEW_H