Add ability to change tileset metatile counts
This commit is contained in:
parent
8db57f3e0c
commit
303f31f3d4
4 changed files with 87 additions and 1 deletions
|
@ -307,7 +307,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>386</width>
|
<width>386</width>
|
||||||
<height>361</height>
|
<height>359</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
@ -397,10 +397,17 @@
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionSave_Tileset"/>
|
<addaction name="actionSave_Tileset"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuTools">
|
||||||
|
<property name="title">
|
||||||
|
<string>Tools</string>
|
||||||
|
</property>
|
||||||
<addaction name="actionImport_Primary_Tiles"/>
|
<addaction name="actionImport_Primary_Tiles"/>
|
||||||
<addaction name="actionImport_Secondary_Tiles"/>
|
<addaction name="actionImport_Secondary_Tiles"/>
|
||||||
|
<addaction name="actionChange_Metatiles_Count"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
|
<addaction name="menuTools"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
<action name="actionSave_Tileset">
|
<action name="actionSave_Tileset">
|
||||||
|
@ -421,6 +428,11 @@
|
||||||
<string>Import Secondary Tiles</string>
|
<string>Import Secondary Tiles</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionChange_Metatiles_Count">
|
||||||
|
<property name="text">
|
||||||
|
<string>Change Number of Metatiles</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -46,6 +46,8 @@ private slots:
|
||||||
|
|
||||||
void on_actionImport_Secondary_Tiles_triggered();
|
void on_actionImport_Secondary_Tiles_triggered();
|
||||||
|
|
||||||
|
void on_actionChange_Metatiles_Count_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void closeEvent(QCloseEvent*);
|
void closeEvent(QCloseEvent*);
|
||||||
void initMetatileSelector();
|
void initMetatileSelector();
|
||||||
|
|
|
@ -12,6 +12,8 @@ public:
|
||||||
this->secondaryTileset = secondaryTileset;
|
this->secondaryTileset = secondaryTileset;
|
||||||
this->numTilesWide = 16;
|
this->numTilesWide = 16;
|
||||||
this->paletteId = 0;
|
this->paletteId = 0;
|
||||||
|
this->xFlip = false;
|
||||||
|
this->yFlip = false;
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
void draw();
|
void draw();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
TilesetEditor::TilesetEditor(Project *project, QString primaryTilesetLabel, QString secondaryTilesetLabel, QWidget *parent) :
|
TilesetEditor::TilesetEditor(Project *project, QString primaryTilesetLabel, QString secondaryTilesetLabel, QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
|
@ -349,3 +350,72 @@ void TilesetEditor::closeEvent(QCloseEvent *event)
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TilesetEditor::on_actionChange_Metatiles_Count_triggered()
|
||||||
|
{
|
||||||
|
QDialog dialog(this, Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
|
||||||
|
dialog.setWindowTitle("Change Number of Metatiles");
|
||||||
|
dialog.setWindowModality(Qt::NonModal);
|
||||||
|
|
||||||
|
QFormLayout form(&dialog);
|
||||||
|
|
||||||
|
QSpinBox *primarySpinBox = new QSpinBox();
|
||||||
|
QSpinBox *secondarySpinBox = new QSpinBox();
|
||||||
|
primarySpinBox->setMinimum(1);
|
||||||
|
secondarySpinBox->setMinimum(1);
|
||||||
|
primarySpinBox->setMaximum(Project::getNumMetatilesPrimary());
|
||||||
|
secondarySpinBox->setMaximum(Project::getNumMetatilesTotal() - Project::getNumMetatilesPrimary());
|
||||||
|
primarySpinBox->setValue(this->primaryTileset->metatiles->length());
|
||||||
|
secondarySpinBox->setValue(this->secondaryTileset->metatiles->length());
|
||||||
|
form.addRow(new QLabel("Primary Tileset"), primarySpinBox);
|
||||||
|
form.addRow(new QLabel("Secondary Tileset"), secondarySpinBox);
|
||||||
|
|
||||||
|
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);
|
||||||
|
connect(&buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
|
||||||
|
connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));
|
||||||
|
form.addRow(&buttonBox);
|
||||||
|
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
int numPrimaryMetatiles = primarySpinBox->value();
|
||||||
|
int numSecondaryMetatiles = secondarySpinBox->value();
|
||||||
|
while (this->primaryTileset->metatiles->length() > numPrimaryMetatiles) {
|
||||||
|
Metatile *metatile = this->primaryTileset->metatiles->takeLast();
|
||||||
|
delete metatile;
|
||||||
|
}
|
||||||
|
while (this->primaryTileset->metatiles->length() < numPrimaryMetatiles) {
|
||||||
|
Tile tile;
|
||||||
|
tile.palette = 0;
|
||||||
|
tile.tile = 0;
|
||||||
|
tile.xflip = 0;
|
||||||
|
tile.yflip = 0;
|
||||||
|
Metatile *metatile = new Metatile;
|
||||||
|
metatile->behavior = 0;
|
||||||
|
metatile->layerType = 0;
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
metatile->tiles->append(tile);
|
||||||
|
}
|
||||||
|
this->primaryTileset->metatiles->append(metatile);
|
||||||
|
}
|
||||||
|
while (this->secondaryTileset->metatiles->length() > numSecondaryMetatiles) {
|
||||||
|
Metatile *metatile = this->secondaryTileset->metatiles->takeLast();
|
||||||
|
delete metatile;
|
||||||
|
}
|
||||||
|
while (this->secondaryTileset->metatiles->length() < numSecondaryMetatiles) {
|
||||||
|
Tile tile;
|
||||||
|
tile.palette = 0;
|
||||||
|
tile.tile = 0;
|
||||||
|
tile.xflip = 0;
|
||||||
|
tile.yflip = 0;
|
||||||
|
Metatile *metatile = new Metatile;
|
||||||
|
metatile->behavior = 0;
|
||||||
|
metatile->layerType = 0;
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
metatile->tiles->append(tile);
|
||||||
|
}
|
||||||
|
this->secondaryTileset->metatiles->append(metatile);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->refresh();
|
||||||
|
this->hasUnsavedChanges = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue