diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index a59c0ad0..9ecc927f 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -509,7 +509,7 @@ - 3 + 0 false @@ -922,306 +922,23 @@ 3 - - - - - 0 - 0 - + + + + 10 - - QFrame::StyledPanel + + 90 - - QFrame::Raised + + 30 + + + Qt::Horizontal - - - - - Primary Tileset - - - - - - - Qt::StrongFocus - - - <html><head/><body><p>Primary Tileset</p><p>Defines the first 0x200 metatiles available for the map.</p></body></html> - - - true - - - - - - - Secondary Tileset - - - - - - - Qt::StrongFocus - - - <html><head/><body><p>Secondary Tileset</p><p>Defines the second 0x200 metatiles available for the map.</p></body></html> - - - true - - - - - - - - - 0 - 0 - - - - - 0 - 92 - - - - - 16777215 - 92 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - QLayout::SetDefaultConstraint - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Selection - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - true - - - - - 0 - 0 - 256 - 74 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - Border - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 16777215 - 48 - - - - <html><head/><body><p>The border is a 2x2 metatile which is repeated outside of the map layout's boundary. Draw on this border area to modify it.</p></body></html> - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Qt::ScrollBarAsNeeded - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - + @@ -1250,10 +967,10 @@ - 0 + 8 0 - 91 - 74 + 408 + 380 @@ -1347,19 +1064,330 @@ - - - 10 + + + + 0 + 0 + - - 90 + + + 0 + 92 + - - 30 + + + 16777215 + 92 + - - Qt::Horizontal + + QFrame::NoFrame + + QFrame::Raised + + + + 0 + + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Selection + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + 0 + 0 + 420 + 74 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + + Border + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 16777215 + 48 + + + + <html><head/><body><p>The border is a 2x2 metatile which is repeated outside of the map layout's boundary. Draw on this border area to modify it.</p></body></html> + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Qt::ScrollBarAsNeeded + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Primary Tileset + + + + + + + Qt::StrongFocus + + + <html><head/><body><p>Primary Tileset</p><p>Defines the first 0x200 metatiles available for the map.</p></body></html> + + + true + + + + + + + Secondary Tileset + + + + + + + Qt::StrongFocus + + + <html><head/><body><p>Secondary Tileset</p><p>Defines the second 0x200 metatiles available for the map.</p></body></html> + + + true + + + + + + + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 2 + + + 2 + + + + + Layout + + + + + + + @@ -1403,8 +1431,8 @@ 0 0 - 92 - 550 + 425 + 696 @@ -1563,8 +1591,8 @@ 0 0 - 91 - 460 + 379 + 611 diff --git a/include/core/map.h b/include/core/map.h index 37ae9b58..87bfd0d9 100644 --- a/include/core/map.h +++ b/include/core/map.h @@ -59,6 +59,7 @@ public: QMap customHeaders; Layout *layout = nullptr; + void setLayout(Layout *layout); bool isPersistedToFile = true; bool hasUnsavedDataChanges = false; diff --git a/include/mainwindow.h b/include/mainwindow.h index c5643b66..d4390bbb 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -200,6 +200,7 @@ private slots: void on_comboBox_Weather_currentTextChanged(const QString &arg1); void on_comboBox_Type_currentTextChanged(const QString &arg1); void on_comboBox_BattleScene_currentTextChanged(const QString &arg1); + void on_comboBox_LayoutSelector_currentTextChanged(const QString &arg1); void on_checkBox_ShowLocation_stateChanged(int selected); void on_checkBox_AllowRunning_stateChanged(int selected); void on_checkBox_AllowBiking_stateChanged(int selected); diff --git a/src/core/map.cpp b/src/core/map.cpp index ee7a1884..fc167ea1 100644 --- a/src/core/map.cpp +++ b/src/core/map.cpp @@ -29,6 +29,13 @@ void Map::setName(QString mapName) { constantName = mapConstantFromName(mapName); } +void Map::setLayout(Layout *layout) { + this->layout = layout; + if (layout) { + this->layoutId = layout->id; + } +} + QString Map::mapConstantFromName(QString mapName) { // Transform map names of the form 'GraniteCave_B1F` into map constants like 'MAP_GRANITE_CAVE_B1F'. static const QRegularExpression caseChange("([a-z])([A-Z])"); diff --git a/src/editor.cpp b/src/editor.cpp index 8a508bbf..18915bdc 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1154,6 +1154,18 @@ bool Editor::setLayout(QString layoutId) { map_ruler->setMapDimensions(QSize(this->layout->getWidth(), this->layout->getHeight())); connect(this->layout, &Layout::layoutDimensionsChanged, map_ruler, &MapRuler::setMapDimensions); + ui->comboBox_PrimaryTileset->blockSignals(true); + ui->comboBox_SecondaryTileset->blockSignals(true); + ui->comboBox_PrimaryTileset->setCurrentText(this->layout->tileset_primary_label); + ui->comboBox_SecondaryTileset->setCurrentText(this->layout->tileset_secondary_label); + ui->comboBox_PrimaryTileset->blockSignals(false); + ui->comboBox_SecondaryTileset->blockSignals(false); + + const QSignalBlocker b0(this->ui->comboBox_LayoutSelector); + int index = this->ui->comboBox_LayoutSelector->findText(layoutId); + if (index < 0) index = 0; + this->ui->comboBox_LayoutSelector->setCurrentIndex(index); + return true; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c503d23d..3904ca0c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -640,6 +640,7 @@ void MainWindow::unsetMap() { this->ui->mainTabBar->setTabEnabled(4, false); // + this->ui->comboBox_LayoutSelector->setEnabled(false); } bool MainWindow::setMap(QString map_name, bool scrollTreeView) { @@ -721,12 +722,7 @@ bool MainWindow::setLayout(QString layoutId) { // connect(editor->map, &Map::modified, [this](){ this->markMapEdited(); }); // displayMapProperties - ui->comboBox_PrimaryTileset->blockSignals(true); - ui->comboBox_SecondaryTileset->blockSignals(true); - ui->comboBox_PrimaryTileset->setCurrentText(this->editor->layout->tileset_primary_label); - ui->comboBox_SecondaryTileset->setCurrentText(this->editor->layout->tileset_secondary_label); - ui->comboBox_PrimaryTileset->blockSignals(false); - ui->comboBox_SecondaryTileset->blockSignals(false); + // // connect(editor->layout, &Layout::mapChanged, this, &MainWindow::onMapChanged); @@ -876,6 +872,18 @@ void MainWindow::displayMapProperties() { ui->tableWidget_CustomHeaderFields->blockSignals(false); } +void MainWindow::on_comboBox_LayoutSelector_currentTextChanged(const QString &text) { + // + if (editor && editor->project && editor->map) { + if (editor->project->mapLayouts.contains(text)) { + editor->map->setLayout(editor->project->loadLayout(text)); + // !TODO: method to setMapLayout instead of having to do whole setMap thing, + // also edit history and bug fixes + setMap(editor->map->name); + } + } +} + void MainWindow::on_comboBox_Song_currentTextChanged(const QString &song) { if (editor && editor->map) { @@ -1012,6 +1020,7 @@ bool MainWindow::loadProjectCombos() { const QSignalBlocker blocker5(ui->comboBox_Weather); const QSignalBlocker blocker6(ui->comboBox_BattleScene); const QSignalBlocker blocker7(ui->comboBox_Type); + const QSignalBlocker blocker8(ui->comboBox_LayoutSelector); ui->comboBox_Song->clear(); ui->comboBox_Song->addItems(project->songNames); @@ -1027,6 +1036,8 @@ bool MainWindow::loadProjectCombos() { ui->comboBox_BattleScene->addItems(project->mapBattleScenes); ui->comboBox_Type->clear(); ui->comboBox_Type->addItems(project->mapTypes); + ui->comboBox_LayoutSelector->clear(); + ui->comboBox_LayoutSelector->addItems(project->mapLayoutsTable); return true; }