mirror of
https://github.com/huderlem/porymap.git
synced 2026-03-21 17:45:44 -05:00
Fix status not updating while painting on map, remove redundant CollisionPixmapItem handling
This commit is contained in:
parent
9e820a79fe
commit
edabed0105
|
|
@ -46,6 +46,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
|
|||
- Fix Undo/Redo in the Tileset and Palette Editors and Paste in the Tileset Editor appearing enabled even when they don't do anything.
|
||||
- Fix `Ctrl+Shift+Z` not being set as a default shortcut for Redo in the Palette Editor like it is for other windows.
|
||||
- Fix the Tileset Editor's status bar not updating while selecting tiles in the metatile layer view.
|
||||
- Fix the main window's status bar not immediately reflecting changes made while painting metatiles / movement permissions.
|
||||
- Fix cleared metatile labels not updating until the project is reloaded.
|
||||
- Fix some changes in the Tileset Editor being discarded if the window is closed too quickly.
|
||||
- Fix the Region Map Editor incorrectly displaying whether a `MAPSEC` has region map data.
|
||||
|
|
|
|||
|
|
@ -258,11 +258,11 @@ private:
|
|||
bool canPaintMetatiles() const;
|
||||
void onMapStartPaint(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *item);
|
||||
void onMapEndPaint(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *item);
|
||||
void setStatusFromMapPos(const QPoint &pos);
|
||||
|
||||
private slots:
|
||||
void setSmartPathCursorMode(QGraphicsSceneMouseEvent *event);
|
||||
void mouseEvent_map(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *item);
|
||||
void mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item);
|
||||
void setSelectedConnectionItem(ConnectionPixmapItem *connectionItem);
|
||||
void onHoveredMovementPermissionChanged(uint16_t, uint16_t);
|
||||
void onHoveredMovementPermissionCleared();
|
||||
|
|
|
|||
|
|
@ -30,23 +30,7 @@ public:
|
|||
void draw(bool ignoreCache = false) override;
|
||||
|
||||
private:
|
||||
unsigned actionId_ = 0;
|
||||
QPoint previousPos;
|
||||
void updateSelection(QPoint pos);
|
||||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *);
|
||||
void hoverEntered(const QPoint &pos);
|
||||
void hoverChanged(const QPoint &pos);
|
||||
void hoverCleared();
|
||||
|
||||
protected:
|
||||
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*) override;
|
||||
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent*) override;
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override;
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent*) override;
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*) override;
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
|
||||
};
|
||||
|
||||
#endif // COLLISIONPIXMAPITEM_H
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ public:
|
|||
void lockNondominantAxis(QGraphicsSceneMouseEvent *event);
|
||||
QPoint adjustCoords(QPoint pos);
|
||||
|
||||
protected:
|
||||
unsigned actionId_ = 0;
|
||||
|
||||
private:
|
||||
void paintSmartPath(int x, int y, bool fromScriptCall = false);
|
||||
static bool isValidSmartPathSelection(MetatileSelection selection);
|
||||
|
|
@ -97,8 +100,6 @@ private:
|
|||
static constexpr int smartPathMiddleIndex = (smartPathWidth / 2) + ((smartPathHeight / 2) * smartPathWidth);
|
||||
QPoint lastMetatileSelectionPos = QPoint(-1,-1);
|
||||
|
||||
unsigned actionId_ = 0;
|
||||
|
||||
signals:
|
||||
void startPaint(QGraphicsSceneMouseEvent *, LayoutPixmapItem *);
|
||||
void endPaint(QGraphicsSceneMouseEvent *, LayoutPixmapItem *);
|
||||
|
|
|
|||
|
|
@ -1231,6 +1231,19 @@ void Editor::onMapHoverChanged(const QPoint &pos) {
|
|||
if (!layout || !layout->isWithinBounds(pos))
|
||||
return;
|
||||
|
||||
setStatusFromMapPos(pos);
|
||||
Scripting::cb_BlockHoverChanged(pos.x(), pos.y());
|
||||
}
|
||||
|
||||
void Editor::onMapHoverCleared() {
|
||||
updateCursorRectVisibility();
|
||||
if (getEditingLayout()) {
|
||||
ui->statusBar->clearMessage();
|
||||
}
|
||||
Scripting::cb_BlockHoverCleared();
|
||||
}
|
||||
|
||||
void Editor::setStatusFromMapPos(const QPoint &pos) {
|
||||
int x = pos.x();
|
||||
int y = pos.y();
|
||||
if (this->editMode == EditMode::Metatiles) {
|
||||
|
|
@ -1255,16 +1268,6 @@ void Editor::onMapHoverChanged(const QPoint &pos) {
|
|||
.arg(y)
|
||||
.arg(QString::number(zoomLevels[this->scaleIndex], 'g', 2)));
|
||||
}
|
||||
|
||||
Scripting::cb_BlockHoverChanged(x, y);
|
||||
}
|
||||
|
||||
void Editor::onMapHoverCleared() {
|
||||
updateCursorRectVisibility();
|
||||
if (getEditingLayout()) {
|
||||
ui->statusBar->clearMessage();
|
||||
}
|
||||
Scripting::cb_BlockHoverCleared();
|
||||
}
|
||||
|
||||
QString Editor::getMovementPermissionText(uint16_t collision, uint16_t elevation) {
|
||||
|
|
@ -1438,10 +1441,15 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *i
|
|||
|
||||
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
|
||||
|
||||
if (this->editMode == EditMode::Metatiles) {
|
||||
if (this->editMode == EditMode::Metatiles || this->editMode == EditMode::Collision) {
|
||||
if (editAction == EditAction::Paint) {
|
||||
if (event->buttons() & Qt::RightButton) {
|
||||
item->updateMetatileSelection(event);
|
||||
if (this->editMode == EditMode::Collision) {
|
||||
auto collisionItem = dynamic_cast<CollisionPixmapItem*>(item);
|
||||
if (collisionItem) collisionItem->updateMovementPermissionSelection(event);
|
||||
} else {
|
||||
item->updateMetatileSelection(event);
|
||||
}
|
||||
} else if (event->buttons() & Qt::MiddleButton) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
item->magicFill(event);
|
||||
|
|
@ -1457,18 +1465,24 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *i
|
|||
adjustStraightPathPos(event, item, &pos);
|
||||
item->paint(event);
|
||||
}
|
||||
setStatusFromMapPos(pos);
|
||||
} else if (editAction == EditAction::Select) {
|
||||
item->select(event);
|
||||
} else if (editAction == EditAction::Fill) {
|
||||
if (event->buttons() & Qt::RightButton) {
|
||||
item->updateMetatileSelection(event);
|
||||
if (this->editMode == EditMode::Metatiles) {
|
||||
item->updateMetatileSelection(event);
|
||||
} else {
|
||||
item->pick(event);
|
||||
}
|
||||
} else if (event->modifiers() & Qt::ControlModifier) {
|
||||
item->magicFill(event);
|
||||
} else {
|
||||
item->floodFill(event);
|
||||
}
|
||||
setStatusFromMapPos(pos);
|
||||
} else if (editAction == EditAction::Pick) {
|
||||
if (event->buttons() & Qt::RightButton) {
|
||||
if (this->editMode == EditMode::Metatiles && (event->buttons() & Qt::RightButton)) {
|
||||
item->updateMetatileSelection(event);
|
||||
} else if (event->type() != QEvent::GraphicsSceneMouseRelease) {
|
||||
item->pick(event);
|
||||
|
|
@ -1520,46 +1534,6 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *i
|
|||
}
|
||||
}
|
||||
|
||||
void Editor::mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item) {
|
||||
auto editAction = getEditAction();
|
||||
if (this->editMode != EditMode::Collision || editAction == EditAction::Move) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
|
||||
|
||||
if (editAction == EditAction::Paint) {
|
||||
if (event->buttons() & Qt::RightButton) {
|
||||
item->updateMovementPermissionSelection(event);
|
||||
} else if (event->buttons() & Qt::MiddleButton) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
item->magicFill(event);
|
||||
} else {
|
||||
item->floodFill(event);
|
||||
}
|
||||
} else {
|
||||
adjustStraightPathPos(event, item, &pos);
|
||||
item->paint(event);
|
||||
}
|
||||
} else if (editAction == EditAction::Select) {
|
||||
item->select(event);
|
||||
} else if (editAction == EditAction::Fill) {
|
||||
if (event->buttons() & Qt::RightButton) {
|
||||
item->pick(event);
|
||||
} else if (event->modifiers() & Qt::ControlModifier) {
|
||||
item->magicFill(event);
|
||||
} else {
|
||||
item->floodFill(event);
|
||||
}
|
||||
} else if (editAction == EditAction::Pick) {
|
||||
item->pick(event);
|
||||
} else if (editAction == EditAction::Shift) {
|
||||
adjustStraightPathPos(event, item, &pos);
|
||||
item->shift(event);
|
||||
}
|
||||
}
|
||||
|
||||
// On project close we want to leave the editor view empty.
|
||||
// Otherwise a map is normally only cleared when a new one is being displayed.
|
||||
void Editor::clearMap() {
|
||||
|
|
@ -1697,7 +1671,7 @@ void Editor::displayMapMovementPermissions() {
|
|||
|
||||
collision_item = new CollisionPixmapItem(this->layout, ui->spinBox_SelectedCollision, ui->spinBox_SelectedElevation,
|
||||
this->metatile_selector_item, this->settings, &this->collisionOpacity);
|
||||
connect(collision_item, &CollisionPixmapItem::mouseEvent, this, &Editor::mouseEvent_collision);
|
||||
connect(collision_item, &CollisionPixmapItem::mouseEvent, this, &Editor::mouseEvent_map);
|
||||
connect(collision_item, &CollisionPixmapItem::hoverEntered, this, &Editor::onMapHoverEntered);
|
||||
connect(collision_item, &CollisionPixmapItem::hoverChanged, this, &Editor::onMapHoverChanged);
|
||||
connect(collision_item, &CollisionPixmapItem::hoverCleared, this, &Editor::onMapHoverCleared);
|
||||
|
|
|
|||
|
|
@ -2,46 +2,6 @@
|
|||
#include "editcommands.h"
|
||||
#include "metatile.h"
|
||||
|
||||
void CollisionPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
|
||||
if (pos != this->previousPos) {
|
||||
this->previousPos = pos;
|
||||
emit this->hoverChanged(pos);
|
||||
}
|
||||
}
|
||||
|
||||
void CollisionPixmapItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) {
|
||||
this->has_mouse = true;
|
||||
this->previousPos = Metatile::coordFromPixmapCoord(event->pos());
|
||||
emit this->hoverEntered(this->previousPos);
|
||||
}
|
||||
|
||||
void CollisionPixmapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) {
|
||||
this->has_mouse = false;
|
||||
emit this->hoverCleared();
|
||||
}
|
||||
|
||||
void CollisionPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
|
||||
this->paint_tile_initial_x = this->straight_path_initial_x = pos.x();
|
||||
this->paint_tile_initial_y = this->straight_path_initial_y = pos.y();
|
||||
emit mouseEvent(event, this);
|
||||
}
|
||||
|
||||
void CollisionPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
|
||||
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
|
||||
if (pos != this->previousPos) {
|
||||
this->previousPos = pos;
|
||||
emit this->hoverChanged(pos);
|
||||
}
|
||||
emit mouseEvent(event, this);
|
||||
}
|
||||
|
||||
void CollisionPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||
this->lockedAxis = CollisionPixmapItem::Axis::None;
|
||||
emit mouseEvent(event, this);
|
||||
}
|
||||
|
||||
void CollisionPixmapItem::draw(bool ignoreCache) {
|
||||
if (this->layout) {
|
||||
this->layout->setCollisionItem(this);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user