Add Cut to Tileset Editor
This commit is contained in:
parent
691ab2b9cf
commit
eb8b9b0352
3 changed files with 37 additions and 6 deletions
|
@ -567,6 +567,7 @@
|
|||
<property name="title">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<addaction name="actionCut"/>
|
||||
<addaction name="actionCopy"/>
|
||||
<addaction name="actionPaste"/>
|
||||
<addaction name="actionUndo"/>
|
||||
|
@ -665,6 +666,14 @@
|
|||
<string>Import Secondary Metatiles from Advance Map 1.92...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCut">
|
||||
<property name="text">
|
||||
<string>Cut</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+X</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopy">
|
||||
<property name="text">
|
||||
<string>Copy</string>
|
||||
|
|
|
@ -105,8 +105,8 @@ private slots:
|
|||
|
||||
void on_copyButton_metatileLabel_clicked();
|
||||
|
||||
void on_actionCut_triggered();
|
||||
void on_actionCopy_triggered();
|
||||
|
||||
void on_actionPaste_triggered();
|
||||
|
||||
private:
|
||||
|
@ -133,7 +133,9 @@ private:
|
|||
void closeEvent(QCloseEvent*);
|
||||
void countMetatileUsage();
|
||||
void countTileUsage();
|
||||
bool replaceMetatile(uint16_t metatileId, Metatile * src);
|
||||
void copyMetatile(bool cut);
|
||||
void pasteMetatile(const Metatile * toPaste);
|
||||
bool replaceMetatile(uint16_t metatileId, const Metatile * src);
|
||||
|
||||
Ui::TilesetEditor *ui;
|
||||
History<MetatileHistoryItem*> metatileHistory;
|
||||
|
|
|
@ -818,7 +818,7 @@ void TilesetEditor::onPaletteEditorChangedPalette(int paletteId) {
|
|||
this->on_spinBox_paletteSelector_valueChanged(paletteId);
|
||||
}
|
||||
|
||||
bool TilesetEditor::replaceMetatile(uint16_t metatileId, Metatile * src)
|
||||
bool TilesetEditor::replaceMetatile(uint16_t metatileId, const Metatile * src)
|
||||
{
|
||||
Metatile * dest = Tileset::getMetatile(metatileId, this->primaryTileset, this->secondaryTileset);
|
||||
if (!dest || !src || *dest == *src)
|
||||
|
@ -850,8 +850,28 @@ void TilesetEditor::on_actionRedo_triggered()
|
|||
this->replaceMetatile(commit->metatileId, commit->newMetatile);
|
||||
}
|
||||
|
||||
void TilesetEditor::on_actionCut_triggered()
|
||||
{
|
||||
int numTiles = projectConfig.getTripleLayerMetatilesEnabled() ? 12 : 8;
|
||||
Metatile * empty = new Metatile();
|
||||
for (int i = 0; i < numTiles; i++)
|
||||
empty->tiles.append(Tile());
|
||||
this->copyMetatile(true);
|
||||
this->pasteMetatile(empty);
|
||||
delete empty;
|
||||
}
|
||||
|
||||
void TilesetEditor::on_actionCopy_triggered()
|
||||
{
|
||||
this->copyMetatile(false);
|
||||
}
|
||||
|
||||
void TilesetEditor::on_actionPaste_triggered()
|
||||
{
|
||||
this->pasteMetatile(this->copiedMetatile);
|
||||
}
|
||||
|
||||
void TilesetEditor::copyMetatile(bool cut) {
|
||||
Metatile * toCopy = Tileset::getMetatile(this->getSelectedMetatileId(), this->primaryTileset, this->secondaryTileset);
|
||||
if (!toCopy) return;
|
||||
|
||||
|
@ -859,14 +879,14 @@ void TilesetEditor::on_actionCopy_triggered()
|
|||
this->copiedMetatile = new Metatile(*toCopy);
|
||||
else
|
||||
*this->copiedMetatile = *toCopy;
|
||||
this->copiedMetatile->label = ""; // Don't copy the label, these should be unique to each metatile
|
||||
if (!cut) this->copiedMetatile->label = ""; // Don't copy the label unless it's a cut, these should be unique to each metatile
|
||||
}
|
||||
|
||||
void TilesetEditor::on_actionPaste_triggered()
|
||||
void TilesetEditor::pasteMetatile(const Metatile * toPaste)
|
||||
{
|
||||
Metatile *prevMetatile = new Metatile(*this->metatile);
|
||||
uint16_t metatileId = this->getSelectedMetatileId();
|
||||
if (!this->replaceMetatile(metatileId, this->copiedMetatile)) {
|
||||
if (!this->replaceMetatile(metatileId, toPaste)) {
|
||||
delete prevMetatile;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue