diff --git a/forms/connectionslistitem.ui b/forms/connectionslistitem.ui
new file mode 100644
index 00000000..f35c509e
--- /dev/null
+++ b/forms/connectionslistitem.ui
@@ -0,0 +1,92 @@
+
+
+ ConnectionsListItem
+
+
+
+ 0
+ 0
+ 176
+ 153
+
+
+
+
+ 0
+ 0
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Map
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Offset
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Direction
+
+
+
+ -
+
+
+ ...
+
+
+
+ :/icons/delete.ico:/icons/delete.ico
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+ NoScrollComboBox
+ QComboBox
+
+
+
+
+
+
+
+
diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui
index a28f1db9..02f1a690 100644
--- a/forms/mainwindow.ui
+++ b/forms/mainwindow.ui
@@ -260,7 +260,7 @@
- 0
+ 2
false
@@ -769,8 +769,8 @@
0
0
- 423
- 79
+ 256
+ 74
@@ -888,8 +888,8 @@
0
0
- 423
- 79
+ 256
+ 74
@@ -990,10 +990,10 @@
- 8
+ 0
0
- 411
- 446
+ 98
+ 74
@@ -1193,8 +1193,8 @@
0
0
- 427
- 594
+ 98
+ 512
@@ -1413,8 +1413,8 @@
0
0
- 382
- 699
+ 98
+ 444
@@ -1715,7 +1715,7 @@
0
0
100
- 16
+ 30
@@ -1809,7 +1809,7 @@
0
0
100
- 16
+ 30
@@ -1903,7 +1903,7 @@
0
0
100
- 16
+ 30
@@ -2003,7 +2003,7 @@
0
0
100
- 16
+ 30
@@ -2097,7 +2097,7 @@
0
0
100
- 16
+ 30
@@ -2541,7 +2541,7 @@
0
-
-
+
0
@@ -2554,24 +2554,9 @@
QFrame::Raised
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
+
+
-
+
0
@@ -2590,10 +2575,7 @@
QFrame::Raised
-
-
- 4
-
+
4
@@ -2606,229 +2588,7 @@
4
-
-
-
-
-
- 0
- 0
-
-
-
- <html><head/><body><p>Add a new connection.</p></body></html>
-
-
-
-
-
-
- :/icons/add.ico
-
-
-
-
- -
-
-
- <html><head/><body><p>Remove the currently-selected connection.</p></body></html>
-
-
-
-
-
-
- :/icons/delete.ico
-
-
-
-
- -
-
-
- Number of Connections:
-
-
-
- -
-
-
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Expanding
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- <html><head/><body><p>If enabled, connections will automatically be updated on the connected map.</p></body></html>
-
-
- Mirror to Connecting Maps
-
-
- true
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- false
-
-
- false
-
-
- Qt::ScrollBarAsNeeded
-
-
- Qt::ScrollBarAsNeeded
-
-
- QAbstractScrollArea::AdjustIgnored
-
-
- QGraphicsView::NoDrag
-
-
- QGraphicsView::AnchorUnderMouse
-
-
- QGraphicsView::AnchorUnderMouse
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 32
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
- 6
-
-
- 4
-
-
- 4
-
-
- 4
-
-
- 4
-
-
-
-
-
- Map
-
-
-
- -
-
-
- <html><head/><body><p>The destination map name of the connection.</p></body></html>
-
-
- true
-
-
-
- -
-
-
- Offset
-
-
-
- -
-
-
- <html><head/><body><p>The number of metatiles to offset the connection.</p></body></html>
-
-
- -999
-
-
- 999
-
-
-
- -
-
-
- <html><head/><body><p>The direction of the connection.</p></body></html>
-
-
-
-
- up
-
-
- -
-
- right
-
-
- -
-
- down
-
-
- -
-
- left
-
-
-
-
- -
+
-
Qt::Horizontal
@@ -2841,47 +2601,34 @@
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
-
- 4
-
-
- 4
-
-
- 4
-
-
- 4
-
-
- 4
-
-
-
-
+
-
+
+
+ If enabled, connections will automatically be updated on the connected map.
+
+
+ Mirror to Connecting Maps
+
+
+ true
+
+
+
+ -
+
+
+ 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>
@@ -2891,14 +2638,7 @@
- -
-
-
- Emerge Map
-
-
-
- -
+
-
<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>
@@ -2908,22 +2648,147 @@
- -
-
-
- Qt::Horizontal
+
-
+
+
+ Open the selected Dive Map
-
-
- 40
- 20
-
+
+ ...
-
+
+
+ :/icons/map_go.ico:/icons/map_go.ico
+
+
+
+ -
+
+
+ Open the selected Emerge Map
+
+
+ ...
+
+
+
+ :/icons/map_go.ico:/icons/map_go.ico
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+
+ 0
+ 0
+
+
+
+ false
+
+
+ false
+
+
+ Qt::ScrollBarAsNeeded
+
+
+ Qt::ScrollBarAsNeeded
+
+
+ QAbstractScrollArea::AdjustIgnored
+
+
+ QGraphicsView::NoDrag
+
+
+ QGraphicsView::AnchorUnderMouse
+
+
+ QGraphicsView::AnchorUnderMouse
+
+
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
-
+
+
+ Add Connection
+
+
+
+ :/icons/add.ico:/icons/add.ico
+
+
+
+ -
+
+
+ QFrame::NoFrame
+
+
+ true
+
+
+
+
+ 0
+ 0
+ 365
+ 658
+
+
+
+
+ 8
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/include/editor.h b/include/editor.h
index f684b491..e9588cae 100644
--- a/include/editor.h
+++ b/include/editor.h
@@ -171,11 +171,10 @@ private:
void setConnectionItemsVisible(bool);
void setBorderItemsVisible(bool, qreal = 1);
void setConnectionEditControlValues(MapConnection*);
- void setConnectionEditControlsEnabled(bool);
void setConnectionsEditable(bool);
void createConnectionItem(MapConnection* connection);
- void populateConnectionMapPickers();
- void setDiveEmergeControls();
+ void populateConnectionsList();
+ void addConnectionToList(const MapConnection * connection);
void updateDiveEmergeMap(QString mapName, QString direction);
void onConnectionOffsetChanged(int newOffset);
void removeMirroredConnection(MapConnection*);
diff --git a/include/ui/connectionslistitem.h b/include/ui/connectionslistitem.h
new file mode 100644
index 00000000..0c4ee923
--- /dev/null
+++ b/include/ui/connectionslistitem.h
@@ -0,0 +1,26 @@
+#ifndef CONNECTIONSLISTITEM_H
+#define CONNECTIONSLISTITEM_H
+
+#include "mapconnection.h"
+
+#include
+
+namespace Ui {
+class ConnectionsListItem;
+}
+
+class ConnectionsListItem : public QFrame
+{
+ Q_OBJECT
+
+public:
+ explicit ConnectionsListItem(QWidget *parent, const QStringList &mapNames);
+ ~ConnectionsListItem();
+
+ void populate(const MapConnection * connection);
+
+public:
+ Ui::ConnectionsListItem *ui;
+};
+
+#endif // CONNECTIONSLISTITEM_H
diff --git a/porymap.pro b/porymap.pro
index dfc3306e..5c898302 100644
--- a/porymap.pro
+++ b/porymap.pro
@@ -46,6 +46,7 @@ SOURCES += src/core/block.cpp \
src/scriptapi/apiutility.cpp \
src/scriptapi/scripting.cpp \
src/ui/aboutporymap.cpp \
+ src/ui/connectionslistitem.cpp \
src/ui/customscriptseditor.cpp \
src/ui/customscriptslistitem.cpp \
src/ui/draggablepixmapitem.cpp \
@@ -139,6 +140,7 @@ HEADERS += include/core/block.h \
include/lib/orderedmap.h \
include/lib/orderedjson.h \
include/ui/aboutporymap.h \
+ include/ui/connectionslistitem.h \
include/ui/customscriptseditor.h \
include/ui/customscriptslistitem.h \
include/ui/draggablepixmapitem.h \
@@ -205,6 +207,7 @@ HEADERS += include/core/block.h \
include/ui/updatepromoter.h
FORMS += forms/mainwindow.ui \
+ forms/connectionslistitem.ui \
forms/prefabcreationdialog.ui \
forms/prefabframe.ui \
forms/tileseteditor.ui \
diff --git a/resources/icons/map_go.ico b/resources/icons/map_go.ico
new file mode 100755
index 00000000..8ca93206
Binary files /dev/null and b/resources/icons/map_go.ico differ
diff --git a/resources/images.qrc b/resources/images.qrc
index 86d56cb2..bdac1a47 100644
--- a/resources/images.qrc
+++ b/resources/images.qrc
@@ -65,5 +65,6 @@
images/Entities_16x16.png
images/pokemon_icon_placeholder.png
icons/clipboard.ico
+ icons/map_go.ico
diff --git a/src/editor.cpp b/src/editor.cpp
index 014fa489..39e2718d 100644
--- a/src/editor.cpp
+++ b/src/editor.cpp
@@ -2,7 +2,7 @@
#include "draggablepixmapitem.h"
#include "imageproviders.h"
#include "log.h"
-#include "mapconnection.h"
+#include "connectionslistitem.h"
#include "currentselectedmetatilespixmapitem.h"
#include "mapsceneeventfilter.h"
#include "metatile.h"
@@ -178,11 +178,7 @@ void Editor::setEditingConnections() {
map_item->paintingMode = MapPixmapItem::PaintMode::Disabled;
map_item->draw();
map_item->setVisible(true);
- populateConnectionMapPickers();
- ui->label_NumConnections->setText(QString::number(map->connections.length()));
- setDiveEmergeControls();
- bool controlsEnabled = selected_connection_item != nullptr;
- setConnectionEditControlsEnabled(controlsEnabled);
+ populateConnectionsList();
if (selected_connection_item) {
onConnectionOffsetChanged(selected_connection_item->connection->offset);
setConnectionMap(selected_connection_item->connection->map_name);
@@ -739,11 +735,18 @@ void Editor::updateEncounterFields(EncounterFields newFields) {
project->wildMonFields = newFields;
}
-void Editor::setDiveEmergeControls() {
- ui->comboBox_DiveMap->blockSignals(true);
- ui->comboBox_EmergeMap->blockSignals(true);
+void Editor::populateConnectionsList() {
+ const QSignalBlocker blocker1(ui->comboBox_DiveMap);
+ const QSignalBlocker blocker2(ui->comboBox_EmergeMap);
+
+ ui->comboBox_DiveMap->clear();
+ ui->comboBox_DiveMap->addItems(project->mapNames);
ui->comboBox_DiveMap->setCurrentText("");
+
+ ui->comboBox_EmergeMap->clear();
+ ui->comboBox_EmergeMap->addItems(project->mapNames);
ui->comboBox_EmergeMap->setCurrentText("");
+
for (MapConnection* connection : map->connections) {
if (connection->direction == "dive") {
ui->comboBox_DiveMap->setCurrentText(connection->map_name);
@@ -751,25 +754,20 @@ void Editor::setDiveEmergeControls() {
ui->comboBox_EmergeMap->setCurrentText(connection->map_name);
}
}
- ui->comboBox_DiveMap->blockSignals(false);
- ui->comboBox_EmergeMap->blockSignals(false);
+
+ // Clear any existing connections in list
+ for (auto w : ui->scrollAreaContents_ConnectionsList->findChildren())
+ w->deleteLater();
+
+ for (auto item :connection_items)
+ addConnectionToList(item->connection);
}
-void Editor::populateConnectionMapPickers() {
- ui->comboBox_ConnectedMap->blockSignals(true);
- ui->comboBox_DiveMap->blockSignals(true);
- ui->comboBox_EmergeMap->blockSignals(true);
-
- ui->comboBox_ConnectedMap->clear();
- ui->comboBox_ConnectedMap->addItems(project->mapNames);
- ui->comboBox_DiveMap->clear();
- ui->comboBox_DiveMap->addItems(project->mapNames);
- ui->comboBox_EmergeMap->clear();
- ui->comboBox_EmergeMap->addItems(project->mapNames);
-
- ui->comboBox_ConnectedMap->blockSignals(false);
- ui->comboBox_DiveMap->blockSignals(true);
- ui->comboBox_EmergeMap->blockSignals(true);
+// TODO: Vertical scrolling
+void Editor::addConnectionToList(const MapConnection * connection) {
+ ConnectionsListItem *listItem = new ConnectionsListItem(ui->scrollAreaContents_ConnectionsList, project->mapNames);
+ listItem->populate(connection);
+ ui->layout_ConnectionsList->insertWidget(ui->layout_ConnectionsList->count() - 1, listItem); // Insert above the vertical spacer
}
void Editor::setConnectionItemsVisible(bool visible) {
@@ -848,38 +846,15 @@ void Editor::onConnectionMoved(MapConnection* connection) {
}
void Editor::onConnectionOffsetChanged(int newOffset) {
- ui->spinBox_ConnectionOffset->blockSignals(true);
+ // Connections TODO: Change offset spin box for selected connection
+ /*ui->spinBox_ConnectionOffset->blockSignals(true);
ui->spinBox_ConnectionOffset->setValue(newOffset);
ui->spinBox_ConnectionOffset->blockSignals(false);
-
+ */
}
void Editor::setConnectionEditControlValues(MapConnection* connection) {
- QString mapName = connection ? connection->map_name : "";
- QString direction = connection ? connection->direction : "";
- int offset = connection ? connection->offset : 0;
-
- ui->comboBox_ConnectedMap->blockSignals(true);
- ui->comboBox_ConnectionDirection->blockSignals(true);
- ui->spinBox_ConnectionOffset->blockSignals(true);
-
- ui->comboBox_ConnectedMap->setCurrentText(mapName);
- ui->comboBox_ConnectionDirection->setCurrentText(direction);
- ui->spinBox_ConnectionOffset->setValue(offset);
-
- ui->comboBox_ConnectedMap->blockSignals(false);
- ui->comboBox_ConnectionDirection->blockSignals(false);
- ui->spinBox_ConnectionOffset->blockSignals(false);
-}
-
-void Editor::setConnectionEditControlsEnabled(bool enabled) {
- ui->comboBox_ConnectionDirection->setEnabled(enabled);
- ui->comboBox_ConnectedMap->setEnabled(enabled);
- ui->spinBox_ConnectionOffset->setEnabled(enabled);
-
- if (!enabled) {
- setConnectionEditControlValues(nullptr);
- }
+ // Connections TODO: Highlight selected connection
}
void Editor::setConnectionsEditable(bool editable) {
@@ -896,10 +871,11 @@ void Editor::onConnectionItemSelected(ConnectionPixmapItem* connectionItem) {
selected_connection_item = connectionItem;
for (ConnectionPixmapItem* item : connection_items)
item->updateHighlight(item == selected_connection_item);
- setConnectionEditControlsEnabled(true);
setConnectionEditControlValues(selected_connection_item->connection);
+ /* // Connections TODO:
ui->spinBox_ConnectionOffset->setMaximum(selected_connection_item->getMaxOffset());
ui->spinBox_ConnectionOffset->setMinimum(selected_connection_item->getMinOffset());
+ */
onConnectionOffsetChanged(selected_connection_item->connection->offset);
}
@@ -918,9 +894,11 @@ void Editor::onConnectionItemDoubleClicked(ConnectionPixmapItem* connectionItem)
}
void Editor::onConnectionDirectionChanged(QString newDirection) {
+ /* // Connections TODO:
ui->comboBox_ConnectionDirection->blockSignals(true);
ui->comboBox_ConnectionDirection->setCurrentText(newDirection);
ui->comboBox_ConnectionDirection->blockSignals(false);
+ */
}
void Editor::onBorderMetatilesChanged() {
@@ -1746,13 +1724,12 @@ void Editor::setConnectionMap(QString mapName) {
}
QString originalMapName = selected_connection_item->connection->map_name;
- setConnectionEditControlsEnabled(true);
selected_connection_item->connection->map_name = mapName;
setCurrentConnectionDirection(selected_connection_item->connection->direction);
// New map may have a different minimum offset than the last one. The maximum will be the same.
int min = selected_connection_item->getMinOffset();
- ui->spinBox_ConnectionOffset->setMinimum(min);
+ //ui->spinBox_ConnectionOffset->setMinimum(min); // Connections TODO:
onConnectionOffsetChanged(qMax(min, selected_connection_item->connection->offset));
updateMirroredConnectionMap(selected_connection_item->connection, originalMapName);
@@ -1786,8 +1763,8 @@ void Editor::addNewConnection() {
newConnection->map_name = defaultMapName;
map->connections.append(newConnection);
createConnectionItem(newConnection);
+ addConnectionToList(newConnection);
onConnectionItemSelected(connection_items.last());
- ui->label_NumConnections->setText(QString::number(map->connections.length()));
updateMirroredConnection(newConnection, newConnection->direction, newConnection->map_name);
}
@@ -1867,9 +1844,7 @@ void Editor::removeCurrentConnection() {
}
selected_connection_item = nullptr;
- setConnectionEditControlsEnabled(false);
- ui->spinBox_ConnectionOffset->setValue(0);
- ui->label_NumConnections->setText(QString::number(map->connections.length()));
+ //ui->spinBox_ConnectionOffset->setValue(0); // Connections TODO:
if (connection_items.length() > 0) {
onConnectionItemSelected(connection_items.last());
@@ -1918,8 +1893,6 @@ void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
updateMirroredConnectionMap(connection, originalMapName);
}
}
-
- ui->label_NumConnections->setText(QString::number(map->connections.length()));
}
void Editor::updatePrimaryTileset(QString tilesetLabel, bool forceLoad)
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 98b602ee..814e60fa 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2546,18 +2546,19 @@ void MainWindow::showExportMapImageWindow(ImageExporterMode mode) {
openSubWindow(this->mapImageExporter);
}
+// TODO: Move responsibility to list item
void MainWindow::on_comboBox_ConnectionDirection_currentTextChanged(const QString &direction)
{
editor->updateCurrentConnectionDirection(direction);
markMapEdited();
}
-
+// TODO: Move responsibility to list item
void MainWindow::on_spinBox_ConnectionOffset_valueChanged(int offset)
{
editor->updateConnectionOffset(offset);
markMapEdited();
}
-
+// TODO: Move responsibility to list item
void MainWindow::on_comboBox_ConnectedMap_currentTextChanged(const QString &mapName)
{
if (mapName.isEmpty() || editor->project->mapNames.contains(mapName)) {
@@ -2568,10 +2569,11 @@ void MainWindow::on_comboBox_ConnectedMap_currentTextChanged(const QString &mapN
void MainWindow::on_pushButton_AddConnection_clicked()
{
+ // TODO: Bring up a prompt for information. Mark the current map *AND* the connected map as edited
editor->addNewConnection();
markMapEdited();
}
-
+// TODO: Move responsibility to list item
void MainWindow::on_pushButton_RemoveConnection_clicked()
{
editor->removeCurrentConnection();
diff --git a/src/ui/connectionslistitem.cpp b/src/ui/connectionslistitem.cpp
new file mode 100644
index 00000000..47589a12
--- /dev/null
+++ b/src/ui/connectionslistitem.cpp
@@ -0,0 +1,37 @@
+#include "connectionslistitem.h"
+#include "ui_connectionslistitem.h"
+
+static const QStringList directions = {"up", "down", "left", "right"};
+
+ConnectionsListItem::ConnectionsListItem(QWidget *parent, const QStringList &mapNames) :
+ QFrame(parent),
+ ui(new Ui::ConnectionsListItem)
+{
+ ui->setupUi(this);
+
+ const QSignalBlocker blocker1(ui->comboBox_Direction);
+ const QSignalBlocker blocker2(ui->comboBox_Map);
+ const QSignalBlocker blocker3(ui->spinBox_Offset);
+
+ ui->comboBox_Direction->setEditable(false);
+ ui->comboBox_Direction->setMinimumContentsLength(0);
+ ui->comboBox_Direction->addItems(directions);
+
+ ui->comboBox_Map->setMinimumContentsLength(6);
+ ui->comboBox_Map->addItems(mapNames);
+}
+
+void ConnectionsListItem::populate(const MapConnection * connection) {
+ const QSignalBlocker blocker1(ui->comboBox_Direction);
+ const QSignalBlocker blocker2(ui->comboBox_Map);
+ const QSignalBlocker blocker3(ui->spinBox_Offset);
+
+ ui->comboBox_Direction->setTextItem(connection->direction);
+ ui->comboBox_Map->setTextItem(connection->map_name);
+ ui->spinBox_Offset->setValue(connection->offset);
+}
+
+ConnectionsListItem::~ConnectionsListItem()
+{
+ delete ui;
+}