17 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Quest creation"),
18 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Treasure creation"),
19 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Archetype creation"),
22 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Quest file definition"),
23 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Treasure list file definition"),
24 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Archetype file definition"),
27 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"quest"),
28 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"treasure"),
29 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"archetype"),
45 const std::vector<std::string> &origins,
const std::vector<std::string> &assets) : myType(
type), myAssets(assets) {
48 QGridLayout *
layout =
new QGridLayout(
this);
52 layout->addWidget(
new QLabel(tr(
"Code:")), 1, 0);
53 layout->addWidget(
myCode =
new QLineEdit(
this), 1, 1, 1, 2);
59 QRadioButton *existing =
new QRadioButton(tr(
"Add to an existing %1 file:").arg(
names[
type]),
this);
60 layout->addWidget(existing, 2, 0);
62 for (
const auto &origin : origins) {
67 QRadioButton *nqf =
new QRadioButton(tr(
"Create a new %1 file:").arg(
names[
type]),
this);
68 layout->addWidget(nqf, 3, 0);
71 auto browse =
new QPushButton(tr(
"Browse..."),
this);
72 layout->addWidget(browse, 3, 2);
73 connect(browse, &QAbstractButton::clicked, [
this] () {
76 dlg.setDirectory(myRootDirectory);
78 dlg.selectFile(myNewFile->text());
81 dlg.setAcceptMode(QFileDialog::AcceptSave);
82 dlg.setFileMode(QFileDialog::AnyFile);
83 if (dlg.exec() == QDialog::Accepted) {
84 myNewFile->setText(dlg.selectedFiles()[0]);
88 connect(existing, &QAbstractButton::clicked, [
this, browse] {
91 browse->setEnabled(
false);
93 connect(nqf, &QAbstractButton::clicked, [
this, browse] {
96 browse->setEnabled(
true);
103 auto buttons =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
104 connect(buttons, &QDialogButtonBox::rejected,
this, &QDialog::reject);
105 connect(buttons, &QDialogButtonBox::accepted, [
this] () {
validate(); });
106 layout->addWidget(buttons, 4, 0, 1, 3);
110 if (!
myCode->isReadOnly()) {
111 if (
myCode->text().isEmpty()) {
112 QMessageBox::critical(
this, tr(
"Empty required field"), tr(
"Please enter a code."));
117 QMessageBox::critical(
this, tr(
"Code already exists"), tr(
"The code you entered matches an existing code."));
124 QMessageBox::critical(
this, tr(
"Empty file"), tr(
"Please enter a file to define the %1 into.").arg(
names[
myType]));
129 if (QMessageBox::question(
this, tr(
"File warning"), tr(
"The file seems to be outside the root directory for this kind of assets (%1).\nThis means the asset will not be visible to the game.\nAre you sure you want to use this file?").arg(
myRootDirectory)) != QMessageBox::Yes) {
135 if (QMessageBox::question(
this, tr(
"File warning"), tr(
"The file does not end with '%1'.\nThis means the asset will not be visible to the game.\nAre you sure you want to use this file?").arg(
extensions[
myType])) != QMessageBox::Yes) {