Add dividing line for tilesets in Tileset Editor
This commit is contained in:
parent
883087d161
commit
64a9e2cacb
10 changed files with 60 additions and 1 deletions
|
@ -13,6 +13,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
||||||
- Add a `Close Project` option
|
- Add a `Close Project` option
|
||||||
- Add charts to the `Wild Pokémon` tab that show species and level distributions.
|
- 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 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.
|
- 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 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.
|
- Add button to enable editing map groups including renaming groups and rearranging the maps within them.
|
||||||
|
|
|
@ -647,6 +647,7 @@
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionLayer_Grid"/>
|
<addaction name="actionLayer_Grid"/>
|
||||||
<addaction name="actionMetatile_Grid"/>
|
<addaction name="actionMetatile_Grid"/>
|
||||||
|
<addaction name="actionShow_Tileset_Divider"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionShow_Counts"/>
|
<addaction name="actionShow_Counts"/>
|
||||||
<addaction name="actionShow_Unused"/>
|
<addaction name="actionShow_Unused"/>
|
||||||
|
@ -799,6 +800,14 @@
|
||||||
<string>Ctrl+G</string>
|
<string>Ctrl+G</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionShow_Tileset_Divider">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Show Tileset Divider</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
this->showGrid = false;
|
this->showGrid = false;
|
||||||
this->showTilesetEditorMetatileGrid = false;
|
this->showTilesetEditorMetatileGrid = false;
|
||||||
this->showTilesetEditorLayerGrid = true;
|
this->showTilesetEditorLayerGrid = true;
|
||||||
|
this->showTilesetEditorDivider = false;
|
||||||
this->monitorFiles = true;
|
this->monitorFiles = true;
|
||||||
this->tilesetCheckerboardFill = true;
|
this->tilesetCheckerboardFill = true;
|
||||||
this->theme = "default";
|
this->theme = "default";
|
||||||
|
@ -119,6 +120,7 @@ public:
|
||||||
bool showGrid;
|
bool showGrid;
|
||||||
bool showTilesetEditorMetatileGrid;
|
bool showTilesetEditorMetatileGrid;
|
||||||
bool showTilesetEditorLayerGrid;
|
bool showTilesetEditorLayerGrid;
|
||||||
|
bool showTilesetEditorDivider;
|
||||||
bool monitorFiles;
|
bool monitorFiles;
|
||||||
bool tilesetCheckerboardFill;
|
bool tilesetCheckerboardFill;
|
||||||
QString theme;
|
QString theme;
|
||||||
|
|
|
@ -88,6 +88,7 @@ private slots:
|
||||||
void on_actionShow_UnusedTiles_toggled(bool checked);
|
void on_actionShow_UnusedTiles_toggled(bool checked);
|
||||||
void on_actionMetatile_Grid_triggered(bool checked);
|
void on_actionMetatile_Grid_triggered(bool checked);
|
||||||
void on_actionLayer_Grid_triggered(bool checked);
|
void on_actionLayer_Grid_triggered(bool checked);
|
||||||
|
void on_actionShow_Tileset_Divider_triggered(bool checked);
|
||||||
|
|
||||||
void on_actionUndo_triggered();
|
void on_actionUndo_triggered();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ public:
|
||||||
QVector<uint16_t> usedMetatiles;
|
QVector<uint16_t> usedMetatiles;
|
||||||
bool selectorShowUnused = false;
|
bool selectorShowUnused = false;
|
||||||
bool selectorShowCounts = false;
|
bool selectorShowCounts = false;
|
||||||
bool showGrid;
|
bool showGrid = false;
|
||||||
|
bool showDivider = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||||
|
@ -44,6 +45,7 @@ private:
|
||||||
int numRows(int numMetatiles);
|
int numRows(int numMetatiles);
|
||||||
int numRows();
|
int numRows();
|
||||||
void drawGrid();
|
void drawGrid();
|
||||||
|
void drawDivider();
|
||||||
void drawFilters();
|
void drawFilters();
|
||||||
void drawUnused();
|
void drawUnused();
|
||||||
void drawCounts();
|
void drawCounts();
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
|
|
||||||
QVector<uint16_t> usedTiles;
|
QVector<uint16_t> usedTiles;
|
||||||
bool showUnused = false;
|
bool showUnused = false;
|
||||||
|
bool showDivider = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||||
|
|
|
@ -368,6 +368,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
this->showTilesetEditorMetatileGrid = getConfigBool(key, value);
|
this->showTilesetEditorMetatileGrid = getConfigBool(key, value);
|
||||||
} else if (key == "show_tileset_editor_layer_grid") {
|
} else if (key == "show_tileset_editor_layer_grid") {
|
||||||
this->showTilesetEditorLayerGrid = getConfigBool(key, value);
|
this->showTilesetEditorLayerGrid = getConfigBool(key, value);
|
||||||
|
} else if (key == "show_tileset_editor_divider") {
|
||||||
|
this->showTilesetEditorDivider = getConfigBool(key, value);
|
||||||
} else if (key == "monitor_files") {
|
} else if (key == "monitor_files") {
|
||||||
this->monitorFiles = getConfigBool(key, value);
|
this->monitorFiles = getConfigBool(key, value);
|
||||||
} else if (key == "tileset_checkerboard_fill") {
|
} else if (key == "tileset_checkerboard_fill") {
|
||||||
|
@ -452,6 +454,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
||||||
map.insert("show_grid", this->showGrid ? "1" : "0");
|
map.insert("show_grid", this->showGrid ? "1" : "0");
|
||||||
map.insert("show_tileset_editor_metatile_grid", this->showTilesetEditorMetatileGrid ? "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_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("monitor_files", this->monitorFiles ? "1" : "0");
|
||||||
map.insert("tileset_checkerboard_fill", this->tilesetCheckerboardFill ? "1" : "0");
|
map.insert("tileset_checkerboard_fill", this->tilesetCheckerboardFill ? "1" : "0");
|
||||||
map.insert("theme", this->theme);
|
map.insert("theme", this->theme);
|
||||||
|
|
|
@ -99,6 +99,7 @@ void TilesetEditor::initUi() {
|
||||||
this->paletteId = ui->spinBox_paletteSelector->value();
|
this->paletteId = ui->spinBox_paletteSelector->value();
|
||||||
this->ui->spinBox_paletteSelector->setMinimum(0);
|
this->ui->spinBox_paletteSelector->setMinimum(0);
|
||||||
this->ui->spinBox_paletteSelector->setMaximum(Project::getNumPalettesTotal() - 1);
|
this->ui->spinBox_paletteSelector->setMaximum(Project::getNumPalettesTotal() - 1);
|
||||||
|
this->ui->actionShow_Tileset_Divider->setChecked(porymapConfig.showTilesetEditorDivider);
|
||||||
|
|
||||||
this->setAttributesUi();
|
this->setAttributesUi();
|
||||||
this->setMetatileLabelValidator();
|
this->setMetatileLabelValidator();
|
||||||
|
@ -191,6 +192,7 @@ void TilesetEditor::initMetatileSelector()
|
||||||
bool showGrid = porymapConfig.showTilesetEditorMetatileGrid;
|
bool showGrid = porymapConfig.showTilesetEditorMetatileGrid;
|
||||||
this->ui->actionMetatile_Grid->setChecked(showGrid);
|
this->ui->actionMetatile_Grid->setChecked(showGrid);
|
||||||
this->metatileSelector->showGrid = showGrid;
|
this->metatileSelector->showGrid = showGrid;
|
||||||
|
this->metatileSelector->showDivider = this->ui->actionShow_Tileset_Divider->isChecked();
|
||||||
|
|
||||||
this->metatilesScene = new QGraphicsScene;
|
this->metatilesScene = new QGraphicsScene;
|
||||||
this->metatilesScene->addItem(this->metatileSelector);
|
this->metatilesScene->addItem(this->metatileSelector);
|
||||||
|
@ -232,6 +234,8 @@ void TilesetEditor::initTileSelector()
|
||||||
connect(this->tileSelector, &TilesetEditorTileSelector::selectedTilesChanged,
|
connect(this->tileSelector, &TilesetEditorTileSelector::selectedTilesChanged,
|
||||||
this, &TilesetEditor::onSelectedTilesChanged);
|
this, &TilesetEditor::onSelectedTilesChanged);
|
||||||
|
|
||||||
|
this->tileSelector->showDivider = this->ui->actionShow_Tileset_Divider->isChecked();
|
||||||
|
|
||||||
this->tilesScene = new QGraphicsScene;
|
this->tilesScene = new QGraphicsScene;
|
||||||
this->tilesScene->addItem(this->tileSelector);
|
this->tilesScene->addItem(this->tileSelector);
|
||||||
this->tileSelector->select(0);
|
this->tileSelector->select(0);
|
||||||
|
@ -1048,6 +1052,16 @@ void TilesetEditor::on_actionLayer_Grid_triggered(bool checked) {
|
||||||
porymapConfig.showTilesetEditorLayerGrid = 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() {
|
void TilesetEditor::countMetatileUsage() {
|
||||||
// do not double count
|
// do not double count
|
||||||
metatileSelector->usedMetatiles.fill(0);
|
metatileSelector->usedMetatiles.fill(0);
|
||||||
|
|
|
@ -70,6 +70,7 @@ QImage TilesetEditorMetatileSelector::buildImage(int metatileIdStart, int numMet
|
||||||
void TilesetEditorMetatileSelector::draw() {
|
void TilesetEditorMetatileSelector::draw() {
|
||||||
this->setPixmap(QPixmap::fromImage(this->buildAllMetatilesImage()));
|
this->setPixmap(QPixmap::fromImage(this->buildAllMetatilesImage()));
|
||||||
this->drawGrid();
|
this->drawGrid();
|
||||||
|
this->drawDivider();
|
||||||
this->drawSelection();
|
this->drawSelection();
|
||||||
this->drawFilters();
|
this->drawFilters();
|
||||||
}
|
}
|
||||||
|
@ -186,6 +187,20 @@ void TilesetEditorMetatileSelector::drawGrid() {
|
||||||
this->setPixmap(pixmap);
|
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() {
|
void TilesetEditorMetatileSelector::drawFilters() {
|
||||||
if (selectorShowUnused) {
|
if (selectorShowUnused) {
|
||||||
drawUnused();
|
drawUnused();
|
||||||
|
|
|
@ -46,6 +46,17 @@ void TilesetEditorTileSelector::draw() {
|
||||||
painter.drawImage(origin, tileImage);
|
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();
|
painter.end();
|
||||||
this->setPixmap(QPixmap::fromImage(image));
|
this->setPixmap(QPixmap::fromImage(image));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue