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

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>631</width>
<height>600</height>
<width>642</width>
<height>609</height>
</rect>
</property>
<property name="windowTitle">
@@ -38,8 +38,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<height>589</height>
<width>570</width>
<height>692</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@@ -281,44 +281,86 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_PlayerViewSize">
<widget class="QGroupBox" name="groupBox_PlayerViewDistance">
<property name="title">
<string>Player View Size</string>
<string>Player View Distance</string>
</property>
<layout class="QFormLayout" name="formLayout_PlayerViewSize">
<item row="0" column="0">
<widget class="QLabel" name="label_PlayerViewWidth">
<property name="text">
<string>Width</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QFormLayout" name="formLayout_PlayerViewDistanceCol1">
<item row="0" column="0">
<widget class="QLabel" name="label_PlayerViewDistance_North">
<property name="text">
<string>North</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_PlayerViewDistance_South">
<property name="text">
<string>South</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="NoScrollSpinBox" name="spinBox_PlayerViewDistance_North">
<property name="minimum">
<number>0</number>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The distance (in pixels) that a player is able to see North of their character's position in-game. By default this is the distance from the center 16x16 to the edge of the 160 pixel tall GBA screen.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="NoScrollSpinBox" name="spinBox_PlayerViewDistance_South">
<property name="minimum">
<number>0</number>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The distance (in pixels) that a player is able to see South of their character's position in-game. By default this is the distance from the center 16x16 to the edge of the 160 pixel tall GBA screen.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="NoScrollSpinBox" name="spinBox_PlayerViewWidth">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The horizontal size in pixels of the area that the player can see in-game (normally, the full width of the GBA screen).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum">
<number>16</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_PlayerViewHeight">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="NoScrollSpinBox" name="spinBox_PlayerViewHeight">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The vertical size in pixels of the area that the player can see in-game (normally, the full height of the GBA screen).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum">
<number>16</number>
</property>
</widget>
<item>
<layout class="QFormLayout" name="formLayout_PlayerViewDistanceCol2">
<item row="0" column="0">
<widget class="QLabel" name="label_PlayerViewDistance_West">
<property name="text">
<string>West</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_PlayerViewDistance_East">
<property name="text">
<string>East</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="NoScrollSpinBox" name="spinBox_PlayerViewDistance_West">
<property name="minimum">
<number>0</number>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The distance (in pixels) that a player is able to see West of their character's position in-game. By default this is the distance from the center 16x16 to the edge of the 240 pixel wide GBA screen.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="NoScrollSpinBox" name="spinBox_PlayerViewDistance_East">
<property name="minimum">
<number>0</number>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The distance (in pixels) that a player is able to see East of their character's position in-game. By default this is the distance from the center 16x16 to the edge of the 240 pixel wide GBA screen.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
@@ -421,7 +463,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<width>561</width>
<height>622</height>
</rect>
</property>
@@ -792,7 +834,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<width>561</width>
<height>798</height>
</rect>
</property>
@@ -1134,7 +1176,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<width>561</width>
<height>840</height>
</rect>
</property>
@@ -1516,8 +1558,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<height>490</height>
<width>561</width>
<height>593</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
@@ -1563,8 +1605,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>533</width>
<height>428</height>
<width>535</width>
<height>531</height>
</rect>
</property>
<layout class="QFormLayout" name="layout_ProjectPaths">
@@ -1605,8 +1647,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<height>490</height>
<width>561</width>
<height>593</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_19">
@@ -1652,8 +1694,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>533</width>
<height>428</height>
<width>535</width>
<height>531</height>
</rect>
</property>
<layout class="QFormLayout" name="layout_Identifiers">

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;
};

View File

@@ -18,6 +18,12 @@
#include <QAction>
#include <QAbstractButton>
const QVersionNumber porymapVersion = QVersionNumber::fromString(PORYMAP_VERSION);
// In both versions the default new map border is a generic tree
const QList<uint16_t> defaultBorder_RSE = {0x1D4, 0x1D5, 0x1DC, 0x1DD};
const QList<uint16_t> defaultBorder_FRLG = {0x14, 0x15, 0x1C, 0x1D};
const QList<uint32_t> defaultWarpBehaviors_RSE = {
0x0E, // MB_MOSSDEEP_GYM_WARP
0x0F, // MB_MT_PYRE_HOLE
@@ -835,10 +841,14 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
this->collisionSheetSize.setWidth(getConfigInteger(key, value, 1, Block::maxValue));
} else if (key == "collision_sheet_height") {
this->collisionSheetSize.setHeight(getConfigInteger(key, value, 1, Block::maxValue));
} else if (key == "player_view_width") {
this->playerViewSize.setWidth(getConfigInteger(key, value, 16, INT_MAX, 240));
} else if (key == "player_view_height") {
this->playerViewSize.setHeight(getConfigInteger(key, value, 16, INT_MAX, 160));
} else if (key == "player_view_north") {
this->playerViewDistance.setTop(getConfigInteger(key, value, 0, INT_MAX, GBA_V_DIST_TO_CENTER));
} else if (key == "player_view_south") {
this->playerViewDistance.setBottom(getConfigInteger(key, value, 0, INT_MAX, GBA_V_DIST_TO_CENTER));
} else if (key == "player_view_west") {
this->playerViewDistance.setLeft(getConfigInteger(key, value, 0, INT_MAX, GBA_H_DIST_TO_CENTER));
} else if (key == "player_view_east") {
this->playerViewDistance.setRight(getConfigInteger(key, value, 0, INT_MAX, GBA_H_DIST_TO_CENTER));
} else if (key == "warp_behaviors") {
this->warpBehaviors.clear();
value.remove(" ");
@@ -872,7 +882,7 @@ void ProjectConfig::setUnreadKeys() {
if (!readKeys.contains("enable_event_clone_object")) this->eventCloneObjectEnabled = isPokefirered;
if (!readKeys.contains("enable_floor_number")) this->floorNumberEnabled = isPokefirered;
if (!readKeys.contains("create_map_text_file")) this->createMapTextFileEnabled = (this->baseGameVersion != BaseGameVersion::pokeemerald);
if (!readKeys.contains("new_map_border_metatiles")) this->newMapBorderMetatileIds = isPokefirered ? DEFAULT_BORDER_FRLG : DEFAULT_BORDER_RSE;
if (!readKeys.contains("new_map_border_metatiles")) this->newMapBorderMetatileIds = isPokefirered ? defaultBorder_FRLG : defaultBorder_RSE;
if (!readKeys.contains("default_secondary_tileset")) this->defaultSecondaryTileset = isPokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg";
if (!readKeys.contains("metatile_attributes_size")) this->metatileAttributesSize = Metatile::getDefaultAttributesSize(this->baseGameVersion);
if (!readKeys.contains("metatile_behavior_mask")) this->metatileBehaviorMask = Metatile::getDefaultAttributesMask(this->baseGameVersion, Metatile::Attr::Behavior);
@@ -941,8 +951,10 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
map.insert("collision_sheet_path", this->collisionSheetPath);
map.insert("collision_sheet_width", QString::number(this->collisionSheetSize.width()));
map.insert("collision_sheet_height", QString::number(this->collisionSheetSize.height()));
map.insert("player_view_width", QString::number(this->playerViewSize.width()));
map.insert("player_view_height", QString::number(this->playerViewSize.height()));
map.insert("player_view_north", QString::number(this->playerViewDistance.top()));
map.insert("player_view_south", QString::number(this->playerViewDistance.bottom()));
map.insert("player_view_west", QString::number(this->playerViewDistance.left()));
map.insert("player_view_east", QString::number(this->playerViewDistance.right()));
QStringList warpBehaviorStrs;
for (const auto &value : this->warpBehaviors)
warpBehaviorStrs.append("0x" + QString("%1").arg(value, 2, 16, QChar('0')).toUpper());

View File

@@ -83,17 +83,17 @@ QRect Map::getConnectionRect(const QString &direction, Layout * fromLayout) cons
int x = 0, y = 0;
int w = getWidth(), h = getHeight();
QSize viewDistance = Project::getMetatileViewDistance();
QMargins viewDistance = Project::getMetatileViewDistance();
if (direction == "up") {
h = qMin(h, viewDistance.height());
h = qMin(h, viewDistance.top());
y = getHeight() - h;
} else if (direction == "down") {
h = qMin(h, viewDistance.height());
h = qMin(h, viewDistance.bottom());
} else if (direction == "left") {
w = qMin(w, viewDistance.width());
w = qMin(w, viewDistance.left());
x = getWidth() - w;
} else if (direction == "right") {
w = qMin(w, viewDistance.width());
w = qMin(w, viewDistance.right());
} else if (MapConnection::isDiving(direction)) {
if (fromLayout) {
w = qMin(w, fromLayout->getWidth());

View File

@@ -63,14 +63,6 @@ bool Layout::isWithinBorderBounds(int x, int y) const {
return (x >= 0 && x < this->getBorderWidth() && y >= 0 && y < this->getBorderHeight());
}
int Layout::getBorderDrawWidth() const {
return getBorderDrawDistance(border_width, Project::getMetatileViewDistance().width());
}
int Layout::getBorderDrawHeight() const {
return getBorderDrawDistance(border_height, Project::getMetatileViewDistance().height());
}
// Calculate the distance away from the layout's edge that we need to start drawing border blocks.
// We need to fulfill two requirements here:
// - We should draw enough to fill the player's in-game view
@@ -83,13 +75,22 @@ int Layout::getBorderDrawDistance(int dimension, qreal minimum) {
// Get first multiple of dimension >= the minimum
return dimension * qCeil(minimum / qMax(dimension, 1));
}
QMargins Layout::getBorderMargins() const {
QMargins minimum = Project::getMetatileViewDistance();
QMargins distance;
distance.setTop(getBorderDrawDistance(this->border_height, minimum.top()));
distance.setBottom(getBorderDrawDistance(this->border_height, minimum.bottom()));
distance.setLeft(getBorderDrawDistance(this->border_width, minimum.left()));
distance.setRight(getBorderDrawDistance(this->border_width, minimum.right()));
return distance;
}
// Get a rectangle that represents (in pixels) the layout's map area and the visible area of its border.
// At maximum, this is equal to the map size plus the border margins.
// If the border is large (and so beyond player the view) it may be smaller than that.
QRect Layout::getVisibleRect() const {
QRect area = QRect(0, 0, this->width * 16, this->height * 16);
QSize viewDistance = Project::getMetatileViewDistance() * 16;
area += QMargins(viewDistance.width(), viewDistance.height(), viewDistance.width(), viewDistance.height());
return area;
return area += (Project::getMetatileViewDistance() * 16);
}
bool Layout::getBlock(int x, int y, Block *out) {

View File

@@ -30,7 +30,6 @@ Editor::Editor(Ui::MainWindow* ui)
{
this->ui = ui;
this->settings = new Settings();
this->playerViewRect = new MovableRect(&this->settings->playerViewRectEnabled, 30 * 8, 20 * 8, qRgb(255, 255, 255));
this->cursorMapTileRect = new CursorTileRect(&this->settings->cursorTileRectEnabled, qRgb(255, 255, 255));
this->map_ruler = new MapRuler(4);
connect(this->map_ruler, &MapRuler::statusChanged, this, &Editor::mapRulerStatusChanged);
@@ -1061,14 +1060,9 @@ void Editor::scaleMapView(int s) {
ui->graphicsView_Connections->setTransform(transform);
}
void Editor::setPlayerViewSize(const QSize &size) {
if (!this->playerViewRect)
return;
auto rect = this->playerViewRect->rect();
rect.setWidth(qMax(size.width(), 16));
rect.setHeight(qMax(size.height(), 16));
this->playerViewRect->setRect(rect);
void Editor::setPlayerViewRect(const QRectF &rect) {
delete this->playerViewRect;
this->playerViewRect = new MovableRect(&this->settings->playerViewRectEnabled, rect, qRgb(255, 255, 255));
if (ui->graphicsView_Map->scene())
ui->graphicsView_Map->scene()->update();
}
@@ -1794,11 +1788,10 @@ void Editor::clearMapBorder() {
void Editor::displayMapBorder() {
clearMapBorder();
int borderHorzDist = this->layout->getBorderDrawWidth();
int borderVertDist = this->layout->getBorderDrawHeight();
QPixmap pixmap = this->layout->renderBorder();
for (int y = -borderVertDist; y < this->layout->getHeight() + borderVertDist; y += this->layout->getBorderHeight())
for (int x = -borderHorzDist; x < this->layout->getWidth() + borderHorzDist; x += this->layout->getBorderWidth()) {
const QMargins borderMargins = layout->getBorderMargins();
for (int y = -borderMargins.top(); y < this->layout->getHeight() + borderMargins.bottom(); y += this->layout->getBorderHeight())
for (int x = -borderMargins.left(); x < this->layout->getWidth() + borderMargins.right(); x += this->layout->getBorderWidth()) {
QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap);
item->setX(x * 16);
item->setY(y * 16);

View File

@@ -1171,7 +1171,7 @@ bool MainWindow::setProjectUI() {
ui->newEventToolButton->setEventTypeVisible(Event::Type::SecretBase, projectConfig.eventSecretBaseEnabled);
ui->newEventToolButton->setEventTypeVisible(Event::Type::CloneObject, projectConfig.eventCloneObjectEnabled);
this->editor->setPlayerViewSize(projectConfig.playerViewSize);
this->editor->setPlayerViewRect(QRectF(0, 0, 16, 16).marginsAdded(projectConfig.playerViewDistance));
editor->setCollisionGraphics();
ui->spinBox_SelectedElevation->setMaximum(Block::getMaxElevation());

View File

@@ -3235,18 +3235,14 @@ QString Project::getEmptySpeciesName() {
return projectConfig.getIdentifier(ProjectIdentifier::define_species_prefix) + projectConfig.getIdentifier(ProjectIdentifier::define_species_empty);
}
// Get the distance in pixels that the player is able to see from the space they're standing on.
// For the default size of the view area (i.e. the full 240x160 GBA screen) this is 112x72.
QSize Project::getViewDistance() {
return ((projectConfig.playerViewSize) - QSize(16,16)) / 2;
}
// Get the distance in metatiles that the player is able to see from the space they're standing on, rounded up.
// For the default size of the view area (i.e. the full 240x160 GBA screen) this is 7x5 metatiles.
QSize Project::getMetatileViewDistance() {
QSize viewDistance = getViewDistance();
viewDistance.setWidth(qCeil(viewDistance.width() / 16.0));
viewDistance.setHeight(qCeil(viewDistance.height() / 16.0));
// Get the distance in metatiles (rounded up) that the player is able to see in each direction in-game.
// For the default view distance (i.e. assuming the player is centered in a 240x160 pixel GBA screen) this is 7x5 metatiles.
QMargins Project::getMetatileViewDistance() {
QMargins viewDistance = projectConfig.playerViewDistance;
viewDistance.setTop(qCeil(viewDistance.top() / 16.0));
viewDistance.setBottom(qCeil(viewDistance.bottom() / 16.0));
viewDistance.setLeft(qCeil(viewDistance.left() / 16.0));
viewDistance.setRight(qCeil(viewDistance.right() / 16.0));
return viewDistance;
}

View File

@@ -606,11 +606,7 @@ QPixmap MapImageExporter::getFormattedMapPixmap() {
QMargins MapImageExporter::getMargins(const Map *map) {
QMargins margins;
if (m_settings.showBorder) {
// When we render map borders we render them in full increments of the border dimensions.
// This means for large border dimensions the painted area of the border may extend well beyond the area the player can see.
// When we call paintBorder we will clip the painting to this visible area, so we only need to consider the visible area here.
QSize viewDistance = m_project->getMetatileViewDistance() * 16;
margins = QMargins(viewDistance.width(), viewDistance.height(), viewDistance.width(), viewDistance.height());
margins = m_project->getMetatileViewDistance() * 16;
} else if (map && connectionsEnabled()) {
for (const auto &connection : map->getConnections()) {
const QString dir = connection->direction();
@@ -654,10 +650,9 @@ void MapImageExporter::paintBorder(QPainter *painter, Layout *layout) {
painter->save();
painter->setClipRect(layout->getVisibleRect());
int borderHorzDist = layout->getBorderDrawWidth();
int borderVertDist = layout->getBorderDrawHeight();
for (int y = -borderVertDist; y < layout->getHeight() + borderVertDist; y += layout->getBorderHeight())
for (int x = -borderHorzDist; x < layout->getWidth() + borderHorzDist; x += layout->getBorderWidth()) {
const QMargins borderMargins = layout->getBorderMargins();
for (int y = -borderMargins.top(); y < layout->getHeight() + borderMargins.bottom(); y += layout->getBorderHeight())
for (int x = -borderMargins.left(); x < layout->getWidth() + borderMargins.right(); x += layout->getBorderWidth()) {
// Skip border painting if it would be fully covered by the rest of the map
if (layout->isWithinBounds(QRect(x, y, layout->getBorderWidth(), layout->getBorderHeight())))
continue;

View File

@@ -5,17 +5,21 @@
#include "movablerect.h"
#include "utility.h"
MovableRect::MovableRect(bool *enabled, int width, int height, QRgb color)
: QGraphicsRectItem(0, 0, width, height)
MovableRect::MovableRect(bool *enabled, const QRectF &rect, const QRgb &color)
: QGraphicsRectItem(rect),
enabled(enabled),
baseRect(rect),
color(color)
{
this->enabled = enabled;
this->color = color;
this->setVisible(*enabled);
}
/// Center rect on grid position (x, y)
void MovableRect::updateLocation(int x, int y) {
this->setRect((x * 16) - this->rect().width() / 2 + 8, (y * 16) - this->rect().height() / 2 + 8, this->rect().width(), this->rect().height());
this->setRect(this->baseRect.x() + (x * 16),
this->baseRect.y() + (y * 16),
this->baseRect.width(),
this->baseRect.height());
this->setVisible(*this->enabled);
}
@@ -25,7 +29,7 @@ void MovableRect::updateLocation(int x, int y) {
ResizableRect::ResizableRect(QObject *parent, bool *enabled, int width, int height, QRgb color)
: QObject(parent),
MovableRect(enabled, width * 16, height * 16, color)
MovableRect(enabled, QRect(0, 0, width * 16, height * 16), color)
{
setZValue(0xFFFFFFFF); // ensure on top of view
setAcceptHoverEvents(true);

View File

@@ -138,8 +138,10 @@ void ProjectSettingsEditor::initUi() {
ui->spinBox_MaxEvents->setMaximum(INT_MAX);
ui->spinBox_MapWidth->setMaximum(INT_MAX);
ui->spinBox_MapHeight->setMaximum(INT_MAX);
ui->spinBox_PlayerViewWidth->setMaximum(INT_MAX);
ui->spinBox_PlayerViewHeight->setMaximum(INT_MAX);
ui->spinBox_PlayerViewDistance_West->setMaximum(INT_MAX);
ui->spinBox_PlayerViewDistance_North->setMaximum(INT_MAX);
ui->spinBox_PlayerViewDistance_East->setMaximum(INT_MAX);
ui->spinBox_PlayerViewDistance_South->setMaximum(INT_MAX);
// The values for some of the settings we provide in this window can be determined using constants in the user's projects.
// If the user has these constants we disable these settings in the UI -- they can modify them using their constants.
@@ -475,8 +477,10 @@ void ProjectSettingsEditor::refresh() {
ui->spinBox_UnusedTileCovered->setValue(projectConfig.unusedTileCovered);
ui->spinBox_UnusedTileSplit->setValue(projectConfig.unusedTileSplit);
ui->spinBox_MaxEvents->setValue(projectConfig.maxEventsPerGroup);
ui->spinBox_PlayerViewWidth->setValue(projectConfig.playerViewSize.width());
ui->spinBox_PlayerViewHeight->setValue(projectConfig.playerViewSize.height());
ui->spinBox_PlayerViewDistance_West->setValue(projectConfig.playerViewDistance.left());
ui->spinBox_PlayerViewDistance_North->setValue(projectConfig.playerViewDistance.top());
ui->spinBox_PlayerViewDistance_East->setValue(projectConfig.playerViewDistance.right());
ui->spinBox_PlayerViewDistance_South->setValue(projectConfig.playerViewDistance.bottom());
// Set (and sync) border metatile IDs
this->setBorderMetatileIds(false, projectConfig.newMapBorderMetatileIds);
@@ -553,7 +557,10 @@ void ProjectSettingsEditor::save() {
projectConfig.unusedTileCovered = ui->spinBox_UnusedTileCovered->value();
projectConfig.unusedTileSplit = ui->spinBox_UnusedTileSplit->value();
projectConfig.maxEventsPerGroup = ui->spinBox_MaxEvents->value();
projectConfig.playerViewSize = QSize(ui->spinBox_PlayerViewWidth->value(), ui->spinBox_PlayerViewHeight->value());
projectConfig.playerViewDistance = QMargins(ui->spinBox_PlayerViewDistance_West->value(),
ui->spinBox_PlayerViewDistance_North->value(),
ui->spinBox_PlayerViewDistance_East->value(),
ui->spinBox_PlayerViewDistance_South->value());
// Save line edit settings
projectConfig.prefabFilepath = ui->lineEdit_PrefabsPath->text();