Add dive map toggle under View

This commit is contained in:
GriffinR 2024-07-25 16:32:26 -04:00
parent a07517be83
commit 2bb01a9988
4 changed files with 41 additions and 25 deletions

View file

@ -1715,7 +1715,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>100</width>
<height>16</height> <height>30</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -1809,7 +1809,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>100</width>
<height>16</height> <height>30</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -1903,7 +1903,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>100</width>
<height>16</height> <height>30</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -2003,7 +2003,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>100</width>
<height>16</height> <height>30</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -2097,7 +2097,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>100</width> <width>100</width>
<height>16</height> <height>30</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -2596,9 +2596,6 @@
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="clearButtonEnabled" stdset="0">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="7"> <item row="0" column="7">
@ -2636,9 +2633,6 @@
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="clearButtonEnabled" stdset="0">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="6"> <item row="0" column="6">
@ -2880,8 +2874,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>365</width> <width>100</width>
<height>651</height> <height>30</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="layout_ConnectionsList"> <layout class="QVBoxLayout" name="layout_ConnectionsList">
@ -3082,6 +3076,7 @@
<addaction name="actionCursor_Tile_Outline"/> <addaction name="actionCursor_Tile_Outline"/>
<addaction name="actionPlayer_View_Rectangle"/> <addaction name="actionPlayer_View_Rectangle"/>
<addaction name="actionBetter_Cursors"/> <addaction name="actionBetter_Cursors"/>
<addaction name="actionDive_Emerge_Map"/>
</widget> </widget>
<widget class="QMenu" name="menuTools"> <widget class="QMenu" name="menuTools">
<property name="title"> <property name="title">
@ -3421,6 +3416,17 @@
<string>Ctrl+W</string> <string>Ctrl+W</string>
</property> </property>
</action> </action>
<action name="actionDive_Emerge_Map">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Dive/Emerge Map</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>

View file

@ -269,6 +269,7 @@ private slots:
void eventTabChanged(int index); void eventTabChanged(int index);
void on_actionDive_Emerge_Map_triggered();
void on_groupBox_DiveMapOpacity_toggled(bool on); void on_groupBox_DiveMapOpacity_toggled(bool on);
void on_slider_DiveEmergeMapOpacity_valueChanged(int value); void on_slider_DiveEmergeMapOpacity_valueChanged(int value);
void on_slider_DiveMapOpacity_valueChanged(int value); void on_slider_DiveMapOpacity_valueChanged(int value);
@ -409,6 +410,7 @@ private:
int insertTilesetLabel(QStringList * list, QString label); int insertTilesetLabel(QStringList * list, QString label);
void checkForUpdates(bool requestedByUser); void checkForUpdates(bool requestedByUser);
void setDiveEmergeMapVisible(bool visible);
}; };
enum MapListUserRoles { enum MapListUserRoles {

View file

@ -951,7 +951,6 @@ void Editor::createDiveEmergeConnection(MapConnection* connection) {
} else { } else {
item = new QGraphicsPixmapItem(connectedMap->render()); item = new QGraphicsPixmapItem(connectedMap->render());
} }
// TODO: Set pos. In-game, how are diving coordinates converted if the maps are different sizes?
scene->addItem(item); scene->addItem(item);
if (connection->direction == "dive") { if (connection->direction == "dive") {
@ -995,9 +994,6 @@ void Editor::setDiveEmergeMapName(QString mapName, QString direction) {
} }
if (connection) { if (connection) {
if (connection->map_name == mapName)
return;
// Update existing connection // Update existing connection
if (mapName.isEmpty()) { if (mapName.isEmpty()) {
removeConnection(map, connection); removeConnection(map, connection);

View file

@ -486,7 +486,6 @@ void MainWindow::loadUserSettings() {
this->editor->settings->cursorTileRectEnabled = porymapConfig.showCursorTile; this->editor->settings->cursorTileRectEnabled = porymapConfig.showCursorTile;
ui->checkBox_ToggleBorder->setChecked(porymapConfig.showBorder); ui->checkBox_ToggleBorder->setChecked(porymapConfig.showBorder);
ui->checkBox_ToggleGrid->setChecked(porymapConfig.showGrid); ui->checkBox_ToggleGrid->setChecked(porymapConfig.showGrid);
ui->groupBox_DiveMapOpacity->setChecked(porymapConfig.showDiveEmergeMaps);
mapSortOrder = porymapConfig.mapSortOrder; mapSortOrder = porymapConfig.mapSortOrder;
this->editor->collisionOpacity = static_cast<qreal>(porymapConfig.collisionOpacity) / 100; this->editor->collisionOpacity = static_cast<qreal>(porymapConfig.collisionOpacity) / 100;
@ -498,6 +497,7 @@ void MainWindow::loadUserSettings() {
ui->horizontalSlider_CollisionZoom->setValue(porymapConfig.collisionZoom); ui->horizontalSlider_CollisionZoom->setValue(porymapConfig.collisionZoom);
setTheme(porymapConfig.theme); setTheme(porymapConfig.theme);
setDiveEmergeMapVisible(porymapConfig.showDiveEmergeMaps);
} }
void MainWindow::restoreWindowState() { void MainWindow::restoreWindowState() {
@ -910,12 +910,8 @@ void MainWindow::displayMapProperties() {
ui->frame_3->setEnabled(true); ui->frame_3->setEnabled(true);
Map *map = editor->map; Map *map = editor->map;
ui->comboBox_PrimaryTileset->blockSignals(true);
ui->comboBox_SecondaryTileset->blockSignals(true);
ui->comboBox_PrimaryTileset->setCurrentText(map->layout->tileset_primary_label); ui->comboBox_PrimaryTileset->setCurrentText(map->layout->tileset_primary_label);
ui->comboBox_SecondaryTileset->setCurrentText(map->layout->tileset_secondary_label); ui->comboBox_SecondaryTileset->setCurrentText(map->layout->tileset_secondary_label);
ui->comboBox_PrimaryTileset->blockSignals(false);
ui->comboBox_SecondaryTileset->blockSignals(false);
ui->comboBox_Song->setCurrentText(map->song); ui->comboBox_Song->setCurrentText(map->song);
ui->comboBox_Location->setCurrentText(map->location); ui->comboBox_Location->setCurrentText(map->location);
@ -1058,8 +1054,10 @@ bool MainWindow::setProjectUI() {
ui->comboBox_Type->addItems(project->mapTypes); ui->comboBox_Type->addItems(project->mapTypes);
ui->comboBox_DiveMap->clear(); ui->comboBox_DiveMap->clear();
ui->comboBox_DiveMap->addItems(project->mapNames); ui->comboBox_DiveMap->addItems(project->mapNames);
ui->comboBox_DiveMap->setClearButtonEnabled(true);
ui->comboBox_EmergeMap->clear(); ui->comboBox_EmergeMap->clear();
ui->comboBox_EmergeMap->addItems(project->mapNames); ui->comboBox_EmergeMap->addItems(project->mapNames);
ui->comboBox_EmergeMap->setClearButtonEnabled(true);
sortMapList(); sortMapList();
@ -2270,15 +2268,29 @@ void MainWindow::eventTabChanged(int index) {
isProgrammaticEventTabChange = false; isProgrammaticEventTabChange = false;
} }
void MainWindow::on_actionDive_Emerge_Map_triggered() {
setDiveEmergeMapVisible(ui->actionDive_Emerge_Map->isChecked());
}
void MainWindow::on_groupBox_DiveMapOpacity_toggled(bool on) { void MainWindow::on_groupBox_DiveMapOpacity_toggled(bool on) {
setDiveEmergeMapVisible(on);
}
void MainWindow::setDiveEmergeMapVisible(bool visible) {
// Qt doesn't change the style of disabled sliders, so we do it ourselves // Qt doesn't change the style of disabled sliders, so we do it ourselves
QString stylesheet = on ? "" : "QSlider::groove:horizontal {border: 1px solid #999999; border-radius: 3px; height: 2px; background: #B1B1B1;}" QString stylesheet = visible ? "" : "QSlider::groove:horizontal {border: 1px solid #999999; border-radius: 3px; height: 2px; background: #B1B1B1;}"
"QSlider::handle:horizontal {border: 1px solid #444444; border-radius: 3px; width: 10px; height: 9px; margin: -5px -1px; background: #5C5C5C; }"; "QSlider::handle:horizontal {border: 1px solid #444444; border-radius: 3px; width: 10px; height: 9px; margin: -5px -1px; background: #5C5C5C; }";
ui->slider_DiveEmergeMapOpacity->setStyleSheet(stylesheet); ui->slider_DiveEmergeMapOpacity->setStyleSheet(stylesheet);
ui->slider_DiveMapOpacity->setStyleSheet(stylesheet); ui->slider_DiveMapOpacity->setStyleSheet(stylesheet);
ui->slider_EmergeMapOpacity->setStyleSheet(stylesheet); ui->slider_EmergeMapOpacity->setStyleSheet(stylesheet);
porymapConfig.showDiveEmergeMaps = on; // Sync UI toggle elements
const QSignalBlocker blocker1(ui->groupBox_DiveMapOpacity);
const QSignalBlocker blocker2(ui->actionDive_Emerge_Map);
ui->groupBox_DiveMapOpacity->setChecked(visible);
ui->actionDive_Emerge_Map->setChecked(visible);
porymapConfig.showDiveEmergeMaps = visible;
this->editor->updateDiveEmergeVisibility(); this->editor->updateDiveEmergeVisibility();
} }