mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-09 09:25:36 -05:00
More usage of Tile/Metatile size constants
This commit is contained in:
@@ -66,57 +66,7 @@ class PorymapConfig: public KeyValueConfigBase
|
||||
{
|
||||
public:
|
||||
PorymapConfig();
|
||||
virtual void reset() override {
|
||||
setRoot(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
|
||||
this->recentProjects.clear();
|
||||
this->projectManuallyClosed = false;
|
||||
this->reopenOnLaunch = true;
|
||||
this->mapListTab = 0;
|
||||
this->mapListEditGroupsEnabled = false;
|
||||
this->mapListHideEmptyEnabled.clear();
|
||||
this->prettyCursors = true;
|
||||
this->mirrorConnectingMaps = true;
|
||||
this->showDiveEmergeMaps = false;
|
||||
this->diveEmergeMapOpacity = 30;
|
||||
this->diveMapOpacity = 15;
|
||||
this->emergeMapOpacity = 15;
|
||||
this->collisionOpacity = 50;
|
||||
this->collisionZoom = 30;
|
||||
this->metatilesZoom = 30;
|
||||
this->tilesetEditorMetatilesZoom = 30;
|
||||
this->tilesetEditorTilesZoom = 30;
|
||||
this->showPlayerView = false;
|
||||
this->showCursorTile = true;
|
||||
this->showBorder = true;
|
||||
this->showGrid = false;
|
||||
this->showTilesetEditorMetatileGrid = false;
|
||||
this->showTilesetEditorLayerGrid = true;
|
||||
this->showTilesetEditorDivider = false;
|
||||
this->showTilesetEditorRawAttributes = false;
|
||||
this->monitorFiles = true;
|
||||
this->tilesetCheckerboardFill = true;
|
||||
this->newMapHeaderSectionExpanded = false;
|
||||
this->theme = "default";
|
||||
this->wildMonChartTheme = "";
|
||||
this->textEditorOpenFolder = "";
|
||||
this->textEditorGotoLine = "";
|
||||
this->paletteEditorBitDepth = 24;
|
||||
this->projectSettingsTab = 0;
|
||||
this->loadAllEventScripts = false;
|
||||
this->warpBehaviorWarningDisabled = false;
|
||||
this->eventDeleteWarningDisabled = false;
|
||||
this->eventOverlayEnabled = false;
|
||||
this->checkForUpdates = true;
|
||||
this->lastUpdateCheckTime = QDateTime();
|
||||
this->lastUpdateCheckVersion = porymapVersion;
|
||||
this->rateLimitTimes.clear();
|
||||
this->eventSelectionShapeMode = QGraphicsPixmapItem::MaskShape;
|
||||
this->shownInGameReloadMessage = false;
|
||||
this->gridSettings = GridSettings();
|
||||
this->statusBarLogTypes = { LogType::LOG_ERROR, LogType::LOG_WARN };
|
||||
this->applicationFont = QFont();
|
||||
this->mapListFont = PorymapConfig::defaultMapListFont();
|
||||
}
|
||||
virtual void reset() override;
|
||||
void addRecentProject(QString project);
|
||||
void setRecentProjects(QStringList projects);
|
||||
QString getRecentProject();
|
||||
|
||||
@@ -51,10 +51,12 @@ public:
|
||||
void setLayoutId(const QString &layoutId) { m_layoutId = layoutId; }
|
||||
QString layoutId() const { return layout() ? layout()->id : m_layoutId; }
|
||||
|
||||
int getWidth() const;
|
||||
int getHeight() const;
|
||||
int getBorderWidth() const;
|
||||
int getBorderHeight() const;
|
||||
int getWidth() const { return m_layout ? m_layout->getWidth() : 0; }
|
||||
int getHeight() const { return m_layout ? m_layout->getHeight() : 0; }
|
||||
int getBorderWidth() const { return m_layout ? m_layout->getBorderWidth() : 0; }
|
||||
int getBorderHeight() const { return m_layout ? m_layout->getBorderHeight() : 0; }
|
||||
int pixelWidth() const { return m_layout ? m_layout->pixelWidth() : 0; }
|
||||
int pixelHeight() const { return m_layout ? m_layout->pixelHeight() : 0; }
|
||||
|
||||
void setHeader(const MapHeader &header) { *m_header = header; }
|
||||
MapHeader* header() const { return m_header; }
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
MapConnection* createMirror();
|
||||
|
||||
QPixmap render() const;
|
||||
QPoint relativePos(bool clipped = false) const;
|
||||
QPoint relativePixelPos(bool clipped = false) const;
|
||||
|
||||
static QPointer<Project> project;
|
||||
static const QMap<QString, QString> oppositeDirections;
|
||||
|
||||
@@ -32,6 +32,9 @@ public:
|
||||
int height;
|
||||
int border_width;
|
||||
int border_height;
|
||||
int pixelWidth() const { return this->width * Metatile::pixelWidth(); }
|
||||
int pixelHeight() const { return this->height * Metatile::pixelHeight(); }
|
||||
QSize pixelSize() const { return QSize(pixelWidth(), pixelHeight()); }
|
||||
|
||||
QString border_path;
|
||||
QString blockdata_path;
|
||||
@@ -153,7 +156,7 @@ public:
|
||||
void _floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation);
|
||||
void magicFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation);
|
||||
|
||||
QPixmap render(bool ignoreCache = false, Layout *fromLayout = nullptr, QRect bounds = QRect(0, 0, -1, -1));
|
||||
QPixmap render(bool ignoreCache = false, Layout *fromLayout = nullptr, const QRect &bounds = QRect(0, 0, -1, -1));
|
||||
QPixmap renderCollision(bool ignoreCache);
|
||||
// QPixmap renderConnection(MapConnection, Layout *);
|
||||
QPixmap renderBorder(bool ignoreCache = false);
|
||||
|
||||
@@ -64,12 +64,12 @@ public:
|
||||
static QString getMetatileIdStrings(const QList<uint16_t> metatileIds);
|
||||
static QString getLayerName(int layerNum);
|
||||
|
||||
static int tileWidth() { return 2; }
|
||||
static int tileHeight() { return 2; }
|
||||
static int tilesPerLayer() { return Metatile::tileWidth() * Metatile::tileHeight(); }
|
||||
static int pixelWidth() { return Metatile::tileWidth() * Tile::pixelWidth(); }
|
||||
static int pixelHeight() { return Metatile::tileHeight() * Tile::pixelHeight(); }
|
||||
static QSize pixelSize() { return QSize(pixelWidth(), pixelHeight()); }
|
||||
static constexpr int tileWidth() { return 2; }
|
||||
static constexpr int tileHeight() { return 2; }
|
||||
static constexpr int tilesPerLayer() { return Metatile::tileWidth() * Metatile::tileHeight(); }
|
||||
static constexpr int pixelWidth() { return Metatile::tileWidth() * Tile::pixelWidth(); }
|
||||
static constexpr int pixelHeight() { return Metatile::tileHeight() * Tile::pixelHeight(); }
|
||||
static constexpr QSize pixelSize() { return QSize(pixelWidth(), pixelHeight()); }
|
||||
|
||||
inline bool operator==(const Metatile &other) {
|
||||
return this->tiles == other.tiles && this->attributes == other.attributes;
|
||||
|
||||
@@ -26,9 +26,9 @@ public:
|
||||
|
||||
static const uint16_t maxValue;
|
||||
|
||||
static int pixelWidth() { return 8; }
|
||||
static int pixelHeight() { return 8; }
|
||||
static QSize pixelSize() { return QSize(Tile::pixelWidth(), Tile::pixelHeight()); }
|
||||
static constexpr int pixelWidth() { return 8; }
|
||||
static constexpr int pixelHeight() { return 8; }
|
||||
static constexpr QSize pixelSize() { return QSize(Tile::pixelWidth(), Tile::pixelHeight()); }
|
||||
};
|
||||
|
||||
inline bool operator==(const Tile &a, const Tile &b) {
|
||||
|
||||
@@ -251,6 +251,7 @@ public:
|
||||
static QString getDynamicMapDefineName();
|
||||
static QString getDynamicMapName();
|
||||
static QString getEmptySpeciesName();
|
||||
static QMargins getPixelViewDistance();
|
||||
static QMargins getMetatileViewDistance();
|
||||
static int getNumTilesPrimary() { return num_tiles_primary; }
|
||||
static int getNumTilesTotal() { return num_tiles_total; }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define CONNECTIONPIXMAPITEM_H
|
||||
|
||||
#include "mapconnection.h"
|
||||
#include "metatile.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QPainter>
|
||||
#include <QPointer>
|
||||
@@ -31,8 +32,8 @@ private:
|
||||
bool selected = false;
|
||||
unsigned actionId = 0;
|
||||
|
||||
static const int mWidth = 16;
|
||||
static const int mHeight = 16;
|
||||
static const int mWidth = Metatile::pixelWidth();
|
||||
static const int mHeight = Metatile::pixelHeight();
|
||||
|
||||
void updatePos();
|
||||
void updateOrigin();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QGraphicsObject>
|
||||
#include <QLine>
|
||||
#include "metatile.h"
|
||||
|
||||
|
||||
class MapRuler : public QGraphicsObject, private QLine
|
||||
@@ -63,8 +64,8 @@ private:
|
||||
QPoint snapToWithinBounds(QPoint pos) const;
|
||||
void updateGeometry();
|
||||
void updateStatus(Qt::Corner corner);
|
||||
int pixWidth() const { return width() * 16; }
|
||||
int pixHeight() const { return height() * 16; }
|
||||
int pixWidth() const { return width() * Metatile::pixelWidth(); }
|
||||
int pixHeight() const { return height() * Metatile::pixelHeight(); }
|
||||
};
|
||||
|
||||
#endif // MAPRULER_H
|
||||
|
||||
@@ -31,7 +31,7 @@ struct MetatileSelection
|
||||
class MetatileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MetatileSelector(int numMetatilesWide, Layout *layout): SelectablePixmapItem(16, 16) {
|
||||
MetatileSelector(int numMetatilesWide, Layout *layout): SelectablePixmapItem(Metatile::pixelWidth(), Metatile::pixelHeight()) {
|
||||
this->externalSelection = false;
|
||||
this->prefabSelection = false;
|
||||
this->numMetatilesWide = numMetatilesWide;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
class MovableRect : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
MovableRect(const QRectF &rect, const QRgb &color);
|
||||
MovableRect(const QRectF &rect, const QSize &cellSize, const QRgb &color);
|
||||
QRectF boundingRect() const override {
|
||||
qreal penWidth = 4;
|
||||
return QRectF(-penWidth,
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
|
||||
protected:
|
||||
QRectF baseRect;
|
||||
QSize cellSize;
|
||||
QRgb color;
|
||||
|
||||
void updateVisibility();
|
||||
@@ -43,7 +44,7 @@ class ResizableRect : public QObject, public MovableRect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ResizableRect(QObject *parent, int width, int height, QRgb color);
|
||||
ResizableRect(QObject *parent, const QSize &cellSize, const QSize &size, const QRgb &color);
|
||||
|
||||
QRectF boundingRect() const override {
|
||||
return QRectF(this->rect() + QMargins(lineWidth, lineWidth, lineWidth, lineWidth));
|
||||
|
||||
@@ -45,10 +45,10 @@ private:
|
||||
|
||||
/// PixmapItem subclass which allows for creating a boundary which determine whether
|
||||
/// the pixmap paints normally or with a black tint.
|
||||
/// This item is movable and snaps on a 16x16 grid.
|
||||
/// This item is movable and snaps on a 'cellSize' grid.
|
||||
class BoundedPixmapItem : public QGraphicsPixmapItem {
|
||||
public:
|
||||
BoundedPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = nullptr);
|
||||
BoundedPixmapItem(const QPixmap &pixmap, const QSize &cellSize, QGraphicsItem *parent = nullptr);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||
|
||||
void setBoundary(ResizableRect *rect) { this->boundary = rect; }
|
||||
@@ -59,6 +59,7 @@ protected:
|
||||
private:
|
||||
ResizableRect *boundary = nullptr;
|
||||
QPointF clickedPos = QPointF();
|
||||
QSize cellSize;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -7,13 +7,18 @@
|
||||
class SelectablePixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SelectablePixmapItem(int cellWidth, int cellHeight): SelectablePixmapItem(cellWidth, cellHeight, INT_MAX, INT_MAX) {}
|
||||
SelectablePixmapItem(int cellWidth, int cellHeight, int maxSelectionWidth, int maxSelectionHeight) {
|
||||
this->cellWidth = cellWidth;
|
||||
this->cellHeight = cellHeight;
|
||||
this->maxSelectionWidth = maxSelectionWidth;
|
||||
this->maxSelectionHeight = maxSelectionHeight;
|
||||
}
|
||||
SelectablePixmapItem(const QSize &size, const QSize &maxSelectionSize = QSize(INT_MAX, INT_MAX))
|
||||
: SelectablePixmapItem(size.width(), size.height(), maxSelectionSize.width(), maxSelectionSize.height()) {}
|
||||
SelectablePixmapItem(int cellWidth, int cellHeight, int maxSelectionWidth = INT_MAX, int maxSelectionHeight = INT_MAX)
|
||||
: cellWidth(cellWidth),
|
||||
cellHeight(cellHeight),
|
||||
maxSelectionWidth(maxSelectionWidth),
|
||||
maxSelectionHeight(maxSelectionHeight),
|
||||
selectionInitialX(0),
|
||||
selectionInitialY(0),
|
||||
selectionOffsetX(0),
|
||||
selectionOffsetY(0)
|
||||
{}
|
||||
virtual QPoint getSelectionDimensions();
|
||||
virtual void draw() = 0;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class TilesetEditorTileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilesetEditorTileSelector(Tileset *primaryTileset, Tileset *secondaryTileset, int numLayers)
|
||||
: SelectablePixmapItem(16, 16, numLayers * 2, 2) {
|
||||
: SelectablePixmapItem(16, 16, numLayers * Metatile::tileWidth(), Metatile::tileHeight()) {
|
||||
this->primaryTileset = primaryTileset;
|
||||
this->secondaryTileset = secondaryTileset;
|
||||
this->numTilesWide = 16;
|
||||
|
||||
Reference in New Issue
Block a user