Add player view size settings

This commit is contained in:
GriffinR 2025-02-20 12:01:55 -05:00
parent 366933e2b0
commit db24687360
9 changed files with 86 additions and 18 deletions

View File

@ -280,6 +280,49 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_PlayerViewSize">
<property name="title">
<string>Player View Size</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>
</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>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_Warning">
<property name="styleSheet">

View File

@ -331,8 +331,8 @@ public:
this->eventIconPaths.clear();
this->pokemonIconPaths.clear();
this->collisionSheetPath = QString();
this->collisionSheetWidth = 2;
this->collisionSheetHeight = 16;
this->collisionSheetSize = QSize(2, 16);
this->playerViewSize = QSize(240, 160);
this->blockMetatileIdMask = 0x03FF;
this->blockCollisionMask = 0x0C00;
this->blockElevationMask = 0xF000;
@ -408,8 +408,8 @@ public:
uint16_t unusedTileSplit;
bool mapAllowFlagsEnabled;
QString collisionSheetPath;
int collisionSheetWidth;
int collisionSheetHeight;
QSize collisionSheetSize;
QSize playerViewSize;
QList<uint32_t> warpBehaviors;
int maxEventsPerGroup;

View File

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

View File

@ -15,8 +15,8 @@ public:
qreal penWidth = 4;
return QRectF(-penWidth,
-penWidth,
30 * 8 + penWidth * 2,
20 * 8 + penWidth * 2);
this->rect().width() + penWidth * 2,
this->rect().height() + penWidth * 2);
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override {

View File

@ -832,9 +832,13 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
} else if (key == "collision_sheet_path") {
this->collisionSheetPath = value;
} else if (key == "collision_sheet_width") {
this->collisionSheetWidth = getConfigUint32(key, value, 1, Block::maxValue);
this->collisionSheetSize.setWidth(getConfigInteger(key, value, 1, Block::maxValue));
} else if (key == "collision_sheet_height") {
this->collisionSheetHeight = getConfigUint32(key, value, 1, Block::maxValue);
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 == "warp_behaviors") {
this->warpBehaviors.clear();
value.remove(" ");
@ -935,8 +939,10 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
map.insert("ident/"+defaultIdentifiers.value(i.key()).first, i.value());
}
map.insert("collision_sheet_path", this->collisionSheetPath);
map.insert("collision_sheet_width", QString::number(this->collisionSheetWidth));
map.insert("collision_sheet_height", QString::number(this->collisionSheetHeight));
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()));
QStringList warpBehaviorStrs;
for (const auto &value : this->warpBehaviors)
warpBehaviorStrs.append("0x" + QString("%1").arg(value, 2, 16, QChar('0')).toUpper());

View File

@ -1061,6 +1061,18 @@ 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);
if (ui->graphicsView_Map->scene())
ui->graphicsView_Map->scene()->update();
}
void Editor::updateCursorRectPos(int x, int y) {
if (this->playerViewRect)
this->playerViewRect->updateLocation(x, y);
@ -2338,8 +2350,8 @@ void Editor::setCollisionGraphics() {
// Users are not required to provide an image that gives an icon for every elevation/collision combination.
// Instead they tell us how many are provided in their image by specifying the number of columns and rows.
const int imgColumns = projectConfig.collisionSheetWidth;
const int imgRows = projectConfig.collisionSheetHeight;
const int imgColumns = projectConfig.collisionSheetSize.width();
const int imgRows = projectConfig.collisionSheetSize.height();
// Create a pixmap for the selector on the Collision tab. If a project was previously opened we'll also need to refresh the selector.
this->collisionSheetPixmap = QPixmap::fromImage(imgSheet).scaled(MovementPermissionsSelector::CellWidth * imgColumns,

View File

@ -1171,6 +1171,8 @@ bool MainWindow::setProjectUI() {
ui->newEventToolButton->setEventTypeVisible(Event::Type::SecretBase, projectConfig.eventSecretBaseEnabled);
ui->newEventToolButton->setEventTypeVisible(Event::Type::CloneObject, projectConfig.eventCloneObjectEnabled);
this->editor->setPlayerViewSize(projectConfig.playerViewSize);
editor->setCollisionGraphics();
ui->spinBox_SelectedElevation->setMaximum(Block::getMaxElevation());
ui->spinBox_SelectedCollision->setMaximum(Block::getMaxCollision());

View File

@ -3268,8 +3268,8 @@ void Project::applyParsedLimits() {
projectConfig.defaultMetatileId = qMin(projectConfig.defaultMetatileId, Block::getMaxMetatileId());
projectConfig.defaultElevation = qMin(projectConfig.defaultElevation, Block::getMaxElevation());
projectConfig.defaultCollision = qMin(projectConfig.defaultCollision, Block::getMaxCollision());
projectConfig.collisionSheetHeight = qMin(qMax(projectConfig.collisionSheetHeight, 1), Block::getMaxElevation() + 1);
projectConfig.collisionSheetWidth = qMin(qMax(projectConfig.collisionSheetWidth, 1), Block::getMaxCollision() + 1);
projectConfig.collisionSheetSize.setHeight(qMin(qMax(projectConfig.collisionSheetSize.height(), 1), Block::getMaxElevation() + 1));
projectConfig.collisionSheetSize.setWidth(qMin(qMax(projectConfig.collisionSheetSize.width(), 1), Block::getMaxCollision() + 1));
}
bool Project::hasUnsavedChanges() {

View File

@ -138,6 +138,8 @@ 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);
// 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.
@ -460,8 +462,8 @@ void ProjectSettingsEditor::refresh() {
ui->spinBox_FillMetatile->setValue(projectConfig.defaultMetatileId);
ui->spinBox_MapWidth->setValue(projectConfig.defaultMapSize.width());
ui->spinBox_MapHeight->setValue(projectConfig.defaultMapSize.height());
ui->spinBox_MaxElevation->setValue(projectConfig.collisionSheetHeight - 1);
ui->spinBox_MaxCollision->setValue(projectConfig.collisionSheetWidth - 1);
ui->spinBox_MaxElevation->setValue(projectConfig.collisionSheetSize.height() - 1);
ui->spinBox_MaxCollision->setValue(projectConfig.collisionSheetSize.width() - 1);
ui->spinBox_BehaviorMask->setValue(projectConfig.metatileBehaviorMask & ui->spinBox_BehaviorMask->maximum());
ui->spinBox_EncounterTypeMask->setValue(projectConfig.metatileEncounterTypeMask & ui->spinBox_EncounterTypeMask->maximum());
ui->spinBox_LayerTypeMask->setValue(projectConfig.metatileLayerTypeMask & ui->spinBox_LayerTypeMask->maximum());
@ -473,6 +475,8 @@ 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());
// Set (and sync) border metatile IDs
this->setBorderMetatileIds(false, projectConfig.newMapBorderMetatileIds);
@ -537,8 +541,7 @@ void ProjectSettingsEditor::save() {
projectConfig.defaultCollision = ui->spinBox_Collision->value();
projectConfig.defaultMetatileId = ui->spinBox_FillMetatile->value();
projectConfig.defaultMapSize = QSize(ui->spinBox_MapWidth->value(), ui->spinBox_MapHeight->value());
projectConfig.collisionSheetHeight = ui->spinBox_MaxElevation->value() + 1;
projectConfig.collisionSheetWidth = ui->spinBox_MaxCollision->value() + 1;
projectConfig.collisionSheetSize = QSize(ui->spinBox_MaxElevation->value() + 1, ui->spinBox_MaxCollision->value() + 1);
projectConfig.metatileBehaviorMask = ui->spinBox_BehaviorMask->value();
projectConfig.metatileTerrainTypeMask = ui->spinBox_TerrainTypeMask->value();
projectConfig.metatileEncounterTypeMask = ui->spinBox_EncounterTypeMask->value();
@ -550,6 +553,7 @@ 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());
// Save line edit settings
projectConfig.prefabFilepath = ui->lineEdit_PrefabsPath->text();