Allow off-center player view size

This commit is contained in:
GriffinR
2025-04-17 11:21:23 -04:00
parent a6ec91724f
commit 5d475513d5
15 changed files with 180 additions and 131 deletions

View File

@@ -15,11 +15,11 @@
#include "events.h"
static const QVersionNumber porymapVersion = QVersionNumber::fromString(PORYMAP_VERSION);
extern const QVersionNumber porymapVersion;
// In both versions the default new map border is a generic tree
#define DEFAULT_BORDER_RSE (QList<uint16_t>{0x1D4, 0x1D5, 0x1DC, 0x1DD})
#define DEFAULT_BORDER_FRLG (QList<uint16_t>{0x14, 0x15, 0x1C, 0x1D})
// Distance in pixels from the edge of a GBA screen (240x160) to the center 16x16 pixels.
#define GBA_H_DIST_TO_CENTER ((240-16)/2)
#define GBA_V_DIST_TO_CENTER ((160-16)/2)
#define CONFIG_BACKWARDS_COMPATABILITY
@@ -332,7 +332,7 @@ public:
this->pokemonIconPaths.clear();
this->collisionSheetPath = QString();
this->collisionSheetSize = QSize(2, 16);
this->playerViewSize = QSize(240, 160);
this->playerViewDistance = QMargins(GBA_H_DIST_TO_CENTER, GBA_V_DIST_TO_CENTER, GBA_H_DIST_TO_CENTER, GBA_V_DIST_TO_CENTER);
this->blockMetatileIdMask = 0x03FF;
this->blockCollisionMask = 0x0C00;
this->blockElevationMask = 0xF000;
@@ -409,7 +409,7 @@ public:
bool mapAllowFlagsEnabled;
QString collisionSheetPath;
QSize collisionSheetSize;
QSize playerViewSize;
QMargins playerViewDistance;
QList<uint32_t> warpBehaviors;
int maxEventsPerGroup;

View File

@@ -96,8 +96,7 @@ public:
int getHeight() const { return height; }
int getBorderWidth() const { return border_width; }
int getBorderHeight() const { return border_height; }
int getBorderDrawWidth() const;
int getBorderDrawHeight() const;
QMargins getBorderMargins() const;
QRect getVisibleRect() const;
bool isWithinBounds(int x, int y) const;

View File

@@ -119,7 +119,7 @@ public:
void redrawEventPixmapItem(DraggablePixmapItem *item);
qreal getEventOpacity(const Event *event) const;
void setPlayerViewSize(const QSize &size);
void setPlayerViewRect(const QRectF &rect);
void updateCursorRectPos(int x, int y);
void setCursorRectVisible(bool visible);

View File

@@ -256,8 +256,7 @@ public:
static QString getDynamicMapDefineName();
static QString getDynamicMapName();
static QString getEmptySpeciesName();
static QSize getViewDistance();
static QSize getMetatileViewDistance();
static QMargins getMetatileViewDistance();
static int getNumTilesPrimary() { return num_tiles_primary; }
static int getNumTilesTotal() { return num_tiles_total; }
static int getNumMetatilesPrimary() { return num_metatiles_primary; }

View File

@@ -10,7 +10,7 @@
class MovableRect : public QGraphicsRectItem
{
public:
MovableRect(bool *enabled, int width, int height, QRgb color);
MovableRect(bool *enabled, const QRectF &rect, const QRgb &color);
QRectF boundingRect() const override {
qreal penWidth = 4;
return QRectF(-penWidth,
@@ -31,6 +31,7 @@ public:
bool *enabled;
protected:
QRectF baseRect;
QRgb color;
};