diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d64777f..984f3879 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Redesigned the new map dialog, including better error checking and a collapsible section for header data. - New maps/layouts are no longer saved automatically, and can be fully discarded by closing without saving. - Map groups and ``MAPSEC`` names specified when creating a new map will be added automatically if they don't already exist. +- Custom fields in JSON files that Porymap writes are no longer discarded. - Edits to map connections now have Undo/Redo and can be viewed in exported timelapses. - Changes to the "Mirror to Connecting Maps" setting will now be saved between sessions. - A notice will be displayed when attempting to open the "Dynamic" map, rather than nothing happening. diff --git a/include/core/utility.h b/include/core/utility.h index 1b9277ab..6613ee71 100644 --- a/include/core/utility.h +++ b/include/core/utility.h @@ -9,6 +9,7 @@ namespace Util { int roundUp(int numToRound, int multiple); QString toDefineCase(QString input); QString toHexString(uint32_t value, int minLength = 0); + Qt::Orientations getOrientation(bool xflip, bool yflip); } #endif // UTILITY_H diff --git a/include/mainwindow.h b/include/mainwindow.h index 370fd40a..832d51ee 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -248,8 +248,6 @@ private slots: void on_comboBox_PrimaryTileset_currentTextChanged(const QString &arg1); void on_comboBox_SecondaryTileset_currentTextChanged(const QString &arg1); void on_pushButton_ChangeDimensions_clicked(); - void on_checkBox_smartPaths_stateChanged(int selected); - void on_checkBox_ToggleBorder_stateChanged(int selected); void resetMapViewScale(); @@ -260,7 +258,6 @@ private slots: void eventTabChanged(int index); - void on_checkBox_MirrorConnections_stateChanged(int selected); void on_actionDive_Emerge_Map_triggered(); void on_actionShow_Events_In_Map_View_triggered(); void on_groupBox_DiveMapOpacity_toggled(bool on); @@ -437,6 +434,10 @@ private: void checkForUpdates(bool requestedByUser); void setDivingMapsVisible(bool visible); + + void setSmartPathsEnabled(bool enabled); + void setBorderVisibility(bool visible); + void setMirrorConnectionsEnabled(bool enabled); }; // These are namespaced in a struct to avoid colliding with e.g. class Map. diff --git a/include/ui/mapheaderform.h b/include/ui/mapheaderform.h index 79f4f6c8..7f246d6d 100644 --- a/include/ui/mapheaderform.h +++ b/include/ui/mapheaderform.h @@ -73,11 +73,11 @@ private: void onWeatherChanged(const QString &weather); void onTypeChanged(const QString &type); void onBattleSceneChanged(const QString &battleScene); - void onRequiresFlashChanged(int selected); - void onShowLocationNameChanged(int selected); - void onAllowRunningChanged(int selected); - void onAllowBikingChanged(int selected); - void onAllowEscapingChanged(int selected); + void onRequiresFlashChanged(bool enabled); + void onShowLocationNameChanged(bool enabled); + void onAllowRunningChanged(bool enabled); + void onAllowBikingChanged(bool enabled); + void onAllowEscapingChanged(bool enabled); void onFloorNumberChanged(int offset); }; diff --git a/include/ui/mapimageexporter.h b/include/ui/mapimageexporter.h index ffc4d272..51c1afe3 100644 --- a/include/ui/mapimageexporter.h +++ b/include/ui/mapimageexporter.h @@ -91,30 +91,27 @@ protected: virtual void showEvent(QShowEvent *) override; virtual void resizeEvent(QResizeEvent *) override; -private slots: - void on_checkBox_Objects_stateChanged(int state); - void on_checkBox_Warps_stateChanged(int state); - void on_checkBox_BGs_stateChanged(int state); - void on_checkBox_Triggers_stateChanged(int state); - void on_checkBox_HealLocations_stateChanged(int state); - void on_checkBox_AllEvents_stateChanged(int state); - - void on_checkBox_ConnectionUp_stateChanged(int state); - void on_checkBox_ConnectionDown_stateChanged(int state); - void on_checkBox_ConnectionLeft_stateChanged(int state); - void on_checkBox_ConnectionRight_stateChanged(int state); - void on_checkBox_AllConnections_stateChanged(int state); - - void on_checkBox_Collision_stateChanged(int state); - void on_checkBox_Grid_stateChanged(int state); - void on_checkBox_Border_stateChanged(int state); +private: + void setShowGrid(bool checked); + void setShowBorder(bool checked); + void setShowObjects(bool checked); + void setShowWarps(bool checked); + void setShowBgs(bool checked); + void setShowTriggers(bool checked); + void setShowHealLocations(bool checked); + void setShowAllEvents(bool checked); + void setShowConnectionUp(bool checked); + void setShowConnectionDown(bool checked); + void setShowConnectionLeft(bool checked); + void setShowConnectionRight(bool checked); + void setShowAllConnections(bool checked); + void setShowCollision(bool checked); + void setDisablePreviewScaling(bool checked); + void setDisablePreviewUpdates(bool checked); void on_pushButton_Reset_pressed(); void on_spinBox_TimelapseDelay_editingFinished(); void on_spinBox_FrameSkip_editingFinished(); - - void on_checkBox_DisablePreviewScaling_stateChanged(int state); - void on_checkBox_DisablePreviewUpdates_stateChanged(int state); }; #endif // MAPIMAGEEXPORTER_H diff --git a/include/ui/regionmapeditor.h b/include/ui/regionmapeditor.h index 8ecf0a76..432eaab6 100644 --- a/include/ui/regionmapeditor.h +++ b/include/ui/regionmapeditor.h @@ -121,6 +121,9 @@ private: void restoreWindowState(); void closeEvent(QCloseEvent* event); + void setTileHFlip(bool enabled); + void setTileVFlip(bool enabled); + private slots: void on_action_RegionMap_Save_triggered(); void on_actionSave_All_triggered(); @@ -145,8 +148,6 @@ private slots: void on_spinBox_RM_LayoutWidth_valueChanged(int); void on_spinBox_RM_LayoutHeight_valueChanged(int); void on_spinBox_tilePalette_valueChanged(int); - void on_checkBox_tileHFlip_stateChanged(int); - void on_checkBox_tileVFlip_stateChanged(int); void on_verticalSlider_Zoom_Map_Image_valueChanged(int); void on_verticalSlider_Zoom_Image_Tiles_valueChanged(int); void onHoveredRegionMapTileChanged(int x, int y); diff --git a/include/ui/shortcut.h b/include/ui/shortcut.h index 8989401d..5fdbfaee 100644 --- a/include/ui/shortcut.h +++ b/include/ui/shortcut.h @@ -49,9 +49,6 @@ public: void setAutoRepeat(bool on); bool autoRepeat() const; - int id() const; - QList ids() const; - inline QWidget *parentWidget() const { return static_cast(QObject::parent()); } diff --git a/include/ui/tileseteditor.h b/include/ui/tileseteditor.h index d659390a..fdd4751c 100644 --- a/include/ui/tileseteditor.h +++ b/include/ui/tileseteditor.h @@ -71,10 +71,6 @@ private slots: void on_spinBox_paletteSelector_valueChanged(int arg1); - void on_checkBox_xFlip_stateChanged(int arg1); - - void on_checkBox_yFlip_stateChanged(int arg1); - void on_actionSave_Tileset_triggered(); void on_actionImport_Primary_Tiles_triggered(); @@ -149,6 +145,8 @@ private: void commitTerrainType(); void commitLayerType(); void setRawAttributesVisible(bool visible); + void setXFlip(bool enabled); + void setYFlip(bool enabled); Ui::TilesetEditor *ui; History metatileHistory; diff --git a/src/core/utility.cpp b/src/core/utility.cpp index 1053f879..55830b8a 100644 --- a/src/core/utility.cpp +++ b/src/core/utility.cpp @@ -42,3 +42,10 @@ QString Util::toDefineCase(QString input) { QString Util::toHexString(uint32_t value, int minLength) { return "0x" + QString("%1").arg(value, minLength, 16, QChar('0')).toUpper(); } + +Qt::Orientations Util::getOrientation(bool xflip, bool yflip) { + Qt::Orientations flags; + if (xflip) flags |= Qt::Orientation::Horizontal; + if (yflip) flags |= Qt::Orientation::Vertical; + return flags; +} diff --git a/src/editor.cpp b/src/editor.cpp index cf9dd632..6230771a 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -296,8 +296,8 @@ void Editor::addNewWildMonGroup(QWidget *window) { form.addRow(new QLabel(monField.name), fieldCheckbox); } // Reading from ui here so not saving to disk before user. - connect(copyCheckbox, &QCheckBox::stateChanged, [=](int state){ - if (state == Qt::Checked) { + connect(copyCheckbox, &QCheckBox::toggled, [=](bool checked){ + if (checked) { int fieldIndex = 0; MonTabWidget *monWidget = static_cast(stack->widget(stack->currentIndex())); for (EncounterField monField : project->wildMonFields) { @@ -305,7 +305,7 @@ void Editor::addNewWildMonGroup(QWidget *window) { fieldCheckboxes[fieldIndex]->setEnabled(false); fieldIndex++; } - } else if (state == Qt::Unchecked) { + } else { int fieldIndex = 0; for (EncounterField monField : project->wildMonFields) { fieldCheckboxes[fieldIndex]->setEnabled(true); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 67f48be7..b8de0b63 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -299,6 +299,9 @@ void MainWindow::initExtraSignals() { connect(ui->action_NewLayout, &QAction::triggered, this, &MainWindow::openNewLayoutDialog); connect(ui->actionDuplicate_Current_Map_Layout, &QAction::triggered, this, &MainWindow::openDuplicateMapOrLayoutDialog); connect(ui->comboBox_LayoutSelector->lineEdit(), &QLineEdit::editingFinished, this, &MainWindow::onLayoutSelectorEditingFinished); + connect(ui->checkBox_smartPaths, &QCheckBox::toggled, this, &MainWindow::setSmartPathsEnabled); + connect(ui->checkBox_ToggleBorder, &QCheckBox::toggled, this, &MainWindow::setBorderVisibility); + connect(ui->checkBox_MirrorConnections, &QCheckBox::toggled, this, &MainWindow::setMirrorConnectionsEnabled); } void MainWindow::on_actionCheck_for_Updates_triggered() { @@ -2753,25 +2756,20 @@ void MainWindow::on_pushButton_ChangeDimensions_clicked() { } } -void MainWindow::on_checkBox_smartPaths_stateChanged(int selected) +void MainWindow::setSmartPathsEnabled(bool enabled) { - bool enabled = selected == Qt::Checked; - editor->settings->smartPathsEnabled = enabled; - if (enabled) { - editor->cursorMapTileRect->setSmartPathMode(true); - } else { - editor->cursorMapTileRect->setSmartPathMode(false); - } + this->editor->settings->smartPathsEnabled = enabled; + this->editor->cursorMapTileRect->setSmartPathMode(enabled); } -void MainWindow::on_checkBox_ToggleBorder_stateChanged(int selected) +void MainWindow::setBorderVisibility(bool visible) { - editor->toggleBorderVisibility(selected != 0); + editor->toggleBorderVisibility(visible); } -void MainWindow::on_checkBox_MirrorConnections_stateChanged(int selected) +void MainWindow::setMirrorConnectionsEnabled(bool enabled) { - porymapConfig.mirrorConnectingMaps = (selected == Qt::Checked); + porymapConfig.mirrorConnectingMaps = enabled; } void MainWindow::on_actionTileset_Editor_triggered() diff --git a/src/scriptapi/apioverlay.cpp b/src/scriptapi/apioverlay.cpp index 4b1f75b8..00a34495 100644 --- a/src/scriptapi/apioverlay.cpp +++ b/src/scriptapi/apioverlay.cpp @@ -276,7 +276,12 @@ void MapView::addTileImage(int x, int y, int tileId, bool xflip, bool yflip, int this->editor->layout->tileset_primary, this->editor->layout->tileset_secondary, paletteId) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + .flipped(Util::getOrientation(xflip, yflip)); +#else .mirrored(xflip, yflip); +#endif + if (setTransparency) image.setColor(0, qRgba(0, 0, 0, 0)); if (this->getOverlay(layer)->addImage(x, y, image)) diff --git a/src/ui/customscriptseditor.cpp b/src/ui/customscriptseditor.cpp index eddbc7ae..7cc89a14 100644 --- a/src/ui/customscriptseditor.cpp +++ b/src/ui/customscriptseditor.cpp @@ -105,7 +105,7 @@ void CustomScriptsEditor::displayScript(const QString &filepath, bool enabled) { connect(widget->ui->b_Choose, &QAbstractButton::clicked, [this, item](bool) { this->replaceScript(item); }); connect(widget->ui->b_Edit, &QAbstractButton::clicked, [this, item](bool) { this->openScript(item); }); connect(widget->ui->b_Delete, &QAbstractButton::clicked, [this, item](bool) { this->removeScript(item); }); - connect(widget->ui->checkBox_Enable, &QCheckBox::stateChanged, this, &CustomScriptsEditor::markEdited); + connect(widget->ui->checkBox_Enable, &QCheckBox::toggled, this, &CustomScriptsEditor::markEdited); connect(widget->ui->lineEdit_filepath, &QLineEdit::textEdited, this, &CustomScriptsEditor::markEdited); // Per the Qt manual, for performance reasons QListWidget::setItemWidget shouldn't be used with non-static items. diff --git a/src/ui/eventframes.cpp b/src/ui/eventframes.cpp index c8682aa7..3b5d71fa 100644 --- a/src/ui/eventframes.cpp +++ b/src/ui/eventframes.cpp @@ -843,8 +843,8 @@ void HiddenItemFrame::connectSignals(MainWindow *window) { // underfoot this->check_itemfinder->disconnect(); - connect(this->check_itemfinder, &QCheckBox::stateChanged, [=](int state) { - this->hiddenItem->setUnderfoot(state == Qt::Checked); + connect(this->check_itemfinder, &QCheckBox::toggled, [=](bool checked) { + this->hiddenItem->setUnderfoot(checked); this->hiddenItem->modify(); }); } diff --git a/src/ui/imageproviders.cpp b/src/ui/imageproviders.cpp index 33ec3596..b1510195 100644 --- a/src/ui/imageproviders.cpp +++ b/src/ui/imageproviders.cpp @@ -127,7 +127,12 @@ QImage getMetatileImage( color.setAlpha(0); tile_image.setColor(0, color.rgba()); - metatile_painter.drawImage(origin, tile_image.mirrored(tile.xflip, tile.yflip)); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + tile_image.flip(Util::getOrientation(tile.xflip, tile.yflip)); +#else + tile_image = tile_image.mirrored(tile.xflip, tile.yflip); +#endif + metatile_painter.drawImage(origin, tile_image); } metatile_painter.end(); diff --git a/src/ui/mapheaderform.cpp b/src/ui/mapheaderform.cpp index 09cb22c7..65fe6ead 100644 --- a/src/ui/mapheaderform.cpp +++ b/src/ui/mapheaderform.cpp @@ -20,12 +20,11 @@ MapHeaderForm::MapHeaderForm(QWidget *parent) connect(ui->comboBox_Weather, &QComboBox::currentTextChanged, this, &MapHeaderForm::onWeatherChanged); connect(ui->comboBox_Type, &QComboBox::currentTextChanged, this, &MapHeaderForm::onTypeChanged); connect(ui->comboBox_BattleScene, &QComboBox::currentTextChanged, this, &MapHeaderForm::onBattleSceneChanged); - - connect(ui->checkBox_RequiresFlash, &QCheckBox::stateChanged, this, &MapHeaderForm::onRequiresFlashChanged); - connect(ui->checkBox_ShowLocationName, &QCheckBox::stateChanged, this, &MapHeaderForm::onShowLocationNameChanged); - connect(ui->checkBox_AllowRunning, &QCheckBox::stateChanged, this, &MapHeaderForm::onAllowRunningChanged); - connect(ui->checkBox_AllowBiking, &QCheckBox::stateChanged, this, &MapHeaderForm::onAllowBikingChanged); - connect(ui->checkBox_AllowEscaping, &QCheckBox::stateChanged, this, &MapHeaderForm::onAllowEscapingChanged); + connect(ui->checkBox_RequiresFlash, &QCheckBox::toggled, this, &MapHeaderForm::onRequiresFlashChanged); + connect(ui->checkBox_ShowLocationName, &QCheckBox::toggled, this, &MapHeaderForm::onShowLocationNameChanged); + connect(ui->checkBox_AllowRunning, &QCheckBox::toggled, this, &MapHeaderForm::onAllowRunningChanged); + connect(ui->checkBox_AllowBiking, &QCheckBox::toggled, this, &MapHeaderForm::onAllowBikingChanged); + connect(ui->checkBox_AllowEscaping, &QCheckBox::toggled, this, &MapHeaderForm::onAllowEscapingChanged); connect(ui->spinBox_FloorNumber, QOverload::of(&QSpinBox::valueChanged), this, &MapHeaderForm::onFloorNumberChanged); @@ -207,11 +206,11 @@ void MapHeaderForm::onSongUpdated(const QString &song) { if (m_hea void MapHeaderForm::onWeatherChanged(const QString &weather) { if (m_header) m_header->setWeather(weather); } void MapHeaderForm::onTypeChanged(const QString &type) { if (m_header) m_header->setType(type); } void MapHeaderForm::onBattleSceneChanged(const QString &battleScene) { if (m_header) m_header->setBattleScene(battleScene); } -void MapHeaderForm::onRequiresFlashChanged(int selected) { if (m_header) m_header->setRequiresFlash(selected == Qt::Checked); } -void MapHeaderForm::onShowLocationNameChanged(int selected) { if (m_header) m_header->setShowsLocationName(selected == Qt::Checked); } -void MapHeaderForm::onAllowRunningChanged(int selected) { if (m_header) m_header->setAllowsRunning(selected == Qt::Checked); } -void MapHeaderForm::onAllowBikingChanged(int selected) { if (m_header) m_header->setAllowsBiking(selected == Qt::Checked); } -void MapHeaderForm::onAllowEscapingChanged(int selected) { if (m_header) m_header->setAllowsEscaping(selected == Qt::Checked); } +void MapHeaderForm::onRequiresFlashChanged(bool enabled) { if (m_header) m_header->setRequiresFlash(enabled); } +void MapHeaderForm::onShowLocationNameChanged(bool enabled) { if (m_header) m_header->setShowsLocationName(enabled); } +void MapHeaderForm::onAllowRunningChanged(bool enabled) { if (m_header) m_header->setAllowsRunning(enabled); } +void MapHeaderForm::onAllowBikingChanged(bool enabled) { if (m_header) m_header->setAllowsBiking(enabled); } +void MapHeaderForm::onAllowEscapingChanged(bool enabled) { if (m_header) m_header->setAllowsEscaping(enabled); } void MapHeaderForm::onFloorNumberChanged(int offset) { if (m_header) m_header->setFloorNumber(offset); } void MapHeaderForm::onLocationChanged(const QString &location) { if (m_header) m_header->setLocation(location); diff --git a/src/ui/mapimageexporter.cpp b/src/ui/mapimageexporter.cpp index fe2865b0..3272acfe 100644 --- a/src/ui/mapimageexporter.cpp +++ b/src/ui/mapimageexporter.cpp @@ -60,6 +60,23 @@ MapImageExporter::MapImageExporter(QWidget *parent, Project *project, Map *map, connect(ui->comboBox_MapSelection, QOverload::of(&QComboBox::currentIndexChanged), this, &MapImageExporter::updateMapSelection); connect(ui->comboBox_MapSelection->lineEdit(), &QLineEdit::editingFinished, this, &MapImageExporter::updateMapSelection); + connect(ui->checkBox_Objects, &QCheckBox::toggled, this, &MapImageExporter::setShowObjects); + connect(ui->checkBox_Warps, &QCheckBox::toggled, this, &MapImageExporter::setShowWarps); + connect(ui->checkBox_BGs, &QCheckBox::toggled, this, &MapImageExporter::setShowBgs); + connect(ui->checkBox_Triggers, &QCheckBox::toggled, this, &MapImageExporter::setShowTriggers); + connect(ui->checkBox_HealLocations, &QCheckBox::toggled, this, &MapImageExporter::setShowHealLocations); + connect(ui->checkBox_AllEvents, &QCheckBox::toggled, this, &MapImageExporter::setShowAllEvents); + connect(ui->checkBox_ConnectionUp, &QCheckBox::toggled, this, &MapImageExporter::setShowConnectionUp); + connect(ui->checkBox_ConnectionDown, &QCheckBox::toggled, this, &MapImageExporter::setShowConnectionDown); + connect(ui->checkBox_ConnectionLeft, &QCheckBox::toggled, this, &MapImageExporter::setShowConnectionLeft); + connect(ui->checkBox_ConnectionRight, &QCheckBox::toggled, this, &MapImageExporter::setShowConnectionRight); + connect(ui->checkBox_AllConnections, &QCheckBox::toggled, this, &MapImageExporter::setShowAllConnections); + connect(ui->checkBox_Collision, &QCheckBox::toggled, this, &MapImageExporter::setShowCollision); + connect(ui->checkBox_Grid, &QCheckBox::toggled, this, &MapImageExporter::setShowGrid); + connect(ui->checkBox_Border, &QCheckBox::toggled, this, &MapImageExporter::setShowBorder); + connect(ui->checkBox_DisablePreviewScaling, &QCheckBox::toggled, this, &MapImageExporter::setDisablePreviewScaling); + connect(ui->checkBox_DisablePreviewUpdates, &QCheckBox::toggled, this, &MapImageExporter::setDisablePreviewUpdates); + ui->graphicsView_Preview->setFocus(); } @@ -719,127 +736,123 @@ void MapImageExporter::setConnectionDirectionEnabled(const QString &dir, bool en } } -void MapImageExporter::on_checkBox_Collision_stateChanged(int state) { - m_settings.showCollision = (state == Qt::Checked); +void MapImageExporter::setShowCollision(bool checked) { + m_settings.showCollision = checked; updatePreview(); } -void MapImageExporter::on_checkBox_Grid_stateChanged(int state) { - m_settings.showGrid = (state == Qt::Checked); +void MapImageExporter::setShowGrid(bool checked) { + m_settings.showGrid = checked; updatePreview(); } -void MapImageExporter::on_checkBox_Border_stateChanged(int state) { - m_settings.showBorder = (state == Qt::Checked); +void MapImageExporter::setShowBorder(bool checked) { + m_settings.showBorder = checked; updatePreview(); } -void MapImageExporter::on_checkBox_Objects_stateChanged(int state) { - setEventGroupEnabled(Event::Group::Object, state == Qt::Checked); +void MapImageExporter::setShowObjects(bool checked) { + setEventGroupEnabled(Event::Group::Object, checked); updatePreview(); } -void MapImageExporter::on_checkBox_Warps_stateChanged(int state) { - setEventGroupEnabled(Event::Group::Warp, state == Qt::Checked); +void MapImageExporter::setShowWarps(bool checked) { + setEventGroupEnabled(Event::Group::Warp, checked); updatePreview(); } -void MapImageExporter::on_checkBox_BGs_stateChanged(int state) { - setEventGroupEnabled(Event::Group::Bg, state == Qt::Checked); +void MapImageExporter::setShowBgs(bool checked) { + setEventGroupEnabled(Event::Group::Bg, checked); updatePreview(); } -void MapImageExporter::on_checkBox_Triggers_stateChanged(int state) { - setEventGroupEnabled(Event::Group::Coord, state == Qt::Checked); +void MapImageExporter::setShowTriggers(bool checked) { + setEventGroupEnabled(Event::Group::Coord, checked); updatePreview(); } -void MapImageExporter::on_checkBox_HealLocations_stateChanged(int state) { - setEventGroupEnabled(Event::Group::Heal, state == Qt::Checked); +void MapImageExporter::setShowHealLocations(bool checked) { + setEventGroupEnabled(Event::Group::Heal, checked); updatePreview(); } // Shortcut setting for enabling all events -void MapImageExporter::on_checkBox_AllEvents_stateChanged(int state) { - bool on = (state == Qt::Checked); - +void MapImageExporter::setShowAllEvents(bool checked) { const QSignalBlocker b_Objects(ui->checkBox_Objects); - ui->checkBox_Objects->setChecked(on); - ui->checkBox_Objects->setDisabled(on); - setEventGroupEnabled(Event::Group::Object, on); + ui->checkBox_Objects->setChecked(checked); + ui->checkBox_Objects->setDisabled(checked); + setEventGroupEnabled(Event::Group::Object, checked); const QSignalBlocker b_Warps(ui->checkBox_Warps); - ui->checkBox_Warps->setChecked(on); - ui->checkBox_Warps->setDisabled(on); - setEventGroupEnabled(Event::Group::Warp, on); + ui->checkBox_Warps->setChecked(checked); + ui->checkBox_Warps->setDisabled(checked); + setEventGroupEnabled(Event::Group::Warp, checked); const QSignalBlocker b_BGs(ui->checkBox_BGs); - ui->checkBox_BGs->setChecked(on); - ui->checkBox_BGs->setDisabled(on); - setEventGroupEnabled(Event::Group::Bg, on); + ui->checkBox_BGs->setChecked(checked); + ui->checkBox_BGs->setDisabled(checked); + setEventGroupEnabled(Event::Group::Bg, checked); const QSignalBlocker b_Triggers(ui->checkBox_Triggers); - ui->checkBox_Triggers->setChecked(on); - ui->checkBox_Triggers->setDisabled(on); - setEventGroupEnabled(Event::Group::Coord, on); + ui->checkBox_Triggers->setChecked(checked); + ui->checkBox_Triggers->setDisabled(checked); + setEventGroupEnabled(Event::Group::Coord, checked); const QSignalBlocker b_HealLocations(ui->checkBox_HealLocations); - ui->checkBox_HealLocations->setChecked(on); - ui->checkBox_HealLocations->setDisabled(on); - setEventGroupEnabled(Event::Group::Heal, on); + ui->checkBox_HealLocations->setChecked(checked); + ui->checkBox_HealLocations->setDisabled(checked); + setEventGroupEnabled(Event::Group::Heal, checked); updatePreview(); } -void MapImageExporter::on_checkBox_ConnectionUp_stateChanged(int state) { - setConnectionDirectionEnabled("up", state == Qt::Checked); +void MapImageExporter::setShowConnectionUp(bool checked) { + setConnectionDirectionEnabled("up", checked); updatePreview(); } -void MapImageExporter::on_checkBox_ConnectionDown_stateChanged(int state) { - setConnectionDirectionEnabled("down", state == Qt::Checked); +void MapImageExporter::setShowConnectionDown(bool checked) { + setConnectionDirectionEnabled("down", checked); updatePreview(); } -void MapImageExporter::on_checkBox_ConnectionLeft_stateChanged(int state) { - setConnectionDirectionEnabled("left", state == Qt::Checked); +void MapImageExporter::setShowConnectionLeft(bool checked) { + setConnectionDirectionEnabled("left", checked); updatePreview(); } -void MapImageExporter::on_checkBox_ConnectionRight_stateChanged(int state) { - setConnectionDirectionEnabled("right", state == Qt::Checked); +void MapImageExporter::setShowConnectionRight(bool checked) { + setConnectionDirectionEnabled("right", checked); updatePreview(); } // Shortcut setting for enabling all connection directions -void MapImageExporter::on_checkBox_AllConnections_stateChanged(int state) { - bool on = (state == Qt::Checked); - +void MapImageExporter::setShowAllConnections(bool checked) { const QSignalBlocker b_Up(ui->checkBox_ConnectionUp); - ui->checkBox_ConnectionUp->setChecked(on); - ui->checkBox_ConnectionUp->setDisabled(on); - setConnectionDirectionEnabled("up", on); + ui->checkBox_ConnectionUp->setChecked(checked); + ui->checkBox_ConnectionUp->setDisabled(checked); + setConnectionDirectionEnabled("up", checked); const QSignalBlocker b_Down(ui->checkBox_ConnectionDown); - ui->checkBox_ConnectionDown->setChecked(on); - ui->checkBox_ConnectionDown->setDisabled(on); - setConnectionDirectionEnabled("down", on); + ui->checkBox_ConnectionDown->setChecked(checked); + ui->checkBox_ConnectionDown->setDisabled(checked); + setConnectionDirectionEnabled("down", checked); const QSignalBlocker b_Left(ui->checkBox_ConnectionLeft); - ui->checkBox_ConnectionLeft->setChecked(on); - ui->checkBox_ConnectionLeft->setDisabled(on); - setConnectionDirectionEnabled("left", on); + ui->checkBox_ConnectionLeft->setChecked(checked); + ui->checkBox_ConnectionLeft->setDisabled(checked); + setConnectionDirectionEnabled("left", checked); const QSignalBlocker b_Right(ui->checkBox_ConnectionRight); - ui->checkBox_ConnectionRight->setChecked(on); - ui->checkBox_ConnectionRight->setDisabled(on); - setConnectionDirectionEnabled("right", on); + ui->checkBox_ConnectionRight->setChecked(checked); + ui->checkBox_ConnectionRight->setDisabled(checked); + setConnectionDirectionEnabled("right", checked); updatePreview(); } -void MapImageExporter::on_checkBox_DisablePreviewScaling_stateChanged(int state) { - m_settings.disablePreviewScaling = (state == Qt::Checked); +void MapImageExporter::setDisablePreviewScaling(bool checked) { + m_settings.disablePreviewScaling = checked; if (m_settings.disablePreviewScaling) { ui->graphicsView_Preview->resetTransform(); } else { @@ -847,8 +860,8 @@ void MapImageExporter::on_checkBox_DisablePreviewScaling_stateChanged(int state) } } -void MapImageExporter::on_checkBox_DisablePreviewUpdates_stateChanged(int state) { - m_settings.disablePreviewUpdates = (state == Qt::Checked); +void MapImageExporter::setDisablePreviewUpdates(bool checked) { + m_settings.disablePreviewUpdates = checked; if (m_settings.disablePreviewUpdates) { if (m_timelapseMovie) { m_timelapseMovie->stop(); diff --git a/src/ui/metatilelayersitem.cpp b/src/ui/metatilelayersitem.cpp index 3050e761..87218f52 100644 --- a/src/ui/metatilelayersitem.cpp +++ b/src/ui/metatilelayersitem.cpp @@ -1,6 +1,7 @@ #include "config.h" #include "metatilelayersitem.h" #include "imageproviders.h" +#include "utility.h" #include static const QList tilePositions = { @@ -28,7 +29,11 @@ void MetatileLayersItem::draw() { for (int i = 0; i < numTiles; i++) { Tile tile = this->metatile->tiles.at(i); QImage tileImage = getPalettedTileImage(tile.tileId, this->primaryTileset, this->secondaryTileset, tile.palette, true) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + .flipped(Util::getOrientation(tile.xflip, tile.yflip)) +#else .mirrored(tile.xflip, tile.yflip) +#endif .scaled(16, 16); painter.drawImage(tilePositions.at(i) * 16, tileImage); } diff --git a/src/ui/projectsettingseditor.cpp b/src/ui/projectsettingseditor.cpp index a00eac54..365567f3 100644 --- a/src/ui/projectsettingseditor.cpp +++ b/src/ui/projectsettingseditor.cpp @@ -45,12 +45,11 @@ void ProjectSettingsEditor::connectSignals() { connect(ui->comboBox_BaseGameVersion, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::promptRestoreDefaults); connect(ui->comboBox_AttributesSize, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::updateAttributeLimits); connect(ui->comboBox_IconSpecies, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::updatePokemonIconPath); - connect(ui->checkBox_EnableCustomBorderSize, &QCheckBox::stateChanged, [this](int state) { - bool customSize = (state == Qt::Checked); + connect(ui->checkBox_EnableCustomBorderSize, &QCheckBox::toggled, [this](bool enabled) { // When switching between the spin boxes or line edit for border metatiles we set // the newly-shown UI using the values from the hidden UI. - this->setBorderMetatileIds(customSize, this->getBorderMetatileIds(!customSize)); - this->setBorderMetatilesUi(customSize); + this->setBorderMetatileIds(enabled, this->getBorderMetatileIds(!enabled)); + this->setBorderMetatilesUi(enabled); }); connect(ui->button_AddWarpBehavior, &QAbstractButton::clicked, [this](bool) { this->updateWarpBehaviorsList(true); }); connect(ui->button_RemoveWarpBehavior, &QAbstractButton::clicked, [this](bool) { this->updateWarpBehaviorsList(false); }); @@ -82,8 +81,8 @@ void ProjectSettingsEditor::connectSignals() { connect(combo, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::markEdited); } for (auto checkBox : ui->centralwidget->findChildren()) - connect(checkBox, &QCheckBox::stateChanged, this, &ProjectSettingsEditor::markEdited); - for (auto radioButton : ui->centralwidget->findChildren()) + connect(checkBox, &QCheckBox::toggled, this, &ProjectSettingsEditor::markEdited); + for (auto radioButton : ui->centralwidget->findChildren()) connect(radioButton, &QRadioButton::toggled, this, &ProjectSettingsEditor::markEdited); for (auto lineEdit : ui->centralwidget->findChildren()) connect(lineEdit, &QLineEdit::textEdited, this, &ProjectSettingsEditor::markEdited); diff --git a/src/ui/regionmapeditor.cpp b/src/ui/regionmapeditor.cpp index 27fb5f2f..b66d442b 100644 --- a/src/ui/regionmapeditor.cpp +++ b/src/ui/regionmapeditor.cpp @@ -27,6 +27,10 @@ RegionMapEditor::RegionMapEditor(QWidget *parent, Project *project) : this->ui->setupUi(this); this->project = project; connect(this->project, &Project::mapSectionIdNamesChanged, this, &RegionMapEditor::setLocations); + connect(ui->checkBox_tileHFlip, &QCheckBox::toggled, this, &RegionMapEditor::setTileHFlip); + connect(ui->checkBox_tileVFlip, &QCheckBox::toggled, this, &RegionMapEditor::setTileVFlip); + + this->configFilepath = QString("%1/%2").arg(this->project->root).arg(projectConfig.getFilePath(ProjectFilePath::json_region_porymap_cfg)); this->initShortcuts(); this->restoreWindowState(); @@ -1030,15 +1034,18 @@ void RegionMapEditor::on_pushButton_RM_Options_delete_clicked() { } void RegionMapEditor::on_spinBox_tilePalette_valueChanged(int value) { - this->mapsquare_selector_item->selectPalette(value); + if (this->mapsquare_selector_item) + this->mapsquare_selector_item->selectPalette(value); } -void RegionMapEditor::on_checkBox_tileHFlip_stateChanged(int state) { - this->mapsquare_selector_item->selectHFlip(state == Qt::Checked); +void RegionMapEditor::setTileHFlip(bool enabled) { + if (this->mapsquare_selector_item) + this->mapsquare_selector_item->selectHFlip(enabled); } -void RegionMapEditor::on_checkBox_tileVFlip_stateChanged(int state) { - this->mapsquare_selector_item->selectVFlip(state == Qt::Checked); +void RegionMapEditor::setTileVFlip(bool enabled) { + if (this->mapsquare_selector_item) + this->mapsquare_selector_item->selectVFlip(enabled); } void RegionMapEditor::on_action_RegionMap_Resize_triggered() { diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp index e94b4095..6b72da09 100644 --- a/src/ui/shortcut.cpp +++ b/src/ui/shortcut.cpp @@ -123,21 +123,10 @@ bool Shortcut::autoRepeat() const { return sc_vec.first()->autoRepeat(); } -int Shortcut::id() const { - return sc_vec.first()->id(); -} - -QList Shortcut::ids() const { - QList id_list; - for (auto *sc : sc_vec) - id_list.append(sc->id()); - return id_list; -} - bool Shortcut::event(QEvent *e) { if (isEnabled() && e->type() == QEvent::Shortcut) { auto se = static_cast(e); - if (ids().contains(se->shortcutId()) && keys().contains(se->key())) { + if (keys().contains(se->key())) { if (QWhatsThis::inWhatsThisMode()) { QWhatsThis::showText(QCursor::pos(), whatsThis()); } else { diff --git a/src/ui/tilemaptileselector.cpp b/src/ui/tilemaptileselector.cpp index a4ef5719..9093b694 100644 --- a/src/ui/tilemaptileselector.cpp +++ b/src/ui/tilemaptileselector.cpp @@ -93,7 +93,11 @@ QImage TilemapTileSelector::tileImg(shared_ptr tile) { // take a tile from the tileset QImage img = tilesetImage.copy(pos.x() * 8, pos.y() * 8, 8, 8); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + img.flip(Util::getOrientation(tile->hFlip(), tile->vFlip())); +#else img = img.mirrored(tile->hFlip(), tile->vFlip()); +#endif return img; } diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index 351771df..3d610fb9 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -26,6 +26,8 @@ TilesetEditor::TilesetEditor(Project *project, Layout *layout, QWidget *parent) setAttribute(Qt::WA_DeleteOnClose); setTilesets(this->layout->tileset_primary_label, this->layout->tileset_secondary_label); ui->setupUi(this); + connect(ui->checkBox_xFlip, &QCheckBox::toggled, this, &TilesetEditor::setXFlip); + connect(ui->checkBox_yFlip, &QCheckBox::toggled, this, &TilesetEditor::setYFlip); this->tileXFlip = ui->checkBox_xFlip->isChecked(); this->tileYFlip = ui->checkBox_yFlip->isChecked(); @@ -388,8 +390,13 @@ void TilesetEditor::drawSelectedTiles() { int tileIndex = 0; for (int j = 0; j < dimensions.y(); j++) { for (int i = 0; i < dimensions.x(); i++) { - QImage tileImage = getPalettedTileImage(tiles.at(tileIndex).tileId, this->primaryTileset, this->secondaryTileset, tiles.at(tileIndex).palette, true) - .mirrored(tiles.at(tileIndex).xflip, tiles.at(tileIndex).yflip) + auto tile = tiles.at(tileIndex); + QImage tileImage = getPalettedTileImage(tile.tileId, this->primaryTileset, this->secondaryTileset, tile.palette, true) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + .flipped(Util::getOrientation(tile.xflip, tile.yflip)) +#else + .mirrored(tile.xflip, tile.yflip) +#endif .scaled(16, 16); tileIndex++; painter.drawImage(i * 16, j * 16, tileImage); @@ -540,17 +547,17 @@ void TilesetEditor::on_spinBox_paletteSelector_valueChanged(int paletteId) this->metatileLayersItem->clearLastModifiedCoords(); } -void TilesetEditor::on_checkBox_xFlip_stateChanged(int checked) +void TilesetEditor::setXFlip(bool enabled) { - this->tileXFlip = checked; + this->tileXFlip = enabled; this->tileSelector->setTileFlips(this->tileXFlip, this->tileYFlip); this->drawSelectedTiles(); this->metatileLayersItem->clearLastModifiedCoords(); } -void TilesetEditor::on_checkBox_yFlip_stateChanged(int checked) +void TilesetEditor::setYFlip(bool enabled) { - this->tileYFlip = checked; + this->tileYFlip = enabled; this->tileSelector->setTileFlips(this->tileXFlip, this->tileYFlip); this->drawSelectedTiles(); this->metatileLayersItem->clearLastModifiedCoords(); diff --git a/src/ui/updatepromoter.cpp b/src/ui/updatepromoter.cpp index f9331a16..8afc8d9c 100644 --- a/src/ui/updatepromoter.cpp +++ b/src/ui/updatepromoter.cpp @@ -19,8 +19,8 @@ UpdatePromoter::UpdatePromoter(QWidget *parent, NetworkAccessManager *manager) // Set up "Do not alert me" check box this->updatePreferences(); ui->checkBox_StopAlerts->setVisible(false); - connect(ui->checkBox_StopAlerts, &QCheckBox::stateChanged, [this](int state) { - porymapConfig.checkForUpdates = (state != Qt::Checked); + connect(ui->checkBox_StopAlerts, &QCheckBox::toggled, [this](bool stopAlerts) { + porymapConfig.checkForUpdates = !stopAlerts; emit this->changedPreferences(); });