diff --git a/src/Host.cpp b/src/Host.cpp index d7960625b1f..5fe0f394662 100644 --- a/src/Host.cpp +++ b/src/Host.cpp @@ -262,45 +262,6 @@ Host::Host(int port, const QString& hostname, const QString& login, const QStrin , mEditorThemeFile(QLatin1String("Mudlet.tmTheme")) , mThemePreviewItemID(-1) , mThemePreviewType(QString()) -, mBlack(QColorConstants::Black) -, mLightBlack(QColorConstants::DarkGray) -, mRed(QColorConstants::DarkRed) -, mLightRed(QColorConstants::Red) -, mLightGreen(QColorConstants::Green) -, mGreen(QColorConstants::DarkGreen) -, mLightBlue(QColorConstants::Blue) -, mBlue(QColorConstants::DarkBlue) -, mLightYellow(QColorConstants::Yellow) -, mYellow(QColorConstants::DarkYellow) -, mLightCyan(QColorConstants::Cyan) -, mCyan(QColorConstants::DarkCyan) -, mLightMagenta(QColorConstants::Magenta) -, mMagenta(QColorConstants::DarkMagenta) -, mLightWhite(QColorConstants::White) -, mWhite(QColorConstants::LightGray) -, mFgColor(QColorConstants::LightGray) -, mBgColor(QColorConstants::Black) -, mCommandBgColor(QColorConstants::Black) -, mCommandFgColor(QColor(113, 113, 0)) -, mBlack_2(QColorConstants::Black) -, mLightBlack_2(QColorConstants::DarkGray) -, mRed_2(QColorConstants::DarkRed) -, mLightRed_2(QColorConstants::Red) -, mLightGreen_2(QColorConstants::Green) -, mGreen_2(QColorConstants::DarkGreen) -, mLightBlue_2(QColorConstants::Blue) -, mBlue_2(QColorConstants::DarkBlue) -, mLightYellow_2(QColorConstants::Yellow) -, mYellow_2(QColorConstants::DarkYellow) -, mLightCyan_2(QColorConstants::Cyan) -, mCyan_2(QColorConstants::DarkCyan) -, mLightMagenta_2(QColorConstants::Magenta) -, mMagenta_2(QColorConstants::DarkMagenta) -, mLightWhite_2(QColorConstants::White) -, mWhite_2(QColorConstants::LightGray) -, mFgColor_2(QColorConstants::LightGray) -, mBgColor_2(QColorConstants::Black) -, mRoomBorderColor(QColorConstants::LightGray) , mMapStrongHighlight(false) , mEnableSpellCheck(true) , mDiscordDisableServerSide(true) diff --git a/src/Host.h b/src/Host.h index eda0c2a7c9b..18a85224d80 100644 --- a/src/Host.h +++ b/src/Host.h @@ -577,46 +577,48 @@ class Host : public QObject // the type of item (a trigger, an alias, etc) that's previewed QString mThemePreviewType; - QColor mBlack; - QColor mLightBlack; - QColor mRed; - QColor mLightRed; - QColor mLightGreen; - QColor mGreen; - QColor mLightBlue; - QColor mBlue; - QColor mLightYellow; - QColor mYellow; - QColor mLightCyan; - QColor mCyan; - QColor mLightMagenta; - QColor mMagenta; - QColor mLightWhite; - QColor mWhite; - QColor mFgColor; - QColor mBgColor; - QColor mCommandBgColor; - QColor mCommandFgColor; - - QColor mBlack_2; - QColor mLightBlack_2; - QColor mRed_2; - QColor mLightRed_2; - QColor mLightGreen_2; - QColor mGreen_2; - QColor mLightBlue_2; - QColor mBlue_2; - QColor mLightYellow_2; - QColor mYellow_2; - QColor mLightCyan_2; - QColor mCyan_2; - QColor mLightMagenta_2; - QColor mMagenta_2; - QColor mLightWhite_2; - QColor mWhite_2; - QColor mFgColor_2; - QColor mBgColor_2; - QColor mRoomBorderColor; + QColor mBlack{QColorConstants::Black}; + QColor mLightBlack{QColorConstants::DarkGray}; + QColor mRed{QColorConstants::DarkRed}; + QColor mLightRed{QColorConstants::Red}; + QColor mLightGreen{QColorConstants::Green}; + QColor mGreen{QColorConstants::DarkGreen}; + QColor mLightBlue{QColorConstants::Blue}; + QColor mBlue{QColorConstants::DarkBlue}; + QColor mLightYellow{QColorConstants::Yellow}; + QColor mYellow{QColorConstants::DarkYellow}; + QColor mLightCyan{QColorConstants::Cyan}; + QColor mCyan{QColorConstants::DarkCyan}; + QColor mLightMagenta{QColorConstants::Magenta}; + QColor mMagenta{QColorConstants::DarkMagenta}; + QColor mLightWhite{QColorConstants::White}; + QColor mWhite{QColorConstants::LightGray}; + QColor mFgColor{QColorConstants::LightGray}; + QColor mBgColor{QColorConstants::Black}; + QColor mCommandBgColor{QColorConstants::Black}; + QColor mCommandFgColor{QColor(113, 113, 0)}; + + QColor mBlack_2{QColorConstants::Black}; + QColor mLightBlack_2{QColorConstants::DarkGray}; + QColor mRed_2{QColorConstants::DarkRed}; + QColor mLightRed_2{QColorConstants::Red}; + QColor mLightGreen_2{QColorConstants::Green}; + QColor mGreen_2{QColorConstants::DarkGreen}; + QColor mLightBlue_2{QColorConstants::Blue}; + QColor mBlue_2{QColorConstants::DarkBlue}; + QColor mLightYellow_2{QColorConstants::Yellow}; + QColor mYellow_2{QColorConstants::DarkYellow}; + QColor mLightCyan_2{QColorConstants::Cyan}; + QColor mCyan_2{QColorConstants::DarkCyan}; + QColor mLightMagenta_2{QColorConstants::Magenta}; + QColor mMagenta_2{QColorConstants::DarkMagenta}; + QColor mLightWhite_2{QColorConstants::White}; + QColor mWhite_2{QColorConstants::LightGray}; + QColor mFgColor_2{QColorConstants::LightGray}; + QColor mBgColor_2{QColorConstants::Black}; + QColor mRoomBorderColor{QColorConstants::LightGray}; + QColor mRoomCollisionBorderColor{QColorConstants::Yellow}; + QColor mMapInfoBg = QColor(150, 150, 150, 120); bool mMapStrongHighlight; QStringList mGMCP_merge_table_keys; diff --git a/src/T2DMap.cpp b/src/T2DMap.cpp index 07343f6bf6a..d74fde4ce31 100644 --- a/src/T2DMap.cpp +++ b/src/T2DMap.cpp @@ -589,7 +589,7 @@ void T2DMap::initiateSpeedWalk(const int speedWalkStartRoomId, const int speedWa // player's room if it is visible. This is so it is drawn LAST (and any effects, // or extra markings for it do not get overwritten by the drawing of the other // rooms)... -inline void T2DMap::drawRoom(QPainter& painter, +/* inline */ void T2DMap::drawRoom(QPainter& painter, QFont& roomVNumFont, QFont& mapNameFont, QPen& pen, @@ -600,7 +600,8 @@ inline void T2DMap::drawRoom(QPainter& painter, const int speedWalkStartRoomId, const float rx, const float ry, - const QMap& areaExitsMap) + const QMap& areaExitsMap, + const bool showRoomCollision) { const int currentRoomId = pRoom->getId(); pRoom->rendered = false; @@ -696,19 +697,25 @@ inline void T2DMap::drawRoom(QPainter& painter, roomPen.setWidth(borderWidth); painter.setBrush(roomColor); - if (shouldDrawBorder && mRoomWidth >= 12) { - roomPen.setColor(mpHost->mRoomBorderColor); + if (showRoomCollision) { + roomPen.setColor(mpHost->mRoomCollisionBorderColor); } else if (shouldDrawBorder) { - auto fadingColor = QColor(mpHost->mRoomBorderColor); - fadingColor.setAlpha(255 * (mRoomWidth / 12)); - roomPen.setColor(fadingColor); + if (mRoomWidth >= 12) { + roomPen.setColor(mpHost->mRoomBorderColor); + } else if (shouldDrawBorder) { + auto fadingColor = QColor(mpHost->mRoomBorderColor); + fadingColor.setAlpha(255 * (mRoomWidth / 12)); + roomPen.setColor(fadingColor); + } } if (isRoomSelected) { QLinearGradient selectionBg(roomRectangle.topLeft(), roomRectangle.bottomRight()); selectionBg.setColorAt(0.2, roomColor); selectionBg.setColorAt(1, Qt::blue); - roomPen.setColor(QColor(255, 50, 50)); + if (!showRoomCollision) { + roomPen.setColor(QColor(255, 50, 50)); + } painter.setBrush(selectionBg); } @@ -1409,6 +1416,8 @@ void T2DMap::paintEvent(QPaintEvent* e) QPointF playerRoomOnWidgetCoordinates; bool isPlayerRoomVisible = false; + // QPoint doesn't work here as the key as it can't be hashed...! + QSet> usedRoomPositions; // Draw the rooms: QSetIterator itRoom(pDrawnArea->getAreaRooms()); while (itRoom.hasNext()) { @@ -1433,13 +1442,18 @@ void T2DMap::paintEvent(QPaintEvent* e) isPlayerRoomVisible = true; playerRoomOnWidgetCoordinates = QPointF(static_cast(rx), static_cast(ry)); } else { - // Not the player's room: - drawRoom(painter, roomVNumFont, mapNameFont, pen, room, pDrawnArea->gridMode, isFontBigEnoughToShowRoomVnum, showRoomNames, playerRoomId, rx, ry, areaExitsMap); + // Not the player's room + const QPair roomPos{room->x(), room->y()}; + const bool roomCollision = usedRoomPositions.contains(roomPos); + usedRoomPositions.insert(roomPos); + drawRoom(painter, roomVNumFont, mapNameFont, pen, room, pDrawnArea->gridMode, isFontBigEnoughToShowRoomVnum, showRoomNames, playerRoomId, rx, ry, areaExitsMap, roomCollision); } } // End of while loop for each room in area if (isPlayerRoomVisible) { - drawRoom(painter, roomVNumFont, mapNameFont, pen, pPlayerRoom, pDrawnArea->gridMode, isFontBigEnoughToShowRoomVnum, showRoomNames, playerRoomId, static_cast(playerRoomOnWidgetCoordinates.x()), static_cast(playerRoomOnWidgetCoordinates.y()), areaExitsMap); + const QPair roomPos{pPlayerRoom->x(), pPlayerRoom->y()}; + const bool roomCollision = usedRoomPositions.contains(roomPos); + drawRoom(painter, roomVNumFont, mapNameFont, pen, pPlayerRoom, pDrawnArea->gridMode, isFontBigEnoughToShowRoomVnum, showRoomNames, playerRoomId, static_cast(playerRoomOnWidgetCoordinates.x()), static_cast(playerRoomOnWidgetCoordinates.y()), areaExitsMap, roomCollision); painter.save(); const QPen transparentPen(Qt::transparent); QPainterPath myPath; diff --git a/src/T2DMap.h b/src/T2DMap.h index b107ce3e842..dd01764bfab 100644 --- a/src/T2DMap.h +++ b/src/T2DMap.h @@ -254,7 +254,7 @@ public slots: std::pair getMousePosition(); bool checkButtonIsForGivenDirection(const QPushButton*, const QString&, const int&); bool sizeFontToFitTextInRect(QFont&, const QRectF&, const QString&, const quint8 percentageMargin = 10, const qreal minFontSize = 7.0); - void drawRoom(QPainter&, QFont&, QFont&, QPen&, TRoom*, const bool isGridMode, const bool areRoomIdsLegible, const bool showRoomNames, const int, const float, const float, const QMap&); + inline void drawRoom(QPainter&, QFont&, QFont&, QPen&, TRoom*, const bool isGridMode, const bool areRoomIdsLegible, const bool showRoomNames, const int, const float, const float, const QMap&, const bool showRoomCollision); void paintMapInfo(const QElapsedTimer& renderTimer, QPainter& painter, const int displayAreaId, QColor& infoColor); int paintMapInfoContributor(QPainter&, int xOffset, int yOffset, const MapInfoProperties& properties); void paintRoomExits(QPainter&, QPen&, QList& exitList, QList& oneWayExits, const TArea*, int, float, QMap&); diff --git a/src/XMLexport.cpp b/src/XMLexport.cpp index 67d0e0085b0..0dbe38ed169 100644 --- a/src/XMLexport.cpp +++ b/src/XMLexport.cpp @@ -571,6 +571,7 @@ void XMLexport::writeHost(Host* pHost, pugi::xml_node mudletPackage) host.append_child("mFgColor2").text().set(pHost->mFgColor_2.name().toUtf8().constData()); host.append_child("mBgColor2").text().set(pHost->mBgColor_2.name().toUtf8().constData()); host.append_child("mRoomBorderColor").text().set(pHost->mRoomBorderColor.name().toUtf8().constData()); + host.append_child("mRoomCollisionBorderColor").text().set(pHost->mRoomCollisionBorderColor.name().toUtf8().constData()); auto mapInfoBgNode = host.append_child("mMapInfoBg"); mapInfoBgNode.text().set(pHost->mMapInfoBg.name().toUtf8().constData()); mapInfoBgNode.append_attribute("alpha").set_value(pHost->mMapInfoBg.alpha()); diff --git a/src/XMLimport.cpp b/src/XMLimport.cpp index dbb2fb72278..7f13b37517a 100644 --- a/src/XMLimport.cpp +++ b/src/XMLimport.cpp @@ -1180,6 +1180,8 @@ void XMLimport::readHost(Host* pHost) pHost->mBgColor_2.setNamedColor(readElementText()); } else if (name() == qsl("mRoomBorderColor")) { pHost->mRoomBorderColor.setNamedColor(readElementText()); + } else if (name() == qsl("mRoomCollisionBorderColor")) { + pHost->mRoomCollisionBorderColor.setNamedColor(readElementText()); } else if (name() == qsl("mMapInfoBg")) { auto alpha = (attributes().hasAttribute(qsl("alpha"))) ? attributes().value(qsl("alpha")).toInt() : 255; pHost->mMapInfoBg.setNamedColor(readElementText()); @@ -1222,6 +1224,8 @@ void XMLimport::readHost(Host* pHost) pHost->mBgColor_2 = QColor::fromString(readElementText()); } else if (name() == qsl("mRoomBorderColor")) { pHost->mRoomBorderColor = QColor::fromString(readElementText()); + } else if (name() == qsl("mRoomCollisionBorderColor")) { + pHost->mRoomCollisionBorderColor = QColor::fromString(readElementText()); } else if (name() == qsl("mMapInfoBg")) { auto alpha = (attributes().hasAttribute(qsl("alpha"))) ? attributes().value(qsl("alpha")).toInt() : 255; pHost->mMapInfoBg = QColor::fromString(readElementText()); diff --git a/src/dlgProfilePreferences.cpp b/src/dlgProfilePreferences.cpp index 384dd441af7..1a471e1be6f 100644 --- a/src/dlgProfilePreferences.cpp +++ b/src/dlgProfilePreferences.cpp @@ -1233,6 +1233,7 @@ void dlgProfilePreferences::initWithHost(Host* pHost) connect(pushButton_background_color_2, &QAbstractButton::clicked, this, &dlgProfilePreferences::slot_setMapBgColor); connect(pushButton_roomBorderColor, &QAbstractButton::clicked, this, &dlgProfilePreferences::slot_setMapRoomBorderColor); connect(pushButton_mapInfoBg, &QAbstractButton::clicked, this, &dlgProfilePreferences::slot_setMapInfoBgColor); + connect(pushButton_roomCollisionBorderColor, &QAbstractButton::clicked, this, &dlgProfilePreferences::slot_setMapRoomCollisionBorderColor); connect(mEnableGMCP, &QAbstractButton::clicked, need_reconnect_for_data_protocol, &QWidget::show); connect(mEnableMSDP, &QAbstractButton::clicked, need_reconnect_for_data_protocol, &QWidget::show); @@ -1351,6 +1352,7 @@ void dlgProfilePreferences::disconnectHostRelatedControls() disconnect(pushButton_background_color_2, &QAbstractButton::clicked, nullptr, nullptr); disconnect(pushButton_roomBorderColor, &QAbstractButton::clicked, nullptr, nullptr); disconnect(pushButton_mapInfoBg, &QAbstractButton::clicked, nullptr, nullptr); + disconnect(pushButton_roomCollisionBorderColor, &QAbstractButton::clicked, nullptr, nullptr); disconnect(mEnableGMCP, &QAbstractButton::clicked, nullptr, nullptr); disconnect(mEnableMSSP, &QAbstractButton::clicked, nullptr, nullptr); @@ -1651,6 +1653,7 @@ void dlgProfilePreferences::setColors2() pushButton_background_color_2->setStyleSheet(mudlet::self()->mBG_ONLY_STYLESHEET.arg(pHost->mBgColor_2.name())); pushButton_roomBorderColor->setStyleSheet(mudlet::self()->mBG_ONLY_STYLESHEET.arg(pHost->mRoomBorderColor.name())); pushButton_mapInfoBg->setStyleSheet(mudlet::self()->mBG_ONLY_STYLESHEET.arg(pHost->mMapInfoBg.name())); + pushButton_roomCollisionBorderColor->setStyleSheet(mudlet::self()->mBG_ONLY_STYLESHEET.arg(pHost->mRoomCollisionBorderColor.name())); } else { pushButton_black_2->setStyleSheet(QString()); pushButton_Lblack_2->setStyleSheet(QString()); @@ -1673,6 +1676,7 @@ void dlgProfilePreferences::setColors2() pushButton_background_color_2->setStyleSheet(QString()); pushButton_roomBorderColor->setStyleSheet(QString()); pushButton_mapInfoBg->setStyleSheet(QString()); + pushButton_roomCollisionBorderColor->setStyleSheet(QString()); } } @@ -1748,6 +1752,7 @@ void dlgProfilePreferences::slot_resetMapColors() pHost->mFgColor_2 = Qt::lightGray; pHost->mBgColor_2 = Qt::black; pHost->mRoomBorderColor = Qt::lightGray; + pHost->mRoomCollisionBorderColor = Qt::yellow; pHost->mBlack_2 = Qt::black; pHost->mLightBlack_2 = Qt::darkGray; pHost->mRed_2 = Qt::darkRed; @@ -2100,6 +2105,14 @@ void dlgProfilePreferences::slot_setMapRoomBorderColor() } } +void dlgProfilePreferences::slot_setMapRoomCollisionBorderColor() +{ + Host* pHost = mpHost; + if (pHost) { + setButtonAndProfileColor(pushButton_roomCollisionBorderColor, pHost->mRoomCollisionBorderColor); + } +} + void dlgProfilePreferences::slot_setMapInfoBgColor() { Host* pHost = mpHost; diff --git a/src/dlgProfilePreferences.h b/src/dlgProfilePreferences.h index 639508fc986..ad4d45110f6 100644 --- a/src/dlgProfilePreferences.h +++ b/src/dlgProfilePreferences.h @@ -106,6 +106,7 @@ public slots: void slot_setMapBgColor(); void slot_setMapRoomBorderColor(); void slot_setMapInfoBgColor(); + void slot_setMapRoomCollisionBorderColor(); void slot_resetMapColors(); // Map. diff --git a/src/main.cpp b/src/main.cpp index 8d2f075ad24..b810ef53b2e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -199,11 +199,13 @@ int main(int argc, char* argv[]) // is open - see https://bugreports.qt.io/browse/QTBUG-41257 QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); #elif defined(Q_OS_FREEBSD) +#if defined(INCLUDE_3DMAPPER) // Cure for diagnostic: // "Qt WebEngine seems to be initialized from a plugin. Please set // Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute // before constructing QGuiApplication." QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); +#endif // INCLUDE_3DMAPPER #endif auto app = qobject_cast(new QApplication(argc, argv)); diff --git a/src/ui/profile_preferences.ui b/src/ui/profile_preferences.ui index 8f0a3707bae..7e3092cc15a 100644 --- a/src/ui/profile_preferences.ui +++ b/src/ui/profile_preferences.ui @@ -2480,14 +2480,34 @@ you can use it but there could be issues with aligning columns of text - + + + + Overlapping rooms border: + + + pushButton_roomCollisionBorderColor + + + + + + + true + + + + + + + Qt::Horizontal - + Black: @@ -2497,7 +2517,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2507,7 +2527,7 @@ you can use it but there could be issues with aligning columns of text - + Light black: @@ -2517,7 +2537,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2527,7 +2547,7 @@ you can use it but there could be issues with aligning columns of text - + Red: @@ -2537,7 +2557,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2547,7 +2567,7 @@ you can use it but there could be issues with aligning columns of text - + Light red: @@ -2557,7 +2577,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2567,7 +2587,7 @@ you can use it but there could be issues with aligning columns of text - + Green: @@ -2577,7 +2597,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2587,7 +2607,7 @@ you can use it but there could be issues with aligning columns of text - + Light green: @@ -2597,7 +2617,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2607,7 +2627,7 @@ you can use it but there could be issues with aligning columns of text - + Yellow: @@ -2617,7 +2637,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2627,7 +2647,7 @@ you can use it but there could be issues with aligning columns of text - + Light yellow: @@ -2637,7 +2657,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2647,7 +2667,7 @@ you can use it but there could be issues with aligning columns of text - + Blue: @@ -2657,7 +2677,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2667,7 +2687,7 @@ you can use it but there could be issues with aligning columns of text - + Light blue: @@ -2677,7 +2697,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2687,7 +2707,7 @@ you can use it but there could be issues with aligning columns of text - + Magenta: @@ -2697,7 +2717,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2707,7 +2727,7 @@ you can use it but there could be issues with aligning columns of text - + Light magenta: @@ -2717,7 +2737,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2727,7 +2747,7 @@ you can use it but there could be issues with aligning columns of text - + Cyan: @@ -2737,7 +2757,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2747,7 +2767,7 @@ you can use it but there could be issues with aligning columns of text - + Light cyan: @@ -2757,7 +2777,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2767,7 +2787,7 @@ you can use it but there could be issues with aligning columns of text - + White: @@ -2777,7 +2797,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2787,7 +2807,7 @@ you can use it but there could be issues with aligning columns of text - + Light white: @@ -2797,7 +2817,7 @@ you can use it but there could be issues with aligning columns of text - + true @@ -2807,7 +2827,7 @@ you can use it but there could be issues with aligning columns of text - + Reset all colors to default @@ -4272,6 +4292,7 @@ you can use it but there could be issues with aligning columns of text spinBox_playerRoomInnerDiameter pushButton_foreground_color_2 pushButton_roomBorderColor + pushButton_roomCollisionBorderColor pushButton_background_color_2 pushButton_mapInfoBg pushButton_black_2