[nostalgia/core/studio] Move NewTileSheetWizard validation to accept
This commit is contained in:
parent
23c8a5eefc
commit
5189fefaa1
@ -20,14 +20,8 @@ namespace nostalgia::core {
|
|||||||
NewTilesheetWizardPage::NewTilesheetWizardPage(const studio::Context *ctx) {
|
NewTilesheetWizardPage::NewTilesheetWizardPage(const studio::Context *ctx) {
|
||||||
m_ctx = ctx;
|
m_ctx = ctx;
|
||||||
addLineEdit(tr("&Tile Sheet Name:"), QString(TileSheetName) + "*", "", [this](QString name) {
|
addLineEdit(tr("&Tile Sheet Name:"), QString(TileSheetName) + "*", "", [this](QString name) {
|
||||||
auto path = QString(TileSheetDir) + name + FileExt_ng;
|
return 0;
|
||||||
auto err = m_ctx->project->exists(path);
|
});
|
||||||
if (err) {
|
|
||||||
showValidationError(tr("A tile sheet with this name already exists."));
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
m_palettePicker = addComboBox(tr("&Palette:"), QString(Palette) + "*", {""});
|
m_palettePicker = addComboBox(tr("&Palette:"), QString(Palette) + "*", {""});
|
||||||
m_ctx->project->subscribe(studio::ProjectEvent::FileRecognized, m_palettePicker, [this](QString path) {
|
m_ctx->project->subscribe(studio::ProjectEvent::FileRecognized, m_palettePicker, [this](QString path) {
|
||||||
if (path.startsWith(PaletteDir) && path.endsWith(FileExt_npal)) {
|
if (path.startsWith(PaletteDir) && path.endsWith(FileExt_npal)) {
|
||||||
@ -40,6 +34,12 @@ int NewTilesheetWizardPage::accept() {
|
|||||||
const auto tilesheetName = field(TileSheetName).toString();
|
const auto tilesheetName = field(TileSheetName).toString();
|
||||||
const auto palette = m_palettePicker->itemData(field(Palette).toInt()).toString();
|
const auto palette = m_palettePicker->itemData(field(Palette).toInt()).toString();
|
||||||
const auto outPath = TileSheetDir + tilesheetName + FileExt_ng;
|
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;
|
NostalgiaGraphic ng;
|
||||||
ng.columns = 1;
|
ng.columns = 1;
|
||||||
ng.rows = 1;
|
ng.rows = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user