2021-12-12 17:19:59 +00:00
|
|
|
#ifndef MAPVIEW_H
|
|
|
|
#define MAPVIEW_H
|
|
|
|
|
2022-09-05 02:17:50 +01:00
|
|
|
#include <QJSValue>
|
2021-12-12 17:19:59 +00:00
|
|
|
#include "graphicsview.h"
|
|
|
|
#include "overlay.h"
|
|
|
|
|
|
|
|
class MapView : public GraphicsView
|
|
|
|
{
|
2022-09-05 02:17:50 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2021-12-12 17:19:59 +00:00
|
|
|
public:
|
|
|
|
MapView() : GraphicsView() {}
|
|
|
|
MapView(QWidget *parent) : GraphicsView(parent) {}
|
2022-09-05 02:17:50 +01:00
|
|
|
|
2021-12-12 17:19:59 +00:00
|
|
|
Overlay * getOverlay(int layer);
|
2022-09-05 02:17:50 +01:00
|
|
|
void clearOverlayMap();
|
2021-12-12 17:19:59 +00:00
|
|
|
|
2022-09-05 02:17:50 +01:00
|
|
|
// Overlay scripting API
|
|
|
|
Q_INVOKABLE void clear(int layer);
|
|
|
|
Q_INVOKABLE void clear();
|
|
|
|
Q_INVOKABLE void hide(int layer);
|
|
|
|
Q_INVOKABLE void hide();
|
|
|
|
Q_INVOKABLE void show(int layer);
|
|
|
|
Q_INVOKABLE void show();
|
|
|
|
Q_INVOKABLE bool getVisibility(int layer = 0);
|
|
|
|
Q_INVOKABLE void setVisibility(bool visible, int layer);
|
|
|
|
Q_INVOKABLE void setVisibility(bool visible);
|
|
|
|
Q_INVOKABLE int getX(int layer = 0);
|
|
|
|
Q_INVOKABLE int getY(int layer = 0);
|
|
|
|
Q_INVOKABLE void setX(int x, int layer);
|
|
|
|
Q_INVOKABLE void setX(int x);
|
|
|
|
Q_INVOKABLE void setY(int y, int layer);
|
|
|
|
Q_INVOKABLE void setY(int y);
|
2022-10-10 17:22:38 +01:00
|
|
|
Q_INVOKABLE void setClippingRect(int x, int y, int width, int height, int layer);
|
|
|
|
Q_INVOKABLE void setClippingRect(int x, int y, int width, int height);
|
|
|
|
Q_INVOKABLE void clearClippingRect(int layer);
|
|
|
|
Q_INVOKABLE void clearClippingRect();
|
2022-09-05 02:17:50 +01:00
|
|
|
Q_INVOKABLE QJSValue getPosition(int layer = 0);
|
|
|
|
Q_INVOKABLE void setPosition(int x, int y, int layer);
|
|
|
|
Q_INVOKABLE void setPosition(int x, int y);
|
|
|
|
Q_INVOKABLE void move(int deltaX, int deltaY, int layer);
|
|
|
|
Q_INVOKABLE void move(int deltaX, int deltaY);
|
|
|
|
Q_INVOKABLE int getOpacity(int layer = 0);
|
|
|
|
Q_INVOKABLE void setOpacity(int opacity, int layer);
|
|
|
|
Q_INVOKABLE void setOpacity(int opacity);
|
2022-10-14 02:58:59 +01:00
|
|
|
Q_INVOKABLE qreal getHorizontalScale(int layer = 0);
|
|
|
|
Q_INVOKABLE qreal getVerticalScale(int layer = 0);
|
|
|
|
Q_INVOKABLE void setHorizontalScale(qreal scale, int layer);
|
|
|
|
Q_INVOKABLE void setHorizontalScale(qreal scale);
|
|
|
|
Q_INVOKABLE void setVerticalScale(qreal scale, int layer);
|
|
|
|
Q_INVOKABLE void setVerticalScale(qreal scale);
|
2022-11-03 17:19:57 +00:00
|
|
|
Q_INVOKABLE void setScale(qreal hScale, qreal vScale, int layer);
|
|
|
|
Q_INVOKABLE void setScale(qreal hScale, qreal vScale);
|
2022-10-15 18:12:40 +01:00
|
|
|
Q_INVOKABLE int getRotation(int layer = 0);
|
|
|
|
Q_INVOKABLE void setRotation(int angle, int layer);
|
|
|
|
Q_INVOKABLE void setRotation(int angle);
|
2022-10-11 22:21:44 +01:00
|
|
|
Q_INVOKABLE void rotate(int degrees, int layer);
|
|
|
|
Q_INVOKABLE void rotate(int degrees);
|
2022-09-05 02:17:50 +01:00
|
|
|
Q_INVOKABLE void addText(QString text, int x, int y, QString color = "#000000", int fontSize = 12, int layer = 0);
|
2022-10-11 19:52:52 +01:00
|
|
|
Q_INVOKABLE void addRect(int x, int y, int width, int height, QString borderColor = "#000000", QString fillColor = "transparent", int rounding = 0, int layer = 0);
|
2022-10-15 17:33:12 +01:00
|
|
|
Q_INVOKABLE void addPath(QList<QList<int>> coords, QString borderColor = "#000000", QString fillColor = "transparent", int layer = 0);
|
2022-10-13 23:24:32 +01:00
|
|
|
Q_INVOKABLE void addPath(QList<int> xCoords, QList<int> yCoords, QString borderColor = "#000000", QString fillColor = "transparent", int layer = 0);
|
2022-09-05 02:17:50 +01:00
|
|
|
Q_INVOKABLE void addImage(int x, int y, QString filepath, int layer = 0, bool useCache = true);
|
|
|
|
Q_INVOKABLE void createImage(int x, int y, QString filepath,
|
2022-10-01 22:38:50 +01:00
|
|
|
int width = -1, int height = -1, int xOffset = 0, int yOffset = 0,
|
2022-09-05 02:17:50 +01:00
|
|
|
qreal hScale = 1, qreal vScale = 1, int paletteId = -1, bool setTransparency = false,
|
|
|
|
int layer = 0, bool useCache = true);
|
|
|
|
Q_INVOKABLE void addTileImage(int x, int y, int tileId, bool xflip, bool yflip, int paletteId, bool setTransparency = false, int layer = 0);
|
|
|
|
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:
|
2021-12-12 17:19:59 +00:00
|
|
|
QMap<int, Overlay*> overlayMap;
|
|
|
|
protected:
|
|
|
|
void drawForeground(QPainter *painter, const QRectF &rect);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GRAPHICSVIEW_H
|