Add onMapShifted to API
This commit is contained in:
parent
8ed891d501
commit
b39906c03f
3 changed files with 15 additions and 0 deletions
|
@ -14,6 +14,7 @@ enum CallbackType {
|
||||||
OnBlockChanged,
|
OnBlockChanged,
|
||||||
OnMapOpened,
|
OnMapOpened,
|
||||||
OnMapResized,
|
OnMapResized,
|
||||||
|
OnMapShifted,
|
||||||
OnTilesetUpdated,
|
OnTilesetUpdated,
|
||||||
OnTabChanged,
|
OnTabChanged,
|
||||||
};
|
};
|
||||||
|
@ -38,6 +39,7 @@ public:
|
||||||
static void cb_MetatileChanged(int x, int y, Block prevBlock, Block newBlock);
|
static void cb_MetatileChanged(int x, int y, Block prevBlock, Block newBlock);
|
||||||
static void cb_MapOpened(QString mapName);
|
static void cb_MapOpened(QString mapName);
|
||||||
static void cb_MapResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
|
static void cb_MapResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
|
||||||
|
static void cb_MapShifted(int xDelta, int yDelta);
|
||||||
static void cb_TilesetUpdated(QString tilesetName);
|
static void cb_TilesetUpdated(QString tilesetName);
|
||||||
static void cb_TabChanged(int oldTab, int newTab);
|
static void cb_TabChanged(int oldTab, int newTab);
|
||||||
static bool tryErrorJS(QJSValue js);
|
static bool tryErrorJS(QJSValue js);
|
||||||
|
|
|
@ -7,6 +7,7 @@ QMap<CallbackType, QString> callbackFunctions = {
|
||||||
{OnBlockChanged, "onBlockChanged"},
|
{OnBlockChanged, "onBlockChanged"},
|
||||||
{OnMapOpened, "onMapOpened"},
|
{OnMapOpened, "onMapOpened"},
|
||||||
{OnMapResized, "onMapResized"},
|
{OnMapResized, "onMapResized"},
|
||||||
|
{OnMapShifted, "onMapShifted"},
|
||||||
{OnTilesetUpdated, "onTilesetUpdated"},
|
{OnTilesetUpdated, "onTilesetUpdated"},
|
||||||
{OnTabChanged, "onTabChanged"},
|
{OnTabChanged, "onTabChanged"},
|
||||||
};
|
};
|
||||||
|
@ -155,6 +156,16 @@ void Scripting::cb_MapResized(int oldWidth, int oldHeight, int newWidth, int new
|
||||||
instance->invokeCallback(OnMapResized, args);
|
instance->invokeCallback(OnMapResized, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scripting::cb_MapShifted(int xDelta, int yDelta) {
|
||||||
|
if (!instance) return;
|
||||||
|
|
||||||
|
QJSValueList args {
|
||||||
|
xDelta,
|
||||||
|
yDelta,
|
||||||
|
};
|
||||||
|
instance->invokeCallback(OnMapShifted, args);
|
||||||
|
}
|
||||||
|
|
||||||
void Scripting::cb_TilesetUpdated(QString tilesetName) {
|
void Scripting::cb_TilesetUpdated(QString tilesetName) {
|
||||||
if (!instance) return;
|
if (!instance) return;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "mappixmapitem.h"
|
#include "mappixmapitem.h"
|
||||||
#include "metatile.h"
|
#include "metatile.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "scripting.h"
|
||||||
|
|
||||||
#include "editcommands.h"
|
#include "editcommands.h"
|
||||||
|
|
||||||
|
@ -95,6 +96,7 @@ void MapPixmapItem::shift(int xDelta, int yDelta, bool fromScriptCall) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||||
|
Scripting::cb_MapShifted(xDelta, yDelta);
|
||||||
map->editHistory.push(new ShiftMetatiles(map, oldMetatiles, map->layout->blockdata, actionId_));
|
map->editHistory.push(new ShiftMetatiles(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue