diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui
index f5e0a0b8..11f6ac21 100644
--- a/forms/mainwindow.ui
+++ b/forms/mainwindow.ui
@@ -233,23 +233,23 @@
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
+ -
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
-
@@ -362,8 +362,8 @@
0
0
- 543
- 600
+ 508
+ 665
@@ -890,8 +890,8 @@
0
0
- 443
- 74
+ 442
+ 77
@@ -1078,10 +1078,10 @@
- 8
+ 0
0
- 431
- 341
+ 425
+ 419
@@ -1496,8 +1496,8 @@
0
0
- 430
- 521
+ 98
+ 28
@@ -1541,8 +1541,8 @@
0
0
- 430
- 521
+ 98
+ 28
@@ -1586,8 +1586,8 @@
0
0
- 430
- 521
+ 98
+ 28
@@ -1631,8 +1631,8 @@
0
0
- 430
- 521
+ 98
+ 28
@@ -1676,8 +1676,8 @@
0
0
- 430
- 521
+ 98
+ 28
@@ -1727,8 +1727,8 @@
0
0
- 430
- 521
+ 98
+ 28
@@ -2428,8 +2428,8 @@
0
0
- 118
- 118
+ 101
+ 101
@@ -2690,7 +2690,7 @@
0
0
1287
- 22
+ 21
@@ -3028,6 +3029,14 @@
Export Map Stitch Image...
+
+
+ true
+
+
+ Use Triple Layer Metatiles
+
+
@@ -3040,6 +3049,7 @@
AdjustingStackedWidget
QStackedWidget
+ 1
GraphicsView
diff --git a/include/config.h b/include/config.h
index 5d2cf40a..4bd21cfe 100644
--- a/include/config.h
+++ b/include/config.h
@@ -122,6 +122,7 @@ public:
this->enableHealLocationRespawnData = false;
this->enableObjectEventInConnection = false;
this->enableFloorNumber = false;
+ this->enableTripleLayerMetatiles = false;
this->customScripts.clear();
this->readKeys.clear();
}
@@ -149,6 +150,8 @@ public:
bool getObjectEventInConnectionEnabled();
void setFloorNumberEnabled(bool enable);
bool getFloorNumberEnabled();
+ void setTripleLayerMetatilesEnabled(bool enable);
+ bool getTripleLayerMetatilesEnabled();
void setCustomScripts(QList scripts);
QList getCustomScripts();
protected:
@@ -170,6 +173,7 @@ private:
bool enableHealLocationRespawnData;
bool enableObjectEventInConnection;
bool enableFloorNumber;
+ bool enableTripleLayerMetatiles;
QList customScripts;
QStringList readKeys;
};
diff --git a/include/mainwindow.h b/include/mainwindow.h
index af9266d1..9193c3a2 100644
--- a/include/mainwindow.h
+++ b/include/mainwindow.h
@@ -148,6 +148,7 @@ private slots:
void on_actionUse_Encounter_Json_triggered(bool checked);
void on_actionMonitor_Project_Files_triggered(bool checked);
void on_actionUse_Poryscript_triggered(bool checked);
+ void on_actionUse_Triple_Layer_Metatiles_triggered(bool checked);
void on_mainTabBar_tabBarClicked(int index);
diff --git a/src/config.cpp b/src/config.cpp
index 0c5517c7..8934f707 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -423,6 +423,12 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
if (!ok) {
logWarn(QString("Invalid config value for enable_floor_number: '%1'. Must be 0 or 1.").arg(value));
}
+ } else if (key == "enable_triple_layer_metatiles") {
+ bool ok;
+ this->enableTripleLayerMetatiles = value.toInt(&ok);
+ if (!ok) {
+ logWarn(QString("Invalid config value for enable_triple_layer_metatiles: '%1'. Must be 0 or 1.").arg(value));
+ }
} else if (key == "custom_scripts") {
this->customScripts.clear();
QList paths = value.split(",");
@@ -464,6 +470,7 @@ QMap ProjectConfig::getKeyValueMap() {
map.insert("enable_heal_location_respawn_data", QString::number(this->enableHealLocationRespawnData));
map.insert("enable_object_event_in_connection", QString::number(this->enableObjectEventInConnection));
map.insert("enable_floor_number", QString::number(this->enableFloorNumber));
+ map.insert("enable_triple_layer_metatiles", QString::number(this->enableTripleLayerMetatiles));
map.insert("custom_scripts", this->customScripts.join(","));
return map;
}
@@ -505,6 +512,7 @@ void ProjectConfig::onNewConfigFileCreated() {
this->enableFloorNumber = isPokefirered;
this->useEncounterJson = true;
this->usePoryScript = false;
+ this->enableTripleLayerMetatiles = false;
this->customScripts.clear();
}
@@ -615,6 +623,15 @@ bool ProjectConfig::getFloorNumberEnabled() {
return this->enableFloorNumber;
}
+void ProjectConfig::setTripleLayerMetatilesEnabled(bool enable) {
+ this->enableTripleLayerMetatiles = enable;
+ this->save();
+}
+
+bool ProjectConfig::getTripleLayerMetatilesEnabled() {
+ return this->enableTripleLayerMetatiles;
+}
+
void ProjectConfig::setCustomScripts(QList scripts) {
this->customScripts = scripts;
this->save();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9f698931..9211a13c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -165,6 +165,7 @@ void MainWindow::setProjectSpecificUIVisibility()
{
ui->actionUse_Encounter_Json->setChecked(projectConfig.getEncounterJsonActive());
ui->actionUse_Poryscript->setChecked(projectConfig.getUsePoryScript());
+ ui->actionUse_Triple_Layer_Metatiles->setChecked(projectConfig.getTripleLayerMetatilesEnabled());
ui->mainTabBar->setTabEnabled(4, projectConfig.getEncounterJsonActive());
@@ -1328,6 +1329,15 @@ void MainWindow::on_actionUse_Poryscript_triggered(bool checked)
projectConfig.setUsePoryScript(checked);
}
+void MainWindow::on_actionUse_Triple_Layer_Metatiles_triggered(bool checked)
+{
+ QMessageBox warning(this);
+ warning.setText("You must reload the project for this setting to take effect.");
+ warning.setIcon(QMessageBox::Information);
+ warning.exec();
+ projectConfig.setTripleLayerMetatilesEnabled(checked);
+}
+
void MainWindow::on_actionPencil_triggered()
{
on_toolButton_Paint_clicked();
diff --git a/src/project.cpp b/src/project.cpp
index 5600bc54..e22222c4 100644
--- a/src/project.cpp
+++ b/src/project.cpp
@@ -1088,7 +1088,8 @@ void Project::saveTilesetMetatiles(Tileset *tileset) {
if (metatiles_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QByteArray data;
for (Metatile *metatile : *tileset->metatiles) {
- for (int i = 0; i < 8; i++) {
+ int numTiles = projectConfig.getTripleLayerMetatilesEnabled() ? 12 : 8;
+ for (int i = 0; i < numTiles; i++) {
Tile tile = metatile->tiles->at(i);
uint16_t value = static_cast((tile.tile & 0x3ff)
| ((tile.xflip & 1) << 10)
@@ -1602,8 +1603,9 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
QFile metatiles_file(tileset->metatiles_path);
if (metatiles_file.open(QIODevice::ReadOnly)) {
QByteArray data = metatiles_file.readAll();
- int num_metatiles = data.length() / 16;
- int num_layers = 2;
+ int metatile_data_length = projectConfig.getTripleLayerMetatilesEnabled() ? 24 : 16;
+ int num_metatiles = data.length() / metatile_data_length;
+ int num_layers = projectConfig.getTripleLayerMetatilesEnabled() ? 3 : 2;
QList *metatiles = new QList;
for (int i = 0; i < num_metatiles; i++) {
Metatile *metatile = new Metatile;
diff --git a/src/ui/imageproviders.cpp b/src/ui/imageproviders.cpp
index f060450e..e32026ca 100644
--- a/src/ui/imageproviders.cpp
+++ b/src/ui/imageproviders.cpp
@@ -1,3 +1,4 @@
+#include "config.h"
#include "imageproviders.h"
#include "log.h"
#include
@@ -30,7 +31,9 @@ QImage getMetatileImage(uint16_t tile, Tileset *primaryTileset, Tileset *seconda
QList> palettes = Tileset::getBlockPalettes(primaryTileset, secondaryTileset, useTruePalettes);
QPainter metatile_painter(&metatile_image);
- for (int layer = 0; layer < 2; layer++)
+ bool isTripleLayerMetatile = projectConfig.getTripleLayerMetatilesEnabled();
+ int numLayers = isTripleLayerMetatile ? 3: 2;
+ for (int layer = 0; layer < numLayers; layer++)
for (int y = 0; y < 2; y++)
for (int x = 0; x < 2; x++) {
Tile tile_ = metatile->tiles->value((y * 2) + x + (layer * 4));
diff --git a/src/ui/metatilelayersitem.cpp b/src/ui/metatilelayersitem.cpp
index cf4c3b9f..0feb543f 100644
--- a/src/ui/metatilelayersitem.cpp
+++ b/src/ui/metatilelayersitem.cpp
@@ -1,3 +1,4 @@
+#include "config.h"
#include "metatilelayersitem.h"
#include "imageproviders.h"
#include
@@ -12,11 +13,18 @@ void MetatileLayersItem::draw() {
QPoint(48, 0),
QPoint(32, 16),
QPoint(48, 16),
+ QPoint(64, 0),
+ QPoint(80, 0),
+ QPoint(64, 16),
+ QPoint(80, 16),
};
- QPixmap pixmap(64, 32);
+ bool isTripleLayerMetatile = projectConfig.getTripleLayerMetatilesEnabled();
+ int width = isTripleLayerMetatile ? 96 : 64;
+ QPixmap pixmap(width, 32);
QPainter painter(&pixmap);
- for (int i = 0; i < 8; i++) {
+ int numTiles = isTripleLayerMetatile ? 12 : 8;
+ for (int i = 0; i < numTiles; i++) {
Tile tile = this->metatile->tiles->at(i);
QImage tileImage = getPalettedTileImage(tile.tile, this->primaryTileset, this->secondaryTileset, tile.palette, true)
.mirrored(tile.xflip, tile.yflip)
@@ -92,10 +100,12 @@ void MetatileLayersItem::clearLastModifiedCoords() {
}
void MetatileLayersItem::getBoundedCoords(QPointF pos, int *x, int *y) {
+ bool isTripleLayerMetatile = projectConfig.getTripleLayerMetatilesEnabled();
+ int maxX = isTripleLayerMetatile ? 5 : 3;
*x = static_cast(pos.x()) / 16;
*y = static_cast(pos.y()) / 16;
if (*x < 0) *x = 0;
if (*y < 0) *y = 0;
- if (*x > 3) *x = 3;
+ if (*x > maxX) *x = maxX;
if (*y > 1) *y = 1;
}
diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp
index 3b09a069..386f62fc 100644
--- a/src/ui/tileseteditor.cpp
+++ b/src/ui/tileseteditor.cpp
@@ -223,6 +223,7 @@ void TilesetEditor::onSelectedMetatileChanged(uint16_t metatileId) {
this->metatile = Tileset::getMetatile(metatileId, this->primaryTileset, this->secondaryTileset);
this->metatileLayersItem->setMetatile(metatile);
this->metatileLayersItem->draw();
+ this->ui->graphicsView_metatileLayers->setFixedSize(this->metatileLayersItem->pixmap().width() + 2, this->metatileLayersItem->pixmap().height() + 2);
this->ui->comboBox_metatileBehaviors->setCurrentIndex(this->ui->comboBox_metatileBehaviors->findData(this->metatile->behavior));
this->ui->lineEdit_metatileLabel->setText(this->metatile->label);
this->ui->comboBox_layerType->setCurrentIndex(this->ui->comboBox_layerType->findData(this->metatile->layerType));
@@ -255,16 +256,22 @@ void TilesetEditor::onMetatileLayerTileChanged(int x, int y) {
QPoint(2, 0),
QPoint(3, 0),
QPoint(2, 1),
- QPoint(3, 1)
+ QPoint(3, 1),
+ QPoint(4, 0),
+ QPoint(5, 0),
+ QPoint(4, 1),
+ QPoint(5, 1),
};
Metatile *prevMetatile = this->metatile->copy();
QPoint dimensions = this->tileSelector->getSelectionDimensions();
QList tiles = this->tileSelector->getSelectedTiles();
int selectedTileIndex = 0;
+ bool isTripleLayerMetatile = projectConfig.getTripleLayerMetatilesEnabled();
+ int maxTileIndex = isTripleLayerMetatile ? 12: 8;
for (int j = 0; j < dimensions.y(); j++) {
for (int i = 0; i < dimensions.x(); i++) {
int tileIndex = ((x + i) / 2 * 4) + ((y + j) * 2) + ((x + i) % 2);
- if (tileIndex < 8
+ if (tileIndex < maxTileIndex
&& tileCoords.at(tileIndex).x() >= x
&& tileCoords.at(tileIndex).y() >= y){
Tile *tile = &(*this->metatile->tiles)[tileIndex];
@@ -289,10 +296,12 @@ void TilesetEditor::onMetatileLayerSelectionChanged(QPoint selectionOrigin, int
QList tiles;
int x = selectionOrigin.x();
int y = selectionOrigin.y();
+ bool isTripleLayerMetatile = projectConfig.getTripleLayerMetatilesEnabled();
+ int maxTileIndex = isTripleLayerMetatile ? 12: 8;
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
int tileIndex = ((x + i) / 2 * 4) + ((y + j) * 2) + ((x + i) % 2);
- if (tileIndex < 8) {
+ if (tileIndex < maxTileIndex) {
tiles.append(this->metatile->tiles->at(tileIndex));
}
}