[nostalgia/core/studio] Move NewTileSheetWizard validation to accept

This commit is contained in:
Gary Talent 2020-03-31 22:01:32 -05:00
parent 23c8a5eefc
commit 5189fefaa1

View File

@ -20,14 +20,8 @@ namespace nostalgia::core {
NewTilesheetWizardPage::NewTilesheetWizardPage(const studio::Context *ctx) {
m_ctx = ctx;
addLineEdit(tr("&Tile Sheet Name:"), QString(TileSheetName) + "*", "", [this](QString name) {
auto path = QString(TileSheetDir) + name + FileExt_ng;
auto err = m_ctx->project->exists(path);
if (err) {
showValidationError(tr("A tile sheet with this name already exists."));
}
return err;
}
);
return 0;
});
m_palettePicker = addComboBox(tr("&Palette:"), QString(Palette) + "*", {""});
m_ctx->project->subscribe(studio::ProjectEvent::FileRecognized, m_palettePicker, [this](QString path) {
if (path.startsWith(PaletteDir) && path.endsWith(FileExt_npal)) {
@ -40,6 +34,12 @@ int NewTilesheetWizardPage::accept() {
const auto tilesheetName = field(TileSheetName).toString();
const auto palette = m_palettePicker->itemData(field(Palette).toInt()).toString();
const auto outPath = TileSheetDir + tilesheetName + FileExt_ng;
auto outPath = QString(TileSheetDir) + name + FileExt_ng;
auto err = m_ctx->project->exists(outPath);
if (err) {
showValidationError(tr("A tile sheet with this name already exists."));
return err;
}
NostalgiaGraphic ng;
ng.columns = 1;
ng.rows = 1;