Add onBlockHoverChanged and onBlockHoverCleared
This commit is contained in:
parent
9dc44b3373
commit
5f79f15554
5 changed files with 37 additions and 1 deletions
|
@ -15,7 +15,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
|||
- Events, current metatile selections, and map images can now be copied and pasted, including between windows.
|
||||
- The grid and map border visibility are now saved as config options.
|
||||
- Add ~60 new API functions, including new features like reading/writing metatile data, layering, moving, and hiding items in the overlay, creating modified images and tile/metatile images, reading tileset sizes, logging warnings and errors, and more.
|
||||
- Add 5 new scripting callbacks.
|
||||
- Add 7 new scripting callbacks.
|
||||
|
||||
### Changed
|
||||
- New events will be placed in the center of the current view of the map.
|
||||
|
|
|
@ -118,6 +118,17 @@ Callbacks
|
|||
:param object prevBlock: the block's state before it was modified. The object's shape is ``{metatileId, collision, elevation, rawValue}``
|
||||
:param object newBlock: the block's new state after it was modified. The object's shape is ``{metatileId, collision, elevation, rawValue}``
|
||||
|
||||
.. js:function:: onBlockHoverChanged(x, y)
|
||||
|
||||
Called when the mouse enters a new map block.
|
||||
|
||||
:param number x: x coordinate of the block
|
||||
:param number y: y coordinate of the block
|
||||
|
||||
.. js:function:: onBlockHoverCleared()
|
||||
|
||||
Called when the mouse exits the map.
|
||||
|
||||
.. js:function:: onMapResized(oldWidth, oldHeight, newWidth, newHeight)
|
||||
|
||||
Called when the dimensions of the map are changed.
|
||||
|
|
|
@ -12,6 +12,8 @@ enum CallbackType {
|
|||
OnProjectOpened,
|
||||
OnProjectClosed,
|
||||
OnBlockChanged,
|
||||
OnBlockHoverChanged,
|
||||
OnBlockHoverCleared,
|
||||
OnMapOpened,
|
||||
OnMapResized,
|
||||
OnMapShifted,
|
||||
|
@ -38,6 +40,8 @@ public:
|
|||
static void cb_ProjectOpened(QString projectPath);
|
||||
static void cb_ProjectClosed(QString projectPath);
|
||||
static void cb_MetatileChanged(int x, int y, Block prevBlock, Block newBlock);
|
||||
static void cb_BlockHoverChanged(int x, int y);
|
||||
static void cb_BlockHoverCleared();
|
||||
static void cb_MapOpened(QString mapName);
|
||||
static void cb_MapResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
|
||||
static void cb_MapShifted(int xDelta, int yDelta);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "montabwidget.h"
|
||||
#include "editcommands.h"
|
||||
#include "config.h"
|
||||
#include "scripting.h"
|
||||
#include <QCheckBox>
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
|
@ -992,6 +993,7 @@ void Editor::updateCursorRectPos(int x, int y) {
|
|||
this->cursorMapTileRect->updateLocation(x, y);
|
||||
if (ui->graphicsView_Map->scene())
|
||||
ui->graphicsView_Map->scene()->update();
|
||||
Scripting::cb_BlockHoverChanged(x, y);
|
||||
}
|
||||
|
||||
void Editor::setCursorRectVisible(bool visible) {
|
||||
|
@ -1029,6 +1031,7 @@ void Editor::onHoveredMapMetatileCleared() {
|
|||
|| map_item->paintingMode == MapPixmapItem::PaintMode::EventObjects) {
|
||||
this->ui->statusBar->clearMessage();
|
||||
}
|
||||
Scripting::cb_BlockHoverCleared();
|
||||
}
|
||||
|
||||
void Editor::onHoveredMapMovementPermissionChanged(int x, int y) {
|
||||
|
@ -1051,6 +1054,7 @@ void Editor::onHoveredMapMovementPermissionCleared() {
|
|||
if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles) {
|
||||
this->ui->statusBar->clearMessage();
|
||||
}
|
||||
Scripting::cb_BlockHoverCleared();
|
||||
}
|
||||
|
||||
QString Editor::getMovementPermissionText(uint16_t collision, uint16_t elevation) {
|
||||
|
|
|
@ -5,6 +5,8 @@ QMap<CallbackType, QString> callbackFunctions = {
|
|||
{OnProjectOpened, "onProjectOpened"},
|
||||
{OnProjectClosed, "onProjectClosed"},
|
||||
{OnBlockChanged, "onBlockChanged"},
|
||||
{OnBlockHoverChanged, "onBlockHoverChanged"},
|
||||
{OnBlockHoverCleared, "onBlockHoverCleared"},
|
||||
{OnMapOpened, "onMapOpened"},
|
||||
{OnMapResized, "onMapResized"},
|
||||
{OnMapShifted, "onMapShifted"},
|
||||
|
@ -136,6 +138,21 @@ void Scripting::cb_MetatileChanged(int x, int y, Block prevBlock, Block newBlock
|
|||
instance->invokeCallback(OnBlockChanged, args);
|
||||
}
|
||||
|
||||
void Scripting::cb_BlockHoverChanged(int x, int y) {
|
||||
if (!instance) return;
|
||||
|
||||
QJSValueList args {
|
||||
x,
|
||||
y,
|
||||
};
|
||||
instance->invokeCallback(OnBlockHoverChanged, args);
|
||||
}
|
||||
|
||||
void Scripting::cb_BlockHoverCleared() {
|
||||
if (!instance) return;
|
||||
instance->invokeCallback(OnBlockHoverCleared, QJSValueList());
|
||||
}
|
||||
|
||||
void Scripting::cb_MapOpened(QString mapName) {
|
||||
if (!instance) return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue