diff --git a/CHANGELOG.md b/CHANGELOG.md index 199bd659..34b75bed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Add a `Close Project` option - Add charts to the `Wild Pokémon` tab that show species and level distributions. - Add options for customizing the map grid under `View -> Grid Settings`. +- Add an option to display a dividing line between tilesets in the Tileset Editor. - An alert will be displayed when attempting to open a seemingly invalid project. - Add support for defining project values with `enum` where `#define` was expected. - Add button to enable editing map groups including renaming groups and rearranging the maps within them. diff --git a/forms/tileseteditor.ui b/forms/tileseteditor.ui index c144e5f2..8623a9bc 100644 --- a/forms/tileseteditor.ui +++ b/forms/tileseteditor.ui @@ -647,6 +647,7 @@ + @@ -799,6 +800,14 @@ Ctrl+G + + + true + + + Show Tileset Divider + + diff --git a/include/config.h b/include/config.h index 6b64b612..47bc2010 100644 --- a/include/config.h +++ b/include/config.h @@ -68,6 +68,7 @@ public: this->showGrid = false; this->showTilesetEditorMetatileGrid = false; this->showTilesetEditorLayerGrid = true; + this->showTilesetEditorDivider = false; this->monitorFiles = true; this->tilesetCheckerboardFill = true; this->theme = "default"; @@ -119,6 +120,7 @@ public: bool showGrid; bool showTilesetEditorMetatileGrid; bool showTilesetEditorLayerGrid; + bool showTilesetEditorDivider; bool monitorFiles; bool tilesetCheckerboardFill; QString theme; diff --git a/include/ui/tileseteditor.h b/include/ui/tileseteditor.h index 32bdc97f..86d53cc2 100644 --- a/include/ui/tileseteditor.h +++ b/include/ui/tileseteditor.h @@ -88,6 +88,7 @@ private slots: void on_actionShow_UnusedTiles_toggled(bool checked); void on_actionMetatile_Grid_triggered(bool checked); void on_actionLayer_Grid_triggered(bool checked); + void on_actionShow_Tileset_Divider_triggered(bool checked); void on_actionUndo_triggered(); diff --git a/include/ui/tileseteditormetatileselector.h b/include/ui/tileseteditormetatileselector.h index 6b2c9a6f..760da8e4 100644 --- a/include/ui/tileseteditormetatileselector.h +++ b/include/ui/tileseteditormetatileselector.h @@ -23,7 +23,8 @@ public: QVector usedMetatiles; bool selectorShowUnused = false; bool selectorShowCounts = false; - bool showGrid; + bool showGrid = false; + bool showDivider = false; protected: void mousePressEvent(QGraphicsSceneMouseEvent*); @@ -44,6 +45,7 @@ private: int numRows(int numMetatiles); int numRows(); void drawGrid(); + void drawDivider(); void drawFilters(); void drawUnused(); void drawCounts(); diff --git a/include/ui/tileseteditortileselector.h b/include/ui/tileseteditortileselector.h index 7e34d52a..aa2a1923 100644 --- a/include/ui/tileseteditortileselector.h +++ b/include/ui/tileseteditortileselector.h @@ -33,6 +33,7 @@ public: QVector usedTiles; bool showUnused = false; + bool showDivider = false; protected: void mousePressEvent(QGraphicsSceneMouseEvent*); diff --git a/src/config.cpp b/src/config.cpp index 3d604da6..c0c00194 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -368,6 +368,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { this->showTilesetEditorMetatileGrid = getConfigBool(key, value); } else if (key == "show_tileset_editor_layer_grid") { this->showTilesetEditorLayerGrid = getConfigBool(key, value); + } else if (key == "show_tileset_editor_divider") { + this->showTilesetEditorDivider = getConfigBool(key, value); } else if (key == "monitor_files") { this->monitorFiles = getConfigBool(key, value); } else if (key == "tileset_checkerboard_fill") { @@ -452,6 +454,7 @@ QMap PorymapConfig::getKeyValueMap() { map.insert("show_grid", this->showGrid ? "1" : "0"); map.insert("show_tileset_editor_metatile_grid", this->showTilesetEditorMetatileGrid ? "1" : "0"); map.insert("show_tileset_editor_layer_grid", this->showTilesetEditorLayerGrid ? "1" : "0"); + map.insert("show_tileset_editor_divider", this->showTilesetEditorDivider ? "1" : "0"); map.insert("monitor_files", this->monitorFiles ? "1" : "0"); map.insert("tileset_checkerboard_fill", this->tilesetCheckerboardFill ? "1" : "0"); map.insert("theme", this->theme); diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index e709bed1..49cfe147 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -99,6 +99,7 @@ void TilesetEditor::initUi() { this->paletteId = ui->spinBox_paletteSelector->value(); this->ui->spinBox_paletteSelector->setMinimum(0); this->ui->spinBox_paletteSelector->setMaximum(Project::getNumPalettesTotal() - 1); + this->ui->actionShow_Tileset_Divider->setChecked(porymapConfig.showTilesetEditorDivider); this->setAttributesUi(); this->setMetatileLabelValidator(); @@ -191,6 +192,7 @@ void TilesetEditor::initMetatileSelector() bool showGrid = porymapConfig.showTilesetEditorMetatileGrid; this->ui->actionMetatile_Grid->setChecked(showGrid); this->metatileSelector->showGrid = showGrid; + this->metatileSelector->showDivider = this->ui->actionShow_Tileset_Divider->isChecked(); this->metatilesScene = new QGraphicsScene; this->metatilesScene->addItem(this->metatileSelector); @@ -232,6 +234,8 @@ void TilesetEditor::initTileSelector() connect(this->tileSelector, &TilesetEditorTileSelector::selectedTilesChanged, this, &TilesetEditor::onSelectedTilesChanged); + this->tileSelector->showDivider = this->ui->actionShow_Tileset_Divider->isChecked(); + this->tilesScene = new QGraphicsScene; this->tilesScene->addItem(this->tileSelector); this->tileSelector->select(0); @@ -1048,6 +1052,16 @@ void TilesetEditor::on_actionLayer_Grid_triggered(bool checked) { porymapConfig.showTilesetEditorLayerGrid = checked; } +void TilesetEditor::on_actionShow_Tileset_Divider_triggered(bool checked) { + this->metatileSelector->showDivider = checked; + this->metatileSelector->draw(); + + this->tileSelector->showDivider = checked; + this->tileSelector->draw(); + + porymapConfig.showTilesetEditorDivider = checked; +} + void TilesetEditor::countMetatileUsage() { // do not double count metatileSelector->usedMetatiles.fill(0); diff --git a/src/ui/tileseteditormetatileselector.cpp b/src/ui/tileseteditormetatileselector.cpp index 778fde9c..6175a923 100644 --- a/src/ui/tileseteditormetatileselector.cpp +++ b/src/ui/tileseteditormetatileselector.cpp @@ -70,6 +70,7 @@ QImage TilesetEditorMetatileSelector::buildImage(int metatileIdStart, int numMet void TilesetEditorMetatileSelector::draw() { this->setPixmap(QPixmap::fromImage(this->buildAllMetatilesImage())); this->drawGrid(); + this->drawDivider(); this->drawSelection(); this->drawFilters(); } @@ -186,6 +187,20 @@ void TilesetEditorMetatileSelector::drawGrid() { this->setPixmap(pixmap); } +void TilesetEditorMetatileSelector::drawDivider() { + if (!this->showDivider) + return; + + const int y = this->numRows(this->primaryTileset->numMetatiles()) * 32; + + QPixmap pixmap = this->pixmap(); + QPainter painter(&pixmap); + painter.setPen(Qt::white); + painter.drawLine(0, y, this->numMetatilesWide * 32, y); + painter.end(); + this->setPixmap(pixmap); +} + void TilesetEditorMetatileSelector::drawFilters() { if (selectorShowUnused) { drawUnused(); diff --git a/src/ui/tileseteditortileselector.cpp b/src/ui/tileseteditortileselector.cpp index 7431e928..4cec089e 100644 --- a/src/ui/tileseteditortileselector.cpp +++ b/src/ui/tileseteditortileselector.cpp @@ -46,6 +46,17 @@ void TilesetEditorTileSelector::draw() { painter.drawImage(origin, tileImage); } + if (this->showDivider) { + int row = this->primaryTileset->tiles.length() / this->numTilesWide; + if (this->primaryTileset->tiles.length() % this->numTilesWide != 0) { + // Round up height for incomplete last row + row++; + } + const int y = row * 16; + painter.setPen(Qt::white); + painter.drawLine(0, y, this->numTilesWide * 16, y); + } + painter.end(); this->setPixmap(QPixmap::fromImage(image));