2019-03-21 23:50:50 +00:00
|
|
|
#include "newtilesetdialog.h"
|
|
|
|
#include "ui_newtilesetdialog.h"
|
|
|
|
#include "project.h"
|
|
|
|
|
|
|
|
NewTilesetDialog::NewTilesetDialog(Project* project, QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::NewTilesetDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
this->setFixedSize(this->width(), this->height());
|
|
|
|
this->project = project;
|
|
|
|
//only allow characters valid for a symbol
|
2022-11-23 03:57:26 +00:00
|
|
|
static const QRegularExpression expression("[_A-Za-z0-9]+$");
|
2021-02-06 00:43:49 +00:00
|
|
|
QRegularExpressionValidator *validator = new QRegularExpressionValidator(expression);
|
2019-03-21 23:50:50 +00:00
|
|
|
this->ui->nameLineEdit->setValidator(validator);
|
|
|
|
|
2024-07-15 21:14:38 +01:00
|
|
|
bool checkerboard = porymapConfig.tilesetCheckerboardFill;
|
2022-11-28 19:04:47 +00:00
|
|
|
this->ui->fillCheckBox->setChecked(checkerboard);
|
|
|
|
this->checkerboardFill = checkerboard;
|
|
|
|
|
2019-03-21 23:50:50 +00:00
|
|
|
connect(this->ui->nameLineEdit, &QLineEdit::textChanged, this, &NewTilesetDialog::NameOrSecondaryChanged);
|
|
|
|
connect(this->ui->typeComboBox, &QComboBox::currentTextChanged, this, &NewTilesetDialog::SecondaryChanged);
|
2022-11-28 19:04:47 +00:00
|
|
|
connect(this->ui->fillCheckBox, &QCheckBox::stateChanged, this, &NewTilesetDialog::FillChanged);
|
2019-03-21 23:50:50 +00:00
|
|
|
//connect(this->ui->toolButton, &QToolButton::clicked, this, &NewTilesetDialog::ChangeFilePath);
|
|
|
|
this->SecondaryChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
NewTilesetDialog::~NewTilesetDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewTilesetDialog::SecondaryChanged(){
|
|
|
|
this->isSecondary = (this->ui->typeComboBox->currentIndex() == 1);
|
|
|
|
NameOrSecondaryChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewTilesetDialog::NameOrSecondaryChanged() {
|
|
|
|
this->friendlyName = this->ui->nameLineEdit->text();
|
2023-12-18 07:19:12 +00:00
|
|
|
this->fullSymbolName = projectConfig.getIdentifier(ProjectIdentifier::symbol_tilesets_prefix) + this->friendlyName;
|
2019-03-21 23:50:50 +00:00
|
|
|
this->ui->symbolNameLineEdit->setText(this->fullSymbolName);
|
2022-10-07 19:29:51 +01:00
|
|
|
this->path = Tileset::getExpectedDir(this->fullSymbolName, this->isSecondary);
|
2019-03-21 23:50:50 +00:00
|
|
|
this->ui->pathLineEdit->setText(this->path);
|
|
|
|
}
|
2022-11-28 19:04:47 +00:00
|
|
|
|
|
|
|
void NewTilesetDialog::FillChanged() {
|
|
|
|
this->checkerboardFill = this->ui->fillCheckBox->isChecked();
|
2024-07-15 21:14:38 +01:00
|
|
|
porymapConfig.tilesetCheckerboardFill = this->checkerboardFill;
|
2022-11-28 19:04:47 +00:00
|
|
|
}
|