diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui
index 02f1a690..75ceeb2e 100644
--- a/forms/mainwindow.ui
+++ b/forms/mainwindow.ui
@@ -992,7 +992,7 @@
0
0
- 98
+ 91
74
@@ -1193,7 +1193,7 @@
0
0
- 98
+ 91
512
@@ -1413,8 +1413,8 @@
0
0
- 98
- 444
+ 93
+ 460
@@ -1715,7 +1715,7 @@
0
0
100
- 30
+ 16
@@ -1809,7 +1809,7 @@
0
0
100
- 30
+ 16
@@ -1903,7 +1903,7 @@
0
0
100
- 30
+ 16
@@ -2003,7 +2003,7 @@
0
0
100
- 30
+ 16
@@ -2097,7 +2097,7 @@
0
0
100
- 30
+ 16
@@ -2588,7 +2588,7 @@
4
- -
+
-
Qt::Horizontal
@@ -2601,7 +2601,7 @@
- -
+
-
If enabled, connections will automatically be updated on the connected map.
@@ -2614,41 +2614,7 @@
- -
-
-
- Emerge Map
-
-
-
- -
-
-
- Dive Map
-
-
-
- -
-
-
- <html><head/><body><p>Destination map name when using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html>
-
-
- true
-
-
-
- -
-
-
- <html><head/><body><p>Destination map name when emerging using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html>
-
-
- true
-
-
-
- -
+
-
Open the selected Dive Map
@@ -2662,7 +2628,7 @@
- -
+
-
Open the selected Emerge Map
@@ -2676,6 +2642,40 @@
+ -
+
+
+ Emerge Map
+
+
+
+ -
+
+
+ Dive Map
+
+
+
+ -
+
+
+ <html><head/><body><p>Destination map name when using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html>
+
+
+ true
+
+
+
+ -
+
+
+ <html><head/><body><p>Destination map name when emerging using <span style=" font-weight:600;">Dive</span>. If empty, no such connection will exist.</p></body></html>
+
+
+ true
+
+
+
diff --git a/include/mainwindow.h b/include/mainwindow.h
index 7fda1b09..6bcef815 100644
--- a/include/mainwindow.h
+++ b/include/mainwindow.h
@@ -248,6 +248,8 @@ private slots:
void on_comboBox_ConnectedMap_currentTextChanged(const QString &mapName);
void on_pushButton_AddConnection_clicked();
void on_pushButton_RemoveConnection_clicked();
+ void on_button_OpenDiveMap_clicked();
+ void on_button_OpenEmergeMap_clicked();
void on_comboBox_DiveMap_currentTextChanged(const QString &mapName);
void on_comboBox_EmergeMap_currentTextChanged(const QString &mapName);
void on_comboBox_PrimaryTileset_currentTextChanged(const QString &arg1);
@@ -342,6 +344,7 @@ private:
bool tilesetNeedsRedraw = false;
+ bool userSetMap(QString, bool scrollTreeView = false);
bool setMap(QString, bool scrollTreeView = false);
void redrawMapScene();
void refreshMapScene();
diff --git a/include/project.h b/include/project.h
index 643f74da..49c0aaa8 100644
--- a/include/project.h
+++ b/include/project.h
@@ -119,6 +119,7 @@ public:
bool readMapGroups();
Map* addNewMapToGroup(QString, int, Map*, bool, bool);
QString getNewMapName();
+ bool isExistingMapName(const QString&);
QString getProjectTitle();
QString readMapLayoutId(QString map_name);
diff --git a/src/editor.cpp b/src/editor.cpp
index 39e2718d..ee314c19 100644
--- a/src/editor.cpp
+++ b/src/editor.cpp
@@ -763,7 +763,7 @@ void Editor::populateConnectionsList() {
addConnectionToList(item->connection);
}
-// TODO: Vertical scrolling
+// TODO: Don't allow splitter resizing to shrink list items to the point where horizontal scroll is needed
void Editor::addConnectionToList(const MapConnection * connection) {
ConnectionsListItem *listItem = new ConnectionsListItem(ui->scrollAreaContents_ConnectionsList, project->mapNames);
listItem->populate(connection);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 814e60fa..20a48990 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -718,6 +718,21 @@ void MainWindow::on_action_Reload_Project_triggered() {
openProject(editor->project->root);
}
+// setMap, but with a visible error message in case of failure.
+// Use when the user is specifically requesting a map to open.
+bool MainWindow::userSetMap(QString map_name, bool scrollTreeView) {
+ if (!setMap(map_name, scrollTreeView)) {
+ QMessageBox msgBox(this);
+ QString errorMsg = QString("There was an error opening map %1. Please see %2 for full error details.\n\n%3")
+ .arg(map_name)
+ .arg(getLogPath())
+ .arg(getMostRecentError());
+ msgBox.critical(nullptr, "Error Opening Map", errorMsg);
+ return false;
+ }
+ return true;
+}
+
bool MainWindow::setMap(QString map_name, bool scrollTreeView) {
logInfo(QString("Setting map to '%1'").arg(map_name));
if (map_name.isEmpty()) {
@@ -810,15 +825,8 @@ void MainWindow::openWarpMap(QString map_name, int event_id, Event::Group event_
}
// Open the destination map.
- if (!setMap(map_name, true)) {
- QMessageBox msgBox(this);
- QString errorMsg = QString("There was an error opening map %1. Please see %2 for full error details.\n\n%3")
- .arg(map_name)
- .arg(getLogPath())
- .arg(getMostRecentError());
- msgBox.critical(nullptr, "Error Opening Map", errorMsg);
+ if (!userSetMap(map_name, true))
return;
- }
// Select the target event.
int index = event_id - Event::getIndexOffset(event_group);
@@ -1468,17 +1476,8 @@ void MainWindow::currentMetatilesSelectionChanged() {
void MainWindow::on_mapList_activated(const QModelIndex &index)
{
QVariant data = index.data(Qt::UserRole);
- if (index.data(MapListUserRoles::TypeRole) == "map_name" && !data.isNull()) {
- QString mapName = data.toString();
- if (!setMap(mapName)) {
- QMessageBox msgBox(this);
- QString errorMsg = QString("There was an error opening map %1. Please see %2 for full error details.\n\n%3")
- .arg(mapName)
- .arg(getLogPath())
- .arg(getMostRecentError());
- msgBox.critical(nullptr, "Error Opening Map", errorMsg);
- }
- }
+ if (index.data(MapListUserRoles::TypeRole) == "map_name" && !data.isNull())
+ userSetMap(data.toString());
}
void MainWindow::drawMapListIcons(QAbstractItemModel *model) {
@@ -2421,16 +2420,8 @@ void MainWindow::clickToolButtonFromEditMode(QString editMode) {
}
void MainWindow::onLoadMapRequested(QString mapName, QString fromMapName) {
- if (!setMap(mapName, true)) {
- QMessageBox msgBox(this);
- QString errorMsg = QString("There was an error opening map %1. Please see %2 for full error details.\n\n%3")
- .arg(mapName)
- .arg(getLogPath())
- .arg(getMostRecentError());
- msgBox.critical(nullptr, "Error Opening Map", errorMsg);
- return;
- }
- editor->setSelectedConnectionFromMap(fromMapName);
+ if (userSetMap(mapName, true))
+ editor->setSelectedConnectionFromMap(fromMapName);
}
void MainWindow::onMapChanged(Map *) {
@@ -2592,17 +2583,27 @@ void MainWindow::on_pushButton_ConfigureEncountersJSON_clicked() {
editor->configureEncounterJSON(this);
}
-void MainWindow::on_comboBox_DiveMap_currentTextChanged(const QString &mapName)
-{
- if (mapName.isEmpty() || editor->project->mapNames.contains(mapName)) {
+void MainWindow::on_button_OpenDiveMap_clicked() {
+ const QString mapName = ui->comboBox_DiveMap->currentText();
+ if (editor->project->isExistingMapName(mapName))
+ userSetMap(mapName, true);
+}
+
+void MainWindow::on_button_OpenEmergeMap_clicked() {
+ const QString mapName = ui->comboBox_EmergeMap->currentText();
+ if (editor->project->isExistingMapName(mapName))
+ userSetMap(mapName, true);
+}
+
+void MainWindow::on_comboBox_DiveMap_currentTextChanged(const QString &mapName) {
+ if (editor->project->isExistingMapName(mapName)) {
editor->updateDiveMap(mapName);
markMapEdited();
}
}
-void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName)
-{
- if (mapName.isEmpty() || editor->project->mapNames.contains(mapName)) {
+void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName) {
+ if (editor->project->isExistingMapName(mapName)) {
editor->updateEmergeMap(mapName);
markMapEdited();
}
diff --git a/src/project.cpp b/src/project.cpp
index c6550c6a..c1c8f5c7 100644
--- a/src/project.cpp
+++ b/src/project.cpp
@@ -1800,6 +1800,10 @@ QString Project::getNewMapName() {
return newMapName;
}
+bool Project::isExistingMapName(const QString &mapName) {
+ return !mapName.isEmpty() && mapName != DYNAMIC_MAP_NAME && this->mapNames.contains(mapName);
+}
+
Project::DataQualifiers Project::getDataQualifiers(QString text, QString label) {
Project::DataQualifiers qualifiers;