diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index f403f198..39f59836 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -95,11 +95,11 @@ - + - Areas + Locations - + 0 @@ -116,10 +116,10 @@ 0 - + - + 0 @@ -3101,7 +3101,7 @@ Ctrl+T - + true @@ -3110,7 +3110,7 @@ :/icons/sort_alphabet.ico:/icons/sort_alphabet.ico - Sort by &Area + Sort by &Location diff --git a/forms/mapheaderform.ui b/forms/mapheaderform.ui index 06541e2c..8faba290 100644 --- a/forms/mapheaderform.ui +++ b/forms/mapheaderform.ui @@ -57,14 +57,14 @@ - + Requires Flash - + <html><head/><body><p>If checked, the player will need to use Flash to see fully on this map.</p></body></html> @@ -74,14 +74,14 @@ - + Weather - + <html><head/><body><p>The default weather on this map.</p></body></html> @@ -94,14 +94,14 @@ - + 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> @@ -114,14 +114,14 @@ - + 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> @@ -134,14 +134,14 @@ - + 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> @@ -151,14 +151,14 @@ - + Allow Running - + <html><head/><body><p>If checked, the player will be allowed to run on this map.</p></body></html> @@ -168,14 +168,14 @@ - + Allow Biking - + <html><head/><body><p>If checked, the player will be allowed to get on their bike on this map.</p></body></html> @@ -185,14 +185,14 @@ - + 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> @@ -202,20 +202,30 @@ - + Floor Number - + <html><head/><body><p>Floor number to be used for maps with elevators.</p></body></html> + + + + Location Name + + + + + + diff --git a/forms/newlocationdialog.ui b/forms/newlocationdialog.ui new file mode 100644 index 00000000..285e2704 --- /dev/null +++ b/forms/newlocationdialog.ui @@ -0,0 +1,89 @@ + + + NewLocationDialog + + + + 0 + 0 + 252 + 124 + + + + true + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Location ID + + + + + + + true + + + + + + + false + + + color: rgb(255, 0, 0) + + + + + + + + + + + + + Location Name + + + + + + + + + + Qt::Orientation::Horizontal + + + QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok + + + false + + + + + + + + diff --git a/forms/newnamedialog.ui b/forms/newmapgroupdialog.ui similarity index 94% rename from forms/newnamedialog.ui rename to forms/newmapgroupdialog.ui index fa6cb5ae..d475b665 100644 --- a/forms/newnamedialog.ui +++ b/forms/newmapgroupdialog.ui @@ -1,7 +1,7 @@ - NewNameDialog - + NewMapGroupDialog + 0 @@ -32,7 +32,7 @@ - Name + Map Group Name diff --git a/forms/regionmapeditor.ui b/forms/regionmapeditor.ui index 17cff63e..66787b7b 100644 --- a/forms/regionmapeditor.ui +++ b/forms/regionmapeditor.ui @@ -18,10 +18,10 @@ - QFrame::NoFrame + QFrame::Shape::NoFrame - QFrame::Plain + QFrame::Shadow::Plain @@ -46,14 +46,14 @@ - QComboBox::AdjustToContents + QComboBox::SizeAdjustPolicy::AdjustToContents - Qt::Horizontal + Qt::Orientation::Horizontal @@ -83,7 +83,7 @@ - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus 10 @@ -95,10 +95,10 @@ 30 - Qt::Vertical + Qt::Orientation::Vertical - QSlider::NoTicks + QSlider::TickPosition::NoTicks 1 @@ -108,7 +108,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -123,7 +123,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal false @@ -160,7 +160,7 @@ 0 0 466 - 351 + 336 @@ -182,7 +182,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -207,17 +207,17 @@ false - QAbstractScrollArea::AdjustIgnored + QAbstractScrollArea::SizeAdjustPolicy::AdjustIgnored - QGraphicsView::NoDrag + QGraphicsView::DragMode::NoDrag - Qt::Vertical + Qt::Orientation::Vertical @@ -230,7 +230,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -243,7 +243,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -281,7 +281,7 @@ 0 0 466 - 351 + 336 @@ -315,17 +315,17 @@ false - QAbstractScrollArea::AdjustIgnored + QAbstractScrollArea::SizeAdjustPolicy::AdjustIgnored - QGraphicsView::NoDrag + QGraphicsView::DragMode::NoDrag - Qt::Horizontal + Qt::Orientation::Horizontal @@ -338,7 +338,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -351,7 +351,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -364,7 +364,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -402,7 +402,7 @@ 0 0 466 - 351 + 336 @@ -436,17 +436,17 @@ false - QAbstractScrollArea::AdjustIgnored + QAbstractScrollArea::SizeAdjustPolicy::AdjustIgnored - QGraphicsView::NoDrag + QGraphicsView::DragMode::NoDrag - Qt::Horizontal + Qt::Orientation::Horizontal @@ -459,7 +459,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -472,7 +472,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -485,7 +485,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -529,19 +529,19 @@ - Qt::ScrollBarAlwaysOn + Qt::ScrollBarPolicy::ScrollBarAlwaysOn - Qt::ScrollBarAsNeeded + Qt::ScrollBarPolicy::ScrollBarAsNeeded - QAbstractScrollArea::AdjustIgnored + QAbstractScrollArea::SizeAdjustPolicy::AdjustIgnored true - Qt::AlignHCenter|Qt::AlignTop + Qt::AlignmentFlag::AlignHCenter|Qt::AlignmentFlag::AlignTop @@ -552,7 +552,7 @@ 8 0 278 - 342 + 327 @@ -563,7 +563,7 @@ - QLayout::SetDefaultConstraint + QLayout::SizeConstraint::SetDefaultConstraint 0 @@ -583,7 +583,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -596,7 +596,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -618,20 +618,20 @@ - Qt::ScrollBarAlwaysOff + Qt::ScrollBarPolicy::ScrollBarAlwaysOff - Qt::ScrollBarAlwaysOff + Qt::ScrollBarPolicy::ScrollBarAlwaysOff - QAbstractScrollArea::AdjustIgnored + QAbstractScrollArea::SizeAdjustPolicy::AdjustIgnored - Qt::Horizontal + Qt::Orientation::Horizontal @@ -648,10 +648,10 @@ - QFrame::Panel + QFrame::Shape::Panel - QFrame::Sunken + QFrame::Shadow::Sunken @@ -681,7 +681,7 @@ - + 15 @@ -719,10 +719,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised 1 @@ -747,7 +747,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -760,10 +760,10 @@ - QLayout::SetNoConstraint + QLayout::SizeConstraint::SetNoConstraint - + 0 @@ -771,10 +771,10 @@ - <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> + <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 + + false @@ -803,7 +803,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -816,10 +816,10 @@ - + - + @@ -862,10 +862,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised 1 @@ -874,15 +874,15 @@ - QLayout::SetNoConstraint + QLayout::SizeConstraint::SetNoConstraint - + - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -893,10 +893,10 @@ - + - + @@ -909,7 +909,7 @@ - + true @@ -922,25 +922,25 @@ <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 + + false - - + + Dimensions - + - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -951,10 +951,10 @@ - + - + @@ -966,7 +966,7 @@ - + Location @@ -980,16 +980,6 @@ - - - - Map Name - - - - - - @@ -1002,7 +992,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -1037,7 +1027,7 @@ - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus 10 @@ -1049,10 +1039,10 @@ 30 - Qt::Vertical + Qt::Orientation::Vertical - QSlider::NoTicks + QSlider::TickPosition::NoTicks 1 @@ -1062,7 +1052,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -1082,7 +1072,7 @@ 0 0 957 - 22 + 37 @@ -1180,9 +1170,14 @@ NoScrollComboBox - QWidget + QComboBox
noscrollcombobox.h
+ + NoScrollSpinBox + QSpinBox +
noscrollspinbox.h
+
diff --git a/include/core/regionmap.h b/include/core/regionmap.h index 822df79b..18362663 100644 --- a/include/core/regionmap.h +++ b/include/core/regionmap.h @@ -33,7 +33,6 @@ struct LayoutSquare struct MapSectionEntry { - QString name = ""; int x = 0; int y = 0; int width = 1; diff --git a/include/mainwindow.h b/include/mainwindow.h index 20789781..1ee612bc 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -190,6 +190,7 @@ private slots: void onNewMapCreated(Map *newMap, const QString &groupName); void onNewMapGroupCreated(const QString &groupName); void onNewMapSectionCreated(const QString &idName); + void onMapSectionDisplayNameChanged(const QString &idName, const QString &displayName); void onNewLayoutCreated(Layout *layout); void onNewTilesetCreated(Tileset *tileset); void onMapLoaded(Map *map); @@ -311,8 +312,8 @@ private: QPointer groupListProxyModel = nullptr; QPointer mapGroupModel = nullptr; - QPointer areaListProxyModel = nullptr; - QPointer mapAreaModel = nullptr; + QPointer locationListProxyModel = nullptr; + QPointer mapLocationModel = nullptr; QPointer layoutListProxyModel = nullptr; QPointer layoutTreeModel = nullptr; @@ -357,7 +358,7 @@ private: void openNewLayoutDialog(); void openDuplicateLayoutDialog(const QString &layoutId); void openNewMapGroupDialog(); - void openNewAreaDialog(); + void openNewLocationDialog(); void openSubWindow(QWidget * window); void scrollMapList(MapTree *list, const QString &itemName); void scrollMapListToCurrentMap(MapTree *list); @@ -446,7 +447,7 @@ struct MapViewTab { struct MapListTab { enum { - Groups = 0, Areas, Layouts + Groups = 0, Locations, Layouts }; }; diff --git a/include/project.h b/include/project.h index fefa1f34..c29a11b4 100644 --- a/include/project.h +++ b/include/project.h @@ -62,6 +62,7 @@ public: QStringList bgEventFacingDirections; QStringList trainerTypes; QStringList globalScriptLabels; + QStringList mapSectionIdNamesSaveOrder; QStringList mapSectionIdNames; QMap regionMapEntries; QMap> metatileLabelsMap; @@ -79,7 +80,6 @@ public: int pokemonMaxLevel; int maxEncounterRate; bool wildEncountersLoaded; - bool saveEmptyMapsec; void set_root(QString); @@ -156,8 +156,10 @@ public: bool readSpeciesIconPaths(); QMap speciesToIconPath; - void addNewMapsec(const QString &name); - void removeMapsec(const QString &name); + void addNewMapsec(const QString &idName); + void removeMapsec(const QString &idName); + QString getMapsecDisplayName(const QString &idName) const { return this->mapSectionDisplayNames.value(idName); } + void setMapsecDisplayName(const QString &idName, const QString &displayName); bool hasUnsavedChanges(); bool hasUnsavedDataChanges = false; @@ -253,8 +255,13 @@ public: bool calculateDefaultMapSize(); static int getMaxObjectEvents(); static QString getEmptyMapsecName(); + static QString getMapGroupPrefix(); + + static void numericalModeSort(QStringList &list); private: + QMap mapSectionDisplayNames; + void updateLayout(Layout *); void setNewLayoutBlockdata(Layout *layout); @@ -282,6 +289,7 @@ signals: void tilesetCreated(Tileset *newTileset); void mapGroupAdded(const QString &groupName); void mapSectionAdded(const QString &idName); + void mapSectionDisplayNameChanged(const QString &idName, const QString &displayName); void mapSectionIdNamesChanged(const QStringList &idNames); void mapsExcluded(const QStringList &excludedMapNames); }; diff --git a/include/ui/mapheaderform.h b/include/ui/mapheaderform.h index 13e1b67d..8f9adda8 100644 --- a/include/ui/mapheaderform.h +++ b/include/ui/mapheaderform.h @@ -25,7 +25,7 @@ public: explicit MapHeaderForm(QWidget *parent = nullptr); ~MapHeaderForm(); - void init(const Project * project); + void setProject(Project * project, bool allowProjectChanges = true); void clear(); void setHeader(MapHeader *header); @@ -34,6 +34,7 @@ public: void setSong(const QString &song); void setLocation(const QString &location); + void setLocationName(const QString &locationName); void setRequiresFlash(bool requiresFlash); void setWeather(const QString &weather); void setType(const QString &type); @@ -46,6 +47,7 @@ public: QString song() const; QString location() const; + QString locationName() const; bool requiresFlash() const; QString weather() const; QString type() const; @@ -56,14 +58,18 @@ public: bool allowsEscaping() const; int floorNumber() const; - void setLocations(QStringList locations); - private: Ui::MapHeaderForm *ui; QPointer m_header = nullptr; + QPointer m_project = nullptr; + bool m_allowProjectChanges = true; + + void setLocations(const QStringList &locations); + void updateLocationName(); void onSongUpdated(const QString &song); void onLocationChanged(const QString &location); + void onLocationNameChanged(const QString &locationName); void onWeatherChanged(const QString &weather); void onTypeChanged(const QString &type); void onBattleSceneChanged(const QString &battleScene); diff --git a/include/ui/maplistmodels.h b/include/ui/maplistmodels.h index 53a79f4d..b973f438 100644 --- a/include/ui/maplistmodels.h +++ b/include/ui/maplistmodels.h @@ -68,7 +68,8 @@ public: virtual QModelIndex indexOf(const QString &itemName) const; virtual void removeItemAt(const QModelIndex &index); - virtual QStandardItem *getItem(const QModelIndex &index) const; + virtual QStandardItem *itemAt(const QModelIndex &index) const; + virtual QStandardItem *itemAt(const QString &itemName) const; virtual QVariant data(const QModelIndex &index, int role) const override; @@ -124,12 +125,14 @@ signals: -class MapAreaModel : public MapListModel { +class MapLocationModel : public MapListModel { Q_OBJECT public: - MapAreaModel(Project *project, QObject *parent = nullptr); - ~MapAreaModel() {} + MapLocationModel(Project *project, QObject *parent = nullptr); + ~MapLocationModel() {} + + QStandardItem *createMapFolderItem(const QString &folderName, QStandardItem *folder) override; protected: void removeItem(QStandardItem *item) override; diff --git a/include/ui/newlocationdialog.h b/include/ui/newlocationdialog.h new file mode 100644 index 00000000..33af5c9c --- /dev/null +++ b/include/ui/newlocationdialog.h @@ -0,0 +1,34 @@ +#ifndef NEWLOCATIONDIALOG_H +#define NEWLOCATIONDIALOG_H + +#include +#include +#include + +class Project; + +namespace Ui { +class NewLocationDialog; +} + +class NewLocationDialog : public QDialog +{ + Q_OBJECT + +public: + explicit NewLocationDialog(Project *project = nullptr, QWidget *parent = nullptr); + ~NewLocationDialog(); + + virtual void accept() override; + +private: + Ui::NewLocationDialog *ui; + QPointer project = nullptr; + const QString namePrefix; + + bool validateIdName(bool allowEmpty = false); + void onIdNameChanged(const QString &name); + void dialogButtonClicked(QAbstractButton *button); +}; + +#endif // NEWLOCATIONDIALOG_H diff --git a/include/ui/newnamedialog.h b/include/ui/newmapgroupdialog.h similarity index 51% rename from include/ui/newnamedialog.h rename to include/ui/newmapgroupdialog.h index 4abe02df..cbf8aa34 100644 --- a/include/ui/newnamedialog.h +++ b/include/ui/newmapgroupdialog.h @@ -1,5 +1,5 @@ -#ifndef NEWNAMEDIALOG_H -#define NEWNAMEDIALOG_H +#ifndef NEWMAPGROUPDIALOG_H +#define NEWMAPGROUPDIALOG_H /* This is a generic dialog for requesting a new unique name from the user. @@ -11,30 +11,26 @@ class Project; namespace Ui { -class NewNameDialog; +class NewMapGroupDialog; } -class NewNameDialog : public QDialog +class NewMapGroupDialog : public QDialog { Q_OBJECT public: - explicit NewNameDialog(const QString &label, const QString &prefix = "", Project *project = nullptr, QWidget *parent = nullptr); - ~NewNameDialog(); + explicit NewMapGroupDialog(Project *project = nullptr, QWidget *parent = nullptr); + ~NewMapGroupDialog(); virtual void accept() override; -signals: - void applied(const QString &newName); - private: - Ui::NewNameDialog *ui; + Ui::NewMapGroupDialog *ui; Project *project = nullptr; - const QString namePrefix; bool validateName(bool allowEmpty = false); void onNameChanged(const QString &name); void dialogButtonClicked(QAbstractButton *button); }; -#endif // NEWNAMEDIALOG_H +#endif // NEWMAPGROUPDIALOG_H diff --git a/include/ui/regionmapeditor.h b/include/ui/regionmapeditor.h index d5269548..9a838827 100644 --- a/include/ui/regionmapeditor.h +++ b/include/ui/regionmapeditor.h @@ -44,8 +44,6 @@ public: bool reconfigure(); - void setLocations(const QStringList &locations); - QObjectList shortcutableObjects() const; public slots: @@ -118,6 +116,7 @@ private: void displayRegionMapEntryOptions(); void updateRegionMapEntryOptions(QString); void setRegionMap(RegionMap *map); + void setLocations(const QStringList &locations); void restoreWindowState(); void closeEvent(QCloseEvent* event); @@ -135,7 +134,7 @@ private slots: void on_tabWidget_Region_Map_currentChanged(int); void on_pushButton_RM_Options_delete_clicked(); void on_comboBox_RM_ConnectedMap_textActivated(const QString &); - void on_comboBox_RM_Entry_MapSection_textActivated(const QString &); + void on_comboBox_RM_Entry_MapSection_currentTextChanged(const QString &); void on_comboBox_regionSelector_textActivated(const QString &); void on_comboBox_layoutLayer_textActivated(const QString &); void on_spinBox_RM_Entry_x_valueChanged(int); @@ -150,7 +149,6 @@ private slots: void on_checkBox_tileVFlip_stateChanged(int); void on_verticalSlider_Zoom_Map_Image_valueChanged(int); void on_verticalSlider_Zoom_Image_Tiles_valueChanged(int); - void on_lineEdit_RM_MapName_textEdited(const QString &); void onHoveredRegionMapTileChanged(int x, int y); void onHoveredRegionMapTileCleared(); void mouseEvent_region_map(QGraphicsSceneMouseEvent *event, RegionMapPixmapItem *item); diff --git a/porymap.pro b/porymap.pro index f97cd56a..8987b5cc 100644 --- a/porymap.pro +++ b/porymap.pro @@ -104,7 +104,8 @@ SOURCES += src/core/advancemapparser.cpp \ src/ui/neweventtoolbutton.cpp \ src/ui/newlayoutdialog.cpp \ src/ui/newlayoutform.cpp \ - src/ui/newnamedialog.cpp \ + src/ui/newlocationdialog.cpp \ + src/ui/newmapgroupdialog.cpp \ src/ui/noscrollcombobox.cpp \ src/ui/noscrollspinbox.cpp \ src/ui/montabwidget.cpp \ @@ -212,7 +213,8 @@ HEADERS += include/core/advancemapparser.h \ include/ui/neweventtoolbutton.h \ include/ui/newlayoutdialog.h \ include/ui/newlayoutform.h \ - include/ui/newnamedialog.h \ + include/ui/newlocationdialog.h \ + include/ui/newmapgroupdialog.h \ include/ui/noscrollcombobox.h \ include/ui/noscrollspinbox.h \ include/ui/montabwidget.h \ @@ -259,8 +261,9 @@ FORMS += forms/mainwindow.ui \ forms/maplisttoolbar.ui \ forms/newlayoutdialog.ui \ forms/newlayoutform.ui \ - forms/newnamedialog.ui \ + forms/newlocationdialog.ui \ forms/newmapconnectiondialog.ui \ + forms/newmapgroupdialog.ui \ forms/prefabcreationdialog.ui \ forms/prefabframe.ui \ forms/tileseteditor.ui \ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 086f114e..fbd7e409 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -25,7 +25,8 @@ #include "filedialog.h" #include "newmapdialog.h" #include "newtilesetdialog.h" -#include "newnamedialog.h" +#include "newmapgroupdialog.h" +#include "newlocationdialog.h" #include "message.h" #include @@ -425,32 +426,32 @@ void MainWindow::initMapList() { // Connect tool bars to lists ui->mapListToolBar_Groups->setList(ui->mapList); - ui->mapListToolBar_Areas->setList(ui->areaList); + ui->mapListToolBar_Locations->setList(ui->locationList); ui->mapListToolBar_Layouts->setList(ui->layoutList); // Left-clicking on items in the map list opens the corresponding map/layout. - connect(ui->mapList, &QAbstractItemView::activated, this, &MainWindow::openMapListItem); - connect(ui->areaList, &QAbstractItemView::activated, this, &MainWindow::openMapListItem); - connect(ui->layoutList, &QAbstractItemView::activated, this, &MainWindow::openMapListItem); + connect(ui->mapList, &QAbstractItemView::activated, this, &MainWindow::openMapListItem); + connect(ui->locationList, &QAbstractItemView::activated, this, &MainWindow::openMapListItem); + connect(ui->layoutList, &QAbstractItemView::activated, this, &MainWindow::openMapListItem); // Right-clicking on items in the map list brings up a context menu. - connect(ui->mapList, &QTreeView::customContextMenuRequested, this, &MainWindow::onOpenMapListContextMenu); - connect(ui->areaList, &QTreeView::customContextMenuRequested, this, &MainWindow::onOpenMapListContextMenu); - connect(ui->layoutList, &QTreeView::customContextMenuRequested, this, &MainWindow::onOpenMapListContextMenu); + connect(ui->mapList, &QTreeView::customContextMenuRequested, this, &MainWindow::onOpenMapListContextMenu); + connect(ui->locationList, &QTreeView::customContextMenuRequested, this, &MainWindow::onOpenMapListContextMenu); + connect(ui->layoutList, &QTreeView::customContextMenuRequested, this, &MainWindow::onOpenMapListContextMenu); // Only the groups list allows reorganizing folder contents, editing folder names, etc. - ui->mapListToolBar_Areas->setEditsAllowedButtonVisible(false); + ui->mapListToolBar_Locations->setEditsAllowedButtonVisible(false); ui->mapListToolBar_Layouts->setEditsAllowedButtonVisible(false); // When map list search filter is cleared we want the current map/layout in the editor to be visible in the list. - connect(ui->mapListToolBar_Groups, &MapListToolBar::filterCleared, this, &MainWindow::scrollMapListToCurrentMap); - connect(ui->mapListToolBar_Areas, &MapListToolBar::filterCleared, this, &MainWindow::scrollMapListToCurrentMap); - connect(ui->mapListToolBar_Layouts, &MapListToolBar::filterCleared, this, &MainWindow::scrollMapListToCurrentLayout); + connect(ui->mapListToolBar_Groups, &MapListToolBar::filterCleared, this, &MainWindow::scrollMapListToCurrentMap); + connect(ui->mapListToolBar_Locations, &MapListToolBar::filterCleared, this, &MainWindow::scrollMapListToCurrentMap); + connect(ui->mapListToolBar_Layouts, &MapListToolBar::filterCleared, this, &MainWindow::scrollMapListToCurrentLayout); // Connect the "add folder" button in each of the map lists - connect(ui->mapListToolBar_Groups, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewMapGroupDialog); - connect(ui->mapListToolBar_Areas, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewAreaDialog); - connect(ui->mapListToolBar_Layouts, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewLayoutDialog); + connect(ui->mapListToolBar_Groups, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewMapGroupDialog); + connect(ui->mapListToolBar_Locations, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewLocationDialog); + connect(ui->mapListToolBar_Layouts, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewLayoutDialog); connect(ui->mapListContainer, &QTabWidget::currentChanged, this, &MainWindow::saveMapListTab); } @@ -628,7 +629,7 @@ bool MainWindow::openProject(QString dir, bool initial) { connect(project, &Project::tilesetCreated, this, &MainWindow::onNewTilesetCreated); connect(project, &Project::mapGroupAdded, this, &MainWindow::onNewMapGroupCreated); connect(project, &Project::mapSectionAdded, this, &MainWindow::onNewMapSectionCreated); - connect(project, &Project::mapSectionIdNamesChanged, this, &MainWindow::setLocationComboBoxes); + connect(project, &Project::mapSectionDisplayNameChanged, this, &MainWindow::onMapSectionDisplayNameChanged); connect(project, &Project::mapsExcluded, this, &MainWindow::showMapsExcludedAlert); this->editor->setProject(project); @@ -1058,7 +1059,7 @@ void MainWindow::on_comboBox_LayoutSelector_currentTextChanged(const QString &te bool MainWindow::setProjectUI() { Project *project = editor->project; - this->mapHeaderForm->init(project); + this->mapHeaderForm->setProject(project); // Set up project comboboxes const QSignalBlocker b_PrimaryTileset(ui->comboBox_PrimaryTileset); @@ -1108,10 +1109,10 @@ bool MainWindow::setProjectUI() { this->ui->mapList->setItemDelegateForColumn(0, new GroupNameDelegate(this->editor->project, this)); connect(this->mapGroupModel, &MapGroupModel::dragMoveCompleted, this->ui->mapList, &MapTree::removeSelected); - this->mapAreaModel = new MapAreaModel(editor->project); - this->areaListProxyModel = new FilterChildrenProxyModel(); - areaListProxyModel->setSourceModel(this->mapAreaModel); - ui->areaList->setModel(areaListProxyModel); + this->mapLocationModel = new MapLocationModel(editor->project); + this->locationListProxyModel = new FilterChildrenProxyModel(); + locationListProxyModel->setSourceModel(this->mapLocationModel); + ui->locationList->setModel(locationListProxyModel); this->layoutTreeModel = new LayoutTreeModel(editor->project); this->layoutListProxyModel = new FilterChildrenProxyModel(); @@ -1143,8 +1144,8 @@ void MainWindow::clearProjectUI() { // Clear map models delete this->mapGroupModel; delete this->groupListProxyModel; - delete this->mapAreaModel; - delete this->areaListProxyModel; + delete this->mapLocationModel; + delete this->locationListProxyModel; delete this->layoutTreeModel; delete this->layoutListProxyModel; resetMapListFilters(); @@ -1197,14 +1198,14 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point) { QAction* addToFolderAction = nullptr; QAction* deleteFolderAction = nullptr; QAction* openItemAction = nullptr; - QAction* copyDisplayNameAction = nullptr; + QAction* copyListNameAction = nullptr; QAction* copyToolTipAction = nullptr; if (itemType == "map_name") { // Right-clicking on a map. openItemAction = menu.addAction("Open Map"); menu.addSeparator(); - copyDisplayNameAction = menu.addAction("Copy Map Name"); + copyListNameAction = menu.addAction("Copy Map Name"); copyToolTipAction = menu.addAction("Copy Map ID"); menu.addSeparator(); connect(menu.addAction("Duplicate Map"), &QAction::triggered, [this, itemName] { @@ -1219,18 +1220,19 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point) { deleteFolderAction = menu.addAction("Delete Map Group"); } else if (itemType == "map_section") { // Right-clicking on a MAPSEC folder - addToFolderAction = menu.addAction("Add New Map to Area"); + addToFolderAction = menu.addAction("Add New Map to Location"); menu.addSeparator(); - copyDisplayNameAction = menu.addAction("Copy Area Name"); + copyListNameAction = menu.addAction("Copy Location ID Name"); + copyToolTipAction = menu.addAction("Copy Location In-Game Name"); menu.addSeparator(); - deleteFolderAction = menu.addAction("Delete Area"); + deleteFolderAction = menu.addAction("Delete Location"); if (itemName == this->editor->project->getEmptyMapsecName()) deleteFolderAction->setEnabled(false); // Disallow deleting the default name } else if (itemType == "map_layout") { // Right-clicking on a map layout openItemAction = menu.addAction("Open Layout"); menu.addSeparator(); - copyDisplayNameAction = menu.addAction("Copy Layout Name"); + copyListNameAction = menu.addAction("Copy Layout Name"); copyToolTipAction = menu.addAction("Copy Layout ID"); menu.addSeparator(); connect(menu.addAction("Duplicate Layout"), &QAction::triggered, [this, itemName] { @@ -1263,8 +1265,8 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point) { openMapListItem(index); }); } - if (copyDisplayNameAction) { - connect(copyDisplayNameAction, &QAction::triggered, [this, selectedItem] { + if (copyListNameAction) { + connect(copyListNameAction, &QAction::triggered, [this, selectedItem] { setClipboardData(selectedItem->text()); }); } @@ -1278,18 +1280,6 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point) { menu.exec(QCursor::pos()); } -void MainWindow::openNewMapGroupDialog() { - auto dialog = new NewNameDialog("New Group Name", "", this->editor->project, this); - connect(dialog, &NewNameDialog::applied, this->editor->project, &Project::addNewMapGroup); - dialog->open(); -} - -void MainWindow::openNewAreaDialog() { - auto dialog = new NewNameDialog("New Area Name", projectConfig.getIdentifier(ProjectIdentifier::define_map_section_prefix), this->editor->project, this); - connect(dialog, &NewNameDialog::applied, this->editor->project, &Project::addNewMapsec); - dialog->open(); -} - void MainWindow::onNewMapCreated(Map *newMap, const QString &groupName) { logInfo(QString("Created a new map named %1.").arg(newMap->name())); @@ -1301,7 +1291,7 @@ void MainWindow::onNewMapCreated(Map *newMap, const QString &groupName) { // Add new map to the map lists this->mapGroupModel->insertMapItem(newMap->name(), groupName); - this->mapAreaModel->insertMapItem(newMap->name(), newMap->header()->location()); + this->mapLocationModel->insertMapItem(newMap->name(), newMap->header()->location()); this->layoutTreeModel->insertMapItem(newMap->name(), newMap->layout()->id); // Refresh any combo box that displays map names and persists between maps @@ -1344,14 +1334,14 @@ void MainWindow::onNewMapGroupCreated(const QString &groupName) { } void MainWindow::onNewMapSectionCreated(const QString &idName) { - // Add new map section to the Areas map list view - this->mapAreaModel->insertMapFolderItem(idName); + // Add new map section to the Locations map list view + this->mapLocationModel->insertMapFolderItem(idName); } -void MainWindow::setLocationComboBoxes(const QStringList &locations) { - this->mapHeaderForm->setLocations(locations); - if (this->regionMapEditor) - this->regionMapEditor->setLocations(locations); +void MainWindow::onMapSectionDisplayNameChanged(const QString &idName, const QString &displayName) { + // Update the tool tip in the map list that shows the MAPSEC's in-game name. + QStandardItem *item = this->mapLocationModel->itemAt(idName); + if (item) item->setToolTip(displayName); } void MainWindow::onNewTilesetCreated(Tileset *tileset) { @@ -1371,6 +1361,16 @@ void MainWindow::onNewTilesetCreated(Tileset *tileset) { } } +void MainWindow::openNewMapGroupDialog() { + auto dialog = new NewMapGroupDialog(this->editor->project, this); + dialog->open(); +} + +void MainWindow::openNewLocationDialog() { + auto dialog = new NewLocationDialog(this->editor->project, this); + dialog->open(); +} + void MainWindow::openNewMapDialog() { auto dialog = new NewMapDialog(this->editor->project, this); dialog->open(); @@ -1505,7 +1505,7 @@ void MainWindow::updateMapList() { activeItemName = this->editor->map->name(); } else { ui->mapList->clearSelection(); - ui->areaList->clearSelection(); + ui->locationList->clearSelection(); if (this->editor->layout) { activeItemName = this->editor->layout->id; @@ -1515,11 +1515,11 @@ void MainWindow::updateMapList() { } this->mapGroupModel->setActiveItem(activeItemName); - this->mapAreaModel->setActiveItem(activeItemName); + this->mapLocationModel->setActiveItem(activeItemName); this->layoutTreeModel->setActiveItem(activeItemName); this->groupListProxyModel->layoutChanged(); - this->areaListProxyModel->layoutChanged(); + this->locationListProxyModel->layoutChanged(); this->layoutListProxyModel->layoutChanged(); } @@ -1813,6 +1813,7 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index) clickToolButtonFromEditAction(editor->objectEditAction); } else if (index == MainTab::Connections) { editor->setEditingConnections(); + ui->graphicsView_Connections->setFocus(); // Avoid opening tab with focus on something editable } else if (index == MainTab::WildPokemon) { editor->setEditingEncounters(); } @@ -2706,9 +2707,9 @@ void MainWindow::initTilesetEditor() { MapListToolBar* MainWindow::getCurrentMapListToolBar() { switch (ui->mapListContainer->currentIndex()) { - case MapListTab::Groups: return ui->mapListToolBar_Groups; - case MapListTab::Areas: return ui->mapListToolBar_Areas; - case MapListTab::Layouts: return ui->mapListToolBar_Layouts; + case MapListTab::Groups: return ui->mapListToolBar_Groups; + case MapListTab::Locations: return ui->mapListToolBar_Locations; + case MapListTab::Layouts: return ui->mapListToolBar_Layouts; default: return nullptr; } } @@ -2724,7 +2725,7 @@ MapTree* MainWindow::getCurrentMapList() { // When the search filter is cleared the map lists will (if possible) display the currently-selected map/layout. void MainWindow::resetMapListFilters() { ui->mapListToolBar_Groups->clearFilter(); - ui->mapListToolBar_Areas->clearFilter(); + ui->mapListToolBar_Locations->clearFilter(); ui->mapListToolBar_Layouts->clearFilter(); } diff --git a/src/project.cpp b/src/project.cpp index 83fb39c8..9fff8710 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -727,16 +727,16 @@ void Project::saveRegionMapSections() { const QString emptyMapsecName = getEmptyMapsecName(); OrderedJson::array mapSectionArray; - for (const auto &idName : this->mapSectionIdNames) { - if (!this->saveEmptyMapsec && idName == emptyMapsecName) - continue; - + for (const auto &idName : this->mapSectionIdNamesSaveOrder) { OrderedJson::object mapSectionObj; mapSectionObj["id"] = idName; + if (this->mapSectionDisplayNames.contains(idName)) { + mapSectionObj["name"] = this->mapSectionDisplayNames.value(idName); + } + if (this->regionMapEntries.contains(idName)) { MapSectionEntry entry = this->regionMapEntries.value(idName); - mapSectionObj["name"] = entry.name; mapSectionObj["x"] = entry.x; mapSectionObj["y"] = entry.y; mapSectionObj["width"] = entry.width; @@ -2129,8 +2129,8 @@ bool Project::readTilesetLabels() { } } - this->primaryTilesetLabels.sort(); - this->secondaryTilesetLabels.sort(); + numericalModeSort(this->primaryTilesetLabels); + numericalModeSort(this->secondaryTilesetLabels); bool success = true; if (this->secondaryTilesetLabels.isEmpty()) { @@ -2332,8 +2332,9 @@ bool Project::readFieldmapMasks() { bool Project::readRegionMapSections() { this->mapSectionIdNames.clear(); + this->mapSectionIdNamesSaveOrder.clear(); + this->mapSectionDisplayNames.clear(); this->regionMapEntries.clear(); - this->saveEmptyMapsec = false; const QString defaultName = getEmptyMapsecName(); const QString requiredPrefix = projectConfig.getIdentifier(ProjectIdentifier::define_map_section_prefix); @@ -2371,17 +2372,15 @@ bool Project::readRegionMapSections() { } this->mapSectionIdNames.append(idName); - if (idName == defaultName) { - // The default map section (MAPSEC_NONE) isn't normally present in the region map sections data file. - // We append this name to mapSectionIdNames ourselves if it isn't present. - // We need to record whether we found it in the data file, so that we can preserve the data when we save the file later. - this->saveEmptyMapsec = true; - } + this->mapSectionIdNamesSaveOrder.append(idName); + + if (mapSectionObj.contains("name")) + this->mapSectionDisplayNames.insert(idName, ParseUtil::jsonToQString(mapSectionObj["name"])); // Map sections may have additional data indicating their position on the region map. // If they have this data, we can add them to the region map entry list. bool hasRegionMapData = true; - static const QSet regionMapFieldNames = { "name", "x", "y", "width", "height" }; + static const QSet regionMapFieldNames = { "x", "y", "width", "height" }; for (auto fieldName : regionMapFieldNames) { if (!mapSectionObj.contains(fieldName)) { hasRegionMapData = false; @@ -2392,7 +2391,6 @@ bool Project::readRegionMapSections() { continue; MapSectionEntry entry; - entry.name = ParseUtil::jsonToQString(mapSectionObj["name"]); entry.x = ParseUtil::jsonToInt(mapSectionObj["x"]); entry.y = ParseUtil::jsonToInt(mapSectionObj["y"]); entry.width = ParseUtil::jsonToInt(mapSectionObj["width"]); @@ -2405,6 +2403,7 @@ bool Project::readRegionMapSections() { if (!this->mapSectionIdNames.contains(defaultName)) { this->mapSectionIdNames.append(defaultName); } + numericalModeSort(this->mapSectionIdNames); return true; } @@ -2413,29 +2412,47 @@ QString Project::getEmptyMapsecName() { return projectConfig.getIdentifier(ProjectIdentifier::define_map_section_prefix) + projectConfig.getIdentifier(ProjectIdentifier::define_map_section_empty); } +QString Project::getMapGroupPrefix() { + // We could expose this to users, but it's never enforced so it probably won't affect anyone. + return QStringLiteral("gMapGroup_"); +} + // This function assumes a valid and unique name -void Project::addNewMapsec(const QString &name) { - if (this->mapSectionIdNames.last() == getEmptyMapsecName()) { +void Project::addNewMapsec(const QString &idName) { + if (this->mapSectionIdNamesSaveOrder.last() == getEmptyMapsecName()) { // If the default map section name (MAPSEC_NONE) is last in the list we'll keep it last in the list. - this->mapSectionIdNames.insert(this->mapSectionIdNames.length() - 1, name); + this->mapSectionIdNamesSaveOrder.insert(this->mapSectionIdNames.length() - 1, idName); } else { - this->mapSectionIdNames.append(name); + this->mapSectionIdNamesSaveOrder.append(idName); } + + this->mapSectionIdNames.append(idName); + numericalModeSort(this->mapSectionIdNames); + this->hasUnsavedDataChanges = true; - emit mapSectionAdded(name); + emit mapSectionAdded(idName); emit mapSectionIdNamesChanged(this->mapSectionIdNames); } -void Project::removeMapsec(const QString &name) { - if (!this->mapSectionIdNames.contains(name) || name == getEmptyMapsecName()) +void Project::removeMapsec(const QString &idName) { + if (!this->mapSectionIdNames.contains(idName) || idName == getEmptyMapsecName()) return; - this->mapSectionIdNames.removeOne(name); + this->mapSectionIdNames.removeOne(idName); + this->mapSectionIdNamesSaveOrder.removeOne(idName); this->hasUnsavedDataChanges = true; emit mapSectionIdNamesChanged(this->mapSectionIdNames); } +void Project::setMapsecDisplayName(const QString &idName, const QString &displayName) { + if (this->mapSectionDisplayNames[idName] == displayName) + return; + this->mapSectionDisplayNames[idName] = displayName; + this->hasUnsavedDataChanges = true; + emit mapSectionDisplayNameChanged(idName, displayName); +} + // Read the constants to preserve any "unused" heal locations when writing the file later bool Project::readHealLocationConstants() { this->healLocationNameToValue.clear(); @@ -2704,7 +2721,7 @@ bool Project::readSongNames() { // Song names don't have a very useful order (esp. if we include SE_* values), so sort them alphabetically. // The default song should be the first in the list, not the first alphabetically, so save that before sorting. this->defaultSong = this->songNames.value(0, "0"); - this->songNames.sort(); + numericalModeSort(this->songNames); return true; } @@ -3139,3 +3156,14 @@ bool Project::hasUnsavedChanges() { } return false; } + +// TODO: This belongs in a more general utility file, once we have one. +// Sometimes we want to sort names alphabetically to make them easier to find in large combo box lists. +// QStringList::sort (as of writing) can only sort numbers in lexical order, which has an undesirable +// effect (e.g. MAPSEC_ROUTE_10 comes after MAPSEC_ROUTE_1, rather than MAPSEC_ROUTE_9). +// We can use QCollator to sort these lists with better handling for numbers. +void Project::numericalModeSort(QStringList &list) { + QCollator collator; + collator.setNumericMode(true); + std::sort(list.begin(), list.end(), collator); +} diff --git a/src/ui/mapheaderform.cpp b/src/ui/mapheaderform.cpp index 4bea0bef..09cb22c7 100644 --- a/src/ui/mapheaderform.cpp +++ b/src/ui/mapheaderform.cpp @@ -12,18 +12,24 @@ MapHeaderForm::MapHeaderForm(QWidget *parent) ui->spinBox_FloorNumber->setMinimum(INT_MIN); ui->spinBox_FloorNumber->setMaximum(INT_MAX); - // When the UI is updated, sync those changes to the tracked MapHeader (if there is one) + // The layout for this UI keeps fields at their size hint, which is a little short for the line edit. + ui->lineEdit_LocationName->setMinimumWidth(ui->comboBox_Location->sizeHint().width()); + connect(ui->comboBox_Song, &QComboBox::currentTextChanged, this, &MapHeaderForm::onSongUpdated); connect(ui->comboBox_Location, &QComboBox::currentTextChanged, this, &MapHeaderForm::onLocationChanged); connect(ui->comboBox_Weather, &QComboBox::currentTextChanged, this, &MapHeaderForm::onWeatherChanged); connect(ui->comboBox_Type, &QComboBox::currentTextChanged, this, &MapHeaderForm::onTypeChanged); connect(ui->comboBox_BattleScene, &QComboBox::currentTextChanged, this, &MapHeaderForm::onBattleSceneChanged); + connect(ui->checkBox_RequiresFlash, &QCheckBox::stateChanged, this, &MapHeaderForm::onRequiresFlashChanged); connect(ui->checkBox_ShowLocationName, &QCheckBox::stateChanged, this, &MapHeaderForm::onShowLocationNameChanged); connect(ui->checkBox_AllowRunning, &QCheckBox::stateChanged, this, &MapHeaderForm::onAllowRunningChanged); connect(ui->checkBox_AllowBiking, &QCheckBox::stateChanged, this, &MapHeaderForm::onAllowBikingChanged); connect(ui->checkBox_AllowEscaping, &QCheckBox::stateChanged, this, &MapHeaderForm::onAllowEscapingChanged); + connect(ui->spinBox_FloorNumber, QOverload::of(&QSpinBox::valueChanged), this, &MapHeaderForm::onFloorNumberChanged); + + connect(ui->lineEdit_LocationName, &QLineEdit::textChanged, this, &MapHeaderForm::onLocationNameChanged); } MapHeaderForm::~MapHeaderForm() @@ -31,35 +37,39 @@ MapHeaderForm::~MapHeaderForm() delete ui; } -void MapHeaderForm::init(const Project * project) { +void MapHeaderForm::setProject(Project * project, bool allowChanges) { clear(); - if (!project) + if (m_project) { + m_project->disconnect(this); + } + m_project = project; + m_allowProjectChanges = allowChanges; + + if (!m_project) return; // Populate combo boxes const QSignalBlocker b_Song(ui->comboBox_Song); ui->comboBox_Song->clear(); - ui->comboBox_Song->addItems(project->songNames); + ui->comboBox_Song->addItems(m_project->songNames); const QSignalBlocker b_Weather(ui->comboBox_Weather); ui->comboBox_Weather->clear(); - ui->comboBox_Weather->addItems(project->weatherNames); + ui->comboBox_Weather->addItems(m_project->weatherNames); const QSignalBlocker b_Type(ui->comboBox_Type); ui->comboBox_Type->clear(); - ui->comboBox_Type->addItems(project->mapTypes); + ui->comboBox_Type->addItems(m_project->mapTypes); const QSignalBlocker b_BattleScene(ui->comboBox_BattleScene); ui->comboBox_BattleScene->clear(); - ui->comboBox_BattleScene->addItems(project->mapBattleScenes); + ui->comboBox_BattleScene->addItems(m_project->mapBattleScenes); - QStringList locations = project->mapSectionIdNames; - locations.sort(); const QSignalBlocker b_Locations(ui->comboBox_Location); ui->comboBox_Location->clear(); - ui->comboBox_Location->addItems(locations); + ui->comboBox_Location->addItems(m_project->mapSectionIdNames); // Hide config-specific settings @@ -74,12 +84,13 @@ void MapHeaderForm::init(const Project * project) { bool floorNumEnabled = projectConfig.floorNumberEnabled; ui->spinBox_FloorNumber->setVisible(floorNumEnabled); ui->label_FloorNumber->setVisible(floorNumEnabled); + + // If the project changes any of the displayed data, update it accordingly. + connect(m_project, &Project::mapSectionIdNamesChanged, this, &MapHeaderForm::setLocations); + connect(m_project, &Project::mapSectionDisplayNameChanged, this, &MapHeaderForm::updateLocationName); } -// Unlike other combo boxes in the map header form, locations can be added or removed externally. -void MapHeaderForm::setLocations(QStringList locations) { - locations.sort(); - +void MapHeaderForm::setLocations(const QStringList &locations) { const QSignalBlocker b(ui->comboBox_Location); const QString before = ui->comboBox_Location->currentText(); ui->comboBox_Location->clear(); @@ -136,6 +147,7 @@ void MapHeaderForm::setHeaderData(const MapHeader &header) { setAllowsBiking(header.allowsBiking()); setAllowsEscaping(header.allowsEscaping()); setFloorNumber(header.floorNumber()); + updateLocationName(); } MapHeader MapHeaderForm::headerData() const { @@ -158,9 +170,14 @@ MapHeader MapHeaderForm::headerData() const { return header; } +void MapHeaderForm::updateLocationName() { + setLocationName(m_project ? m_project->getMapsecDisplayName(location()) : QString()); +} + // Set data in UI void MapHeaderForm::setSong(const QString &song) { ui->comboBox_Song->setCurrentText(song); } void MapHeaderForm::setLocation(const QString &location) { ui->comboBox_Location->setCurrentText(location); } +void MapHeaderForm::setLocationName(const QString &locationName) { ui->lineEdit_LocationName->setText(locationName); } void MapHeaderForm::setRequiresFlash(bool requiresFlash) { ui->checkBox_RequiresFlash->setChecked(requiresFlash); } void MapHeaderForm::setWeather(const QString &weather) { ui->comboBox_Weather->setCurrentText(weather); } void MapHeaderForm::setType(const QString &type) { ui->comboBox_Type->setCurrentText(type); } @@ -174,6 +191,7 @@ void MapHeaderForm::setFloorNumber(int floorNumber) { ui->spinBox_F // Read data from UI QString MapHeaderForm::song() const { return ui->comboBox_Song->currentText(); } QString MapHeaderForm::location() const { return ui->comboBox_Location->currentText(); } +QString MapHeaderForm::locationName() const { return ui->lineEdit_LocationName->text(); } bool MapHeaderForm::requiresFlash() const { return ui->checkBox_RequiresFlash->isChecked(); } QString MapHeaderForm::weather() const { return ui->comboBox_Weather->currentText(); } QString MapHeaderForm::type() const { return ui->comboBox_Type->currentText(); } @@ -186,7 +204,6 @@ int MapHeaderForm::floorNumber() const { return ui->spinBox_FloorNumber-> // Send changes in UI to tracked MapHeader (if there is one) void MapHeaderForm::onSongUpdated(const QString &song) { if (m_header) m_header->setSong(song); } -void MapHeaderForm::onLocationChanged(const QString &location) { if (m_header) m_header->setLocation(location); } void MapHeaderForm::onWeatherChanged(const QString &weather) { if (m_header) m_header->setWeather(weather); } void MapHeaderForm::onTypeChanged(const QString &type) { if (m_header) m_header->setType(type); } void MapHeaderForm::onBattleSceneChanged(const QString &battleScene) { if (m_header) m_header->setBattleScene(battleScene); } @@ -196,3 +213,14 @@ void MapHeaderForm::onAllowRunningChanged(int selected) { if (m_hea void MapHeaderForm::onAllowBikingChanged(int selected) { if (m_header) m_header->setAllowsBiking(selected == Qt::Checked); } void MapHeaderForm::onAllowEscapingChanged(int selected) { if (m_header) m_header->setAllowsEscaping(selected == Qt::Checked); } void MapHeaderForm::onFloorNumberChanged(int offset) { if (m_header) m_header->setFloorNumber(offset); } +void MapHeaderForm::onLocationChanged(const QString &location) { + if (m_header) m_header->setLocation(location); + updateLocationName(); +} +void MapHeaderForm::onLocationNameChanged(const QString &locationName) { + if (m_project && m_allowProjectChanges) { + // The location name is actually part of the project, not the map header. + // If the field is changed in the UI we can push these changes to the project. + m_project->setMapsecDisplayName(location(), locationName); + } +} diff --git a/src/ui/maplistmodels.cpp b/src/ui/maplistmodels.cpp index a46dfc58..e74d0a93 100644 --- a/src/ui/maplistmodels.cpp +++ b/src/ui/maplistmodels.cpp @@ -56,7 +56,7 @@ MapListModel::MapListModel(Project *project, QObject *parent) : QStandardItemMod this->emptyMapFolderIcon.addFile(QStringLiteral(":/icons/folder.ico"), QSize(), QIcon::Normal, QIcon::On); } -QStandardItem *MapListModel::getItem(const QModelIndex &index) const { +QStandardItem *MapListModel::itemAt(const QModelIndex &index) const { if (index.isValid()) { QStandardItem *item = static_cast(index.internalPointer()); if (item) @@ -65,6 +65,13 @@ QStandardItem *MapListModel::getItem(const QModelIndex &index) const { return this->root; } +QStandardItem *MapListModel::itemAt(const QString &itemName) const { + QModelIndex index = this->indexOf(itemName); + if (!index.isValid()) + return nullptr; + return this->itemAt(index)->child(index.row(), index.column()); +} + QModelIndex MapListModel::indexOf(const QString &itemName) const { if (this->mapItems.contains(itemName)) return this->mapItems.value(itemName)->index(); @@ -76,7 +83,7 @@ QModelIndex MapListModel::indexOf(const QString &itemName) const { } void MapListModel::removeItemAt(const QModelIndex &index) { - QStandardItem *item = this->getItem(index)->child(index.row(), index.column()); + QStandardItem *item = this->itemAt(index)->child(index.row(), index.column()); if (!item) return; @@ -153,7 +160,7 @@ QVariant MapListModel::data(const QModelIndex &index, int role) const { int row = index.row(); int col = index.column(); - const QStandardItem *item = this->getItem(index)->child(row, col); + const QStandardItem *item = this->itemAt(index)->child(row, col); const QString type = item->data(MapListUserRoles::TypeRole).toString(); const QString name = item->data(MapListUserRoles::NameRole).toString(); @@ -179,7 +186,7 @@ QVariant MapListModel::data(const QModelIndex &index, int role) const { QWidget *GroupNameDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const { QLineEdit *editor = new QLineEdit(parent); - editor->setPlaceholderText("gMapGroup_"); + editor->setPlaceholderText(Project::getMapGroupPrefix()); editor->setValidator(new IdentifierValidator(parent)); editor->setFrame(false); return editor; @@ -388,13 +395,13 @@ QVariant MapGroupModel::data(const QModelIndex &index, int role) const { int row = index.row(); int col = index.column(); - const QStandardItem *item = this->getItem(index)->child(row, col); + const QStandardItem *item = this->itemAt(index)->child(row, col); const QString type = item->data(MapListUserRoles::TypeRole).toString(); const QString name = item->data(MapListUserRoles::NameRole).toString(); if (role == Qt::DisplayRole) { if (type == "map_name") { - return QString("[%1.%2] ").arg(this->getItem(index)->row()).arg(row, 2, 10, QLatin1Char('0')) + name; + return QString("[%1.%2] ").arg(this->itemAt(index)->row()).arg(row, 2, 10, QLatin1Char('0')) + name; } else if (type == this->folderTypeName) { return name; @@ -417,7 +424,7 @@ bool MapGroupModel::setData(const QModelIndex &index, const QVariant &value, int -MapAreaModel::MapAreaModel(Project *project, QObject *parent) : MapListModel(project, parent) { +MapLocationModel::MapLocationModel(Project *project, QObject *parent) : MapListModel(project, parent) { this->folderTypeName = "map_section"; for (const auto &idName : this->project->mapSectionIdNames) { @@ -431,11 +438,17 @@ MapAreaModel::MapAreaModel(Project *project, QObject *parent) : MapListModel(pro sort(0, Qt::AscendingOrder); } -void MapAreaModel::removeItem(QStandardItem *item) { +void MapLocationModel::removeItem(QStandardItem *item) { this->project->removeMapsec(item->data(MapListUserRoles::NameRole).toString()); this->removeRow(item->row()); } +QStandardItem *MapLocationModel::createMapFolderItem(const QString &folderName, QStandardItem *folder) { + folder = MapListModel::createMapFolderItem(folderName, folder); + folder->setToolTip(this->project->getMapsecDisplayName(folderName)); + return folder; +} + LayoutTreeModel::LayoutTreeModel(Project *project, QObject *parent) : MapListModel(project, parent) { @@ -477,7 +490,7 @@ QVariant LayoutTreeModel::data(const QModelIndex &index, int role) const { int row = index.row(); int col = index.column(); - const QStandardItem *item = this->getItem(index)->child(row, col); + const QStandardItem *item = this->itemAt(index)->child(row, col); const QString type = item->data(MapListUserRoles::TypeRole).toString(); const QString name = item->data(MapListUserRoles::NameRole).toString(); diff --git a/src/ui/newlocationdialog.cpp b/src/ui/newlocationdialog.cpp new file mode 100644 index 00000000..d0586d99 --- /dev/null +++ b/src/ui/newlocationdialog.cpp @@ -0,0 +1,79 @@ +#include "newlocationdialog.h" +#include "ui_newlocationdialog.h" +#include "project.h" +#include "validator.h" + +const QString lineEdit_ErrorStylesheet = "QLineEdit { background-color: rgba(255, 0, 0, 25%) }"; + +NewLocationDialog::NewLocationDialog(Project* project, QWidget *parent) : + QDialog(parent), + ui(new Ui::NewLocationDialog), + namePrefix(projectConfig.getIdentifier(ProjectIdentifier::define_map_section_prefix)) +{ + setAttribute(Qt::WA_DeleteOnClose); + ui->setupUi(this); + this->project = project; + + ui->lineEdit_IdName->setValidator(new IdentifierValidator(namePrefix, this)); + ui->lineEdit_IdName->setText(namePrefix); + + connect(ui->lineEdit_IdName, &QLineEdit::textChanged, this, &NewLocationDialog::onIdNameChanged); + connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &NewLocationDialog::dialogButtonClicked); + + adjustSize(); +} + +NewLocationDialog::~NewLocationDialog() +{ + delete ui; +} + +void NewLocationDialog::onIdNameChanged(const QString &idName) { + validateIdName(true); + + // Extract a presumed display name from the ID name + QString displayName = idName; + if (displayName.startsWith(namePrefix)) + displayName.remove(0, namePrefix.length()); + displayName.replace("_", " "); + ui->lineEdit_DisplayName->setText(displayName); +} + +bool NewLocationDialog::validateIdName(bool allowEmpty) { + const QString name = ui->lineEdit_IdName->text(); + + QString errorText; + if (name.isEmpty() || name == namePrefix) { + if (!allowEmpty) errorText = QString("%1 cannot be empty.").arg(ui->label_IdName->text()); + } else if (!this->project->isIdentifierUnique(name)) { + errorText = QString("%1 '%2' is not unique.").arg(ui->label_IdName->text()).arg(name); + } + + bool isValid = errorText.isEmpty(); + ui->label_IdNameError->setText(errorText); + ui->label_IdNameError->setVisible(!isValid); + ui->lineEdit_IdName->setStyleSheet(!isValid ? lineEdit_ErrorStylesheet : ""); + return isValid; +} + +void NewLocationDialog::dialogButtonClicked(QAbstractButton *button) { + auto role = ui->buttonBox->buttonRole(button); + if (role == QDialogButtonBox::RejectRole){ + reject(); + } else if (role == QDialogButtonBox::AcceptRole) { + accept(); + } +} + +void NewLocationDialog::accept() { + if (!validateIdName()) + return; + + const QString idName = ui->lineEdit_IdName->text(); + const QString displayName = ui->lineEdit_DisplayName->text(); + + this->project->addNewMapsec(idName); + this->project->setMapsecDisplayName(idName, displayName); + + QDialog::accept(); +} diff --git a/src/ui/newmapdialog.cpp b/src/ui/newmapdialog.cpp index 2d1fa46f..fda3d59a 100644 --- a/src/ui/newmapdialog.cpp +++ b/src/ui/newmapdialog.cpp @@ -53,7 +53,7 @@ NewMapDialog::NewMapDialog(Project *project, const Map *mapToCopy, QWidget *pare // Create a collapsible section that has all the map header data. this->headerForm = new MapHeaderForm(); - this->headerForm->init(project); + this->headerForm->setProject(project, false); auto sectionLayout = new QVBoxLayout(); sectionLayout->addWidget(this->headerForm); @@ -77,13 +77,13 @@ NewMapDialog::NewMapDialog(Project *project, int mapListTab, const QString &mapL case MapListTab::Groups: ui->comboBox_Group->setTextItem(mapListItem); break; - case MapListTab::Areas: + case MapListTab::Locations: this->headerForm->setLocation(mapListItem); break; case MapListTab::Layouts: // We specifically lock the layout ID because otherwise the setting would be overwritten when // the user changes the map name (which will normally automatically update the layout ID to match). - // For the Group/Area settings above we don't care if the user changes them afterwards. + // For the Group/Location settings above we don't care if the user changes them afterwards. ui->comboBox_LayoutID->setTextItem(mapListItem); ui->comboBox_LayoutID->setDisabled(true); break; @@ -252,5 +252,9 @@ void NewMapDialog::accept() { return; } ui->label_GenericError->setVisible(false); + + // If the location name field was changed, update the project for that too. + this->project->setMapsecDisplayName(this->headerForm->location(), this->headerForm->locationName()); + QDialog::accept(); } diff --git a/src/ui/newnamedialog.cpp b/src/ui/newmapgroupdialog.cpp similarity index 57% rename from src/ui/newnamedialog.cpp rename to src/ui/newmapgroupdialog.cpp index 842bf4b7..13461b68 100644 --- a/src/ui/newnamedialog.cpp +++ b/src/ui/newmapgroupdialog.cpp @@ -1,48 +1,43 @@ -#include "newnamedialog.h" -#include "ui_newnamedialog.h" +#include "newmapgroupdialog.h" +#include "ui_newmapgroupdialog.h" #include "project.h" -#include "imageexport.h" #include "validator.h" const QString lineEdit_ErrorStylesheet = "QLineEdit { background-color: rgba(255, 0, 0, 25%) }"; -NewNameDialog::NewNameDialog(const QString &label, const QString &prefix, Project* project, QWidget *parent) : +NewMapGroupDialog::NewMapGroupDialog(Project* project, QWidget *parent) : QDialog(parent), - ui(new Ui::NewNameDialog), - namePrefix(prefix) + ui(new Ui::NewMapGroupDialog) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); this->project = project; - if (!label.isEmpty()) - ui->label_Name->setText(label); + ui->lineEdit_Name->setValidator(new IdentifierValidator(this)); + ui->lineEdit_Name->setText(Project::getMapGroupPrefix()); - ui->lineEdit_Name->setValidator(new IdentifierValidator(namePrefix, this)); - ui->lineEdit_Name->setText(namePrefix); - - connect(ui->lineEdit_Name, &QLineEdit::textChanged, this, &NewNameDialog::onNameChanged); - connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &NewNameDialog::dialogButtonClicked); + connect(ui->lineEdit_Name, &QLineEdit::textChanged, this, &NewMapGroupDialog::onNameChanged); + connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &NewMapGroupDialog::dialogButtonClicked); adjustSize(); } -NewNameDialog::~NewNameDialog() +NewMapGroupDialog::~NewMapGroupDialog() { delete ui; } -void NewNameDialog::onNameChanged(const QString &) { +void NewMapGroupDialog::onNameChanged(const QString &) { validateName(true); } -bool NewNameDialog::validateName(bool allowEmpty) { +bool NewMapGroupDialog::validateName(bool allowEmpty) { const QString name = ui->lineEdit_Name->text(); QString errorText; - if (name.isEmpty() || name == namePrefix) { + if (name.isEmpty()) { if (!allowEmpty) errorText = QString("%1 cannot be empty.").arg(ui->label_Name->text()); - } else if (this->project && !this->project->isIdentifierUnique(name)) { + } else if (!this->project->isIdentifierUnique(name)) { errorText = QString("%1 '%2' is not unique.").arg(ui->label_Name->text()).arg(name); } @@ -53,7 +48,7 @@ bool NewNameDialog::validateName(bool allowEmpty) { return isValid; } -void NewNameDialog::dialogButtonClicked(QAbstractButton *button) { +void NewMapGroupDialog::dialogButtonClicked(QAbstractButton *button) { auto role = ui->buttonBox->buttonRole(button); if (role == QDialogButtonBox::RejectRole){ reject(); @@ -62,10 +57,11 @@ void NewNameDialog::dialogButtonClicked(QAbstractButton *button) { } } -void NewNameDialog::accept() { +void NewMapGroupDialog::accept() { if (!validateName()) return; - emit applied(ui->lineEdit_Name->text()); + this->project->addNewMapGroup(ui->lineEdit_Name->text()); + QDialog::accept(); } diff --git a/src/ui/projectsettingseditor.cpp b/src/ui/projectsettingseditor.cpp index 9324c123..016480a7 100644 --- a/src/ui/projectsettingseditor.cpp +++ b/src/ui/projectsettingseditor.cpp @@ -293,7 +293,7 @@ QStringList ProjectSettingsEditor::getWarpBehaviorsList() { void ProjectSettingsEditor::setWarpBehaviorsList(QStringList list) { list.removeDuplicates(); - list.sort(); + Project::numericalModeSort(list); ui->textEdit_WarpBehaviors->setText(list.join("\n")); } diff --git a/src/ui/regionmapeditor.cpp b/src/ui/regionmapeditor.cpp index f0415726..af0e220b 100644 --- a/src/ui/regionmapeditor.cpp +++ b/src/ui/regionmapeditor.cpp @@ -28,6 +28,7 @@ RegionMapEditor::RegionMapEditor(QWidget *parent, Project *project) : this->setAttribute(Qt::WA_DeleteOnClose); this->ui->setupUi(this); this->project = project; + connect(this->project, &Project::mapSectionIdNamesChanged, this, &RegionMapEditor::setLocations); this->configFilepath = QString("%1/%2").arg(this->project->root).arg(projectConfig.getFilePath(ProjectFilePath::json_region_porymap_cfg)); this->initShortcuts(); this->restoreWindowState(); @@ -728,8 +729,12 @@ void RegionMapEditor::displayRegionMapEntryOptions() { void RegionMapEditor::updateRegionMapEntryOptions(QString section) { if (!this->region_map->layoutEnabled()) return; + const QSignalBlocker b_X(this->ui->spinBox_RM_Entry_x); + const QSignalBlocker b_Y(this->ui->spinBox_RM_Entry_y); + const QSignalBlocker b_W(this->ui->spinBox_RM_Entry_width); + const QSignalBlocker b_H(this->ui->spinBox_RM_Entry_height); + bool enabled = (section != this->region_map->default_map_section) && this->region_map_entries.contains(section); - this->ui->lineEdit_RM_MapName->setEnabled(enabled); this->ui->spinBox_RM_Entry_x->setEnabled(enabled); this->ui->spinBox_RM_Entry_y->setEnabled(enabled); this->ui->spinBox_RM_Entry_width->setEnabled(enabled); @@ -737,56 +742,31 @@ void RegionMapEditor::updateRegionMapEntryOptions(QString section) { this->ui->pushButton_entryActivate->setEnabled(section != this->region_map->default_map_section); this->ui->pushButton_entryActivate->setText(enabled ? "Remove" : "Add"); - this->ui->lineEdit_RM_MapName->blockSignals(true); - this->ui->spinBox_RM_Entry_x->blockSignals(true); - this->ui->spinBox_RM_Entry_y->blockSignals(true); - this->ui->spinBox_RM_Entry_width->blockSignals(true); - this->ui->spinBox_RM_Entry_height->blockSignals(true); - this->ui->comboBox_RM_Entry_MapSection->setCurrentText(section); this->activeEntry = section; this->region_map_entries_item->currentSection = section; MapSectionEntry entry = enabled ? this->region_map_entries[section] : MapSectionEntry(); - this->ui->lineEdit_RM_MapName->setText(entry.name); this->ui->spinBox_RM_Entry_x->setValue(entry.x); this->ui->spinBox_RM_Entry_y->setValue(entry.y); this->ui->spinBox_RM_Entry_width->setValue(entry.width); this->ui->spinBox_RM_Entry_height->setValue(entry.height); - - this->ui->lineEdit_RM_MapName->blockSignals(false); - this->ui->spinBox_RM_Entry_x->blockSignals(false); - this->ui->spinBox_RM_Entry_y->blockSignals(false); - this->ui->spinBox_RM_Entry_width->blockSignals(false); - this->ui->spinBox_RM_Entry_height->blockSignals(false); } void RegionMapEditor::on_pushButton_entryActivate_clicked() { QString section = this->ui->comboBox_RM_Entry_MapSection->currentText(); if (section == this->region_map->default_map_section) return; + MapSectionEntry oldEntry = this->region_map->getEntry(section); if (this->region_map_entries.contains(section)) { // disable - MapSectionEntry oldEntry = this->region_map->getEntry(section); - this->region_map->removeEntry(section); - MapSectionEntry newEntry = this->region_map->getEntry(section); - RemoveEntry *commit = new RemoveEntry(this->region_map, section, oldEntry, newEntry); - this->region_map->editHistory.push(commit); - updateRegionMapEntryOptions(section); - - this->ui->pushButton_entryActivate->setText("Add"); + this->region_map->editHistory.push(new RemoveEntry(this->region_map, section, oldEntry, MapSectionEntry())); } else { // enable - MapSectionEntry oldEntry = this->region_map->getEntry(section); - MapSectionEntry entry = MapSectionEntry(); - entry.valid = true; - this->region_map->setEntry(section, entry); - MapSectionEntry newEntry = this->region_map->getEntry(section); - AddEntry *commit = new AddEntry(this->region_map, section, oldEntry, newEntry); - this->region_map->editHistory.push(commit); - updateRegionMapEntryOptions(section); - - this->ui->pushButton_entryActivate->setText("Remove"); + MapSectionEntry newEntry = MapSectionEntry(); + newEntry.valid = true; + this->region_map->editHistory.push(new AddEntry(this->region_map, section, oldEntry, newEntry)); } + updateRegionMapEntryOptions(section); } void RegionMapEditor::displayRegionMapTileSelector() { @@ -932,7 +912,7 @@ void RegionMapEditor::on_tabWidget_Region_Map_currentChanged(int index) { break; case 2: this->ui->verticalSlider_Zoom_Image_Tiles->setVisible(false); - on_comboBox_RM_Entry_MapSection_textActivated(ui->comboBox_RM_Entry_MapSection->currentText()); + on_comboBox_RM_Entry_MapSection_currentTextChanged(ui->comboBox_RM_Entry_MapSection->currentText()); break; } } @@ -943,7 +923,7 @@ void RegionMapEditor::on_comboBox_RM_ConnectedMap_textActivated(const QString &m onRegionMapLayoutSelectedTileChanged(this->currIndex);// re-draw layout image } -void RegionMapEditor::on_comboBox_RM_Entry_MapSection_textActivated(const QString &text) { +void RegionMapEditor::on_comboBox_RM_Entry_MapSection_currentTextChanged(const QString &text) { this->activeEntry = text; this->region_map_entries_item->currentSection = text; updateRegionMapEntryOptions(text); @@ -1046,15 +1026,6 @@ void RegionMapEditor::on_spinBox_RM_LayoutHeight_valueChanged(int value) { } } -void RegionMapEditor::on_lineEdit_RM_MapName_textEdited(const QString &text) { - if (!this->region_map_entries.contains(activeEntry)) return; - MapSectionEntry oldEntry = this->region_map_entries[activeEntry]; - this->region_map_entries[activeEntry].name = text; - MapSectionEntry newEntry = this->region_map_entries[activeEntry]; - EditEntry *commit = new EditEntry(this->region_map, activeEntry, oldEntry, newEntry); - this->region_map->editHistory.push(commit); -} - void RegionMapEditor::on_pushButton_RM_Options_delete_clicked() { int index = this->region_map->tilemapToLayoutIndex(this->currIndex); QList oldLayout = this->region_map->getLayout(this->region_map->getLayer()); @@ -1147,7 +1118,7 @@ void RegionMapEditor::on_action_Swap_triggered() { connect(&buttonBox, &QDialogButtonBox::accepted, [&popup, &oldSecBox, &newSecBox, &beforeSection, &afterSection](){ beforeSection = oldSecBox->currentText(); afterSection = newSecBox->currentText(); - if (!beforeSection.isEmpty() && !afterSection.isEmpty()) { + if (!beforeSection.isEmpty() && !afterSection.isEmpty() && beforeSection != afterSection) { popup.accept(); } }); @@ -1186,7 +1157,7 @@ void RegionMapEditor::on_action_Replace_triggered() { connect(&buttonBox, &QDialogButtonBox::accepted, [&popup, &oldSecBox, &newSecBox, &beforeSection, &afterSection](){ beforeSection = oldSecBox->currentText(); afterSection = newSecBox->currentText(); - if (!beforeSection.isEmpty() && !afterSection.isEmpty()) { + if (!beforeSection.isEmpty() && !afterSection.isEmpty() && beforeSection != afterSection) { popup.accept(); } }); diff --git a/src/ui/regionmapentriespixmapitem.cpp b/src/ui/regionmapentriespixmapitem.cpp index ace3c38d..8ac888a0 100644 --- a/src/ui/regionmapentriespixmapitem.cpp +++ b/src/ui/regionmapentriespixmapitem.cpp @@ -8,7 +8,7 @@ void RegionMapEntriesPixmapItem::draw() { int entry_x, entry_y, entry_w, entry_h; - if (!entry.valid || entry.name == region_map->default_map_section) { + if (!entry.valid || currentSection == region_map->default_map_section) { entry_x = entry_y = 0; entry_w = entry_h = 1; } else {