Add player view rectangle option

This commit is contained in:
Marcus Huderle
2019-01-08 18:04:48 -06:00
parent 3f88072981
commit 4d088766a0
13 changed files with 115 additions and 11 deletions

View File

@@ -20,6 +20,7 @@
#include "collisionpixmapitem.h"
#include "mappixmapitem.h"
#include "settings.h"
#include "playerviewrect.h"
class DraggablePixmapItem;
class MetatilesPixmapItem;
@@ -94,6 +95,7 @@ public:
QGraphicsItemGroup *events_group = nullptr;
QList<QGraphicsPixmapItem*> borderItems;
QList<QGraphicsLineItem*> gridLines;
PlayerViewRect *playerViewRect = nullptr;
QGraphicsScene *scene_metatiles = nullptr;
QGraphicsScene *scene_current_metatile_selection = nullptr;

View File

@@ -74,6 +74,7 @@ private slots:
void on_actionZoom_In_triggered();
void on_actionZoom_Out_triggered();
void on_actionBetter_Cursors_triggered();
void on_actionPlayer_View_Rectangle_triggered();
void on_actionPencil_triggered();
void on_actionPointer_triggered();
void on_actionFlood_Fill_triggered();

View File

@@ -10,6 +10,7 @@ public:
bool smartPathsEnabled;
bool betterCursors;
QCursor mapCursor;
bool playerViewRectEnabled;
};
#endif // SETTINGS_H

View File

@@ -13,8 +13,10 @@ public:
this->map = map_;
this->metatileSelector = metatileSelector;
this->settings = settings;
this->paintingEnabled = true;
setAcceptHoverEvents(true);
}
bool paintingEnabled;
Map *map;
MetatileSelector *metatileSelector;
Settings *settings;

View File

@@ -0,0 +1,35 @@
#ifndef PLAYERVIEWRECT_H
#define PLAYERVIEWRECT_H
#include <QGraphicsItem>
#include <QPainter>
class PlayerViewRect : public QGraphicsItem
{
public:
PlayerViewRect(bool *enabled);
QRectF boundingRect() const override
{
qreal penWidth = 4;
return QRectF(-penWidth,
-penWidth,
30 * 8 + penWidth * 2,
20 * 8 + penWidth * 2);
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) override
{
int width = 30 * 8;
int height = 20 * 8;
painter->setPen(QColor(0xff, 0xff, 0xff));
painter->drawRect(-2, -2, width + 3, height + 3);
painter->setPen(QColor(0, 0, 0));
painter->drawRect(-3, -3, width + 5, height + 5);
painter->drawRect(-1, -1, width + 1, height + 1);
}
void updateLocation(int x, int y);
bool *enabled;
};
#endif // PLAYERVIEWRECT_H