mirror of
https://github.com/huderlem/porymap.git
synced 2026-04-16 22:55:55 -05:00
Fix event sprite transparency regression
This commit is contained in:
parent
bd78f8de52
commit
f1e507d97e
|
|
@ -8,6 +8,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
|
|||
### Fixed
|
||||
- Fix degraded image quality in exported timelapse gifs.
|
||||
- Fix custom top-level data in the `encounters` object of `wild_encounters.json` being discarded if no `fields` data is present.
|
||||
- Fix event sprites sometimes rendering with incorrect transparency temporarily after a sprite change.
|
||||
|
||||
## [6.3.0] - 2025-12-26
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -118,7 +118,6 @@ public:
|
|||
void redrawEvents(const QList<Event*> &events);
|
||||
void redrawEventPixmapItem(EventPixmapItem *item);
|
||||
void updateEventPixmapItemZValue(EventPixmapItem *item);
|
||||
qreal getEventOpacity(const Event *event) const;
|
||||
|
||||
bool isMouseInMap() const;
|
||||
void setPlayerViewRect(const QRectF &rect);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <QGraphicsItemAnimation>
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <optional>
|
||||
|
||||
#include "events.h"
|
||||
|
||||
|
|
@ -28,6 +29,8 @@ public:
|
|||
void moveTo(int x, int y);
|
||||
void moveTo(const QPoint &pos);
|
||||
|
||||
void setOpacityOverride(qreal opacity) { m_opacityOverride = opacity;}
|
||||
void clearOpacityOverride() { m_opacityOverride.reset(); }
|
||||
private:
|
||||
QPixmap m_basePixmap;
|
||||
Event *const m_event = nullptr;
|
||||
|
|
@ -35,6 +38,7 @@ private:
|
|||
bool m_active = false;
|
||||
bool m_selected = false;
|
||||
bool m_releaseSelectionQueued = false;
|
||||
std::optional<qreal> m_opacityOverride = {};
|
||||
|
||||
void updatePixelPosition();
|
||||
|
||||
|
|
|
|||
|
|
@ -1790,7 +1790,6 @@ void Editor::displayMapEvents() {
|
|||
}
|
||||
|
||||
EventPixmapItem *Editor::addEventPixmapItem(Event *event) {
|
||||
this->project->loadEventPixmap(event);
|
||||
auto item = new EventPixmapItem(event);
|
||||
connect(item, &EventPixmapItem::doubleClicked, this, &Editor::openEventMap);
|
||||
connect(item, &EventPixmapItem::dragged, this, &Editor::onEventDragged);
|
||||
|
|
@ -2048,34 +2047,22 @@ void Editor::redrawEvents(const QList<Event*> &events) {
|
|||
}
|
||||
}
|
||||
|
||||
qreal Editor::getEventOpacity(const Event *event) const {
|
||||
// There are 4 possible opacities for an event's sprite:
|
||||
// - Off the Events tab, and the event overlay is off (0.0)
|
||||
// - Off the Events tab, and the event overlay is on (0.5)
|
||||
// - On the Events tab, and the event has a default sprite (0.7)
|
||||
// - On the Events tab, and the event has a custom sprite (1.0)
|
||||
if (this->editMode != EditMode::Events)
|
||||
return porymapConfig.eventOverlayEnabled ? 0.5 : 0.0;
|
||||
return event->getUsesDefaultPixmap() ? 0.7 : 1.0;
|
||||
}
|
||||
|
||||
void Editor::redrawEventPixmapItem(EventPixmapItem *item) {
|
||||
if (!item) return;
|
||||
Event *event = item->getEvent();
|
||||
if (!event) return;
|
||||
|
||||
if (this->editMode == EditMode::Events) {
|
||||
item->setAcceptedMouseButtons(Qt::AllButtons);
|
||||
item->setSelected(this->selectedEvents.contains(event));
|
||||
item->setSelected(item->getEvent() ? this->selectedEvents.contains(item->getEvent()) : false);
|
||||
item->clearOpacityOverride();
|
||||
} else {
|
||||
// Can't interact with event pixmaps outside of event editing mode.
|
||||
// We could do setEnabled(false), but rather than ignoring the mouse events this
|
||||
// would reject them, which would prevent painting on the map behind the events.
|
||||
item->setAcceptedMouseButtons(Qt::NoButton);
|
||||
item->setSelected(false);
|
||||
// When not on the events tab, events are only visible if certain settings are enabled.
|
||||
item->setOpacityOverride(porymapConfig.eventOverlayEnabled ? 0.5 : 0.0);
|
||||
}
|
||||
updateEventPixmapItemZValue(item);
|
||||
item->setOpacity(getEventOpacity(event));
|
||||
item->setShapeMode(porymapConfig.eventSelectionShapeMode);
|
||||
item->render(project);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,14 @@ void EventPixmapItem::render(Project *project) {
|
|||
|
||||
m_basePixmap = m_event->loadPixmap(project);
|
||||
|
||||
if (m_opacityOverride.has_value()) {
|
||||
setOpacity(m_opacityOverride.value());
|
||||
} else {
|
||||
// This can only happen after loading the pixmap above,
|
||||
// as whether we're using the default or not may have changed.
|
||||
setOpacity(m_event->getUsesDefaultPixmap() ? 0.7 : 1.0);
|
||||
}
|
||||
|
||||
// If the base pixmap changes, the event's pixel position may change.
|
||||
updatePixelPosition();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user