Initial connections tab UI redesign

This commit is contained in:
GriffinR 2024-06-26 16:03:39 -04:00
parent 18bdbc8a09
commit db35ec2c79
10 changed files with 383 additions and 385 deletions

View file

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConnectionsListItem</class>
<widget class="QFrame" name="ConnectionsListItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>176</width>
<height>153</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_Map">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Map</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_Offset">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Offset</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_Direction">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Direction</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="toolButton_Delete">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/delete.ico</normaloff>:/icons/delete.ico</iconset>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="NoScrollComboBox" name="comboBox_Direction"/>
</item>
<item row="0" column="1" colspan="2">
<widget class="NoScrollComboBox" name="comboBox_Map"/>
</item>
<item row="2" column="1" colspan="2">
<widget class="QSpinBox" name="spinBox_Offset"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>NoScrollComboBox</class>
<extends>QComboBox</extends>
<header>noscrollcombobox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../resources/images.qrc"/>
</resources>
<connections/>
</ui>

View file

@ -260,7 +260,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<property name="movable" stdset="0">
<bool>false</bool>
@ -769,8 +769,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>423</width>
<height>79</height>
<width>256</width>
<height>74</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_12">
@ -888,8 +888,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>423</width>
<height>79</height>
<width>256</width>
<height>74</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
@ -990,10 +990,10 @@
</property>
<property name="geometry">
<rect>
<x>8</x>
<x>0</x>
<y>0</y>
<width>411</width>
<height>446</height>
<width>98</width>
<height>74</height>
</rect>
</property>
<property name="sizePolicy">
@ -1193,8 +1193,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>594</height>
<width>98</width>
<height>512</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_7">
@ -1413,8 +1413,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>699</height>
<width>98</width>
<height>444</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
@ -1715,7 +1715,7 @@
<x>0</x>
<y>0</y>
<width>100</width>
<height>16</height>
<height>30</height>
</rect>
</property>
<property name="sizePolicy">
@ -1809,7 +1809,7 @@
<x>0</x>
<y>0</y>
<width>100</width>
<height>16</height>
<height>30</height>
</rect>
</property>
<property name="sizePolicy">
@ -1903,7 +1903,7 @@
<x>0</x>
<y>0</y>
<width>100</width>
<height>16</height>
<height>30</height>
</rect>
</property>
<property name="sizePolicy">
@ -2003,7 +2003,7 @@
<x>0</x>
<y>0</y>
<width>100</width>
<height>16</height>
<height>30</height>
</rect>
</property>
<property name="sizePolicy">
@ -2097,7 +2097,7 @@
<x>0</x>
<y>0</y>
<width>100</width>
<height>16</height>
<height>30</height>
</rect>
</property>
<property name="sizePolicy">
@ -2541,7 +2541,7 @@
<number>0</number>
</property>
<item row="3" column="0">
<widget class="QFrame" name="gridFrame">
<widget class="QFrame" name="frame_Connections">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -2554,24 +2554,9 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_11">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QFrame" name="horizontalFrame">
<layout class="QVBoxLayout" name="verticalLayout_18">
<item>
<widget class="QFrame" name="frame_ConnectionsTopBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -2590,10 +2575,7 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>4</number>
</property>
<layout class="QGridLayout" name="gridLayout_10">
<property name="leftMargin">
<number>4</number>
</property>
@ -2606,229 +2588,7 @@
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QPushButton" name="pushButton_AddConnection">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add a new connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/add.ico</activeon>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_RemoveConnection">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Remove the currently-selected connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/delete.ico</activeon>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Number of Connections:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_NumConnections">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_MirrorConnections">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If enabled, connections will automatically be updated on the connected map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Mirror to Connecting Maps</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="0">
<widget class="QGraphicsView" name="graphicsView_Connections">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="dragMode">
<enum>QGraphicsView::NoDrag</enum>
</property>
<property name="transformationAnchor">
<enum>QGraphicsView::AnchorUnderMouse</enum>
</property>
<property name="resizeAnchor">
<enum>QGraphicsView::AnchorUnderMouse</enum>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QFrame" name="horizontalFrame2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,0,0,0,0">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Map</string>
</property>
</widget>
</item>
<item>
<widget class="NoScrollComboBox" name="comboBox_ConnectedMap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The destination map name of the connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Offset</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_ConnectionOffset">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The number of metatiles to offset the connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum">
<number>-999</number>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item>
<widget class="NoScrollComboBox" name="comboBox_ConnectionDirection">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The direction of the connection.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>up</string>
</property>
</item>
<item>
<property name="text">
<string>right</string>
</property>
</item>
<item>
<property name="text">
<string>down</string>
</property>
</item>
<item>
<property name="text">
<string>left</string>
</property>
</item>
</widget>
</item>
<item>
<item row="0" column="3">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -2841,47 +2601,34 @@
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QFrame" name="horizontalFrame3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QLabel" name="label_14">
<item row="0" column="4">
<widget class="QCheckBox" name="checkBox_MirrorConnections">
<property name="toolTip">
<string>If enabled, connections will automatically be updated on the connected map.</string>
</property>
<property name="text">
<string>Mirror to Connecting Maps</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_EmergeMap">
<property name="text">
<string>Emerge Map</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_DiveMap">
<property name="text">
<string>Dive Map</string>
</property>
</widget>
</item>
<item>
<item row="0" column="2">
<widget class="NoScrollComboBox" name="comboBox_DiveMap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Destination map name when using &lt;span style=&quot; font-weight:600;&quot;&gt;Dive&lt;/span&gt;. If empty, no such connection will exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -2891,14 +2638,7 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>Emerge Map</string>
</property>
</widget>
</item>
<item>
<item row="1" column="2">
<widget class="NoScrollComboBox" name="comboBox_EmergeMap">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Destination map name when emerging using &lt;span style=&quot; font-weight:600;&quot;&gt;Dive&lt;/span&gt;. If empty, no such connection will exist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -2908,22 +2648,147 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="0" column="0">
<widget class="QToolButton" name="button_OpenDiveMap">
<property name="toolTip">
<string>Open the selected Dive Map</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="text">
<string>...</string>
</property>
</spacer>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/map_go.ico</normaloff>:/icons/map_go.ico</iconset>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="button_OpenEmergeMap">
<property name="toolTip">
<string>Open the selected Emerge Map</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/map_go.ico</normaloff>:/icons/map_go.ico</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter_Connections">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QGraphicsView" name="graphicsView_Connections">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="dragMode">
<enum>QGraphicsView::NoDrag</enum>
</property>
<property name="transformationAnchor">
<enum>QGraphicsView::AnchorUnderMouse</enum>
</property>
<property name="resizeAnchor">
<enum>QGraphicsView::AnchorUnderMouse</enum>
</property>
</widget>
<widget class="QFrame" name="frame_EditConnectionsPanel">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
<item>
<widget class="QPushButton" name="pushButton_AddConnection">
<property name="text">
<string>Add Connection</string>
</property>
<property name="icon">
<iconset resource="../resources/images.qrc">
<normaloff>:/icons/add.ico</normaloff>:/icons/add.ico</iconset>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea_ConnectionsList">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaContents_ConnectionsList">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>365</width>
<height>658</height>
</rect>
</property>
<layout class="QVBoxLayout" name="layout_ConnectionsList">
<property name="spacing">
<number>8</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>

View file

@ -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*);

View file

@ -0,0 +1,26 @@
#ifndef CONNECTIONSLISTITEM_H
#define CONNECTIONSLISTITEM_H
#include "mapconnection.h"
#include <QFrame>
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

View file

@ -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 \

BIN
resources/icons/map_go.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -65,5 +65,6 @@
<file>images/Entities_16x16.png</file>
<file>images/pokemon_icon_placeholder.png</file>
<file>icons/clipboard.ico</file>
<file>icons/map_go.ico</file>
</qresource>
</RCC>

View file

@ -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<ConnectionsListItem*>())
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)

View file

@ -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();

View file

@ -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;
}