Add setting to display tile/metatile IDs in decimal
Some checks failed
Build Porymap / build-linux (, 5.14.2) (push) Has been cancelled
Build Porymap / build-linux (, 6.8.*) (push) Has been cancelled
Build Porymap / build-linux (minimal, 5.14.2) (push) Has been cancelled
Build Porymap / build-macos (macos-15-intel) (push) Has been cancelled
Build Porymap / build-macos (macos-latest) (push) Has been cancelled
Build Porymap / build-static-windows (push) Has been cancelled

This commit is contained in:
GriffinR 2026-02-02 14:09:09 -05:00
parent 37882368e0
commit af21a5bee1
7 changed files with 203 additions and 104 deletions

View File

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

View File

@ -38,7 +38,7 @@
<number>12</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<widget class="QScrollArea" name="scrollArea_General">
<property name="widgetResizable">
<bool>true</bool>
</property>
@ -48,19 +48,19 @@
<x>0</x>
<y>0</y>
<width>493</width>
<height>408</height>
<height>374</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_CheckForUpdates">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_MonitorProjectFiles">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, Porymap will automatically alert you on startup if a new release is available&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, a prompt to reload your project will appear if relevant project files are edited&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Automatically check for updates</string>
<string>Monitor project files</string>
</property>
</widget>
</item>
@ -74,41 +74,6 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_MonitorProjectFiles">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, a prompt to reload your project will appear if relevant project files are edited&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Monitor project files</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_ApplicationTheme">
<property name="text">
<string>Application Theme</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="NoScrollComboBox" name="comboBox_ApplicationTheme">
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_ColorSpace">
<property name="text">
<string>Image Export Color Space</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="NoScrollComboBox" name="comboBox_ColorSpace">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The color space to use for exported images. If &amp;quot;---&amp;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_ShowProjectLoadingScreen">
<property name="toolTip">
@ -119,70 +84,45 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_CheckForUpdates">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, Porymap will automatically alert you on startup if a new release is available&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Automatically check for updates</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_Fonts">
<widget class="QGroupBox" name="groupBox_TileMetatileNumberSystem">
<property name="title">
<string>Fonts</string>
<string>Tile / Metatile number system</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radioButton_Decimal">
<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 in decimal.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_ResetMapListFont">
<property name="text">
<string>Reset</string>
<string>Decimal</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_CustomizeMapListFont">
<item>
<widget class="QRadioButton" name="radioButton_Hexadecimal">
<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 in hexadecimal.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Customize...</string>
<string>Hexadecimal</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_MapListFont">
<property name="text">
<string>Map List Font</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_ResetApplicationFont">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButton_CustomizeApplicationFont">
<property name="text">
<string>Customize...</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_ApplicationFont">
<property name="text">
<string>Application Font</string>
</property>
</widget>
</item>
<item row="0" column="3">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
@ -232,22 +172,153 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Visuals">
<attribute name="title">
<string>Visuals</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QScrollArea" name="scrollArea_Visuals">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_Visuals">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<height>366</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_ApplicationTheme">
<property name="text">
<string>Application Theme</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="NoScrollComboBox" name="comboBox_ApplicationTheme"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_ColorSpace">
<property name="text">
<string>Image Export Color Space</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="NoScrollComboBox" name="comboBox_ColorSpace">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The color space to use for exported images. If &amp;quot;---&amp;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_Fonts">
<property name="title">
<string>Fonts</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_ApplicationFont">
<property name="text">
<string>Application Font</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_ResetMapListFont">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_MapListFont">
<property name="text">
<string>Map List Font</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButton_CustomizeApplicationFont">
<property name="text">
<string>Customize...</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_CustomizeMapListFont">
<property name="text">
<string>Customize...</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_ResetApplicationFont">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>

View File

@ -5,6 +5,9 @@
#include <QObject>
#include <QSize>
// 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; }

View File

@ -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<uint16_t> &metatileIds) {

View File

@ -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);
}

View File

@ -1,6 +1,7 @@
#include "preferenceeditor.h"
#include "ui_preferenceeditor.h"
#include "message.h"
#include "tile.h"
#include <QAbstractButton>
#include <QRegularExpression>
@ -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);

View File

@ -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() {