diff --git a/forms/newlayoutdialog.ui b/forms/newlayoutdialog.ui
index bfbc9b02..42c7733c 100644
--- a/forms/newlayoutdialog.ui
+++ b/forms/newlayoutdialog.ui
@@ -13,9 +13,21 @@
New Layout Options
+
+ true
+
+
+ true
+
-
+
+ QFrame::Shape::NoFrame
+
+
+ QFrame::Shadow::Plain
+
true
@@ -24,8 +36,8 @@
0
0
- 238
- 107
+ 240
+ 109
diff --git a/forms/newmapdialog.ui b/forms/newmapdialog.ui
index 3e133dfd..6b32810a 100644
--- a/forms/newmapdialog.ui
+++ b/forms/newmapdialog.ui
@@ -6,16 +6,31 @@
0
0
- 255
- 320
+ 559
+ 614
New Map Options
+
+ true
+
+
+ true
+
-
+
+ QFrame::Shape::NoFrame
+
+
+ QFrame::Shadow::Plain
+
+
+ QAbstractScrollArea::SizeAdjustPolicy::AdjustToContents
+
true
@@ -24,8 +39,8 @@
0
0
- 229
- 228
+ 535
+ 550
@@ -42,6 +57,9 @@
-
+
+ QLayout::SizeConstraint::SetMinAndMaxSize
+
0
diff --git a/forms/newnamedialog.ui b/forms/newnamedialog.ui
index 6fa6b56d..fa6cb5ae 100644
--- a/forms/newnamedialog.ui
+++ b/forms/newnamedialog.ui
@@ -10,15 +10,12 @@
87
+
+ true
+
-
-
- QFrame::Shape::NoFrame
-
-
- QFrame::Shadow::Plain
-
0
diff --git a/forms/newtilesetdialog.ui b/forms/newtilesetdialog.ui
index 1fed2558..3b898761 100644
--- a/forms/newtilesetdialog.ui
+++ b/forms/newtilesetdialog.ui
@@ -13,16 +13,25 @@
Add new Tileset
+
+ true
+
-
-
- QFrame::Shape::StyledPanel
-
-
- QFrame::Shadow::Raised
-
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
-
diff --git a/include/core/map.h b/include/core/map.h
index 6e953877..9cc2a69b 100644
--- a/include/core/map.h
+++ b/include/core/map.h
@@ -107,7 +107,7 @@ public:
private:
QString m_name;
QString m_constantName;
- QString m_layoutId; // TODO: Why do we do half this->layout()->id and half this->layoutId. Should these ever be different?
+ QString m_layoutId;
QString m_sharedEventsMap = "";
QString m_sharedScriptsMap = "";
diff --git a/include/core/maplayout.h b/include/core/maplayout.h
index 7761d7fc..1579b4ad 100644
--- a/include/core/maplayout.h
+++ b/include/core/maplayout.h
@@ -14,8 +14,6 @@ class LayoutPixmapItem;
class CollisionPixmapItem;
class BorderMetatilesPixmapItem;
-// TODO: Privatize members as appropriate
-
class Layout : public QObject {
Q_OBJECT
public:
diff --git a/include/lib/collapsiblesection.h b/include/lib/collapsiblesection.h
index 584e44cb..73169303 100644
--- a/include/lib/collapsiblesection.h
+++ b/include/lib/collapsiblesection.h
@@ -41,7 +41,7 @@ public:
explicit CollapsibleSection(const QString& title = "", const bool expanded = false, const int animationDuration = 0, QWidget* parent = 0);
void setContentLayout(QLayout* contentLayout);
- void setTitle(QString title);
+ void setTitle(const QString &title);
bool isExpanded() const { return this->expanded; }
public slots:
diff --git a/include/mainwindow.h b/include/mainwindow.h
index 1e8c53bb..0eac8947 100644
--- a/include/mainwindow.h
+++ b/include/mainwindow.h
@@ -31,6 +31,7 @@
#include "updatepromoter.h"
#include "aboutporymap.h"
#include "mapheaderform.h"
+#include "newlayoutdialog.h"
@@ -350,8 +351,11 @@ private:
void openNewMapDialog();
void openDuplicateMapDialog(const QString &mapName);
+ NewLayoutDialog* createNewLayoutDialog(const Layout *layoutToCopy = nullptr);
void openNewLayoutDialog();
void openDuplicateLayoutDialog(const QString &layoutId);
+ void openNewMapGroupDialog();
+ void openNewAreaDialog();
void openSubWindow(QWidget * window);
void scrollMapList(MapTree *list, const QString &itemName);
void scrollMapListToCurrentMap(MapTree *list);
@@ -370,8 +374,6 @@ private:
void refreshRecentProjectsMenu();
void updateMapList();
- void mapListAddGroup();
- void mapListAddArea();
void openMapListItem(const QModelIndex &index);
void saveMapListTab(int index);
diff --git a/include/project.h b/include/project.h
index 895f9979..9c9fdf33 100644
--- a/include/project.h
+++ b/include/project.h
@@ -111,7 +111,7 @@ public:
QStringList secondaryTilesetLabels;
QStringList tilesetLabelsOrdered;
- Blockdata readBlockdata(QString);
+ Blockdata readBlockdata(QString, bool *ok = nullptr);
bool loadBlockdata(Layout *);
bool loadLayoutBorder(Layout *);
@@ -121,6 +121,7 @@ public:
bool readMapGroups();
void addNewMapGroup(const QString &groupName);
+ QString mapNameToMapGroup(const QString &mapName);
struct NewMapSettings {
QString name;
@@ -141,6 +142,8 @@ public:
Layout *createNewLayout(const Layout::Settings &layoutSettings, const Layout* toDuplicate = nullptr);
Tileset *createNewTileset(const QString &friendlyName, bool secondary, bool checkerboardFill);
bool isIdentifierUnique(const QString &identifier) const;
+ bool isValidNewIdentifier(const QString &identifier) const;
+ QString toUniqueIdentifier(const QString &identifier) const;
QString getProjectTitle();
bool readWildMonData();
diff --git a/src/lib/collapsiblesection.cpp b/src/lib/collapsiblesection.cpp
index 34dfb780..8ad8560a 100644
--- a/src/lib/collapsiblesection.cpp
+++ b/src/lib/collapsiblesection.cpp
@@ -119,9 +119,9 @@ void CollapsibleSection::setContentLayout(QLayout* contentLayout)
updateAnimationTargets();
}
-void CollapsibleSection::setTitle(QString title)
+void CollapsibleSection::setTitle(const QString &title)
{
- toggleButton->setText(std::move(title));
+ toggleButton->setText(title);
}
int CollapsibleSection::getContentHeight() const
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 629a582f..65a323e2 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -24,7 +24,6 @@
#include "config.h"
#include "filedialog.h"
#include "newmapdialog.h"
-#include "newlayoutdialog.h"
#include "newtilesetdialog.h"
#include "newnamedialog.h"
@@ -69,7 +68,7 @@ MainWindow::MainWindow(QWidget *parent) :
QCoreApplication::setOrganizationName("pret");
QCoreApplication::setApplicationName("porymap");
QCoreApplication::setApplicationVersion(PORYMAP_VERSION);
- QApplication::setApplicationDisplayName("porymap");
+ QApplication::setApplicationDisplayName(QApplication::applicationName());
QApplication::setWindowIcon(QIcon(":/icons/porymap-icon-2.ico"));
ui->setupUi(this);
@@ -448,8 +447,8 @@ void MainWindow::initMapList() {
connect(ui->mapListToolBar_Layouts, &MapListToolBar::filterCleared, this, &MainWindow::scrollMapListToCurrentLayout);
// Connect the "add folder" button in each of the map lists
- connect(ui->mapListToolBar_Groups, &MapListToolBar::addFolderClicked, this, &MainWindow::mapListAddGroup);
- connect(ui->mapListToolBar_Areas, &MapListToolBar::addFolderClicked, this, &MainWindow::mapListAddArea);
+ connect(ui->mapListToolBar_Groups, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewMapGroupDialog);
+ connect(ui->mapListToolBar_Areas, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewAreaDialog);
connect(ui->mapListToolBar_Layouts, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewLayoutDialog);
connect(ui->mapListContainer, &QTabWidget::currentChanged, this, &MainWindow::saveMapListTab);
@@ -699,14 +698,14 @@ bool MainWindow::checkProjectSanity() {
void MainWindow::showProjectOpenFailure() {
QString errorMsg = QString("There was an error opening the project. Please see %1 for full error details.").arg(getLogPath());
- QMessageBox error(QMessageBox::Critical, "porymap", errorMsg, QMessageBox::Ok, this);
+ QMessageBox error(QMessageBox::Critical, QApplication::applicationName(), errorMsg, QMessageBox::Ok, this);
error.setDetailedText(getMostRecentError());
error.exec();
}
// Alert the user that one or more maps have been excluded while loading the project.
void MainWindow::showMapsExcludedAlert(const QStringList &excludedMapNames) {
- QMessageBox msgBox(QMessageBox::Icon::Warning, "porymap", "", QMessageBox::Ok, this);
+ QMessageBox msgBox(QMessageBox::Icon::Warning, QApplication::applicationName(), "", QMessageBox::Ok, this);
QString errorMsg;
if (excludedMapNames.length() == 1) {
@@ -880,7 +879,7 @@ bool MainWindow::userSetMap(QString map_name) {
if (map_name == editor->project->getDynamicMapName()) {
QMessageBox msgBox(QMessageBox::Icon::Warning,
- "Cannot Open Map",
+ QApplication::applicationName(),
QString("The map '%1' can't be opened, it's a placeholder to indicate the specified map will be set programmatically.").arg(map_name),
QMessageBox::Ok,
this);
@@ -890,7 +889,7 @@ bool MainWindow::userSetMap(QString map_name) {
if (!setMap(map_name)) {
QMessageBox msgBox(QMessageBox::Icon::Critical,
- "Error Opening Map",
+ QApplication::applicationName(),
QString("There was an error opening map %1.\n\nPlease see %2 for full error details.").arg(map_name).arg(getLogPath()),
QMessageBox::Ok,
this);
@@ -952,7 +951,7 @@ void MainWindow::setLayoutOnlyMode(bool layoutOnly) {
bool MainWindow::userSetLayout(QString layoutId) {
if (!setLayout(layoutId)) {
QMessageBox msgBox(QMessageBox::Icon::Critical,
- "Error Opening Layout",
+ QApplication::applicationName(),
QString("There was an error opening layout %1.\n\nPlease see %2 for full error details.").arg(layoutId).arg(getLogPath()),
QMessageBox::Ok,
this);
@@ -1310,13 +1309,13 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point) {
menu.exec(QCursor::pos());
}
-void MainWindow::mapListAddGroup() {
+void MainWindow::openNewMapGroupDialog() {
auto dialog = new NewNameDialog("New Group Name", this->editor->project, this);
connect(dialog, &NewNameDialog::applied, this->editor->project, &Project::addNewMapGroup);
dialog->open();
}
-void MainWindow::mapListAddArea() {
+void MainWindow::openNewAreaDialog() {
auto dialog = new NewNameDialog("New Area Name", this->editor->project, this);
dialog->setNamePrefix(projectConfig.getIdentifier(ProjectIdentifier::define_map_section_prefix));
connect(dialog, &NewNameDialog::applied, this->editor->project, &Project::addNewMapsec);
@@ -1388,9 +1387,11 @@ void MainWindow::setLocationComboBoxes(const QStringList &locations) {
}
void MainWindow::onNewTilesetCreated(Tileset *tileset) {
- QString message = QString("Created a new tileset named %1.").arg(tileset->name);
- logInfo(message);
- statusBar()->showMessage(message);
+ logInfo(QString("Created a new tileset named %1.").arg(tileset->name));
+
+ // Unlike creating a new map or layout (which immediately opens the new item)
+ // creating a new tileset has no visual feedback that it succeeded, so we show a message.
+ QMessageBox::information(this, QApplication::applicationName(), QString( "New tileset created at '%1'!").arg(tileset->getExpectedDir()));
// Refresh tileset combo boxes
if (!tileset->is_secondary) {
@@ -1413,24 +1414,40 @@ void MainWindow::openDuplicateMapDialog(const QString &mapName) {
auto dialog = new NewMapDialog(this->editor->project, map, this);
dialog->open();
} else {
- //TODO
+ QMessageBox msgBox(QMessageBox::Icon::Critical,
+ QApplication::applicationName(),
+ QString("Unable to duplicate '%1'.\n\nPlease see %2 for full error details.").arg(mapName).arg(getLogPath()),
+ QMessageBox::Ok,
+ this);
+ msgBox.setDetailedText(getMostRecentError());
+ msgBox.exec();
}
}
-void MainWindow::openNewLayoutDialog() {
- auto dialog = new NewLayoutDialog(this->editor->project, this);
+NewLayoutDialog* MainWindow::createNewLayoutDialog(const Layout *layoutToCopy) {
+ auto dialog = new NewLayoutDialog(this->editor->project, layoutToCopy, this);
connect(dialog, &NewLayoutDialog::applied, this, &MainWindow::userSetLayout);
+ return dialog;
+}
+
+void MainWindow::openNewLayoutDialog() {
+ auto dialog = createNewLayoutDialog();
dialog->open();
}
void MainWindow::openDuplicateLayoutDialog(const QString &layoutId) {
auto layout = this->editor->project->loadLayout(layoutId);
if (layout) {
- auto dialog = new NewLayoutDialog(this->editor->project, layout, this);
- connect(dialog, &NewLayoutDialog::applied, this, &MainWindow::userSetLayout);
+ auto dialog = createNewLayoutDialog(layout);
dialog->open();
} else {
- //TODO
+ QMessageBox msgBox(QMessageBox::Icon::Critical,
+ QApplication::applicationName(),
+ QString("Unable to duplicate '%1'.\n\nPlease see %2 for full error details.").arg(layoutId).arg(getLogPath()),
+ QMessageBox::Ok,
+ this);
+ msgBox.setDetailedText(getMostRecentError());
+ msgBox.exec();
}
}
@@ -1675,7 +1692,7 @@ void MainWindow::setClipboardData(OrderedJson::object object) {
QClipboard *clipboard = QGuiApplication::clipboard();
QString newText;
int indent = 0;
- object["application"] = "porymap";
+ object["application"] = QApplication::applicationName();
OrderedJson data(object);
data.dump(newText, &indent);
clipboard->setText(newText);
@@ -1714,7 +1731,7 @@ void MainWindow::paste() {
QJsonObject pasteObject = pasteJsonDoc.object();
//OrderedJson::object pasteObject = pasteJson.object_items();
- if (pasteObject["application"].toString() != "porymap") {
+ if (pasteObject["application"].toString() != QApplication::applicationName()) {
return;
}
@@ -2530,8 +2547,7 @@ void MainWindow::on_actionImport_Map_from_Advance_Map_1_92_triggered() {
return;
}
- auto dialog = new NewLayoutDialog(this->editor->project, mapLayout, this);
- connect(dialog, &NewLayoutDialog::applied, this, &MainWindow::userSetLayout);
+ auto dialog = createNewLayoutDialog(mapLayout);
connect(dialog, &NewLayoutDialog::finished, [mapLayout] { mapLayout->deleteLater(); });
dialog->open();
}
@@ -2858,7 +2874,7 @@ void MainWindow::onWarpBehaviorWarningClicked() {
"You can disable this warning or edit the list of behaviors that silence this warning under Options -> Project Settings..."
"