mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-12 03:45:51 -05:00
Fix event sprite transparency regression
This commit is contained in:
@@ -18,6 +18,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
|
||||
- Fix actions triggered with the use of `utility.registerAction` calling all functions across plug-ins with the registered name, rather than just the function in the script that registered it.
|
||||
- Fix the tool tips for the tileset selectors always listing the same tileset size.
|
||||
- Fix event sprite names that appear in `symbol_obj_event_gfx_pointers` by value and not by name not rendering with the correct sprite.
|
||||
- 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);
|
||||
|
||||
@@ -28,6 +28,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 +37,7 @@ private:
|
||||
bool m_active = false;
|
||||
bool m_selected = false;
|
||||
bool m_releaseSelectionQueued = false;
|
||||
std::optional<qreal> m_opacityOverride = {};
|
||||
|
||||
void updatePixelPosition();
|
||||
|
||||
|
||||
@@ -1788,7 +1788,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);
|
||||
@@ -2046,34 +2045,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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user