Final MapConnection UI updates
This commit is contained in:
parent
186e20171b
commit
7a0ae53143
8 changed files with 104 additions and 33 deletions
|
@ -65,7 +65,7 @@
|
||||||
<item row="3" column="2">
|
<item row="3" column="2">
|
||||||
<widget class="QToolButton" name="button_Delete">
|
<widget class="QToolButton" name="button_Delete">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Remove this connection</string>
|
<string>Remove this connection.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
|
@ -79,21 +79,35 @@
|
||||||
<item row="1" column="1" colspan="2">
|
<item row="1" column="1" colspan="2">
|
||||||
<widget class="NoScrollComboBox" name="comboBox_Direction">
|
<widget class="NoScrollComboBox" name="comboBox_Direction">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Where the connected map should be positioned relative to the current map</string>
|
<string>Where the connected map should be positioned relative to the current map.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" colspan="2">
|
<item row="0" column="1" colspan="2">
|
||||||
<widget class="NoScrollComboBox" name="comboBox_Map">
|
<widget class="NoScrollComboBox" name="comboBox_Map">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The name of the map to connect to the current map</string>
|
<string>The name of the map to connect to the current map.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="2">
|
<item row="2" column="1" colspan="2">
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_Offset">
|
<widget class="NoScrollSpinBox" name="spinBox_Offset">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The number of spaces to move the connected map perpendicular to its connected direction</string>
|
<string>The number of spaces to move the connected map perpendicular to its connected direction.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QToolButton" name="button_OpenMap">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Open the connected 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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -2664,6 +2664,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4" rowspan="2">
|
<item row="0" column="4" rowspan="2">
|
||||||
<widget class="QGroupBox" name="groupBox_DiveMapOpacity">
|
<widget class="QGroupBox" name="groupBox_DiveMapOpacity">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>If enabled, the connected Emerge and/or Dive maps will be displayed with an opacity set using the slider.</string>
|
||||||
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Show Emerge/Dive Maps</string>
|
<string>Show Emerge/Dive Maps</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -2874,8 +2877,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>100</width>
|
<width>365</width>
|
||||||
<height>30</height>
|
<height>651</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="layout_ConnectionsList">
|
<layout class="QVBoxLayout" name="layout_ConnectionsList">
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>234</width>
|
<width>234</width>
|
||||||
<height>120</height>
|
<height>162</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -43,7 +43,11 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="NoScrollComboBox" name="comboBox_Map"/>
|
<widget class="NoScrollComboBox" name="comboBox_Map">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The name of the map to connect to the current map.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_Direction">
|
<widget class="QLabel" name="label_Direction">
|
||||||
|
@ -53,7 +57,24 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="NoScrollComboBox" name="comboBox_Direction"/>
|
<widget class="NoScrollComboBox" name="comboBox_Direction">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Where the connected map should be positioned relative to the current map.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_Warning">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">color: rgb(255, 0, 0)</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>'Map' must be the name of an existing map.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -84,12 +105,32 @@
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>NewMapConnectionDialog</receiver>
|
<receiver>NewMapConnectionDialog</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>20</x>
|
||||||
|
<y>20</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>20</x>
|
||||||
|
<y>20</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>NewMapConnectionDialog</receiver>
|
<receiver>NewMapConnectionDialog</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>20</x>
|
||||||
|
<y>20</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>20</x>
|
||||||
|
<y>20</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -14,8 +14,7 @@ class ConnectionsListItem;
|
||||||
|
|
||||||
// We show the data for each map connection in the panel on the right side of the Connections tab.
|
// We show the data for each map connection in the panel on the right side of the Connections tab.
|
||||||
// An instance of this class is used for each item in that list.
|
// An instance of this class is used for each item in that list.
|
||||||
// It communicates with the ConnectionPixmapItem on the map through a shared MapConnection pointer,
|
// It communicates with the ConnectionPixmapItem on the map through a shared MapConnection pointer.
|
||||||
// and the two classes should signal one another when they change this data.
|
|
||||||
class ConnectionsListItem : public QFrame
|
class ConnectionsListItem : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -27,28 +26,27 @@ public:
|
||||||
void updateUI();
|
void updateUI();
|
||||||
void setSelected(bool selected);
|
void setSelected(bool selected);
|
||||||
|
|
||||||
QPointer<MapConnection> connection;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ConnectionsListItem *ui;
|
Ui::ConnectionsListItem *ui;
|
||||||
|
QPointer<MapConnection> connection;
|
||||||
Map *map;
|
Map *map;
|
||||||
bool isSelected = false;
|
bool isSelected = false;
|
||||||
unsigned actionId = 0;
|
unsigned actionId = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent*) override;
|
void mousePressEvent(QMouseEvent*) override;
|
||||||
void mouseDoubleClickEvent(QMouseEvent*) override;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void removed(MapConnection*);
|
|
||||||
void selected();
|
void selected();
|
||||||
void doubleClicked(MapConnection*);
|
void removed(MapConnection*);
|
||||||
|
void openMapClicked(MapConnection*);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_comboBox_Direction_currentTextChanged(const QString &direction);
|
void on_comboBox_Direction_currentTextChanged(const QString &direction);
|
||||||
void on_comboBox_Map_currentTextChanged(const QString &mapName);
|
void on_comboBox_Map_currentTextChanged(const QString &mapName);
|
||||||
void on_spinBox_Offset_valueChanged(int offset);
|
void on_spinBox_Offset_valueChanged(int offset);
|
||||||
void on_button_Delete_clicked();
|
void on_button_Delete_clicked();
|
||||||
|
void on_button_OpenMap_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONNECTIONSLISTITEM_H
|
#endif // CONNECTIONSLISTITEM_H
|
||||||
|
|
|
@ -24,6 +24,9 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NewMapConnectionDialog *ui;
|
Ui::NewMapConnectionDialog *ui;
|
||||||
|
|
||||||
|
bool mapNameIsValid();
|
||||||
|
void setWarningVisible(bool visible);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NEWMAPCONNECTIONDIALOG_H
|
#endif // NEWMAPCONNECTIONDIALOG_H
|
||||||
|
|
|
@ -758,8 +758,8 @@ void Editor::displayConnection(MapConnection* connection) {
|
||||||
QObject::disconnect(connection, &MapConnection::directionChanged, nullptr, nullptr);
|
QObject::disconnect(connection, &MapConnection::directionChanged, nullptr, nullptr);
|
||||||
QObject::disconnect(connection, &MapConnection::offsetChanged, nullptr, nullptr);
|
QObject::disconnect(connection, &MapConnection::offsetChanged, nullptr, nullptr);
|
||||||
|
|
||||||
// Double clicking the list item or pixmap opens the connected map
|
// Double clicking the pixmap or clicking the list item's map button opens the connected map
|
||||||
connect(listItem, &ConnectionsListItem::doubleClicked, this, &Editor::onMapConnectionDoubleClicked);
|
connect(listItem, &ConnectionsListItem::openMapClicked, this, &Editor::onMapConnectionDoubleClicked);
|
||||||
connect(pixmapItem, &ConnectionPixmapItem::connectionItemDoubleClicked, this, &Editor::onMapConnectionDoubleClicked);
|
connect(pixmapItem, &ConnectionPixmapItem::connectionItemDoubleClicked, this, &Editor::onMapConnectionDoubleClicked);
|
||||||
|
|
||||||
// Sync the selection highlight between the list UI and the pixmap
|
// Sync the selection highlight between the list UI and the pixmap
|
||||||
|
@ -937,7 +937,6 @@ void Editor::setDivingMapName(QString mapName, QString direction) {
|
||||||
auto pixmapItem = diving_map_items.value(direction);
|
auto pixmapItem = diving_map_items.value(direction);
|
||||||
MapConnection *connection = pixmapItem ? pixmapItem->connection() : nullptr;
|
MapConnection *connection = pixmapItem ? pixmapItem->connection() : nullptr;
|
||||||
|
|
||||||
// TODO: Test edit history
|
|
||||||
if (connection) {
|
if (connection) {
|
||||||
if (mapName == connection->targetMapName())
|
if (mapName == connection->targetMapName())
|
||||||
return; // No change
|
return; // No change
|
||||||
|
@ -1823,11 +1822,8 @@ void Editor::updateMapBorder() {
|
||||||
void Editor::updateMapConnections() {
|
void Editor::updateMapConnections() {
|
||||||
for (auto item : connection_items)
|
for (auto item : connection_items)
|
||||||
item->render(true);
|
item->render(true);
|
||||||
|
|
||||||
maskNonVisibleConnectionTiles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check first condition, move to Map
|
|
||||||
int Editor::getBorderDrawDistance(int dimension) {
|
int Editor::getBorderDrawDistance(int dimension) {
|
||||||
// Draw sufficient border blocks to fill the player's view (BORDER_DISTANCE)
|
// Draw sufficient border blocks to fill the player's view (BORDER_DISTANCE)
|
||||||
if (dimension >= BORDER_DISTANCE) {
|
if (dimension >= BORDER_DISTANCE) {
|
||||||
|
@ -1920,7 +1916,12 @@ void Editor::updateBorderVisibility() {
|
||||||
item->setVisible(visible);
|
item->setVisible(visible);
|
||||||
item->setEditable(editingConnections);
|
item->setEditable(editingConnections);
|
||||||
item->setEnabled(visible);
|
item->setEnabled(visible);
|
||||||
item->render();
|
|
||||||
|
// When connecting a map to itself we don't bother to re-render the map connections in real-time,
|
||||||
|
// i.e. if the user paints a new metatile on the map this isn't immediately reflected in the connection.
|
||||||
|
// We're rendering them now, so we take the opportunity to do a full re-render for self-connections.
|
||||||
|
bool fullRender = (this->map && item->connection && this->map->name == item->connection->targetMapName());
|
||||||
|
item->render(fullRender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,11 +75,6 @@ void ConnectionsListItem::mousePressEvent(QMouseEvent *) {
|
||||||
this->setSelected(true);
|
this->setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This happens by accident a lot. Convert to button?
|
|
||||||
void ConnectionsListItem::mouseDoubleClickEvent(QMouseEvent *) {
|
|
||||||
emit doubleClicked(this->connection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConnectionsListItem::on_comboBox_Direction_currentTextChanged(const QString &direction) {
|
void ConnectionsListItem::on_comboBox_Direction_currentTextChanged(const QString &direction) {
|
||||||
this->setSelected(true);
|
this->setSelected(true);
|
||||||
if (this->map)
|
if (this->map)
|
||||||
|
@ -102,3 +97,7 @@ void ConnectionsListItem::on_button_Delete_clicked() {
|
||||||
if (this->map)
|
if (this->map)
|
||||||
this->map->editHistory.push(new MapConnectionRemove(this->map, this->connection));
|
this->map->editHistory.push(new MapConnectionRemove(this->map, this->connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionsListItem::on_button_OpenMap_clicked() {
|
||||||
|
emit openMapClicked(this->connection);
|
||||||
|
}
|
||||||
|
|
|
@ -9,10 +9,8 @@ NewMapConnectionDialog::NewMapConnectionDialog(QWidget *parent, Map* map, const
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
ui->comboBox_Direction->setEditable(false);
|
ui->comboBox_Direction->setEditable(false);
|
||||||
ui->comboBox_Direction->setMinimumContentsLength(0);
|
|
||||||
ui->comboBox_Direction->addItems(MapConnection::cardinalDirections);
|
ui->comboBox_Direction->addItems(MapConnection::cardinalDirections);
|
||||||
|
|
||||||
ui->comboBox_Map->setMinimumContentsLength(6);
|
|
||||||
ui->comboBox_Map->addItems(mapNames);
|
ui->comboBox_Map->addItems(mapNames);
|
||||||
ui->comboBox_Map->setInsertPolicy(QComboBox::NoInsert);
|
ui->comboBox_Map->setInsertPolicy(QComboBox::NoInsert);
|
||||||
|
|
||||||
|
@ -42,6 +40,12 @@ NewMapConnectionDialog::NewMapConnectionDialog(QWidget *parent, Map* map, const
|
||||||
defaultMapName = mapNames.first();
|
defaultMapName = mapNames.first();
|
||||||
}
|
}
|
||||||
ui->comboBox_Map->setTextItem(defaultMapName);
|
ui->comboBox_Map->setTextItem(defaultMapName);
|
||||||
|
|
||||||
|
connect(ui->comboBox_Map, &QComboBox::currentTextChanged, [this] {
|
||||||
|
if (ui->label_Warning->isVisible() && mapNameIsValid())
|
||||||
|
setWarningVisible(false);
|
||||||
|
});
|
||||||
|
setWarningVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
NewMapConnectionDialog::~NewMapConnectionDialog()
|
NewMapConnectionDialog::~NewMapConnectionDialog()
|
||||||
|
@ -49,10 +53,18 @@ NewMapConnectionDialog::~NewMapConnectionDialog()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NewMapConnectionDialog::mapNameIsValid() {
|
||||||
|
return ui->comboBox_Map->findText(ui->comboBox_Map->currentText()) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewMapConnectionDialog::setWarningVisible(bool visible) {
|
||||||
|
ui->label_Warning->setVisible(visible);
|
||||||
|
adjustSize();
|
||||||
|
}
|
||||||
|
|
||||||
void NewMapConnectionDialog::accept() {
|
void NewMapConnectionDialog::accept() {
|
||||||
// Invalid map names are not allowed
|
if (!mapNameIsValid()) {
|
||||||
if (ui->comboBox_Map->findText(ui->comboBox_Map->currentText()) < 0) {
|
setWarningVisible(true);
|
||||||
// TODO: Display error message
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit accepted(new MapConnection(ui->comboBox_Map->currentText(), ui->comboBox_Direction->currentText()));
|
emit accepted(new MapConnection(ui->comboBox_Map->currentText(), ui->comboBox_Direction->currentText()));
|
||||||
|
|
Loading…
Reference in a new issue