diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 44d69d30..eb6c7345 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -1155,7 +1155,7 @@ 2 - + Layout @@ -2220,7 +2220,7 @@ 0 - + false @@ -2236,206 +2236,10 @@ QFrame::Shadow::Raised - - - QFormLayout::FieldGrowthPolicy::FieldsStayAtSizeHint - - - 12 - + 9 - - - - Song - - - - - - - <html><head/><body><p>The default background music for this map.</p></body></html> - - - true - - - - - - - Location - - - - - - - <html><head/><body><p>The section of the region map which the map is grouped under. This also determines the name of the map that is display when the player enters it.</p></body></html> - - - true - - - - - - - Requires Flash - - - - - - - <html><head/><body><p>Whether or not the map is dark and requires Flash to illuminate.</p></body></html> - - - - - - - - - - Weather - - - - - - - <html><head/><body><p>The default weather for this map.</p></body></html> - - - true - - - - - - - Type - - - - - - - <html><head/><body><p>The map type is a general attribute, which is used for many different things. For example. it determines whether biking or running is allowed.</p></body></html> - - - true - - - - - - - Battle scene - - - - - - - <html><head/><body><p>Determines the type of battle scene graphics to use.</p></body></html> - - - true - - - - - - - Show Location Name - - - - - - - <html><head/><body><p>Whether or not to display the location name when the player enters the map.</p></body></html> - - - - - - - - - - Allow Running - - - - - - - <html><head/><body><p>Allows the player to use Running Shoes</p></body></html> - - - - - - - - - - Allow Biking - - - - - - - <html><head/><body><p>Allows the player to use a Bike</p></body></html> - - - - - - - - - - Allow Dig & Escape Rope - - - - - - - <html><head/><body><p>Allows the player to use Dig or Escape Rope</p></body></html> - - - - - - - - - - Floor Number - - - - - - - <html><head/><body><p>Floor number to be used for maps with elevators.</p></body></html> - - - -128 - - - 127 - - - diff --git a/forms/mapheaderform.ui b/forms/mapheaderform.ui new file mode 100644 index 00000000..06541e2c --- /dev/null +++ b/forms/mapheaderform.ui @@ -0,0 +1,235 @@ + + + MapHeaderForm + + + + 0 + 0 + 407 + 349 + + + + Form + + + + QFormLayout::FieldGrowthPolicy::FieldsStayAtSizeHint + + + + + Song + + + + + + + <html><head/><body><p>The default background music for this map.</p></body></html> + + + true + + + QComboBox::InsertPolicy::NoInsert + + + + + + + Location + + + + + + + <html><head/><body><p>The section of the region map which the map is grouped under. This also determines the name of the map that is displayed when the player enters it.</p></body></html> + + + true + + + QComboBox::InsertPolicy::NoInsert + + + + + + + Requires Flash + + + + + + + <html><head/><body><p>If checked, the player will need to use Flash to see fully on this map.</p></body></html> + + + + + + + + + + Weather + + + + + + + <html><head/><body><p>The default weather on this map.</p></body></html> + + + true + + + QComboBox::InsertPolicy::NoInsert + + + + + + + Type + + + + + + + <html><head/><body><p>The map type is a general attribute, which is used for many different things. For example, underground type maps will have a special transition effect when the player enters/exits the map.</p></body></html> + + + true + + + QComboBox::InsertPolicy::NoInsert + + + + + + + Battle Scene + + + + + + + <html><head/><body><p>This field is used to help determine what graphics to use in the background of battles on this map.</p></body></html> + + + true + + + QComboBox::InsertPolicy::NoInsert + + + + + + + Show Location Name + + + + + + + <html><head/><body><p>If checked, a map name popup will appear when the player enters this map. The name that appears on this popup depends on the Location field.</p></body></html> + + + + + + + + + + Allow Running + + + + + + + <html><head/><body><p>If checked, the player will be allowed to run on this map.</p></body></html> + + + + + + + + + + Allow Biking + + + + + + + <html><head/><body><p>If checked, the player will be allowed to get on their bike on this map.</p></body></html> + + + + + + + + + + Allow Dig & Escape Rope + + + + + + + <html><head/><body><p>If checked, the player will be allowed to use Dig or Escape Rope on this map.</p></body></html> + + + + + + + + + + Floor Number + + + + + + + <html><head/><body><p>Floor number to be used for maps with elevators.</p></body></html> + + + + + + + + NoScrollComboBox + QComboBox +
noscrollcombobox.h
+
+ + NoScrollSpinBox + QSpinBox +
noscrollspinbox.h
+
+
+ + +
diff --git a/forms/newmapdialog.ui b/forms/newmapdialog.ui index 9cf4dc18..dcf4f052 100644 --- a/forms/newmapdialog.ui +++ b/forms/newmapdialog.ui @@ -7,7 +7,7 @@ 0 0 453 - 563 + 588 @@ -25,7 +25,7 @@ 0 0 427 - 841 + 526 @@ -39,7 +39,14 @@
- + + + + ID + + + + <html><head/><body><p>The name of the new map. The name cannot be the same as any other existing map.</p></body></html> @@ -49,7 +56,23 @@ - + + + + false + + + color: rgb(255, 0, 0) + + + + + + true + + + + Border Dimensions @@ -104,357 +127,6 @@ - - - - Map Dimensions - - - - - - - 0 - 0 - - - - Width - - - - - - - <html><head/><body><p>Width (in metatiles) of the new map.</p></body></html> - - - 1 - - - - - - - <html><head/><body><p>Height (in metatiles) of the new map.</p></body></html> - - - 1 - - - - - - - false - - - color: rgb(255, 0, 0) - - - - - - true - - - - - - - - 0 - 0 - - - - Height - - - - - - - - - - <html><head/><body><p>The name of the group this map will be added to.</p></body></html> - - - true - - - QComboBox::InsertPolicy::NoInsert - - - - - - - false - - - color: rgb(255, 0, 0) - - - - - - true - - - - - - - <html><head/><body><p>The constant that will be used to refer to this map. It cannot be the same as any other existing map, and it must start with the specified prefix.</p></body></html> - - - - - - - false - - - color: rgb(255, 0, 0) - - - - - - true - - - - - - - Header Data - - - - - - Song - - - - - - - <html><head/><body><p>The default background music for this map.</p></body></html> - - - true - - - QComboBox::InsertPolicy::NoInsert - - - - - - - Location - - - - - - - Requires Flash - - - - - - - Weather - - - - - - - Type - - - - - - - <html><head/><body><p>The map type is a general attribute, which is used for many different things. For example, underground type maps will have a special transition effect when the player enters/exits the map.</p></body></html> - - - true - - - QComboBox::InsertPolicy::NoInsert - - - - - - - Battle Scene - - - - - - - Show Location - - - - - - - Allow Running - - - - - - - Allow Biking - - - - - - - Allow Escaping - - - - - - - Floor Number - - - - - - - Can Fly To - - - - - - - <html><head/><body><p>The section of the region map which the map is grouped under. This also determines the name of the map that is displayed when the player enters it.</p></body></html> - - - true - - - QComboBox::InsertPolicy::NoInsert - - - - - - - <html><head/><body><p>Floor number to be used for maps with elevators.</p></body></html> - - - 127 - - - - - - - <html><head/><body><p>This field is used to help determine what graphics to use in the background of battles on this map.</p></body></html> - - - true - - - QComboBox::InsertPolicy::NoInsert - - - - - - - <html><head/><body><p>The default weather on this map.</p></body></html> - - - true - - - QComboBox::InsertPolicy::NoInsert - - - - - - - <html><head/><body><p>If checked, the player will need to use Flash to see fully on this map.</p></body></html> - - - - - - - - - - <html><head/><body><p>If checked, a map name popup will appear when the player enters this map. The name that appears on this popup depends on the Location field.</p></body></html> - - - - - - - - - - <html><head/><body><p>If checked, the player will be allowed to run on this map.</p></body></html> - - - - - - - - - - <html><head/><body><p>If checked, the player will be allowed to get on their bike on this map.</p></body></html> - - - - - - - - - - <html><head/><body><p>If checked, the player will be allowed to use Dig or Escape Rope on this map.</p></body></html> - - - - - - - - - - <html><head/><body><p>If checked, a Heal Location will be added to this map automatically.</p></body></html> - - - - - - - - - @@ -462,14 +134,20 @@ - - - - ID + + + + Qt::Orientation::Vertical - + + + 20 + 40 + + + - + false @@ -485,7 +163,14 @@ - + + + + Can Fly To + + + + Tilesets @@ -550,6 +235,131 @@ + + + + Map Dimensions + + + + + + + 0 + 0 + + + + Width + + + + + + + <html><head/><body><p>Width (in metatiles) of the new map.</p></body></html> + + + 1 + + + + + + + + 0 + 0 + + + + Height + + + + + + + <html><head/><body><p>Height (in metatiles) of the new map.</p></body></html> + + + 1 + + + + + + + false + + + color: rgb(255, 0, 0) + + + + + + true + + + + + + + + + + <html><head/><body><p>The constant that will be used to refer to this map. It cannot be the same as any other existing map, and it must start with the specified prefix.</p></body></html> + + + + + + + false + + + color: rgb(255, 0, 0) + + + + + + true + + + + + + + Header Data + + + + + + + + <html><head/><body><p>The name of the group this map will be added to.</p></body></html> + + + true + + + QComboBox::InsertPolicy::NoInsert + + + + + + + <html><head/><body><p>If checked, a Heal Location will be added to this map automatically.</p></body></html> + + + + + + diff --git a/include/core/map.h b/include/core/map.h index eab3110e..314013d7 100644 --- a/include/core/map.h +++ b/include/core/map.h @@ -62,7 +62,7 @@ public: void setRequiresFlash(bool requiresFlash); void setWeather(const QString &weather); void setType(const QString &type); - void setShowsLocation(bool showsLocation); + void setShowsLocationName(bool showsLocationName); void setAllowsRunning(bool allowsRunning); void setAllowsBiking(bool allowsBiking); void setAllowsEscaping(bool allowsEscaping); @@ -74,7 +74,7 @@ public: bool requiresFlash() const { return m_requiresFlash; } QString weather() const { return m_weather; } QString type() const { return m_type; } - bool showsLocation() const { return m_showsLocation; } + bool showsLocationName() const { return m_showsLocationName; } bool allowsRunning() const { return m_allowsRunning; } bool allowsBiking() const { return m_allowsBiking; } bool allowsEscaping() const { return m_allowsEscaping; } @@ -136,7 +136,7 @@ private: bool m_requiresFlash; QString m_weather; QString m_type; - bool m_showsLocation; + bool m_showsLocationName; bool m_allowsRunning; bool m_allowsBiking; bool m_allowsEscaping; diff --git a/include/mainwindow.h b/include/mainwindow.h index 2efe964d..ab4e0482 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -32,6 +32,7 @@ #include "wildmonchart.h" #include "updatepromoter.h" #include "aboutporymap.h" +#include "mapheaderform.h" @@ -199,17 +200,7 @@ private slots: void on_actionNew_Tileset_triggered(); void on_action_Save_triggered(); void on_action_Exit_triggered(); - void on_comboBox_Song_currentTextChanged(const QString &arg1); - void on_comboBox_Location_currentTextChanged(const QString &arg1); - 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); - void on_checkBox_AllowEscaping_stateChanged(int selected); - void on_spinBox_FloorNumber_valueChanged(int offset); + void on_comboBox_LayoutSelector_currentTextChanged(const QString &text); void on_actionShortcuts_triggered(); void on_actionZoom_In_triggered(); @@ -254,7 +245,6 @@ private slots: void on_comboBox_SecondaryTileset_currentTextChanged(const QString &arg1); void on_pushButton_ChangeDimensions_clicked(); void on_checkBox_smartPaths_stateChanged(int selected); - void on_checkBox_Visibility_stateChanged(int selected); void on_checkBox_ToggleBorder_stateChanged(int selected); void resetMapViewScale(); @@ -337,6 +327,8 @@ private: QAction *copyAction = nullptr; QAction *pasteAction = nullptr; + MapHeaderForm *mapHeader = nullptr; + QMap lastSelectedEvent; bool isProgrammaticEventTabChange; diff --git a/include/ui/mapheaderform.h b/include/ui/mapheaderform.h new file mode 100644 index 00000000..afdee728 --- /dev/null +++ b/include/ui/mapheaderform.h @@ -0,0 +1,56 @@ +#ifndef MAPHEADERFORM_H +#define MAPHEADERFORM_H + +#include "project.h" +#include "map.h" +#include "ui_mapheaderform.h" + +#include + +/* + This is the UI class used to edit the fields in a map's header. + It's intended to be used anywhere the UI needs to present an editor for a map's header, + e.g. for the current map in the main editor or in the new map dialog. +*/ + +namespace Ui { +class MapHeaderForm; +} + +class MapHeaderForm : public QWidget +{ + Q_OBJECT + +public: + explicit MapHeaderForm(QWidget *parent = nullptr); + ~MapHeaderForm(); + + void setProject(Project * project); + void setMap(Map * map); + + void clearDisplay(); + void clear(); + + void refreshLocationsComboBox(); + + Ui::MapHeaderForm *ui; + +private: + QPointer map = nullptr; + QPointer project = nullptr; + +private slots: + void on_comboBox_Song_currentTextChanged(const QString &); + void on_comboBox_Location_currentTextChanged(const QString &); + void on_comboBox_Weather_currentTextChanged(const QString &); + void on_comboBox_Type_currentTextChanged(const QString &); + void on_comboBox_BattleScene_currentTextChanged(const QString &); + void on_checkBox_RequiresFlash_stateChanged(int); + void on_checkBox_ShowLocationName_stateChanged(int); + void on_checkBox_AllowRunning_stateChanged(int); + void on_checkBox_AllowBiking_stateChanged(int); + void on_checkBox_AllowEscaping_stateChanged(int); + void on_spinBox_FloorNumber_valueChanged(int); +}; + +#endif // MAPHEADERFORM_H diff --git a/include/ui/newmapdialog.h b/include/ui/newmapdialog.h index 4b17f32b..090fcb96 100644 --- a/include/ui/newmapdialog.h +++ b/include/ui/newmapdialog.h @@ -6,6 +6,7 @@ #include "editor.h" #include "project.h" #include "map.h" +#include "mapheaderform.h" namespace Ui { class NewMapDialog; @@ -34,6 +35,7 @@ signals: private: Ui::NewMapDialog *ui; Project *project; + MapHeaderForm *headerData; bool validateMapDimensions(); bool validateMapGroup(); diff --git a/porymap.pro b/porymap.pro index 1bea489b..d3d870bc 100644 --- a/porymap.pro +++ b/porymap.pro @@ -83,6 +83,7 @@ SOURCES += src/core/block.cpp \ src/ui/prefabcreationdialog.cpp \ src/ui/regionmappixmapitem.cpp \ src/ui/citymappixmapitem.cpp \ + src/ui/mapheaderform.cpp \ src/ui/metatilelayersitem.cpp \ src/ui/metatileselector.cpp \ src/ui/movablerect.cpp \ @@ -166,6 +167,7 @@ HEADERS += include/core/block.h \ include/ui/connectionpixmapitem.h \ include/ui/currentselectedmetatilespixmapitem.h \ include/ui/gridsettings.h \ + include/ui/mapheaderform.h \ include/ui/newmapconnectiondialog.h \ include/ui/prefabframe.h \ include/ui/projectsettingseditor.h \ @@ -233,6 +235,7 @@ FORMS += forms/mainwindow.ui \ forms/colorinputwidget.ui \ forms/connectionslistitem.ui \ forms/gridsettingsdialog.ui \ + forms/mapheaderform.ui \ forms/maplisttoolbar.ui \ forms/newmapconnectiondialog.ui \ forms/prefabcreationdialog.ui \ diff --git a/src/core/map.cpp b/src/core/map.cpp index 942a4e95..ab31ac86 100644 --- a/src/core/map.cpp +++ b/src/core/map.cpp @@ -330,8 +330,8 @@ void Map::setType(const QString &type) { m_type = type; } -void Map::setShowsLocation(bool showsLocation) { - m_showsLocation = showsLocation; +void Map::setShowsLocationName(bool showsLocationName) { + m_showsLocationName = showsLocationName; } void Map::setAllowsRunning(bool allowsRunning) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6105a3b4..d47dfef2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -235,6 +235,10 @@ void MainWindow::initCustomUI() { ui->mainTabBar->addTab(mainTabNames.value(i)); ui->mainTabBar->setTabIcon(i, mainTabIcons.value(i)); } + + // Create map header data widget + this->mapHeader = new MapHeaderForm(); + ui->layout_HeaderData->addWidget(this->mapHeader); } void MainWindow::initExtraSignals() { @@ -597,7 +601,7 @@ bool MainWindow::openProject(QString dir, bool initial) { project->set_root(dir); connect(project, &Project::fileChanged, this, &MainWindow::showFileWatcherWarning); connect(project, &Project::mapLoaded, this, &MainWindow::onMapLoaded); - connect(project, &Project::mapSectionIdNamesChanged, this, &MainWindow::refreshLocationsComboBox); + connect(project, &Project::mapSectionIdNamesChanged, this->mapHeader, &MapHeaderForm::refreshLocationsComboBox); this->editor->setProject(project); // Make sure project looks reasonable before attempting to load it @@ -1005,47 +1009,22 @@ void MainWindow::openWarpMap(QString map_name, int event_id, Event::Group event_ void MainWindow::displayMapProperties() { // Block signals to the comboboxes while they are being modified - const QSignalBlocker blocker1(ui->comboBox_Song); - const QSignalBlocker blocker2(ui->comboBox_Location); - const QSignalBlocker blocker3(ui->comboBox_PrimaryTileset); - const QSignalBlocker blocker4(ui->comboBox_SecondaryTileset); - const QSignalBlocker blocker5(ui->comboBox_Weather); - const QSignalBlocker blocker6(ui->comboBox_BattleScene); - const QSignalBlocker blocker7(ui->comboBox_Type); - const QSignalBlocker blocker8(ui->checkBox_Visibility); - const QSignalBlocker blocker9(ui->checkBox_ShowLocation); - const QSignalBlocker blockerA(ui->checkBox_AllowRunning); - const QSignalBlocker blockerB(ui->checkBox_AllowBiking); - const QSignalBlocker blockerC(ui->spinBox_FloorNumber); - const QSignalBlocker blockerD(ui->checkBox_AllowEscaping); + const QSignalBlocker b_PrimaryTileset(ui->comboBox_PrimaryTileset); + const QSignalBlocker b_SecondaryTileset(ui->comboBox_SecondaryTileset); - ui->checkBox_Visibility->setChecked(false); - ui->checkBox_ShowLocation->setChecked(false); - ui->checkBox_AllowRunning->setChecked(false); - ui->checkBox_AllowBiking->setChecked(false); - ui->checkBox_AllowEscaping->setChecked(false); + this->mapHeader->clearDisplay(); if (!editor || !editor->map || !editor->project) { - ui->frame_3->setEnabled(false); + ui->frame_HeaderData->setEnabled(false); return; } - ui->frame_3->setEnabled(true); + ui->frame_HeaderData->setEnabled(true); Map *map = editor->map; ui->comboBox_PrimaryTileset->setCurrentText(map->layout()->tileset_primary_label); ui->comboBox_SecondaryTileset->setCurrentText(map->layout()->tileset_secondary_label); - ui->comboBox_Song->setCurrentText(map->song()); - ui->comboBox_Location->setCurrentText(map->location()); - ui->checkBox_Visibility->setChecked(map->requiresFlash()); - ui->comboBox_Weather->setCurrentText(map->weather()); - ui->comboBox_Type->setCurrentText(map->type()); - ui->comboBox_BattleScene->setCurrentText(map->battleScene()); - ui->checkBox_ShowLocation->setChecked(map->showsLocation()); - ui->checkBox_AllowRunning->setChecked(map->allowsRunning()); - ui->checkBox_AllowBiking->setChecked(map->allowsBiking()); - ui->checkBox_AllowEscaping->setChecked(map->allowsEscaping()); - ui->spinBox_FloorNumber->setValue(map->floorNumber()); + this->mapHeader->setMap(map); // Custom fields table. /* // TODO: Re-enable @@ -1068,122 +1047,24 @@ void MainWindow::on_comboBox_LayoutSelector_currentTextChanged(const QString &te } } -void MainWindow::on_comboBox_Song_currentTextChanged(const QString &song) -{ - if (editor && editor->map) { - editor->map->setSong(song); - markMapEdited(); - } -} - -void MainWindow::on_comboBox_Location_currentTextChanged(const QString &location) -{ - if (editor && editor->map) { - editor->map->setLocation(location); - markMapEdited(); - } -} - -void MainWindow::on_comboBox_Weather_currentTextChanged(const QString &weather) -{ - if (editor && editor->map) { - editor->map->setWeather(weather); - markMapEdited(); - } -} - -void MainWindow::on_comboBox_Type_currentTextChanged(const QString &type) -{ - if (editor && editor->map) { - editor->map->setType(type); - markMapEdited(); - } -} - -void MainWindow::on_comboBox_BattleScene_currentTextChanged(const QString &battle_scene) -{ - if (editor && editor->map) { - editor->map->setBattleScene(battle_scene); - markMapEdited(); - } -} - -void MainWindow::on_checkBox_Visibility_stateChanged(int selected) -{ - if (editor && editor->map) { - editor->map->setRequiresFlash(selected == Qt::Checked); - markMapEdited(); - } -} - -void MainWindow::on_checkBox_ShowLocation_stateChanged(int selected) -{ - if (editor && editor->map) { - editor->map->setShowsLocation(selected == Qt::Checked); - markMapEdited(); - } -} - -void MainWindow::on_checkBox_AllowRunning_stateChanged(int selected) -{ - if (editor && editor->map) { - editor->map->setAllowsRunning(selected == Qt::Checked); - markMapEdited(); - } -} - -void MainWindow::on_checkBox_AllowBiking_stateChanged(int selected) -{ - if (editor && editor->map) { - editor->map->setAllowsBiking(selected == Qt::Checked); - markMapEdited(); - } -} - -void MainWindow::on_checkBox_AllowEscaping_stateChanged(int selected) -{ - if (editor && editor->map) { - editor->map->setAllowsEscaping(selected == Qt::Checked); - markMapEdited(); - } -} - -void MainWindow::on_spinBox_FloorNumber_valueChanged(int offset) -{ - if (editor && editor->map) { - editor->map->setFloorNumber(offset); - markMapEdited(); - } -} - // Update the UI using information we've read from the user's project files. bool MainWindow::setProjectUI() { Project *project = editor->project; + this->mapHeader->setProject(project); + // Block signals to the comboboxes while they are being modified - const QSignalBlocker blocker1(ui->comboBox_Song); - const QSignalBlocker blocker3(ui->comboBox_PrimaryTileset); - const QSignalBlocker blocker4(ui->comboBox_SecondaryTileset); - const QSignalBlocker blocker5(ui->comboBox_Weather); - const QSignalBlocker blocker6(ui->comboBox_BattleScene); - const QSignalBlocker blocker7(ui->comboBox_Type); - const QSignalBlocker blocker8(ui->comboBox_DiveMap); - const QSignalBlocker blocker9(ui->comboBox_EmergeMap); - const QSignalBlocker blocker10(ui->comboBox_LayoutSelector); + const QSignalBlocker b_PrimaryTileset(ui->comboBox_PrimaryTileset); + const QSignalBlocker b_SecondaryTileset(ui->comboBox_SecondaryTileset); + const QSignalBlocker b_DiveMap(ui->comboBox_DiveMap); + const QSignalBlocker b_EmergeMap(ui->comboBox_EmergeMap); + const QSignalBlocker b_LayoutSelector(ui->comboBox_LayoutSelector); // Set up project comboboxes - ui->comboBox_Song->clear(); - ui->comboBox_Song->addItems(project->songNames); ui->comboBox_PrimaryTileset->clear(); ui->comboBox_PrimaryTileset->addItems(project->primaryTilesetLabels); ui->comboBox_SecondaryTileset->clear(); ui->comboBox_SecondaryTileset->addItems(project->secondaryTilesetLabels); - ui->comboBox_Weather->clear(); - ui->comboBox_Weather->addItems(project->weatherNames); - ui->comboBox_BattleScene->clear(); - 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); ui->comboBox_DiveMap->clear(); @@ -1194,29 +1075,16 @@ bool MainWindow::setProjectUI() { ui->comboBox_EmergeMap->addItems(project->mapNames); ui->comboBox_EmergeMap->setClearButtonEnabled(true); ui->comboBox_EmergeMap->setFocusedScrollingEnabled(false); - refreshLocationsComboBox(); // Show/hide parts of the UI that are dependent on the user's project settings // Wild Encounters tab ui->mainTabBar->setTabEnabled(MainTab::WildPokemon, editor->project->wildEncountersLoaded); - bool hasFlags = projectConfig.mapAllowFlagsEnabled; - ui->checkBox_AllowRunning->setVisible(hasFlags); - ui->checkBox_AllowBiking->setVisible(hasFlags); - ui->checkBox_AllowEscaping->setVisible(hasFlags); - ui->label_AllowRunning->setVisible(hasFlags); - ui->label_AllowBiking->setVisible(hasFlags); - ui->label_AllowEscaping->setVisible(hasFlags); - ui->newEventToolButton->newWeatherTriggerAction->setVisible(projectConfig.eventWeatherTriggerEnabled); ui->newEventToolButton->newSecretBaseAction->setVisible(projectConfig.eventSecretBaseEnabled); ui->newEventToolButton->newCloneObjectAction->setVisible(projectConfig.eventCloneObjectEnabled); - bool floorNumEnabled = projectConfig.floorNumberEnabled; - ui->spinBox_FloorNumber->setVisible(floorNumEnabled); - ui->label_FloorNumber->setVisible(floorNumEnabled); - Event::setIcons(); editor->setCollisionGraphics(); ui->spinBox_SelectedElevation->setMaximum(Block::getMaxElevation()); @@ -1244,41 +1112,22 @@ bool MainWindow::setProjectUI() { return true; } -void MainWindow::refreshLocationsComboBox() { - QStringList locations = this->editor->project->mapSectionIdNames; - locations.sort(); - - const QSignalBlocker b(ui->comboBox_Location); - ui->comboBox_Location->clear(); - ui->comboBox_Location->addItems(locations); - if (this->editor->map) - ui->comboBox_Location->setCurrentText(this->editor->map->location()); -} - void MainWindow::clearProjectUI() { // Block signals to the comboboxes while they are being modified - const QSignalBlocker blocker1(ui->comboBox_Song); - const QSignalBlocker blocker2(ui->comboBox_Location); - const QSignalBlocker blocker3(ui->comboBox_PrimaryTileset); - const QSignalBlocker blocker4(ui->comboBox_SecondaryTileset); - const QSignalBlocker blocker5(ui->comboBox_Weather); - const QSignalBlocker blocker6(ui->comboBox_BattleScene); - const QSignalBlocker blocker7(ui->comboBox_Type); - const QSignalBlocker blocker8(ui->comboBox_DiveMap); - const QSignalBlocker blocker9(ui->comboBox_EmergeMap); - const QSignalBlocker blockerA(ui->comboBox_LayoutSelector); + const QSignalBlocker b_PrimaryTileset(ui->comboBox_PrimaryTileset); + const QSignalBlocker b_SecondaryTileset(ui->comboBox_SecondaryTileset); + const QSignalBlocker b_DiveMap(ui->comboBox_DiveMap); + const QSignalBlocker b_EmergeMap(ui->comboBox_EmergeMap); + const QSignalBlocker b_LayoutSelector(ui->comboBox_LayoutSelector); - ui->comboBox_Song->clear(); - ui->comboBox_Location->clear(); ui->comboBox_PrimaryTileset->clear(); ui->comboBox_SecondaryTileset->clear(); - ui->comboBox_Weather->clear(); - ui->comboBox_BattleScene->clear(); - ui->comboBox_Type->clear(); ui->comboBox_DiveMap->clear(); ui->comboBox_EmergeMap->clear(); ui->comboBox_LayoutSelector->clear(); + this->mapHeader->clear(); + // Clear map models delete this->mapGroupModel; delete this->groupListProxyModel; diff --git a/src/project.cpp b/src/project.cpp index f996ff1c..f36f7543 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -221,7 +221,7 @@ bool Project::loadMapData(Map* map) { map->setRequiresFlash(ParseUtil::jsonToBool(mapObj["requires_flash"])); map->setWeather(ParseUtil::jsonToQString(mapObj["weather"])); map->setType(ParseUtil::jsonToQString(mapObj["map_type"])); - map->setShowsLocation(ParseUtil::jsonToBool(mapObj["show_map_name"])); + map->setShowsLocationName(ParseUtil::jsonToBool(mapObj["show_map_name"])); map->setBattleScene(ParseUtil::jsonToQString(mapObj["battle_scene"])); if (projectConfig.mapAllowFlagsEnabled) { @@ -1293,7 +1293,7 @@ void Project::saveMap(Map *map) { mapObj["allow_escaping"] = map->allowsEscaping(); mapObj["allow_running"] = map->allowsRunning(); } - mapObj["show_map_name"] = map->showsLocation(); + mapObj["show_map_name"] = map->showsLocationName(); if (projectConfig.floorNumberEnabled) { mapObj["floor_number"] = map->floorNumber(); } diff --git a/src/scriptapi/apimap.cpp b/src/scriptapi/apimap.cpp index d13d660b..5a0fa9ce 100644 --- a/src/scriptapi/apimap.cpp +++ b/src/scriptapi/apimap.cpp @@ -811,7 +811,8 @@ QJSValue MainWindow::getTilePixels(int tileId) { // Editing map header //===================== -// TODO: Replace UI setting here with calls to appropriate set functions. Update UI with signals from Map +// TODO: Connect signals from new function calls to update UI +// TODO: Is the error-checking for known constant names still reasonable / needed? (you can type anything after all) QString MainWindow::getSong() { if (!this->editor || !this->editor->map) @@ -820,13 +821,13 @@ QString MainWindow::getSong() { } void MainWindow::setSong(QString song) { - if (!this->ui || !this->editor || !this->editor->project) + if (!this->editor || !this->editor->map || !this->editor->project) return; if (!this->editor->project->songNames.contains(song)) { logError(QString("Unknown song '%1'").arg(song)); return; } - this->ui->comboBox_Song->setCurrentText(song); + this->editor->map->setSong(song); } QString MainWindow::getLocation() { @@ -836,13 +837,13 @@ QString MainWindow::getLocation() { } void MainWindow::setLocation(QString location) { - if (!this->ui || !this->editor || !this->editor->project) + if (!this->editor || !this->editor->map || !this->editor->project) return; if (!this->editor->project->mapSectionIdNames.contains(location)) { logError(QString("Unknown location '%1'").arg(location)); return; } - this->ui->comboBox_Location->setCurrentText(location); + this->editor->map->setLocation(location); } bool MainWindow::getRequiresFlash() { @@ -852,9 +853,9 @@ bool MainWindow::getRequiresFlash() { } void MainWindow::setRequiresFlash(bool require) { - if (!this->ui) + if (!this->editor || !this->editor->map) return; - this->ui->checkBox_Visibility->setChecked(require); + this->editor->map->setRequiresFlash(require); } QString MainWindow::getWeather() { @@ -864,13 +865,13 @@ QString MainWindow::getWeather() { } void MainWindow::setWeather(QString weather) { - if (!this->ui || !this->editor || !this->editor->project) + if (!this->editor || !this->editor->map || !this->editor->project) return; if (!this->editor->project->weatherNames.contains(weather)) { logError(QString("Unknown weather '%1'").arg(weather)); return; } - this->ui->comboBox_Weather->setCurrentText(weather); + this->editor->map->setWeather(weather); } QString MainWindow::getType() { @@ -880,13 +881,13 @@ QString MainWindow::getType() { } void MainWindow::setType(QString type) { - if (!this->ui || !this->editor || !this->editor->project) + if (!this->editor || !this->editor->map || !this->editor->project) return; if (!this->editor->project->mapTypes.contains(type)) { logError(QString("Unknown map type '%1'").arg(type)); return; } - this->ui->comboBox_Type->setCurrentText(type); + this->editor->map->setType(type); } QString MainWindow::getBattleScene() { @@ -896,25 +897,25 @@ QString MainWindow::getBattleScene() { } void MainWindow::setBattleScene(QString battleScene) { - if (!this->ui || !this->editor || !this->editor->project) + if (!this->editor || !this->editor->map || !this->editor->project) return; if (!this->editor->project->mapBattleScenes.contains(battleScene)) { logError(QString("Unknown battle scene '%1'").arg(battleScene)); return; } - this->ui->comboBox_BattleScene->setCurrentText(battleScene); + this->editor->map->setBattleScene(battleScene); } bool MainWindow::getShowLocationName() { if (!this->editor || !this->editor->map) return false; - return this->editor->map->showsLocation(); + return this->editor->map->showsLocationName(); } void MainWindow::setShowLocationName(bool show) { - if (!this->ui) + if (!this->editor || !this->editor->map) return; - this->ui->checkBox_ShowLocation->setChecked(show); + this->editor->map->setShowsLocationName(show); } bool MainWindow::getAllowRunning() { @@ -924,9 +925,9 @@ bool MainWindow::getAllowRunning() { } void MainWindow::setAllowRunning(bool allow) { - if (!this->ui) + if (!this->editor || !this->editor->map) return; - this->ui->checkBox_AllowRunning->setChecked(allow); + this->editor->map->setAllowsRunning(allow); } bool MainWindow::getAllowBiking() { @@ -936,9 +937,9 @@ bool MainWindow::getAllowBiking() { } void MainWindow::setAllowBiking(bool allow) { - if (!this->ui) + if (!this->editor || !this->editor->map) return; - this->ui->checkBox_AllowBiking->setChecked(allow); + this->editor->map->setAllowsBiking(allow); } bool MainWindow::getAllowEscaping() { @@ -948,9 +949,9 @@ bool MainWindow::getAllowEscaping() { } void MainWindow::setAllowEscaping(bool allow) { - if (!this->ui) + if (!this->editor || !this->editor->map) return; - this->ui->checkBox_AllowEscaping->setChecked(allow); + this->editor->map->setAllowsEscaping(allow); } int MainWindow::getFloorNumber() { @@ -960,12 +961,8 @@ int MainWindow::getFloorNumber() { } void MainWindow::setFloorNumber(int floorNumber) { - if (!this->ui) + if (!this->editor || !this->editor->map) return; - if (floorNumber < -128 || floorNumber > 127) { - logError(QString("Invalid floor number '%1'").arg(floorNumber)); - return; - } - this->ui->spinBox_FloorNumber->setValue(floorNumber); + this->editor->map->setFloorNumber(floorNumber); } diff --git a/src/ui/mapheaderform.cpp b/src/ui/mapheaderform.cpp new file mode 100644 index 00000000..88d7fbf1 --- /dev/null +++ b/src/ui/mapheaderform.cpp @@ -0,0 +1,220 @@ +#include "mapheaderform.h" + +#define BLOCK_SIGNALS \ + const QSignalBlocker b_Song(ui->comboBox_Song); \ + const QSignalBlocker b_Location(ui->comboBox_Location); \ + const QSignalBlocker b_RequiresFlash(ui->checkBox_RequiresFlash); \ + const QSignalBlocker b_Weather(ui->comboBox_Weather); \ + const QSignalBlocker b_Type(ui->comboBox_Type); \ + const QSignalBlocker b_BattleScene(ui->comboBox_BattleScene); \ + const QSignalBlocker b_ShowLocationName(ui->checkBox_ShowLocationName); \ + const QSignalBlocker b_AllowRunning(ui->checkBox_AllowRunning); \ + const QSignalBlocker b_AllowBiking(ui->checkBox_AllowBiking); \ + const QSignalBlocker b_AllowEscaping(ui->checkBox_AllowEscaping); \ + const QSignalBlocker b_FloorNumber(ui->spinBox_FloorNumber); + + +MapHeaderForm::MapHeaderForm(QWidget *parent) + : QWidget(parent) + , ui(new Ui::MapHeaderForm) +{ + ui->setupUi(this); + + // This value is an s8 by default, but we don't need to unnecessarily limit users. + ui->spinBox_FloorNumber->setMinimum(INT_MIN); + ui->spinBox_FloorNumber->setMaximum(INT_MAX); +} + +MapHeaderForm::~MapHeaderForm() +{ + delete ui; +} + +void MapHeaderForm::setProject(Project * newProject) { + clear(); + + this->project = newProject; + if (!this->project) + return; + + // Populate combo boxes + BLOCK_SIGNALS + ui->comboBox_Song->addItems(this->project->songNames); + ui->comboBox_Weather->addItems(this->project->weatherNames); + ui->comboBox_Type->addItems(this->project->mapTypes); + ui->comboBox_BattleScene->addItems(this->project->mapBattleScenes); + refreshLocationsComboBox(); + + // Hide config-specific settings + + bool hasFlags = projectConfig.mapAllowFlagsEnabled; + ui->checkBox_AllowRunning->setVisible(hasFlags); + ui->checkBox_AllowBiking->setVisible(hasFlags); + ui->checkBox_AllowEscaping->setVisible(hasFlags); + ui->label_AllowRunning->setVisible(hasFlags); + ui->label_AllowBiking->setVisible(hasFlags); + ui->label_AllowEscaping->setVisible(hasFlags); + + bool floorNumEnabled = projectConfig.floorNumberEnabled; + ui->spinBox_FloorNumber->setVisible(floorNumEnabled); + ui->label_FloorNumber->setVisible(floorNumEnabled); +} + +void MapHeaderForm::setMap(Map * newMap) { + this->map = newMap; + if (!this->map) { + clearDisplay(); + return; + } + + BLOCK_SIGNALS + ui->comboBox_Song->setCurrentText(this->map->song()); + ui->comboBox_Location->setCurrentText(this->map->location()); + ui->checkBox_RequiresFlash->setChecked(this->map->requiresFlash()); + ui->comboBox_Weather->setCurrentText(this->map->weather()); + ui->comboBox_Type->setCurrentText(this->map->type()); + ui->comboBox_BattleScene->setCurrentText(this->map->battleScene()); + ui->checkBox_ShowLocationName->setChecked(this->map->showsLocationName()); + ui->checkBox_AllowRunning->setChecked(this->map->allowsRunning()); + ui->checkBox_AllowBiking->setChecked(this->map->allowsBiking()); + ui->checkBox_AllowEscaping->setChecked(this->map->allowsEscaping()); + ui->spinBox_FloorNumber->setValue(this->map->floorNumber()); +} + +void MapHeaderForm::clearDisplay() { + BLOCK_SIGNALS + ui->comboBox_Song->clearEditText(); + ui->comboBox_Location->clearEditText(); + ui->comboBox_Weather->clearEditText(); + ui->comboBox_Type->clearEditText(); + ui->comboBox_BattleScene->clearEditText(); + ui->checkBox_ShowLocationName->setChecked(false); + ui->checkBox_RequiresFlash->setChecked(false); + ui->checkBox_AllowRunning->setChecked(false); + ui->checkBox_AllowBiking->setChecked(false); + ui->checkBox_AllowEscaping->setChecked(false); + ui->spinBox_FloorNumber->setValue(0); +} + +// Clear display and depopulate combo boxes +void MapHeaderForm::clear() { + BLOCK_SIGNALS + ui->comboBox_Song->clear(); + ui->comboBox_Location->clear(); + ui->comboBox_Weather->clear(); + ui->comboBox_Type->clear(); + ui->comboBox_BattleScene->clear(); + ui->checkBox_ShowLocationName->setChecked(false); + ui->checkBox_RequiresFlash->setChecked(false); + ui->checkBox_AllowRunning->setChecked(false); + ui->checkBox_AllowBiking->setChecked(false); + ui->checkBox_AllowEscaping->setChecked(false); + ui->spinBox_FloorNumber->setValue(0); +} + +void MapHeaderForm::refreshLocationsComboBox() { + const QSignalBlocker b(ui->comboBox_Location); + ui->comboBox_Location->clear(); + + if (this->project) { + QStringList locations = this->project->mapSectionIdNames; + locations.sort(); + ui->comboBox_Location->addItems(locations); + } + if (this->map) { + ui->comboBox_Location->setCurrentText(this->map->location()); + } +} + +void MapHeaderForm::on_comboBox_Song_currentTextChanged(const QString &song) +{ + if (this->map) { + this->map->setSong(song); + this->map->modify(); + } +} + +void MapHeaderForm::on_comboBox_Location_currentTextChanged(const QString &location) +{ + if (this->map) { + this->map->setLocation(location); + this->map->modify(); + + // Update cached location name in the project + // TODO: This should be handled elsewhere now, connected to the map change signal + if (this->project) + this->project->mapNameToMapSectionName.insert(this->map->name(), this->map->location()); + } +} + +void MapHeaderForm::on_comboBox_Weather_currentTextChanged(const QString &weather) +{ + if (this->map) { + this->map->setWeather(weather); + this->map->modify(); + } +} + +void MapHeaderForm::on_comboBox_Type_currentTextChanged(const QString &type) +{ + if (this->map) { + this->map->setType(type); + this->map->modify(); + } +} + +void MapHeaderForm::on_comboBox_BattleScene_currentTextChanged(const QString &battleScene) +{ + if (this->map) { + this->map->setBattleScene(battleScene); + this->map->modify(); + } +} + +void MapHeaderForm::on_checkBox_RequiresFlash_stateChanged(int selected) +{ + if (this->map) { + this->map->setRequiresFlash(selected == Qt::Checked); + this->map->modify(); + } +} + +void MapHeaderForm::on_checkBox_ShowLocationName_stateChanged(int selected) +{ + if (this->map) { + this->map->setShowsLocationName(selected == Qt::Checked); + this->map->modify(); + } +} + +void MapHeaderForm::on_checkBox_AllowRunning_stateChanged(int selected) +{ + if (this->map) { + this->map->setAllowsRunning(selected == Qt::Checked); + this->map->modify(); + } +} + +void MapHeaderForm::on_checkBox_AllowBiking_stateChanged(int selected) +{ + if (this->map) { + this->map->setAllowsBiking(selected == Qt::Checked); + this->map->modify(); + } +} + +void MapHeaderForm::on_checkBox_AllowEscaping_stateChanged(int selected) +{ + if (this->map) { + this->map->setAllowsEscaping(selected == Qt::Checked); + this->map->modify(); + } +} + +void MapHeaderForm::on_spinBox_FloorNumber_valueChanged(int offset) +{ + if (this->map) { + this->map->setFloorNumber(offset); + this->map->modify(); + } +} diff --git a/src/ui/newmapdialog.cpp b/src/ui/newmapdialog.cpp index 0d6bdd77..d3096a86 100644 --- a/src/ui/newmapdialog.cpp +++ b/src/ui/newmapdialog.cpp @@ -31,6 +31,9 @@ NewMapDialog::NewMapDialog(QWidget *parent, Project *project) : ui->lineEdit_Name->setValidator(validator); ui->lineEdit_ID->setValidator(validator); + this->headerData = new MapHeaderForm(); + ui->layout_HeaderData->addWidget(this->headerData); + connect(ui->spinBox_MapWidth, QOverload::of(&QSpinBox::valueChanged), [=](int){validateMapDimensions();}); connect(ui->spinBox_MapHeight, QOverload::of(&QSpinBox::valueChanged), [=](int){validateMapDimensions();}); } @@ -46,11 +49,7 @@ void NewMapDialog::init() { ui->comboBox_PrimaryTileset->addItems(project->primaryTilesetLabels); ui->comboBox_SecondaryTileset->addItems(project->secondaryTilesetLabels); ui->comboBox_Group->addItems(project->groupNames); - ui->comboBox_Song->addItems(project->songNames); - ui->comboBox_Location->addItems(project->mapSectionIdNames); - ui->comboBox_Weather->addItems(project->weatherNames); - ui->comboBox_Type->addItems(project->mapTypes); - ui->comboBox_BattleScene->addItems(project->mapBattleScenes); + this->headerData->setProject(project); // Set spin box limits ui->spinBox_MapWidth->setMaximum(project->getMaxMapWidth()); @@ -58,21 +57,8 @@ void NewMapDialog::init() { ui->spinBox_BorderWidth->setMaximum(MAX_BORDER_WIDTH); ui->spinBox_BorderHeight->setMaximum(MAX_BORDER_HEIGHT); - // Hide config specific ui elements - bool hasFlags = projectConfig.mapAllowFlagsEnabled; - ui->checkBox_AllowRunning->setVisible(hasFlags); - ui->checkBox_AllowBiking->setVisible(hasFlags); - ui->checkBox_AllowEscaping->setVisible(hasFlags); - ui->label_AllowRunning->setVisible(hasFlags); - ui->label_AllowBiking->setVisible(hasFlags); - ui->label_AllowEscaping->setVisible(hasFlags); - ui->groupBox_BorderDimensions->setVisible(projectConfig.useCustomBorderSize); - bool hasFloorNumber = projectConfig.floorNumberEnabled; - ui->spinBox_FloorNumber->setVisible(hasFloorNumber); - ui->label_FloorNumber->setVisible(hasFloorNumber); - // Restore previous settings ui->lineEdit_Name->setText(project->getNewMapName()); ui->comboBox_Group->setTextItem(settings.group); @@ -82,17 +68,17 @@ void NewMapDialog::init() { ui->spinBox_BorderHeight->setValue(settings.borderHeight); ui->comboBox_PrimaryTileset->setTextItem(settings.primaryTilesetLabel); ui->comboBox_SecondaryTileset->setTextItem(settings.secondaryTilesetLabel); - ui->comboBox_Song->setTextItem(settings.song); - ui->comboBox_Location->setTextItem(settings.location); - ui->checkBox_RequiresFlash->setChecked(settings.requiresFlash); - ui->comboBox_Weather->setTextItem(settings.weather); - ui->comboBox_Type->setTextItem(settings.type); - ui->comboBox_BattleScene->setTextItem(settings.battleScene); - ui->checkBox_ShowLocation->setChecked(settings.showLocationName); - ui->checkBox_AllowRunning->setChecked(settings.allowRunning); - ui->checkBox_AllowBiking->setChecked(settings.allowBiking); - ui->checkBox_AllowEscaping->setChecked(settings.allowEscaping); - ui->spinBox_FloorNumber->setValue(settings.floorNumber); + this->headerData->ui->comboBox_Song->setTextItem(settings.song); + this->headerData->ui->comboBox_Location->setTextItem(settings.location); + this->headerData->ui->checkBox_RequiresFlash->setChecked(settings.requiresFlash); + this->headerData->ui->comboBox_Weather->setTextItem(settings.weather); + this->headerData->ui->comboBox_Type->setTextItem(settings.type); + this->headerData->ui->comboBox_BattleScene->setTextItem(settings.battleScene); + this->headerData->ui->checkBox_ShowLocationName->setChecked(settings.showLocationName); + this->headerData->ui->checkBox_AllowRunning->setChecked(settings.allowRunning); + this->headerData->ui->checkBox_AllowBiking->setChecked(settings.allowBiking); + this->headerData->ui->checkBox_AllowEscaping->setChecked(settings.allowEscaping); + this->headerData->ui->spinBox_FloorNumber->setValue(settings.floorNumber); ui->checkBox_CanFlyTo->setChecked(settings.canFlyTo); } @@ -164,17 +150,17 @@ void NewMapDialog::saveSettings() { settings.borderHeight = ui->spinBox_BorderHeight->value(); settings.primaryTilesetLabel = ui->comboBox_PrimaryTileset->currentText(); settings.secondaryTilesetLabel = ui->comboBox_SecondaryTileset->currentText(); - settings.song = ui->comboBox_Song->currentText(); - settings.location = ui->comboBox_Location->currentText(); - settings.requiresFlash = ui->checkBox_RequiresFlash->isChecked(); - settings.weather = ui->comboBox_Weather->currentText(); - settings.type = ui->comboBox_Type->currentText(); - settings.battleScene = ui->comboBox_BattleScene->currentText(); - settings.showLocationName = ui->checkBox_ShowLocation->isChecked(); - settings.allowRunning = ui->checkBox_AllowRunning->isChecked(); - settings.allowBiking = ui->checkBox_AllowBiking->isChecked(); - settings.allowEscaping = ui->checkBox_AllowEscaping->isChecked(); - settings.floorNumber = ui->spinBox_FloorNumber->value(); + settings.song = this->headerData->ui->comboBox_Song->currentText(); + settings.location = this->headerData->ui->comboBox_Location->currentText(); + settings.requiresFlash = this->headerData->ui->checkBox_RequiresFlash->isChecked(); + settings.weather = this->headerData->ui->comboBox_Weather->currentText(); + settings.type = this->headerData->ui->comboBox_Type->currentText(); + settings.battleScene = this->headerData->ui->comboBox_BattleScene->currentText(); + settings.showLocationName = this->headerData->ui->checkBox_ShowLocationName->isChecked(); + settings.allowRunning = this->headerData->ui->checkBox_AllowRunning->isChecked(); + settings.allowBiking = this->headerData->ui->checkBox_AllowBiking->isChecked(); + settings.allowEscaping = this->headerData->ui->checkBox_AllowEscaping->isChecked(); + settings.floorNumber = this->headerData->ui->spinBox_FloorNumber->value(); settings.canFlyTo = ui->checkBox_CanFlyTo->isChecked(); } @@ -334,20 +320,20 @@ void NewMapDialog::on_pushButton_Accept_clicked() { Map *newMap = new Map; newMap->setName(ui->lineEdit_Name->text()); newMap->setConstantName(ui->lineEdit_ID->text()); - newMap->setSong(ui->comboBox_Song->currentText()); - newMap->setLocation(ui->comboBox_Location->currentText()); - newMap->setRequiresFlash(ui->checkBox_RequiresFlash->isChecked()); - newMap->setWeather(ui->comboBox_Weather->currentText()); - newMap->setType(ui->comboBox_Type->currentText()); - newMap->setBattleScene(ui->comboBox_BattleScene->currentText()); - newMap->setShowsLocation(ui->checkBox_ShowLocation->isChecked()); + newMap->setSong(this->headerData->ui->comboBox_Song->currentText()); + newMap->setLocation(this->headerData->ui->comboBox_Location->currentText()); + newMap->setRequiresFlash(this->headerData->ui->checkBox_RequiresFlash->isChecked()); + newMap->setWeather(this->headerData->ui->comboBox_Weather->currentText()); + newMap->setType(this->headerData->ui->comboBox_Type->currentText()); + newMap->setBattleScene(this->headerData->ui->comboBox_BattleScene->currentText()); + newMap->setShowsLocationName(this->headerData->ui->checkBox_ShowLocationName->isChecked()); if (projectConfig.mapAllowFlagsEnabled) { - newMap->setAllowsRunning(ui->checkBox_AllowRunning->isChecked()); - newMap->setAllowsBiking(ui->checkBox_AllowBiking->isChecked()); - newMap->setAllowsEscaping(ui->checkBox_AllowEscaping->isChecked()); + newMap->setAllowsRunning(this->headerData->ui->checkBox_AllowRunning->isChecked()); + newMap->setAllowsBiking(this->headerData->ui->checkBox_AllowBiking->isChecked()); + newMap->setAllowsEscaping(this->headerData->ui->checkBox_AllowEscaping->isChecked()); } if (projectConfig.floorNumberEnabled) { - newMap->setFloorNumber(ui->spinBox_FloorNumber->value()); + newMap->setFloorNumber(this->headerData->ui->spinBox_FloorNumber->value()); } newMap->setNeedsHealLocation(ui->checkBox_CanFlyTo->isChecked());