From 399474c1f2d615d581f161d15ca2130161842278 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 29 Apr 2020 12:34:49 -0400 Subject: [PATCH 1/3] Fix heal loc duplicates, rename flyableMaps --- include/project.h | 2 +- src/editor.cpp | 4 ++-- src/project.cpp | 41 +++++++++++++++++++++-------------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/include/project.h b/include/project.h index e9147b2c..e6daffb0 100644 --- a/include/project.h +++ b/include/project.h @@ -37,7 +37,7 @@ public: QList groupedMapNames; QStringList *mapNames = nullptr; QMap miscConstants; - QList flyableMaps; + QList healLocations; QMap* mapConstantsToMapNames; QMap* mapNamesToMapConstants; QList mapLayoutsTable; diff --git a/src/editor.cpp b/src/editor.cpp index 0e8a0c30..6956e64c 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1845,8 +1845,8 @@ DraggablePixmapItem* Editor::addNewEvent(QString event_type) { event->put("map_name", map->name); if (event_type == "event_heal_location") { HealLocation hl = HealLocation::fromEvent(event); - project->flyableMaps.append(hl); - event->put("index", project->flyableMaps.length()); + project->healLocations.append(hl); + event->put("index", project->healLocations.length()); } map->addEvent(event); project->loadEventPixmaps(map->getAllEvents()); diff --git a/src/project.cpp b/src/project.cpp index f791e50b..7fc42117 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -341,7 +341,7 @@ bool Project::loadMapData(Map* map) { } map->events["heal_event_group"].clear(); - for (auto it = flyableMaps.begin(); it != flyableMaps.end(); it++) { + for (auto it = healLocations.begin(); it != healLocations.end(); it++) { HealLocation loc = *it; @@ -917,33 +917,34 @@ void Project::saveHealLocationStruct(Map *map) { QString constants_text = QString("#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H\n"); constants_text += QString("#define GUARD_CONSTANTS_HEAL_LOCATIONS_H\n\n"); - QMap flyableMapsDupes; - QSet flyableMapsUnique; + QMap healLocationsDupes; + QSet healLocationsUnique; - // set flyableMapsDupes and flyableMapsUnique - for (auto it = flyableMaps.begin(); it != flyableMaps.end(); it++) { + // set healLocationsDupes and healLocationsUnique + for (auto it = healLocations.begin(); it != healLocations.end(); it++) { HealLocation loc = *it; QString xname = loc.idName; - if (flyableMapsUnique.contains(xname)) { - flyableMapsDupes[xname] = 1; + if (healLocationsUnique.contains(xname)) { + healLocationsDupes[xname] = 1; } - flyableMapsUnique.insert(xname); + healLocationsUnique.insert(xname); } - // set new location in flyableMapsList + // set new location in healLocations list if (map->events["heal_event_group"].length() > 0) { for (Event *healEvent : map->events["heal_event_group"]) { HealLocation hl = HealLocation::fromEvent(healEvent); - flyableMaps[hl.index - 1] = hl; + healLocations[hl.index - 1] = hl; } } int i = 1; - for (auto map_in : flyableMaps) { + for (auto map_in : healLocations) { // add numbered suffix for duplicate constants - if (flyableMapsDupes.keys().contains(map_in.idName)) { - map_in.idName += QString("_%1").arg(flyableMapsDupes[map_in.idName]); - flyableMapsDupes[map_in.idName]++; + if (healLocationsDupes.keys().contains(map_in.idName)) { + QString duplicateName = map_in.idName; + map_in.idName += QString("_%1").arg(healLocationsDupes[duplicateName]); + healLocationsDupes[duplicateName]++; } // Save first array (heal location coords), only data array in RSE @@ -973,7 +974,7 @@ void Project::saveHealLocationStruct(Map *map) { data_text += QString("};\n\n%1%2u16 sWhiteoutRespawnHealCenterMapIdxs[][2] =\n{\n") .arg(dataQualifiers.value("heal_locations").isStatic ? "static " : "") .arg(dataQualifiers.value("heal_locations").isConst ? "const " : ""); - for (auto map_in : flyableMaps) { + for (auto map_in : healLocations) { data_text += QString(" [%1%2 - 1] = {MAP_GROUP(%3), MAP_NUM(%3)},\n") .arg(constantPrefix) .arg(map_in.idName) @@ -984,7 +985,7 @@ void Project::saveHealLocationStruct(Map *map) { data_text += QString("};\n\n%1%2u8 sWhiteoutRespawnHealerNpcIds[] =\n{\n") .arg(dataQualifiers.value("heal_locations").isStatic ? "static " : "") .arg(dataQualifiers.value("heal_locations").isConst ? "const " : ""); - for (auto map_in : flyableMaps) { + for (auto map_in : healLocations) { data_text += QString(" [%1%2 - 1] = %3,\n") .arg(constantPrefix) .arg(map_in.idName) @@ -2117,7 +2118,7 @@ bool Project::readRegionMapSections() { bool Project::readHealLocations() { dataQualifiers.clear(); - flyableMaps.clear(); + healLocations.clear(); QString filename = "src/data/heal_locations.h"; fileWatcher.addPath(root + "/" + filename); QString text = parser.readTextFile(root + "/" + filename); @@ -2144,7 +2145,7 @@ bool Project::readHealLocations() { unsigned x = spawn.captured("x").toUShort(); unsigned y = spawn.captured("y").toUShort(); unsigned npc = respawnNPC.captured("npc").toUShort(); - flyableMaps.append(HealLocation(idName, mapName, i, x, y, respawnMapName, npc)); + healLocations.append(HealLocation(idName, mapName, i, x, y, respawnMapName, npc)); } } else { dataQualifiers.insert("heal_locations", getDataQualifiers(text, "sHealLocations")); @@ -2157,7 +2158,7 @@ bool Project::readHealLocations() { QString mapName = match.captured("map"); unsigned x = match.captured("x").toUShort(); unsigned y = match.captured("y").toUShort(); - flyableMaps.append(HealLocation(idName, mapName, i, x, y)); + healLocations.append(HealLocation(idName, mapName, i, x, y)); } } return true; @@ -2494,7 +2495,7 @@ void Project::saveMapHealEvents(Map *map) { if (map->events["heal_event_group"].length() > 0) { for (Event *healEvent : map->events["heal_event_group"]) { HealLocation hl = HealLocation::fromEvent(healEvent); - flyableMaps[hl.index - 1] = hl; + healLocations[hl.index - 1] = hl; } } saveHealLocationStruct(map); From ac9253457621441e3d5daf895e934bf4ae1515d8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 29 Apr 2020 12:38:30 -0400 Subject: [PATCH 2/3] Disallow drawing heal locations --- src/editor.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/editor.cpp b/src/editor.cpp index 6956e64c..985b2892 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1067,10 +1067,14 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item } else { // Left-clicking while in paint mode will add a new event of the // type of the first currently selected events. - DraggablePixmapItem * newEvent = addNewEvent(this->selected_events->first()->event->get("event_type")); - if (newEvent) { - newEvent->move(x, y); - selectMapEvent(newEvent, false); + // Disallow adding heal locations, deleting them is not possible yet + QString eventType = this->selected_events->first()->event->get("event_type"); + if (eventType != "event_heal_location") { + DraggablePixmapItem * newEvent = addNewEvent(eventType); + if (newEvent) { + newEvent->move(x, y); + selectMapEvent(newEvent, false); + } } } } else if (map_edit_mode == "select") { From 37c849f9b5cb5e3c824121d3b2726d2fa5c3eec9 Mon Sep 17 00:00:00 2001 From: garakmon Date: Thu, 30 Apr 2020 19:44:54 -0400 Subject: [PATCH 3/3] allow current widget to dictate size of stacked widget for metatile/collision and events pages --- forms/mainwindow.ui | 7 ++++++- include/ui/adjustingstackedwidget.h | 25 +++++++++++++++++++++++++ porymap.pro | 1 + src/mainwindow.cpp | 1 + 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 include/ui/adjustingstackedwidget.h diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 3e02c9f8..f5e0a0b8 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -677,7 +677,7 @@ - + 0 @@ -3036,6 +3036,11 @@ QComboBox
noscrollcombobox.h
+ + AdjustingStackedWidget + QStackedWidget +
adjustingstackedwidget.h
+
GraphicsView QGraphicsView diff --git a/include/ui/adjustingstackedwidget.h b/include/ui/adjustingstackedwidget.h new file mode 100644 index 00000000..8de23d11 --- /dev/null +++ b/include/ui/adjustingstackedwidget.h @@ -0,0 +1,25 @@ +#ifndef ADJUSTINGSTACKEDWIDGET_H +#define ADJUSTINGSTACKEDWIDGET_H + +#include + + + +class AdjustingStackedWidget : public QStackedWidget +{ + Q_OBJECT + +public: + AdjustingStackedWidget(QWidget *parent = nullptr) : QStackedWidget(parent) {} + + // override this to allow the stacked widget's current page to dictate size + virtual void setCurrentIndex(int index) { + QStackedWidget::setCurrentIndex(index); + for (int i = 0; i < this->count(); ++i) { + this->widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + } + this->widget(index)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + } +}; + +#endif // ADJUSTINGSTACKEDWIDGET_H diff --git a/porymap.pro b/porymap.pro index ad12b9f0..b53d94ae 100644 --- a/porymap.pro +++ b/porymap.pro @@ -119,6 +119,7 @@ HEADERS += include/core/block.h \ include/ui/noscrollcombobox.h \ include/ui/noscrollspinbox.h \ include/ui/montabwidget.h \ + include/ui/adjustingstackedwidget.h \ include/ui/paletteeditor.h \ include/ui/selectablepixmapitem.h \ include/ui/tileseteditor.h \ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2a8cbd77..0adc83ab 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -8,6 +8,7 @@ #include "ui_eventpropertiesframe.h" #include "bordermetatilespixmapitem.h" #include "currentselectedmetatilespixmapitem.h" +#include "adjustingstackedwidget.h" #include #include