mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-19 23:25:09 -05:00
Disallow empty prefabs
Some checks failed
Build Porymap / build-linux (, 5.14.2) (push) Has been cancelled
Build Porymap / build-linux (, 6.8.*) (push) Has been cancelled
Build Porymap / build-linux (minimal, 5.14.2) (push) Has been cancelled
Build Porymap / build-macos (macos-15-intel) (push) Has been cancelled
Build Porymap / build-macos (macos-latest) (push) Has been cancelled
Build Porymap / build-static-windows (push) Has been cancelled
Some checks failed
Build Porymap / build-linux (, 5.14.2) (push) Has been cancelled
Build Porymap / build-linux (, 6.8.*) (push) Has been cancelled
Build Porymap / build-linux (minimal, 5.14.2) (push) Has been cancelled
Build Porymap / build-macos (macos-15-intel) (push) Has been cancelled
Build Porymap / build-macos (macos-latest) (push) Has been cancelled
Build Porymap / build-static-windows (push) Has been cancelled
This commit is contained in:
@@ -22,6 +22,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
|
||||
- Fix not being able to minimize/maximize some windows.
|
||||
- Fix some menu items under `Tools` not being disabled when their corresponding button is disabled.
|
||||
- Fix the map list search bar stealing keyboard focus whenever a map layout was opened.
|
||||
- Disallow creating prefabs with no metatiles.
|
||||
|
||||
## [6.3.1] - 2026-04-12
|
||||
### Added
|
||||
|
||||
@@ -34,6 +34,18 @@ struct MetatileSelection
|
||||
bool hasCollision;
|
||||
QList<MetatileSelectionItem> metatileItems;
|
||||
QList<CollisionSelectionItem> collisionItems;
|
||||
|
||||
bool isEmpty() const {
|
||||
for (const auto& metatileItem : metatileItems) {
|
||||
if (metatileItem.enabled) return false;
|
||||
}
|
||||
if (hasCollision) {
|
||||
for (const auto& collisionItem : collisionItems) {
|
||||
if (collisionItem.enabled) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
class MetatileSelector: public SelectablePixmapItem {
|
||||
|
||||
@@ -24,6 +24,8 @@ private:
|
||||
Layout *layout = nullptr;
|
||||
Ui::PrefabCreationDialog *ui;
|
||||
MetatileSelection selection;
|
||||
|
||||
void validate();
|
||||
};
|
||||
|
||||
#endif // PREFABCREATIONDIALOG_H
|
||||
|
||||
@@ -82,6 +82,7 @@ void Prefab::loadPrefabs() {
|
||||
selection.metatileItems[index].enabled = true;
|
||||
selection.collisionItems[index].enabled = true;
|
||||
}
|
||||
if (selection.isEmpty()) continue;
|
||||
|
||||
this->items.append(PrefabItem{QUuid::createUuid(), name, primaryTileset, secondaryTileset, selection});
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "prefab.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPushButton>
|
||||
|
||||
PrefabCreationDialog::PrefabCreationDialog(QWidget *parent, MetatileSelector *metatileSelector, Layout *layout) :
|
||||
QDialog(parent),
|
||||
@@ -36,9 +37,12 @@ PrefabCreationDialog::PrefabCreationDialog(QWidget *parent, MetatileSelector *me
|
||||
this->selection.collisionItems[index].enabled = toggledState;
|
||||
}
|
||||
pixmapItem->setPixmap(drawMetatileSelection(this->selection, layout));
|
||||
validate();
|
||||
});
|
||||
|
||||
connect(this, &PrefabCreationDialog::accepted, this, &PrefabCreationDialog::savePrefab);
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
PrefabCreationDialog::~PrefabCreationDialog()
|
||||
@@ -46,6 +50,13 @@ PrefabCreationDialog::~PrefabCreationDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrefabCreationDialog::validate() {
|
||||
bool valid = !this->selection.isEmpty();
|
||||
|
||||
QPushButton* okButton = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
if (okButton) okButton->setEnabled(valid);
|
||||
}
|
||||
|
||||
void PrefabCreationDialog::savePrefab() {
|
||||
prefab.addPrefab(this->selection, this->layout, this->ui->lineEdit_PrefabName->text());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user