Add option to show an outline around the currently-hovered map tile

This commit is contained in:
Marcus Huderle
2019-01-09 09:35:34 -06:00
parent 543743bcd0
commit 61b919566a
13 changed files with 120 additions and 32 deletions

View File

@@ -33,6 +33,8 @@ public:
this->mapSortOrder = MapSortOrder::Group;
this->prettyCursors = true;
this->collisionOpacity = 50;
this->showPlayerView = false;
this->showCursorTile = true;
}
void setRecentProject(QString project);
void setRecentMap(QString map);
@@ -40,12 +42,16 @@ public:
void setPrettyCursors(bool enabled);
void setGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray);
void setCollisionOpacity(int opacity);
void setShowPlayerView(bool enabled);
void setShowCursorTile(bool enabled);
QString getRecentProject();
QString getRecentMap();
MapSortOrder getMapSortOrder();
bool getPrettyCursors();
QMap<QString, QByteArray> getGeometry();
int getCollisionOpacity();
bool getShowPlayerView();
bool getShowCursorTile();
protected:
QString getConfigFilepath();
void parseConfigKeyValue(QString key, QString value);
@@ -64,6 +70,8 @@ private:
QByteArray eventsSlpitterState;
QByteArray mainSplitterState;
int collisionOpacity;
bool showPlayerView;
bool showCursorTile;
};
extern PorymapConfig porymapConfig;

View File

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

View File

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

View File

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

View File

@@ -1,13 +1,14 @@
#ifndef PLAYERVIEWRECT_H
#define PLAYERVIEWRECT_H
#ifndef MOVABLERECT_H
#define MOVABLERECT_H
#include <QGraphicsItem>
#include <QPainter>
#include <QRgb>
class PlayerViewRect : public QGraphicsItem
class MovableRect : public QGraphicsItem
{
public:
PlayerViewRect(bool *enabled);
MovableRect(bool *enabled, int width, int height, QRgb color);
QRectF boundingRect() const override
{
qreal penWidth = 4;
@@ -20,16 +21,18 @@ public:
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(this->color);
painter->drawRect(-2, -2, this->width + 3, this->height + 3);
painter->setPen(QColor(0, 0, 0));
painter->drawRect(-3, -3, width + 5, height + 5);
painter->drawRect(-1, -1, width + 1, height + 1);
painter->drawRect(-3, -3, this->width + 5, this->height + 5);
painter->drawRect(-1, -1, this->width + 1, this->height + 1);
}
void updateLocation(int x, int y);
bool *enabled;
private:
int width;
int height;
QRgb color;
};
#endif // PLAYERVIEWRECT_H
#endif // MOVABLERECT_H