Fix some internal use of 'objects' when referring to events

This commit is contained in:
GriffinR
2025-02-09 17:06:30 -05:00
parent c49470c47e
commit 2100aaac93
6 changed files with 49 additions and 50 deletions

View File

@@ -1484,7 +1484,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mapView_ObjectInfo">
<widget class="QWidget" name="mapView_EventInfo">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>1</number>
@@ -1499,7 +1499,7 @@
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame_Objects">
<widget class="QFrame" name="frame_Events">
<property name="enabled">
<bool>true</bool>
</property>
@@ -1582,7 +1582,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_deleteObject">
<widget class="QToolButton" name="toolButton_deleteEvent">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>

View File

@@ -112,7 +112,7 @@ public:
DraggablePixmapItem *addEventPixmapItem(Event *event);
void removeEventPixmapItem(Event *event);
bool eventLimitReached(Map *, Event::Type);
void selectMapEvent(DraggablePixmapItem *object, bool toggle = false);
void selectMapEvent(DraggablePixmapItem *item, bool toggle = false);
DraggablePixmapItem *addNewEvent(Event::Type type);
void updateSelectedEvents();
void duplicateSelectedEvents();
@@ -157,7 +157,7 @@ public:
enum class EditAction { None, Paint, Select, Fill, Shift, Pick, Move };
EditAction mapEditAction = EditAction::Paint;
EditAction objectEditAction = EditAction::Select;
EditAction eventEditAction = EditAction::Select;
enum class EditMode { None, Disabled, Metatiles, Collision, Header, Events, Connections, Encounters };
EditMode editMode = EditMode::None;
@@ -171,7 +171,7 @@ public:
void setEditingMetatiles();
void setEditingCollision();
void setEditingHeader();
void setEditingObjects();
void setEditingEvents();
void setEditingConnections();
void setEditingEncounters();
@@ -183,7 +183,7 @@ public:
int eventShiftActionId = 0;
void objectsView_onMousePress(QMouseEvent *event);
void eventsView_onMousePress(QMouseEvent *event);
int getBorderDrawDistance(int dimension);
@@ -257,7 +257,7 @@ private slots:
void onWheelZoom(int);
signals:
void objectsChanged();
void eventsChanged();
void openConnectedMap(MapConnection*);
void wildMonTableOpened(EncounterTableModel*);
void wildMonTableClosed();

View File

@@ -221,8 +221,8 @@ private slots:
void addNewEvent(Event::Type type);
void tryAddEventTab(QWidget * tab);
void displayEventTabs();
void updateSelectedObjects();
void updateObjects();
void updateSelectedEvents();
void updateEvents();
void on_toolButton_Paint_clicked();
void on_toolButton_Select_clicked();

View File

@@ -178,7 +178,7 @@ void Editor::setEditingHeader() {
setEditorView();
}
void Editor::setEditingObjects() {
void Editor::setEditingEvents() {
this->editMode = EditMode::Events;
setEditorView();
@@ -1295,7 +1295,7 @@ void Editor::setStraightPathCursorMode(QGraphicsSceneMouseEvent *event) {
}
void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *item) {
// TODO: add event tab object painting tool buttons stuff here
// TODO: add event tab event painting tool buttons stuff here
if (!item->getEditsEnabled()) {
return;
}
@@ -1350,10 +1350,10 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *i
item->shift(event);
}
} else if (this->editMode == EditMode::Events) {
if (objectEditAction == EditAction::Paint && event->type() == QEvent::GraphicsSceneMousePress) {
if (eventEditAction == EditAction::Paint && event->type() == QEvent::GraphicsSceneMousePress) {
// Right-clicking while in paint mode will change mode to select.
if (event->buttons() & Qt::RightButton) {
this->objectEditAction = EditAction::Select;
this->eventEditAction = EditAction::Select;
this->settings->mapCursor = QCursor();
this->cursorMapTileRect->setSingleTileMode();
this->ui->toolButton_Paint->setChecked(false);
@@ -1370,14 +1370,14 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *i
DraggablePixmapItem *newEvent = addNewEvent(eventType);
if (newEvent) {
newEvent->move(pos.x(), pos.y());
emit objectsChanged();
emit eventsChanged();
selectMapEvent(newEvent);
}
}
}
} else if (objectEditAction == EditAction::Select) {
} else if (eventEditAction == EditAction::Select) {
// do nothing here, at least for now
} else if (objectEditAction == EditAction::Shift) {
} else if (eventEditAction == EditAction::Shift) {
static QPoint selection_origin;
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
@@ -1715,7 +1715,6 @@ void Editor::displayMapEvents() {
addEventPixmapItem(event);
}
//objects_group->setFiltersChildEvents(false);
events_group->setHandlesChildEvents(false);
}
@@ -2054,23 +2053,23 @@ void Editor::updateSelectedEvents() {
redrawEventPixmapItem(item);
}
emit objectsChanged();
emit eventsChanged();
}
void Editor::selectMapEvent(DraggablePixmapItem *object, bool toggle) {
if (!selected_events || !object)
void Editor::selectMapEvent(DraggablePixmapItem *item, bool toggle) {
if (!selected_events || !item)
return;
if (!toggle) {
// Selecting just this event
selected_events->clear();
selected_events->append(object);
} else if (!selected_events->contains(object)) {
selected_events->append(item);
} else if (!selected_events->contains(item)) {
// Adding event to group selection
selected_events->append(object);
selected_events->append(item);
} else if (selected_events->length() > 1) {
// Removing event from group selection
selected_events->removeOne(object);
selected_events->removeOne(item);
} else {
// Attempting to toggle the only currently-selected event.
// Unselecting an event this way would be unexpected, so we ignore it.
@@ -2271,13 +2270,13 @@ bool Editor::startDetachedProcess(const QString &command, const QString &working
// Since the DraggablePixmapItem's event fires first, we can set a temp
// variable "selectingEvent" so that we can detect whether or not the user
// is clicking on the background instead of an event.
void Editor::objectsView_onMousePress(QMouseEvent *event) {
// make sure we are in object editing mode
void Editor::eventsView_onMousePress(QMouseEvent *event) {
// make sure we are in event editing mode
if (map_item && this->editMode != EditMode::Events) {
return;
}
if (this->objectEditAction == EditAction::Paint && event->buttons() & Qt::RightButton) {
this->objectEditAction = EditAction::Select;
if (this->eventEditAction == EditAction::Paint && event->buttons() & Qt::RightButton) {
this->eventEditAction = EditAction::Select;
this->settings->mapCursor = QCursor();
this->cursorMapTileRect->setSingleTileMode();
this->ui->toolButton_Paint->setChecked(false);

View File

@@ -337,14 +337,14 @@ void MainWindow::checkForUpdates(bool) {}
void MainWindow::initEditor() {
this->editor = new Editor(ui);
connect(this->editor, &Editor::objectsChanged, this, &MainWindow::updateObjects);
connect(this->editor, &Editor::eventsChanged, this, &MainWindow::updateEvents);
connect(this->editor, &Editor::openConnectedMap, this, &MainWindow::onOpenConnectedMap);
connect(this->editor, &Editor::warpEventDoubleClicked, this, &MainWindow::openWarpMap);
connect(this->editor, &Editor::currentMetatilesSelectionChanged, this, &MainWindow::currentMetatilesSelectionChanged);
connect(this->editor, &Editor::wildMonTableEdited, [this] { this->markMapEdited(); });
connect(this->editor, &Editor::mapRulerStatusChanged, this, &MainWindow::onMapRulerStatusChanged);
connect(this->editor, &Editor::tilesetUpdated, this, &Scripting::cb_TilesetUpdated);
connect(ui->toolButton_deleteObject, &QAbstractButton::clicked, this->editor, &Editor::deleteSelectedEvents);
connect(ui->toolButton_deleteEvent, &QAbstractButton::clicked, this->editor, &Editor::deleteSelectedEvents);
this->loadUserSettings();
@@ -1760,7 +1760,7 @@ void MainWindow::paste() {
if (!newEvents.empty()) {
editor->map->commit(new EventPaste(this->editor, editor->map, newEvents));
updateObjects();
updateEvents();
}
break;
@@ -1816,8 +1816,8 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index)
clickToolButtonFromEditAction(editor->mapEditAction);
} else if (index == MainTab::Events) {
ui->stackedWidget_MapEvents->setCurrentIndex(1);
editor->setEditingObjects();
clickToolButtonFromEditAction(editor->objectEditAction);
editor->setEditingEvents();
clickToolButtonFromEditAction(editor->eventEditAction);
} else if (index == MainTab::Connections) {
editor->setEditingConnections();
ui->graphicsView_Connections->setFocus(); // Avoid opening tab with focus on something editable
@@ -1958,13 +1958,13 @@ void MainWindow::resetMapViewScale() {
void MainWindow::addNewEvent(Event::Type type) {
if (editor && editor->project) {
DraggablePixmapItem *object = editor->addNewEvent(type);
if (object) {
DraggablePixmapItem *item = editor->addNewEvent(type);
if (item) {
auto halfSize = ui->graphicsView_Map->size() / 2;
auto centerPos = ui->graphicsView_Map->mapToScene(halfSize.width(), halfSize.height());
object->moveTo(Metatile::coordFromPixmapCoord(centerPos));
updateObjects();
editor->selectMapEvent(object);
item->moveTo(Metatile::coordFromPixmapCoord(centerPos));
updateEvents();
editor->selectMapEvent(item);
} else {
WarningMessage msgBox(QStringLiteral("Failed to add new event."), this);
if (Event::typeToGroup(type) == Event::Group::Object) {
@@ -1996,17 +1996,17 @@ void MainWindow::displayEventTabs() {
tryAddEventTab(ui->tab_Healspots);
}
void MainWindow::updateObjects() {
void MainWindow::updateEvents() {
QList<DraggablePixmapItem *> items = editor->getEventPixmapItems();
for (auto i = this->lastSelectedEvent.cbegin(), end = this->lastSelectedEvent.cend(); i != end; i++) {
if (i.value() && !items.contains(i.value()))
this->lastSelectedEvent.insert(i.key(), nullptr);
}
displayEventTabs();
updateSelectedObjects();
updateSelectedEvents();
}
void MainWindow::updateSelectedObjects() {
void MainWindow::updateSelectedEvents() {
QList<DraggablePixmapItem *> events;
if (editor->selected_events && editor->selected_events->length()) {
@@ -2259,7 +2259,7 @@ void MainWindow::on_toolButton_Paint_clicked()
if (ui->mainTabBar->currentIndex() == MainTab::Map)
editor->mapEditAction = Editor::EditAction::Paint;
else
editor->objectEditAction = Editor::EditAction::Paint;
editor->eventEditAction = Editor::EditAction::Paint;
editor->settings->mapCursor = QCursor(QPixmap(":/icons/pencil_cursor.ico"), 10, 10);
@@ -2280,7 +2280,7 @@ void MainWindow::on_toolButton_Select_clicked()
if (ui->mainTabBar->currentIndex() == MainTab::Map)
editor->mapEditAction = Editor::EditAction::Select;
else
editor->objectEditAction = Editor::EditAction::Select;
editor->eventEditAction = Editor::EditAction::Select;
editor->settings->mapCursor = QCursor();
editor->cursorMapTileRect->setSingleTileMode();
@@ -2299,7 +2299,7 @@ void MainWindow::on_toolButton_Fill_clicked()
if (ui->mainTabBar->currentIndex() == MainTab::Map)
editor->mapEditAction = Editor::EditAction::Fill;
else
editor->objectEditAction = Editor::EditAction::Fill;
editor->eventEditAction = Editor::EditAction::Fill;
editor->settings->mapCursor = QCursor(QPixmap(":/icons/fill_color_cursor.ico"), 10, 10);
editor->cursorMapTileRect->setSingleTileMode();
@@ -2318,7 +2318,7 @@ void MainWindow::on_toolButton_Dropper_clicked()
if (ui->mainTabBar->currentIndex() == MainTab::Map)
editor->mapEditAction = Editor::EditAction::Pick;
else
editor->objectEditAction = Editor::EditAction::Pick;
editor->eventEditAction = Editor::EditAction::Pick;
editor->settings->mapCursor = QCursor(QPixmap(":/icons/pipette_cursor.ico"), 10, 10);
editor->cursorMapTileRect->setSingleTileMode();
@@ -2337,7 +2337,7 @@ void MainWindow::on_toolButton_Move_clicked()
if (ui->mainTabBar->currentIndex() == MainTab::Map)
editor->mapEditAction = Editor::EditAction::Move;
else
editor->objectEditAction = Editor::EditAction::Move;
editor->eventEditAction = Editor::EditAction::Move;
editor->settings->mapCursor = QCursor(QPixmap(":/icons/move.ico"), 7, 7);
editor->cursorMapTileRect->setSingleTileMode();
@@ -2356,7 +2356,7 @@ void MainWindow::on_toolButton_Shift_clicked()
if (ui->mainTabBar->currentIndex() == MainTab::Map)
editor->mapEditAction = Editor::EditAction::Shift;
else
editor->objectEditAction = Editor::EditAction::Shift;
editor->eventEditAction = Editor::EditAction::Shift;
editor->settings->mapCursor = QCursor(QPixmap(":/icons/shift_cursor.ico"), 10, 10);
editor->cursorMapTileRect->setSingleTileMode();
@@ -2375,7 +2375,7 @@ void MainWindow::checkToolButtons() {
if (ui->mainTabBar->currentIndex() == MainTab::Map) {
editAction = editor->mapEditAction;
} else {
editAction = editor->objectEditAction;
editAction = editor->eventEditAction;
if (editAction == Editor::EditAction::Select && editor->map_ruler)
editor->map_ruler->setEnabled(true);
else if (editor->map_ruler)

View File

@@ -5,7 +5,7 @@
void GraphicsView::mousePressEvent(QMouseEvent *event) {
QGraphicsView::mousePressEvent(event);
if (editor) {
editor->objectsView_onMousePress(event);
editor->eventsView_onMousePress(event);
}
}