mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-19 23:25:09 -05:00
Display decimal tile/metatile IDs alongside hex by default
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user