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,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>