From af21a5bee194d14401f2bf17198177c1b3870374 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 2 Feb 2026 14:09:09 -0500 Subject: [PATCH] Add setting to display tile/metatile IDs in decimal --- CHANGELOG.md | 1 + forms/preferenceeditor.ui | 263 +++++++++++++++++++++++------------- include/core/tile.h | 6 + src/core/metatile.cpp | 4 +- src/core/tile.cpp | 16 +++ src/ui/preferenceeditor.cpp | 8 ++ src/ui/tileseteditor.cpp | 9 +- 7 files changed, 203 insertions(+), 104 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f19f7ffc..2d33fd02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp ## [Unreleased] ### Added +- Add setting to display tile and metatile IDs in decimal instead of hexadecimal. - Add API functions for reading and writing text files. ### Changed diff --git a/forms/preferenceeditor.ui b/forms/preferenceeditor.ui index ddb20b9b..d849a1f5 100644 --- a/forms/preferenceeditor.ui +++ b/forms/preferenceeditor.ui @@ -38,7 +38,7 @@ 12 - + true @@ -48,19 +48,19 @@ 0 0 493 - 408 + 374 - - + + - <html><head/><body><p>If checked, Porymap will automatically alert you on startup if a new release is available</p></body></html> + <html><head/><body><p>If checked, a prompt to reload your project will appear if relevant project files are edited</p></body></html> - Automatically check for updates + Monitor project files @@ -74,41 +74,6 @@ - - - - <html><head/><body><p>If checked, a prompt to reload your project will appear if relevant project files are edited</p></body></html> - - - Monitor project files - - - - - - - Application Theme - - - - - - - - - - - Image Export Color Space - - - - - - - <html><head/><body><p>The color space to use for exported images. If &quot;---&quot; is set, no color space will be used for the exported image. For details on each color space, see Qt's manual page for QColorSpace.</p></body></html> - - - @@ -119,70 +84,45 @@ + + + + <html><head/><body><p>If checked, Porymap will automatically alert you on startup if a new release is available</p></body></html> + + + Automatically check for updates + + + - + - Fonts + Tile / Metatile number system - - - - - Qt::Orientation::Vertical + + + + + <html><head/><body><p>If checked, tile IDs and metatile IDs will be displayed in decimal.</p></body></html> - - - 20 - 40 - - - - - - - Reset + Decimal - - + + + + <html><head/><body><p>If checked, tile IDs and metatile IDs will be displayed in hexadecimal.</p></body></html> + - Customize... + Hexadecimal - - - - Map List Font - - - - - - - Reset - - - - - - - Customize... - - - - - - - Application Font - - - - + Qt::Orientation::Horizontal @@ -232,22 +172,153 @@ - - + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + + + + + + + + + + Visuals + + + + + + true + + + + + 0 + 0 + 477 + 366 + + + + + + + + + Application Theme + + + + + + + + + + Image Export Color Space + + + + + + + <html><head/><body><p>The color space to use for exported images. If &quot;---&quot; is set, no color space will be used for the exported image. For details on each color space, see Qt's manual page for QColorSpace.</p></body></html> + + + + + + + + + Fonts + + + + + + Application Font + + + + + + + Reset + + + + + + + Map List Font + + + + + + + Customize... + + + + + + + Customize... + + + + + - Qt::Orientation::Vertical + Qt::Orientation::Horizontal - 20 - 40 + 40 + 20 + + + + Reset + + + + + + + Qt::Orientation::Vertical + + + + 20 + 40 + + + + diff --git a/include/core/tile.h b/include/core/tile.h index 11fd6a99..b4960dc9 100644 --- a/include/core/tile.h +++ b/include/core/tile.h @@ -5,6 +5,9 @@ #include #include +// TODO: Replace once config refactoring is complete. +extern bool ConfigDisplayIdsHexadecimal; + class Tile { public: @@ -24,6 +27,9 @@ public: static int getIndexInTileset(int); + QString toString() const; + static QString getTileIdString(uint16_t tileId); + static const uint16_t maxValue; static constexpr int pixelWidth() { return 8; } diff --git a/src/core/metatile.cpp b/src/core/metatile.cpp index 00fff2ba..7cd17cec 100644 --- a/src/core/metatile.cpp +++ b/src/core/metatile.cpp @@ -45,7 +45,9 @@ QPoint Metatile::coordFromPixmapCoord(const QPointF &pixelCoord) { static int numMetatileIdChars = 4; QString Metatile::getMetatileIdString(uint16_t metatileId) { - return Util::toHexString(metatileId, numMetatileIdChars); + return /*porymapConfig.displayIdsHexadecimal*/ConfigDisplayIdsHexadecimal + ? Util::toHexString(metatileId, numMetatileIdChars) + : QString::number(metatileId); }; QString Metatile::getMetatileIdStrings(const QList &metatileIds) { diff --git a/src/core/tile.cpp b/src/core/tile.cpp index 88b98c50..b8a6217d 100644 --- a/src/core/tile.cpp +++ b/src/core/tile.cpp @@ -2,6 +2,8 @@ #include "project.h" #include "bitpacker.h" +bool ConfigDisplayIdsHexadecimal = true; + // Upper limit for raw value (i.e., uint16_t max). const uint16_t Tile::maxValue = 0xFFFF; @@ -64,3 +66,17 @@ int Tile::getIndexInTileset(int tileId) { return tileId - Project::getNumTilesPrimary(); } } + +QString Tile::toString() const { + return QString("Tile: %1, Palette: %2%3%4") + .arg(getTileIdString(this->tileId)) + .arg(QString::number(this->palette)) + .arg(this->xflip ? ", X-flipped" : "") + .arg(this->yflip ? ", Y-flipped" : ""); +} + +QString Tile::getTileIdString(uint16_t tileId) { + return /*porymapConfig.displayIdsHexadecimal*/ConfigDisplayIdsHexadecimal + ? Util::toHexString(tileId, 3) + : QString::number(tileId); +} diff --git a/src/ui/preferenceeditor.cpp b/src/ui/preferenceeditor.cpp index e2e52be3..d34a37c6 100644 --- a/src/ui/preferenceeditor.cpp +++ b/src/ui/preferenceeditor.cpp @@ -1,6 +1,7 @@ #include "preferenceeditor.h" #include "ui_preferenceeditor.h" #include "message.h" +#include "tile.h" #include #include @@ -102,6 +103,12 @@ void PreferenceEditor::updateFields() { ui->checkBox_StatusWarnings->setChecked(porymapConfig.statusBarLogTypes.find(LogType::LOG_WARN) != logTypeEnd); ui->checkBox_StatusInformation->setChecked(porymapConfig.statusBarLogTypes.find(LogType::LOG_INFO) != logTypeEnd); + if (/*porymapConfig.displayIdsHexadecimal*/ConfigDisplayIdsHexadecimal) { + ui->radioButton_Hexadecimal->setChecked(true); + } else { + ui->radioButton_Decimal->setChecked(true); + } + this->applicationFont = porymapConfig.applicationFont; this->mapListFont = porymapConfig.mapListFont; } @@ -134,6 +141,7 @@ void PreferenceEditor::saveFields() { porymapConfig.checkForUpdates = ui->checkBox_CheckForUpdates->isChecked(); porymapConfig.eventDeleteWarningDisabled = ui->checkBox_DisableEventWarning->isChecked(); porymapConfig.showProjectLoadingScreen = ui->checkBox_ShowProjectLoadingScreen->isChecked(); + /*porymapConfig.displayIdsHexadecimal*/ConfigDisplayIdsHexadecimal = ui->radioButton_Hexadecimal->isChecked(); porymapConfig.statusBarLogTypes.clear(); if (ui->checkBox_StatusErrors->isChecked()) porymapConfig.statusBarLogTypes.insert(LogType::LOG_ERROR); diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index aff49d35..3abbd95a 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -510,16 +510,11 @@ void TilesetEditor::updateLayerTileStatus() { } void TilesetEditor::showTileStatus(const Tile &tile) { - this->ui->statusbar->showMessage(QString("Tile: %1, Palette: %2%3%4") - .arg(Util::toHexString(tile.tileId, 3)) - .arg(QString::number(tile.palette)) - .arg(tile.xflip ? ", X-flipped" : "") - .arg(tile.yflip ? ", Y-flipped" : "") - ); + this->ui->statusbar->showMessage(tile.toString()); } void TilesetEditor::showTileStatus(uint16_t tileId) { - this->ui->statusbar->showMessage(QString("Tile: %1").arg(Util::toHexString(tileId, 3))); + this->ui->statusbar->showMessage(QString("Tile: %1").arg(Tile::getTileIdString(tileId))); } void TilesetEditor::onHoveredTileCleared() {