From 4187732baa3a7a75f28921ca072eec8c7a935ec2 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 25 Oct 2022 17:40:40 -0400 Subject: [PATCH 1/6] Default to Cancel for reload warning --- src/mainwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cdbb0734..e3ee72c6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -633,6 +633,7 @@ void MainWindow::on_action_Reload_Project_triggered() { warning.setText("WARNING"); warning.setInformativeText("Reloading this project will discard any unsaved changes."); warning.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + warning.setDefaultButton(QMessageBox::Cancel); warning.setIcon(QMessageBox::Warning); if (warning.exec() == QMessageBox::Ok) { From ce6abb0a8112ec745a77e763b8e029a3580a0ba4 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 25 Oct 2022 17:53:12 -0400 Subject: [PATCH 2/6] Default to No for file watcher prompt --- src/project.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/project.cpp b/src/project.cpp index 4b68be4a..a0fd661f 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -69,6 +69,7 @@ void Project::initSignals() { notice.setInformativeText(QString("The file %1 has changed on disk. Would you like to reload the project?") .arg(changed.remove(this->root + "/"))); notice.setStandardButtons(QMessageBox::No | QMessageBox::Yes); + notice.setDefaultButton(QMessageBox::No); notice.setIcon(QMessageBox::Question); QCheckBox showAgainCheck("Do not ask again."); From 37b56563763e4ccb00ffd8aa319f938d1adc6876 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 27 Oct 2022 22:11:10 -0400 Subject: [PATCH 3/6] Fix some crashes on project close --- include/ui/eventframes.h | 12 ------------ src/core/tileset.cpp | 15 +++++++++++---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/include/ui/eventframes.h b/include/ui/eventframes.h index a85a8f08..942b9179 100644 --- a/include/ui/eventframes.h +++ b/include/ui/eventframes.h @@ -67,10 +67,6 @@ public: ObjectFrame(ObjectEvent *object, QWidget *parent = nullptr) : EventFrame(object, parent), object(object) {} - virtual ~ObjectFrame() { - delete this->scriptCompleter; - } - virtual void setup() override; virtual void initialize() override; virtual void connectSignals() override; @@ -148,10 +144,6 @@ public: TriggerFrame(TriggerEvent *trigger, QWidget *parent = nullptr) : EventFrame(trigger, parent), trigger(trigger) {} - virtual ~TriggerFrame() { - delete this->scriptCompleter; - } - virtual void setup() override; virtual void initialize() override; virtual void connectSignals() override; @@ -198,10 +190,6 @@ public: SignFrame(SignEvent *sign, QWidget *parent = nullptr) : EventFrame(sign, parent), sign(sign) {} - virtual ~SignFrame() { - delete this->scriptCompleter; - } - virtual void setup() override; virtual void initialize() override; virtual void connectSignals() override; diff --git a/src/core/tileset.cpp b/src/core/tileset.cpp index adfb0a13..50623efd 100644 --- a/src/core/tileset.cpp +++ b/src/core/tileset.cpp @@ -18,12 +18,15 @@ Tileset::Tileset(const Tileset &other) metatile_attrs_label(other.metatile_attrs_label), metatile_attrs_path(other.metatile_attrs_path), tilesImagePath(other.tilesImagePath), - tilesImage(other.tilesImage), + tilesImage(other.tilesImage.copy()), palettePaths(other.palettePaths), - tiles(other.tiles), palettes(other.palettes), palettePreviews(other.palettePreviews) { + for (auto tile : other.tiles) { + tiles.append(tile.copy()); + } + for (auto *metatile : other.metatiles) { metatiles.append(new Metatile(*metatile)); } @@ -39,12 +42,16 @@ Tileset &Tileset::operator=(const Tileset &other) { metatile_attrs_label = other.metatile_attrs_label; metatile_attrs_path = other.metatile_attrs_path; tilesImagePath = other.tilesImagePath; - tilesImage = other.tilesImage; + tilesImage = other.tilesImage.copy(); palettePaths = other.palettePaths; - tiles = other.tiles; palettes = other.palettes; palettePreviews = other.palettePreviews; + tiles.clear(); + for (auto tile : other.tiles) { + tiles.append(tile.copy()); + } + metatiles.clear(); for (auto *metatile : other.metatiles) { metatiles.append(new Metatile(*metatile)); From 15e69dc9e773e62f2c629813ac1f939d7ca755a0 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 28 Oct 2022 13:25:04 -0400 Subject: [PATCH 4/6] Enforce border max for new maps --- src/ui/newmappopup.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ui/newmappopup.cpp b/src/ui/newmappopup.cpp index 31d85954..3c2545b2 100644 --- a/src/ui/newmappopup.cpp +++ b/src/ui/newmappopup.cpp @@ -42,6 +42,8 @@ void NewMapPopup::init() { ui->spinBox_NewMap_Height->setMaximum(project->getMaxMapHeight()); ui->spinBox_NewMap_BorderWidth->setMinimum(1); ui->spinBox_NewMap_BorderHeight->setMinimum(1); + ui->spinBox_NewMap_BorderWidth->setMaximum(MAX_BORDER_WIDTH); + ui->spinBox_NewMap_BorderHeight->setMaximum(MAX_BORDER_HEIGHT); ui->spinBox_NewMap_Floor_Number->setMinimum(-128); ui->spinBox_NewMap_Floor_Number->setMaximum(127); From fa859a691f404fddb7f75621528d50ce7345b61c Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 29 Oct 2022 10:57:08 -0400 Subject: [PATCH 5/6] Fix minimum connection bounds --- CHANGELOG.md | 1 + src/editor.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7992a51b..555fc370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix Border Width/Height being set to 0 when creating a new map from an existing layout. - Fix certain UI elements not highlighting red on some platforms. - Fix Open Config Folder not responding +- Properly update the minimum offset for a connection when the map is changed. ## [4.5.0] - 2021-12-26 ### Added diff --git a/src/editor.cpp b/src/editor.cpp index 69a501b5..21873fd7 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1753,6 +1753,12 @@ void Editor::setConnectionMap(QString mapName) { setConnectionEditControlsEnabled(true); selected_connection_item->connection->map_name = mapName; setCurrentConnectionDirection(selected_connection_item->connection->direction); + + // New map may have a different minimum offset than the last one. The maximum will be the same. + int min = selected_connection_item->getMinOffset(); + ui->spinBox_ConnectionOffset->setMinimum(min); + onConnectionOffsetChanged(qMax(min, selected_connection_item->connection->offset)); + updateMirroredConnectionMap(selected_connection_item->connection, originalMapName); maskNonVisibleConnectionTiles(); } From f0c793424cc0e0c81fe9af4700c821a164deed52 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 29 Oct 2022 11:41:09 -0400 Subject: [PATCH 6/6] Allow number values in the Metatile Behavior field --- CHANGELOG.md | 2 +- include/ui/tileseteditor.h | 2 +- src/ui/tileseteditor.cpp | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 555fc370..a0a7e638 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - The heal location prefixes `SPAWN_` and `HEAL_LOCATION_` may now be used interchangeably. - The number and order of entries in the heal location data tables can now be changed arbitrarily, and independently of each other. - The metatile behavior is now displayed in the bottom bar mouseover text. +- Number values are now allowed in the Tileset Editor's Metatile Behavior field. - Removed some unnecessary error logs from the scripting API and added new useful ones. - If any JSON data is the incorrect type Porymap will now attempt to convert it. @@ -62,7 +63,6 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix drawing large amounts of text with the scripting API causing a significant drop in performance. - Silence unnecessary error logging when parsing C defines Porymap doesn't use. - Fix some windows like the Tileset Editor not raising to the front when reactivated. -- Metatile behaviors with no constant will now display their value in the Tileset Editor. - Fix incorrect limits on Floor Number and Border Width/Height in the New Map Options window. - Fix Border Width/Height being set to 0 when creating a new map from an existing layout. - Fix certain UI elements not highlighting red on some platforms. diff --git a/include/ui/tileseteditor.h b/include/ui/tileseteditor.h index 29912e4d..9ac4bf9f 100644 --- a/include/ui/tileseteditor.h +++ b/include/ui/tileseteditor.h @@ -85,7 +85,7 @@ private slots: void on_actionRedo_triggered(); - void on_comboBox_metatileBehaviors_textActivated(const QString &arg1); + void on_comboBox_metatileBehaviors_currentTextChanged(const QString &arg1); void on_lineEdit_metatileLabel_editingFinished(); diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index 14e9d441..cf6203cb 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -497,11 +497,26 @@ void TilesetEditor::on_checkBox_yFlip_stateChanged(int checked) this->metatileLayersItem->clearLastModifiedCoords(); } -void TilesetEditor::on_comboBox_metatileBehaviors_textActivated(const QString &metatileBehavior) +void TilesetEditor::on_comboBox_metatileBehaviors_currentTextChanged(const QString &metatileBehavior) { if (this->metatile) { + int behavior; + if (project->metatileBehaviorMap.contains(metatileBehavior)) { + behavior = project->metatileBehaviorMap[metatileBehavior]; + } else { + // Check if user has entered a number value instead + bool ok; + behavior = metatileBehavior.toInt(&ok, 0); + if (!ok) return; + } + + // This function can also be called when the user selects + // a different metatile. Stop this from being considered a change. + if (this->metatile->behavior == static_cast(behavior)) + return; + Metatile *prevMetatile = new Metatile(*this->metatile); - this->metatile->behavior = static_cast(project->metatileBehaviorMap[metatileBehavior]); + this->metatile->behavior = behavior; MetatileHistoryItem *commit = new MetatileHistoryItem(this->getSelectedMetatileId(), prevMetatile, new Metatile(*this->metatile)); metatileHistory.push(commit);