Add onMapResized to scripting API callbacks
This commit is contained in:
parent
b16c971f00
commit
206a1d12b3
3 changed files with 19 additions and 0 deletions
|
@ -13,6 +13,7 @@ enum CallbackType {
|
|||
OnProjectClosed,
|
||||
OnBlockChanged,
|
||||
OnMapOpened,
|
||||
OnMapResized,
|
||||
OnTilesetUpdated,
|
||||
};
|
||||
|
||||
|
@ -34,6 +35,7 @@ public:
|
|||
static void cb_ProjectClosed(QString projectPath);
|
||||
static void cb_MetatileChanged(int x, int y, Block prevBlock, Block newBlock);
|
||||
static void cb_MapOpened(QString mapName);
|
||||
static void cb_MapResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
|
||||
static void cb_TilesetUpdated(QString tilesetName);
|
||||
static bool tryErrorJS(QJSValue js);
|
||||
|
||||
|
|
|
@ -2969,6 +2969,10 @@ void MainWindow::on_pushButton_ChangeDimensions_clicked()
|
|||
oldBorder, map->layout->border
|
||||
));
|
||||
}
|
||||
if (oldMapDimensions != newMapDimensions) {
|
||||
Scripting::cb_MapResized(oldMapDimensions.width(), oldMapDimensions.height(),
|
||||
newMapDimensions.width(), newMapDimensions.height());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ QMap<CallbackType, QString> callbackFunctions = {
|
|||
{OnProjectClosed, "onProjectClosed"},
|
||||
{OnBlockChanged, "onBlockChanged"},
|
||||
{OnMapOpened, "onMapOpened"},
|
||||
{OnMapResized, "onMapResized"},
|
||||
{OnTilesetUpdated, "onTilesetUpdated"},
|
||||
};
|
||||
|
||||
|
@ -141,6 +142,18 @@ void Scripting::cb_MapOpened(QString mapName) {
|
|||
instance->invokeCallback(OnMapOpened, args);
|
||||
}
|
||||
|
||||
void Scripting::cb_MapResized(int oldWidth, int oldHeight, int newWidth, int newHeight) {
|
||||
if (!instance) return;
|
||||
|
||||
QJSValueList args {
|
||||
oldWidth,
|
||||
oldHeight,
|
||||
newWidth,
|
||||
newHeight,
|
||||
};
|
||||
instance->invokeCallback(OnMapResized, args);
|
||||
}
|
||||
|
||||
void Scripting::cb_TilesetUpdated(QString tilesetName) {
|
||||
if (!instance) return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue