Improve: add door symbol display to custom exits lines and to stubs#4608
Conversation
This PR will also allow colors for open/closed/locked doors to be customised in the future (by adjusting the new `T2DMap` `QColor` members: `mOpenDoorColor`, `mClosedDoorColor` and `mLockedDoorColor`. Moved the `QMap<int, QPoint> mAreaExitsList` member out of the class header - it is now a local `areaExitsList` value held in the `paintEvent(...)` method and passed by reference to a couple of paint helper methods. Revise the code that painted exit stubs as the formulas being used to work out the inner and outer points on the line were wrong - and as they were dependent on the room size the stubs changed as the room size did. Since we may now be painting a door marker on them it is easier if the length is constant and does not depend on the room size. Since we are now able to show door markings on custom exit lines (including on special exits) and stub exits the tool-tips in the room exits control panel is updated to now reflect this. This will close Mudlet#499 and close Mudlet#668 and address an issue that Fuligin raised in the Discord # help channel on 2021/01/08 . Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
Hey there! Thanks for helping Mudlet improve. 🌟 Test versionsYou can directly test the changes here:
No need to install anything - just unzip and run. |
|
Also a comment I made in another issue #2427 (comment) describes the sort of thing that I have finally done... |
This actually doubles the amount that area exits stick out from the starting room and revises the drawing code so that it is not so dependent on the room size (which modified the `exitWidth` local that the code was using). The particular detail that required this commit was that the way that the underlying line was drawn that was used to derive the door symbol from had the start and end points the opposite way around to that which I had developed the code for! Whilst cleaning things up I spotted that there was a redundant conversion from a `QPointF` to a `QPoint` and then back to a `QPointF` when handling the area exit click location - that is used to record when an area exit is (double) clicked upon to initiate a speedwalk to the room in the adjacent area. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Delwing
left a comment
There was a problem hiding this comment.
Looks good imho.
Although I must admit that I would like non-curve doors.
|
What would you like to see? |
|
Some straight lines :) But this is just a matter of taste I guess. |
|
They were shaped so that when the two rooms are close together and only one direction has a door it is clear to see which direction it applies to... |
|
That's a good point, but majority of the doors are two way, and it does look like a funny little chromosome now. Do you think it can be improved? |
|
How about shape like that? Line with a little triangle in the middle indicating way in case of one way door. |
|
Actually the simplest modification would be to take out the middle section so that you have a pair of "outward opening" doors, either side of the exit line:
Since the two directions are handled separately (as they are each associated with the room the exit leaves from) trying to do that would get more complicated and involved - it would require trying to determine whether the exit was an area exit (which by definition is treated as one way even when it isn't) and whether it was a two or one way exit otherwise... |
As requested during review. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
I agree something is wrong - note that when the destination room is off the map then there should now still be half a line going towards it from the room that is on the map - in the past I think there could have been some cases where the whole line was missed out. 🤔 ... also, it does seem to be a bit arbitrary as to the room(s) that this is going wrong for! |
|
Yeah, strange. |
…xitsLinesAndToStubs
|
@Delwing do you have a small test map that reproduces this. I've gone looking for it and haven't spotted the bug currently but I agree it is there somewhere... |
|
You can find it in https://github.com/IRE-Mudlet-Mapping/AchaeaCrowdmap/blob/gh-pages/Map/map, have a look at room 11122. |
|
Sure, |
…xitsLinesAndToStubs Needed to pull in exit line drawing bug fix. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
…xitsLinesAndToStubs
…xitsLinesAndToStubs Needed to include fix for crashing on exit in TTimerUnit destructor. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Make them a bit (150%) thicker and a little longer. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
This looks exciting! |
…xitsLinesAndToStubs Conflicts resolved in: * src/T2DMap.h * src/TMap.cpp * src/TRoom.h Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
keneanung
left a comment
There was a problem hiding this comment.
The UI text changes seem good to me. I didn't delve into the C++ part, though.
…xitsLinesAndToStubs
| } | ||
|
|
||
| void T2DMap::paintAreaExits(QPainter& painter, QPen& pen, QList<int>& exitList, QList<int>& oneWayExits, const TArea* pArea, int zLevel, float exitWidth) | ||
| void T2DMap::drawDoor(QPainter& painter, const TRoom& room, const QString& dirKey, const QLineF& exitLine) |
There was a problem hiding this comment.
warning: method drawDoor can be made const [readability-make-member-function-const]
void T2DMap::drawDoor(QPainter& painter, const TRoom& room, const QString& dirKey, const QLineF& exitLine)
^
const
src/T2DMap.cpp
Outdated
| if (room->getSouth() == rID) { | ||
| _line = QLine(p2.x(), p2.y() + mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x(), p2.y() + mRoomHeight / 2.0); | ||
| line = QLine(p2.x(), p2.y() + 2.0 * mRoomHeight, |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
line = QLine(p2.x(), p2.y() + 2.0 * mRoomHeight,
^
src/T2DMap.cpp
Outdated
| if (room->getSouth() == rID) { | ||
| _line = QLine(p2.x(), p2.y() + mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x(), p2.y() + mRoomHeight / 2.0); | ||
| line = QLine(p2.x(), p2.y() + 2.0 * mRoomHeight, |
There was a problem hiding this comment.
warning: narrowing conversion from double to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
line = QLine(p2.x(), p2.y() + 2.0 * mRoomHeight,
^
src/T2DMap.cpp
Outdated
| _line = QLine(p2.x(), p2.y() + mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x(), p2.y() + mRoomHeight / 2.0); | ||
| line = QLine(p2.x(), p2.y() + 2.0 * mRoomHeight, | ||
| p2.x(), p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
p2.x(), p2.y());
^
src/T2DMap.cpp
Outdated
| _line = QLine(p2.x(), p2.y() + mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x(), p2.y() + mRoomHeight / 2.0); | ||
| line = QLine(p2.x(), p2.y() + 2.0 * mRoomHeight, | ||
| p2.x(), p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
p2.x(), p2.y());
^
src/T2DMap.cpp
Outdated
| } else if (room->getEast() == rID) { | ||
| _line = QLine(p2.x() + mRoomWidth, p2.y(), p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() + mRoomWidth / 2.0, p2.y()); | ||
| line = QLine(p2.x() + 2.0 * mRoomWidth, p2.y(), |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
line = QLine(p2.x() + 2.0 * mRoomWidth, p2.y(),
^
src/T2DMap.cpp
Outdated
| _line = QLine(p2.x() + mRoomWidth, p2.y(), p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() + mRoomWidth / 2.0, p2.y()); | ||
| line = QLine(p2.x() + 2.0 * mRoomWidth, p2.y(), | ||
| p2.x(), p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
p2.x(), p2.y());
^
src/T2DMap.cpp
Outdated
| _line = QLine(p2.x() + mRoomWidth, p2.y(), p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() + mRoomWidth / 2.0, p2.y()); | ||
| line = QLine(p2.x() + 2.0 * mRoomWidth, p2.y(), | ||
| p2.x(), p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
p2.x(), p2.y());
^
src/T2DMap.cpp
Outdated
| _p = QPoint(p2.x() + mRoomWidth / 2.0, p2.y()); | ||
| line = QLine(p2.x() + 2.0 * mRoomWidth, p2.y(), | ||
| p2.x(), p2.y()); | ||
| clickPoint = QPoint(p2.x() + mRoomWidth, p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
clickPoint = QPoint(p2.x() + mRoomWidth, p2.y());
^
src/T2DMap.cpp
Outdated
| _p = QPoint(p2.x() + mRoomWidth / 2.0, p2.y()); | ||
| line = QLine(p2.x() + 2.0 * mRoomWidth, p2.y(), | ||
| p2.x(), p2.y()); | ||
| clickPoint = QPoint(p2.x() + mRoomWidth, p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
clickPoint = QPoint(p2.x() + mRoomWidth, p2.y());
^Conflicts resolved in: * src/T2DMap.cpp * src/T2DMap.h * src/TRoom.cpp * src/TRoom.h * src/dlgRoomExits.cpp * src/ui/room_exits.ui Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
src/T2DMap.cpp
Outdated
| } else if (room->getNorthwest() == rID) { | ||
| _line = QLine(p2.x() - mRoomWidth, p2.y() - mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() - mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight, |
There was a problem hiding this comment.
warning: narrowing conversion from double to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight,
^
src/T2DMap.cpp
Outdated
| } else if (room->getNorthwest() == rID) { | ||
| _line = QLine(p2.x() - mRoomWidth, p2.y() - mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() - mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight, |
There was a problem hiding this comment.
warning: narrowing conversion from double to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight,
^
src/T2DMap.cpp
Outdated
| _line = QLine(p2.x() - mRoomWidth, p2.y() - mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() - mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight, | ||
| p2.x(), p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
p2.x(), p2.y());
^
src/T2DMap.cpp
Outdated
| _line = QLine(p2.x() - mRoomWidth, p2.y() - mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() - mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight, | ||
| p2.x(), p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
p2.x(), p2.y());
^
src/T2DMap.cpp
Outdated
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() - mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() - 2.0 * mRoomHeight, | ||
| p2.x(), p2.y()); | ||
| clickPoint = QPoint(p2.x() - mRoomWidth, p2.y() - mRoomHeight); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
clickPoint = QPoint(p2.x() - mRoomWidth, p2.y() - mRoomHeight);
^
src/T2DMap.cpp
Outdated
| } else if (room->getSouthwest() == rID) { | ||
| _line = QLine(p2.x() - mRoomWidth, p2.y() + mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() + mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight, |
There was a problem hiding this comment.
warning: narrowing conversion from double to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight,
^
src/T2DMap.cpp
Outdated
| _line = QLine(p2.x() - mRoomWidth, p2.y() + mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() + mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight, | ||
| p2.x(), p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
p2.x(), p2.y());
^
src/T2DMap.cpp
Outdated
| _line = QLine(p2.x() - mRoomWidth, p2.y() + mRoomHeight, p2.x(), p2.y()); | ||
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() + mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight, | ||
| p2.x(), p2.y()); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
p2.x(), p2.y());
^
src/T2DMap.cpp
Outdated
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() + mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight, | ||
| p2.x(), p2.y()); | ||
| clickPoint = QPoint(p2.x() - mRoomWidth, p2.y() + mRoomHeight); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
clickPoint = QPoint(p2.x() - mRoomWidth, p2.y() + mRoomHeight);
^
src/T2DMap.cpp
Outdated
| _p = QPoint(p2.x() - mRoomWidth / 2.0, p2.y() + mRoomHeight / 2.0); | ||
| line = QLine(p2.x() - 2.0 * mRoomWidth, p2.y() + 2.0 * mRoomHeight, | ||
| p2.x(), p2.y()); | ||
| clickPoint = QPoint(p2.x() - mRoomWidth, p2.y() + mRoomHeight); |
There was a problem hiding this comment.
warning: narrowing conversion from float to int [bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions]
clickPoint = QPoint(p2.x() - mRoomWidth, p2.y() + mRoomHeight);
^In fact one of the terms "statics" was correct because it was referring to multiple variables of a certain scope, but rephrasing the sentence avoids offending the *smelling misteak* Bot! Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
…dy Bot It seemed to be unhappy about "narrowing conversions" of `double`s to `int`s. when a local line and point with integer coordinates are created - and which are then used to create others which have floating point values. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
I say merge it and see how people take to this! |
|
Okay, I'll publish and be damned...! |
|
Very cool! do these changes perhaps prelude to: #2427 |
I think that was a long time ago on a PC |
…udlet#4608) This PR will also allow colors for open/closed/locked doors to be customised in the future (by adjusting the new `T2DMap` `QColor` members: `mOpenDoorColor`, `mClosedDoorColor` and `mLockedDoorColor`. Moved the `QMap<int, QPoint> mAreaExitsList` member out of the class header - it is now a local `areaExitsList` value held in the `paintEvent(...)` method and passed by reference to a couple of paint helper methods. Revise the code that painted exit stubs as the formulas being used to work out the inner and outer points on the line were wrong - and as they were dependent on the room size the stubs changed as the room size did. Since we may now be painting a door marker on them it is easier if the length is constant and does not depend on the room size. Since we are now able to show door markings on custom exit lines (including on special exits) and stub exits the tool-tips in the room exits control panel is updated to now reflect this. This will close Mudlet#499 and close Mudlet#668 and address an issue that Fuligin raised in the Discord # help channel on 2021/01/08 . BugFix - revise handling of area exits with doors: This actually doubles the amount that area exits stick out from the starting room and revises the drawing code so that it is not so dependent on the room size (which modified the `exitWidth` local that the code was using). The particular detail that required this commit was that the way that the underlying line was drawn that was used to derive the door symbol from had the start and end points the opposite way around to that which I had developed the code for! Whilst cleaning things up I spotted that there was a redundant conversion from a `QPointF` to a `QPoint` and then back to a `QPointF` when handling the area exit click location - that is used to record when an area exit is (double) clicked upon to initiate a speedwalk to the room in the adjacent area. Revised - provide "pair of doors" representation for doors on 2D Map As requested during review. Revised - tweak some aspects of the door markings Make them a bit (150%) thicker and a little longer. Revised - use QLineF/QPointF instead of QLine/QPoint to pacify clang-tidy Bot It seemed to be unhappy about "narrowing conversions" of `double`s to `int`s. when a local line and point with integer coordinates are created - and which are then used to create others which have floating point values. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
I conceived of this without being aware that the change in part of Mudlet#4608 that stopped drawing the entire exit line between two rooms both visible in the mapper twice (once for each room) had been reverted by Mudlet#5949. This is a suggested alternative that goes back to drawing the half a line from each room towards the other room but additionally draws the other section stating as fully opaque but fading to transparent at the far room. If both rooms are visible this will be hidden by the corresponding fully visible exit line from the other room - but not if not. It is a bit more complex to do than might be first thought because the `QPainter::drawLine(...)` methods only use the `QPainter`'s pen (otherwise used to draw the outline of a shape) and a gradient shading effect only applies to the brush (fill) of a shape. This means that the line has to be constructed as a rectangle - and to draw it at an angle it needs to be done with `QPainter::drawPolyon(...)` using a `QLinearGradient` as the brush and no pen. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This is to allow existing map files that were not laid out to accommodate them to still use the previous smaller ones. The large arrows came about as a side effect of my adding door markings to more exits (and stubs) in Mudlet#4608. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* Fix: allow the large 2D map area exit arrows to be reverted This is to allow existing map files that were not laid out to accommodate them to still use the previous smaller ones. The large arrows came about as a side effect of my adding door markings to more exits (and stubs) in #4608. Signed-off-by: Stephen Lyons <slysven@virginmedia.com> * Revise: fix spelling mistake Signed-off-by: Stephen Lyons <slysven@virginmedia.com> * Revise: adopt peer-review suggestions Small arrows are now the default. The user will have to ask to use the large ones - which means that existing maps should not have an issue with the area exit arrows now - unlike as has been reported for the 4.15.0 release version. A scaling factor used with different values for small and large area exit arrows has been changed to be only generated once per call to `(void) T2DMap::paintRoomExits(...)` instead of once or twice depending on the direction of the exit in the XY-plane. A tooltip for this *knob* has been removed as it specifically mentioned the version of Mudlet that introduced the large area exits - and it doesn't need to now the default is pretty much as Mudlet would have been before that version. Signed-off-by: Stephen Lyons <slysven@virginmedia.com> Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>



This PR will also allow colors for open/closed/locked doors to be customised in the future (by adjusting the new
T2DMapQColormembers:mOpenDoorColor,mClosedDoorColorandmLockedDoorColor.Moved the
QMap<int, QPoint> mAreaExitsListmember out of the class header - it is now a localareaExitsListvalue held in thepaintEvent(...)method and passed by reference to a couple of paint helper methods.Revise the code that painted exit stubs as the formulas being used to work out the inner and outer points on the line were wrong - and as they were dependent on the room size the stubs changed as the room size did. Since we may now be painting a door marker on them it is easier if the length is constant and does not depend on the room size.
Since we are now able to show door markings on custom exit lines (including on special exits) and stub exits the tool-tips in the room exits control panel are updated to now reflect this.
This will close #499 which is the same as an issue that Fuligin raised in the Discord #help channel on 2021/01/08 and close #668.
Signed-off-by: Stephen Lyons slysven@virginmedia.com