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

@@ -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