Speed up opening maps with many warp events

This commit is contained in:
GriffinR 2025-04-03 18:40:39 -04:00
parent a898791a70
commit e1aaf3c18e
3 changed files with 8 additions and 2 deletions

View File

@ -336,10 +336,12 @@ public:
QString getDestinationWarpID() const { return this->destinationWarpID; }
void setWarningEnabled(bool enabled);
bool getWarningEnabled() const { return this->warningEnabled; }
private:
QString destinationMap;
QString destinationWarpID;
bool warningEnabled = false;
};

View File

@ -425,7 +425,11 @@ QSet<QString> WarpEvent::getExpectedFields() {
}
void WarpEvent::setWarningEnabled(bool enabled) {
WarpFrame * frame = static_cast<WarpFrame*>(this->getEventFrame());
this->warningEnabled = enabled;
// Don't call getEventFrame here, because it may create the event frame.
// If the frame hasn't been created yet then we have nothing else to do.
auto frame = static_cast<WarpFrame*>(this->eventFrame.data());
if (frame && frame->warning)
frame->warning->setVisible(enabled);
}

View File

@ -516,7 +516,7 @@ void WarpFrame::setup() {
this->warning = new QPushButton(warningText, this);
this->warning->setFlat(true);
this->warning->setStyleSheet("color: red; text-align: left");
this->warning->setVisible(false);
this->warning->setVisible(this->warp->getWarningEnabled());
l_vbox_warning->addWidget(this->warning);
this->layout_contents->addLayout(l_vbox_warning);