17 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Quest creation"),
18 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Treasure creation"),
21 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Quest file definition"),
22 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"Treasure list file definition"),
25 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"quest"),
26 QT_TRANSLATE_NOOP(
"AssetOriginAndCreationDialog",
"treasure"),
38 const std::vector<std::string> &origins,
const std::vector<std::string> &assets) : myType(
type), myAssets(assets) {
41 QGridLayout *
layout =
new QGridLayout(
this);
45 layout->addWidget(
new QLabel(tr(
"Code:")), 1, 0);
46 layout->addWidget(
myCode =
new QLineEdit(
this), 1, 1, 1, 2);
52 QRadioButton *existing =
new QRadioButton(tr(
"Add to an existing %1 file:").arg(
names[
type]),
this);
53 layout->addWidget(existing, 2, 0);
55 for (
const auto &origin : origins) {
60 QRadioButton *nqf =
new QRadioButton(tr(
"Create a new %1 file:").arg(
names[
type]),
this);
61 layout->addWidget(nqf, 3, 0);
64 auto browse =
new QPushButton(tr(
"Browse..."),
this);
65 layout->addWidget(browse, 3, 2);
66 connect(browse, &QAbstractButton::clicked, [
this] () {
69 dlg.setDirectory(myRootDirectory);
71 dlg.selectFile(myNewFile->text());
74 dlg.setAcceptMode(QFileDialog::AcceptSave);
75 dlg.setFileMode(QFileDialog::AnyFile);
76 if (dlg.exec() == QDialog::Accepted) {
77 myNewFile->setText(dlg.selectedFiles()[0]);
81 connect(existing, &QAbstractButton::clicked, [
this, browse] {
84 browse->setEnabled(
false);
86 connect(nqf, &QAbstractButton::clicked, [
this, browse] {
89 browse->setEnabled(
true);
96 auto buttons =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
97 connect(buttons, &QDialogButtonBox::rejected,
this, &QDialog::reject);
98 connect(buttons, &QDialogButtonBox::accepted, [
this] () {
validate(); });
99 layout->addWidget(buttons, 4, 0, 1, 3);
103 if (!
myCode->isReadOnly()) {
104 if (
myCode->text().isEmpty()) {
105 QMessageBox::critical(
this, tr(
"Empty required field"), tr(
"Please enter a code."));
110 QMessageBox::critical(
this, tr(
"Code already exists"), tr(
"The code you entered matches an existing code."));
117 QMessageBox::critical(
this, tr(
"Empty file"), tr(
"Please enter a file to define the %1 into.").arg(
names[
myType]));
122 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) {
128 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) {