Add dive/emerge map pickers
This commit is contained in:
parent
5301b299e2
commit
6f71c15629
5 changed files with 310 additions and 137 deletions
94
editor.cpp
94
editor.cpp
|
@ -93,12 +93,10 @@ void Editor::setEditingConnections() {
|
|||
map_item->draw();
|
||||
map_item->setVisible(true);
|
||||
map_item->setEnabled(false);
|
||||
ui->comboBox_ConnectedMap->blockSignals(true);
|
||||
ui->comboBox_ConnectedMap->clear();
|
||||
ui->comboBox_ConnectedMap->addItems(*project->mapNames);
|
||||
ui->comboBox_ConnectedMap->blockSignals(false);
|
||||
populateConnectionMapPickers();
|
||||
ui->label_NumConnections->setText(QString::number(map->connections.length()));
|
||||
setConnectionsVisibility(false);
|
||||
setDiveEmergeControls();
|
||||
if (current_connection_edit_item) {
|
||||
onConnectionOffsetChanged(current_connection_edit_item->connection->offset.toInt());
|
||||
updateConnectionMap(current_connection_edit_item->connection->map_name, current_connection_edit_item->connection->direction);
|
||||
|
@ -114,6 +112,39 @@ void Editor::setEditingConnections() {
|
|||
setConnectionItemsVisible(true);
|
||||
}
|
||||
|
||||
void Editor::setDiveEmergeControls() {
|
||||
ui->comboBox_DiveMap->blockSignals(true);
|
||||
ui->comboBox_EmergeMap->blockSignals(true);
|
||||
ui->comboBox_DiveMap->setCurrentText("");
|
||||
ui->comboBox_EmergeMap->setCurrentText("");
|
||||
for (Connection* connection : map->connections) {
|
||||
if (connection->direction == "dive") {
|
||||
ui->comboBox_DiveMap->setCurrentText(connection->map_name);
|
||||
} else if (connection->direction == "emerge") {
|
||||
ui->comboBox_EmergeMap->setCurrentText(connection->map_name);
|
||||
}
|
||||
}
|
||||
ui->comboBox_DiveMap->blockSignals(false);
|
||||
ui->comboBox_EmergeMap->blockSignals(false);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void Editor::setConnectionItemsVisible(bool visible) {
|
||||
for (ConnectionPixmapItem* item : connection_edit_items) {
|
||||
item->setVisible(visible);
|
||||
|
@ -176,13 +207,17 @@ void Editor::onConnectionOffsetChanged(int newOffset) {
|
|||
}
|
||||
|
||||
void Editor::setConnectionEditControlValues(Connection* connection) {
|
||||
QString mapName = connection ? connection->map_name : "";
|
||||
QString direction = connection ? connection->direction : "";
|
||||
int offset = connection ? connection->offset.toInt() : 0;
|
||||
|
||||
ui->comboBox_ConnectedMap->blockSignals(true);
|
||||
ui->comboBox_ConnectionDirection->blockSignals(true);
|
||||
ui->spinBox_ConnectionOffset->blockSignals(true);
|
||||
|
||||
ui->comboBox_ConnectedMap->setCurrentText(connection->map_name);
|
||||
ui->comboBox_ConnectionDirection->setCurrentText(connection->direction);
|
||||
ui->spinBox_ConnectionOffset->setValue(connection->offset.toInt());
|
||||
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);
|
||||
|
@ -193,6 +228,10 @@ void Editor::setConnectionEditControlsEnabled(bool enabled) {
|
|||
ui->comboBox_ConnectionDirection->setEnabled(enabled);
|
||||
ui->comboBox_ConnectedMap->setEnabled(enabled);
|
||||
ui->spinBox_ConnectionOffset->setEnabled(enabled);
|
||||
|
||||
if (!enabled) {
|
||||
setConnectionEditControlValues(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Editor::onConnectionItemSelected(ConnectionPixmapItem* connectionItem) {
|
||||
|
@ -527,6 +566,47 @@ void Editor::removeCurrentConnection() {
|
|||
}
|
||||
}
|
||||
|
||||
void Editor::updateDiveMap(QString mapName) {
|
||||
updateDiveEmergeMap(mapName, "dive");
|
||||
}
|
||||
|
||||
void Editor::updateEmergeMap(QString mapName) {
|
||||
updateDiveEmergeMap(mapName, "emerge");
|
||||
}
|
||||
|
||||
void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
|
||||
if (!mapName.isEmpty() && !project->mapNamesToMapConstants->contains(mapName)) {
|
||||
qDebug() << "Invalid " << direction << " map connection: " << mapName;
|
||||
return;
|
||||
}
|
||||
|
||||
Connection* connection = NULL;
|
||||
for (Connection* conn : map->connections) {
|
||||
if (conn->direction == direction) {
|
||||
connection = conn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mapName.isEmpty()) {
|
||||
// Remove dive/emerge connection
|
||||
if (connection) {
|
||||
map->connections.removeOne(connection);
|
||||
}
|
||||
} else {
|
||||
if (!connection) {
|
||||
connection = new Connection;
|
||||
connection->direction = direction;
|
||||
connection->offset = "0";
|
||||
map->connections.append(connection);
|
||||
}
|
||||
|
||||
connection->map_name = mapName;
|
||||
}
|
||||
|
||||
ui->label_NumConnections->setText(QString::number(map->connections.length()));
|
||||
}
|
||||
|
||||
void MetatilesPixmapItem::paintTileChanged(Map *map) {
|
||||
draw();
|
||||
}
|
||||
|
|
5
editor.h
5
editor.h
|
@ -53,6 +53,8 @@ public:
|
|||
void updateConnectionMap(QString mapName, QString direction);
|
||||
void addNewConnection();
|
||||
void removeCurrentConnection();
|
||||
void updateDiveMap(QString mapName);
|
||||
void updateEmergeMap(QString mapName);
|
||||
|
||||
DraggablePixmapItem *addMapObject(Event *event);
|
||||
void selectMapObject(DraggablePixmapItem *object);
|
||||
|
@ -95,6 +97,9 @@ private:
|
|||
void setConnectionEditControlValues(Connection*);
|
||||
void setConnectionEditControlsEnabled(bool);
|
||||
void createConnectionItem(Connection* connection, bool hide);
|
||||
void populateConnectionMapPickers();
|
||||
void setDiveEmergeControls();
|
||||
void updateDiveEmergeMap(QString mapName, QString direction);
|
||||
|
||||
private slots:
|
||||
void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
|
||||
|
|
|
@ -790,3 +790,13 @@ void MainWindow::on_pushButton_RemoveConnection_clicked()
|
|||
{
|
||||
editor->removeCurrentConnection();
|
||||
}
|
||||
|
||||
void MainWindow::on_comboBox_DiveMap_currentTextChanged(const QString &mapName)
|
||||
{
|
||||
editor->updateDiveMap(mapName);
|
||||
}
|
||||
|
||||
void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName)
|
||||
{
|
||||
editor->updateEmergeMap(mapName);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,10 @@ private slots:
|
|||
|
||||
void on_pushButton_RemoveConnection_clicked();
|
||||
|
||||
void on_comboBox_DiveMap_currentTextChanged(const QString &mapName);
|
||||
|
||||
void on_comboBox_EmergeMap_currentTextChanged(const QString &mapName);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QStandardItemModel *mapListModel;
|
||||
|
|
334
mainwindow.ui
334
mainwindow.ui
|
@ -60,7 +60,7 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>false</bool>
|
||||
|
@ -1247,6 +1247,102 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QFrame" name="horizontalFrame">
|
||||
<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_4">
|
||||
<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="QPushButton" name="pushButton_AddConnection">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</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="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_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QFrame" name="horizontalFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
|
@ -1369,7 +1465,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QFrame" name="gridFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
|
@ -1393,7 +1489,7 @@
|
|||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="scrollArea_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
|
@ -1410,10 +1506,49 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>826</width>
|
||||
<height>587</height>
|
||||
<height>557</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_14">
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<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>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGraphicsView" name="graphicsView_Connections">
|
||||
<property name="backgroundBrush">
|
||||
|
@ -1440,145 +1575,84 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer_8">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<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>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<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>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="horizontalFrame">
|
||||
<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_4">
|
||||
<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="QPushButton" name="pushButton_AddConnection">
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="horizontalFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<activeon>:/icons/add.ico</activeon>
|
||||
</iconset>
|
||||
<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">
|
||||
<property name="text">
|
||||
<string>Dive Map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_DiveMap">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Emerge Map</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_EmergeMap">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_10">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_RemoveConnection">
|
||||
<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_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue