Double clicking on warp events takes you to the destination map and warp
This commit is contained in:
parent
dc6b82b4dc
commit
74c2766c01
4 changed files with 43 additions and 4 deletions
10
editor.cpp
10
editor.cpp
|
@ -1515,13 +1515,15 @@ void DraggablePixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *mouse) {
|
|||
}
|
||||
|
||||
void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouse) {
|
||||
if (clicking) {
|
||||
this->editor->selectMapEvent(this, mouse->modifiers() & Qt::ControlModifier);
|
||||
this->editor->updateSelectedEvents();
|
||||
}
|
||||
active = false;
|
||||
}
|
||||
|
||||
void DraggablePixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouse) {
|
||||
if (this->event->get("event_type") == EventType::Warp) {
|
||||
emit editor->warpEventDoubleClicked(this->event->get("destination_map_name"), this->event->get("destination_warp"));
|
||||
}
|
||||
}
|
||||
|
||||
QList<DraggablePixmapItem *> *Editor::getObjects() {
|
||||
QList<DraggablePixmapItem *> *list = new QList<DraggablePixmapItem *>;
|
||||
for (Event *event : map->getAllEvents()) {
|
||||
|
|
2
editor.h
2
editor.h
|
@ -138,6 +138,7 @@ signals:
|
|||
void selectedObjectsChanged();
|
||||
void loadMapRequested(QString, QString);
|
||||
void tilesetChanged(QString);
|
||||
void warpEventDoubleClicked(QString mapName, QString warpNum);
|
||||
};
|
||||
|
||||
|
||||
|
@ -228,6 +229,7 @@ protected:
|
|||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
|
||||
};
|
||||
|
||||
class EventGroup : public QGraphicsItemGroup {
|
||||
|
|
|
@ -37,6 +37,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
connect(editor, SIGNAL(selectedObjectsChanged()), this, SLOT(updateSelectedObjects()));
|
||||
connect(editor, SIGNAL(loadMapRequested(QString, QString)), this, SLOT(onLoadMapRequested(QString, QString)));
|
||||
connect(editor, SIGNAL(tilesetChanged(QString)), this, SLOT(onTilesetChanged(QString)));
|
||||
connect(editor, SIGNAL(warpEventDoubleClicked(QString,QString)), this, SLOT(openWarpMap(QString,QString)));
|
||||
|
||||
on_toolButton_Paint_clicked();
|
||||
|
||||
|
@ -196,6 +197,39 @@ void MainWindow::redrawMapScene()
|
|||
ui->graphicsView_Elevation->setFixedSize(editor->elevation_metatiles_item->pixmap().width() + 2, editor->elevation_metatiles_item->pixmap().height() + 2);
|
||||
}
|
||||
|
||||
void MainWindow::openWarpMap(QString map_name, QString warp_num) {
|
||||
// Ensure valid destination map name.
|
||||
if (!editor->project->mapNames->contains(map_name)) {
|
||||
qDebug() << QString("Invalid warp destination map name '%1'").arg(map_name);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure valid destination warp number.
|
||||
bool ok;
|
||||
int warpNum = warp_num.toInt(&ok, 0);
|
||||
if (!ok) {
|
||||
qDebug() << QString("Invalid warp number '%1' for destination map '%2'").arg(warp_num).arg(map_name);
|
||||
return;
|
||||
}
|
||||
|
||||
// Open the destination map, and select the target warp event.
|
||||
setMap(map_name);
|
||||
QList<Event*> warp_events = editor->map->events["warp_event_group"];
|
||||
if (warp_events.length() > warpNum) {
|
||||
Event *warp_event = warp_events.at(warpNum);
|
||||
QList<DraggablePixmapItem *> *all_events = editor->getObjects();
|
||||
for (DraggablePixmapItem *item : *all_events) {
|
||||
if (item->event == warp_event) {
|
||||
editor->selected_events->clear();
|
||||
editor->selected_events->append(item);
|
||||
editor->updateSelectedEvents();
|
||||
}
|
||||
}
|
||||
|
||||
delete all_events;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setRecentMap(QString map_name) {
|
||||
QSettings settings;
|
||||
QString key = "project:" + editor->project->root;
|
||||
|
|
|
@ -32,6 +32,7 @@ private slots:
|
|||
void on_action_Open_Project_triggered();
|
||||
void on_mapList_activated(const QModelIndex &index);
|
||||
void on_action_Save_Project_triggered();
|
||||
void openWarpMap(QString map_name, QString warp_num);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
|
Loading…
Reference in a new issue