Display decimal tile/metatile IDs alongside hex by default

This commit is contained in:
GriffinR 2026-03-09 11:39:28 -04:00
parent ce090b27ef
commit e40c48c07d
7 changed files with 45 additions and 15 deletions

View File

@ -6,7 +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 setting to display tile and metatile IDs in decimal instead of hexadecimal. Defaults to displaying both.
- Add API functions for reading and writing text files.
### Changed

View File

@ -122,6 +122,16 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_DecimalHexadecimal">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, tile IDs and metatile IDs will be displayed as &amp;quot;&amp;lt;hexadecimal&amp;gt; (&amp;lt;decimal&amp;gt;)&amp;quot;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Both</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">

View File

@ -6,6 +6,7 @@
#include "block.h"
#include "events.h"
#include "log.h"
#include "utility.h"
#include <QColorSpace>
#include <QFontDatabase>
@ -73,7 +74,7 @@ public:
bool monitorFiles = true;
bool tilesetCheckerboardFill = true;
bool newMapHeaderSectionExpanded = false;
bool displayIdsHexadecimal = true;
NumberSystemMode tileNumberSystem = NumberSystemMode::Both;
QString theme = QStringLiteral("default");
QString wildMonChartTheme;
QString textEditorOpenFolder;
@ -141,7 +142,7 @@ public:
m_fm->addField(&this->monitorFiles, "monitor_files");
m_fm->addField(&this->tilesetCheckerboardFill, "tileset_checkerboard_fill");
m_fm->addField(&this->newMapHeaderSectionExpanded, "new_map_header_section_expanded");
m_fm->addField(&this->displayIdsHexadecimal, "display_ids_hexadecimal");
m_fm->addField(&this->tileNumberSystem, "tile_number_system");
m_fm->addField(&this->theme, "theme");
m_fm->addField(&this->wildMonChartTheme, "wild_mon_chart_theme");
m_fm->addField(&this->textEditorOpenFolder, "text_editor_open_folder");

View File

@ -6,6 +6,12 @@
#include <QLineEdit>
#include <QColorSpace>
enum NumberSystemMode {
Both,
Decimal,
Hexadecimal,
};
namespace Util {
void numericalModeSort(QStringList &list);
int roundUpToMultiple(int numToRound, int multiple);
@ -21,6 +27,19 @@ namespace Util {
QString mkpath(const QString& dirPath);
QString getFileHash(const QString &filepath);
template <typename T>
QString getNumberSystemString(T value, NumberSystemMode mode, int minHexLength = 0) {
switch (mode) {
case NumberSystemMode::Hexadecimal: return toHexString(value, minHexLength);
case NumberSystemMode::Decimal: return QString::number(value);
case NumberSystemMode::Both: return QString("%1 (%2)")
.arg(getNumberSystemString(value, NumberSystemMode::Hexadecimal, minHexLength))
.arg(getNumberSystemString(value, NumberSystemMode::Decimal));
}
Q_ASSERT("Cannot get string for invalid NumberSystemMode.");
return QString();
}
// Given a QMap<T,QString>, erases all entries with empty strings.
// Returns the number of entries erased.
template <typename T>

View File

@ -45,9 +45,7 @@ QPoint Metatile::coordFromPixmapCoord(const QPointF &pixelCoord) {
static int numMetatileIdChars = 4;
QString Metatile::getMetatileIdString(uint16_t metatileId) {
return porymapConfig.displayIdsHexadecimal
? Util::toHexString(metatileId, numMetatileIdChars)
: QString::number(metatileId);
return Util::getNumberSystemString(metatileId, porymapConfig.tileNumberSystem, numMetatileIdChars);
};
QString Metatile::getMetatileIdStrings(const QList<uint16_t> &metatileIds) {

View File

@ -1,6 +1,7 @@
#include "tile.h"
#include "project.h"
#include "bitpacker.h"
#include "utility.h"
// At the moment these are fixed, and not exposed to the user.
// We're only using them for convenience when converting between raw values.
@ -71,7 +72,5 @@ QString Tile::toString() const {
}
QString Tile::getTileIdString(uint16_t tileId) {
return porymapConfig.displayIdsHexadecimal
? Util::toHexString(tileId, 3)
: QString::number(tileId);
}
return Util::getNumberSystemString(tileId, porymapConfig.tileNumberSystem, 3);
};

View File

@ -107,10 +107,10 @@ 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) {
ui->radioButton_Hexadecimal->setChecked(true);
} else {
ui->radioButton_Decimal->setChecked(true);
switch (porymapConfig.tileNumberSystem) {
case NumberSystemMode::Hexadecimal: ui->radioButton_Hexadecimal->setChecked(true); break;
case NumberSystemMode::Decimal: ui->radioButton_Decimal->setChecked(true); break;
case NumberSystemMode::Both: ui->radioButton_DecimalHexadecimal->setChecked(true); break;
}
this->applicationFont = porymapConfig.applicationFont;
@ -150,7 +150,10 @@ void PreferenceEditor::saveFields() {
porymapConfig.checkForUpdates = ui->checkBox_CheckForUpdates->isChecked();
porymapConfig.eventDeleteWarningDisabled = ui->checkBox_DisableEventWarning->isChecked();
porymapConfig.showProjectLoadingScreen = ui->checkBox_ShowProjectLoadingScreen->isChecked();
porymapConfig.displayIdsHexadecimal = ui->radioButton_Hexadecimal->isChecked();
if (ui->radioButton_Hexadecimal->isChecked()) porymapConfig.tileNumberSystem = NumberSystemMode::Hexadecimal;
else if (ui->radioButton_Decimal->isChecked()) porymapConfig.tileNumberSystem = NumberSystemMode::Decimal;
else if (ui->radioButton_DecimalHexadecimal->isChecked()) porymapConfig.tileNumberSystem = NumberSystemMode::Both;
porymapConfig.statusBarLogTypes.clear();
if (ui->checkBox_StatusErrors->isChecked()) porymapConfig.statusBarLogTypes.insert(LogType::LOG_ERROR);