Skip to content

Commit

Permalink
Merge branch 'master' into connections
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards authored Aug 21, 2024
2 parents d154f47 + baaf9c8 commit 4f4e810
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
- Fix config files being written before the project is opened successfully.
- Fix the map and other project info still displaying if a new project fails to open.
- Fix unsaved changes being ignored when quitting (such as with Cmd+Q on macOS).
- Fix selections with multiple Events not always clearing when making a new selection.
- Fix `About porymap` opening a new window each time it's activated.
- Fix the `Edit History` window not raising to the front when reactivated.
- New maps are now always inserted in map dropdowns at the correct position, rather than at the bottom of the list until the project is reloaded.
Expand Down
11 changes: 1 addition & 10 deletions include/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private slots:
void on_toolButton_deleteObject_clicked();

void addNewEvent(Event::Type type);
void tryAddEventTab(QWidget * tab, Event::Group group);
void tryAddEventTab(QWidget * tab);
void displayEventTabs();
void updateSelectedObjects();
void updateObjects();
Expand Down Expand Up @@ -331,19 +331,10 @@ private slots:
QAction *copyAction = nullptr;
QAction *pasteAction = nullptr;

QWidget *eventTabObjectWidget;
QWidget *eventTabWarpWidget;
QWidget *eventTabTriggerWidget;
QWidget *eventTabBGWidget;
QWidget *eventTabHealspotWidget;
QWidget *eventTabMultipleWidget;
QMap<Event::Group, DraggablePixmapItem*> lastSelectedEvent;

bool isProgrammaticEventTabChange;
bool newMapDefaultsSet = false;

MapSortOrder mapSortOrder;

bool tilesetNeedsRedraw = false;

bool userSetMap(QString, bool scrollTreeView = false);
Expand Down
30 changes: 18 additions & 12 deletions src/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1999,19 +1999,25 @@ void Editor::selectMapEvent(DraggablePixmapItem *object) {
}

void Editor::selectMapEvent(DraggablePixmapItem *object, bool toggle) {
if (selected_events && object) {
if (selected_events->contains(object)) {
if (toggle) {
selected_events->removeOne(object);
}
} else {
if (!toggle) {
selected_events->clear();
}
selected_events->append(object);
}
updateSelectedEvents();
if (!selected_events || !object)
return;

if (!toggle) {
// Selecting just this event
selected_events->clear();
selected_events->append(object);
} else if (!selected_events->contains(object)) {
// Adding event to selection
selected_events->append(object);
} else if (selected_events->length() > 1) {
// Removing from group selection
selected_events->removeOne(object);
} else {
// Attempting to toggle the only currently-selected event.
// Unselecting an event this way would be unexpected, so we ignore it.
return;
}
updateSelectedEvents();
}

void Editor::selectedEventIndexChanged(int index, Event::Group eventGroup) {
Expand Down
60 changes: 19 additions & 41 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,6 @@ void MainWindow::initMiscHeapObjects() {
mapListProxyModel->setSourceModel(mapListModel);
ui->mapList->setModel(mapListProxyModel);

eventTabObjectWidget = ui->tab_Objects;
eventTabWarpWidget = ui->tab_Warps;
eventTabTriggerWidget = ui->tab_Triggers;
eventTabBGWidget = ui->tab_BGs;
eventTabHealspotWidget = ui->tab_Healspots;
eventTabMultipleWidget = ui->tab_Multiple;
ui->tabWidget_EventType->clear();
}

Expand All @@ -395,7 +389,7 @@ void MainWindow::initMapSortOrder() {

connect(mapSortOrderActionGroup, &QActionGroup::triggered, this, &MainWindow::mapSortOrder_changed);

QAction* sortOrder = ui->toolButton_MapSortOrder->menu()->actions()[mapSortOrder];
QAction* sortOrder = ui->toolButton_MapSortOrder->menu()->actions()[porymapConfig.mapSortOrder];
ui->toolButton_MapSortOrder->setIcon(sortOrder->icon());
sortOrder->setChecked(true);
}
Expand Down Expand Up @@ -436,7 +430,7 @@ void MainWindow::mapSortOrder_changed(QAction *action)
}
}

if (i != mapSortOrder)
if (i != porymapConfig.mapSortOrder)
{
ui->toolButton_MapSortOrder->setIcon(action->icon());
porymapConfig.mapSortOrder = static_cast<MapSortOrder>(i);
Expand Down Expand Up @@ -482,8 +476,6 @@ void MainWindow::loadUserSettings() {
ui->checkBox_ToggleBorder->setChecked(porymapConfig.showBorder);
ui->checkBox_ToggleGrid->setChecked(porymapConfig.showGrid);
ui->checkBox_MirrorConnections->setChecked(porymapConfig.mirrorConnectingMaps);
mapSortOrder = porymapConfig.mapSortOrder;

this->editor->collisionOpacity = static_cast<qreal>(porymapConfig.collisionOpacity) / 100;
ui->horizontalSlider_CollisionTransparency->setValue(porymapConfig.collisionOpacity);
ui->slider_DiveEmergeMapOpacity->setValue(porymapConfig.diveEmergeMapOpacity);
Expand Down Expand Up @@ -1138,7 +1130,7 @@ void MainWindow::sortMapList() {
mapGroupItemsList->clear();
QStandardItem *root = mapListModel->invisibleRootItem();

switch (mapSortOrder)
switch (porymapConfig.mapSortOrder)
{
case MapSortOrder::Group:
for (int i = 0; i < project->groupNames.length(); i++) {
Expand Down Expand Up @@ -2038,7 +2030,8 @@ void MainWindow::addNewEvent(Event::Type type) {
}
}

void MainWindow::tryAddEventTab(QWidget * tab, Event::Group group) {
void MainWindow::tryAddEventTab(QWidget * tab) {
auto group = getEventGroupFromTabWidget(tab);
if (editor->map->events.value(group).length())
ui->tabWidget_EventType->addTab(tab, QString("%1s").arg(Event::eventGroupToString(group)));
}
Expand All @@ -2047,11 +2040,11 @@ void MainWindow::displayEventTabs() {
const QSignalBlocker blocker(ui->tabWidget_EventType);

ui->tabWidget_EventType->clear();
tryAddEventTab(eventTabObjectWidget, Event::Group::Object);
tryAddEventTab(eventTabWarpWidget, Event::Group::Warp);
tryAddEventTab(eventTabTriggerWidget, Event::Group::Coord);
tryAddEventTab(eventTabBGWidget, Event::Group::Bg);
tryAddEventTab(eventTabHealspotWidget, Event::Group::Heal);
tryAddEventTab(ui->tab_Objects);
tryAddEventTab(ui->tab_Warps);
tryAddEventTab(ui->tab_Triggers);
tryAddEventTab(ui->tab_BGs);
tryAddEventTab(ui->tab_Healspots);
}

void MainWindow::updateObjects() {
Expand Down Expand Up @@ -2211,30 +2204,15 @@ void MainWindow::updateSelectedObjects() {
}
}

Event::Group MainWindow::getEventGroupFromTabWidget(QWidget *tab)
{
Event::Group ret = Event::Group::None;
if (tab == eventTabObjectWidget)
{
ret = Event::Group::Object;
}
else if (tab == eventTabWarpWidget)
{
ret = Event::Group::Warp;
}
else if (tab == eventTabTriggerWidget)
{
ret = Event::Group::Coord;
}
else if (tab == eventTabBGWidget)
{
ret = Event::Group::Bg;
}
else if (tab == eventTabHealspotWidget)
{
ret = Event::Group::Heal;
}
return ret;
Event::Group MainWindow::getEventGroupFromTabWidget(QWidget *tab) {
static const QMap<QWidget*,Event::Group> tabToGroup = {
{ui->tab_Objects, Event::Group::Object},
{ui->tab_Warps, Event::Group::Warp},
{ui->tab_Triggers, Event::Group::Coord},
{ui->tab_BGs, Event::Group::Bg},
{ui->tab_Healspots, Event::Group::Heal},
};
return tabToGroup.value(tab, Event::Group::None);
}

void MainWindow::eventTabChanged(int index) {
Expand Down

0 comments on commit 4f4e810

Please sign in to comment.