#### Brief overview of PR changes/additions
Solves #2720. Two error messages were printed for not downloading the
map, now just one is printed.
#### Motivation for adding to Mudlet
The original issue was deemed to cause confusion for users.
#### Other info (issues closed, discussion etc)
/claim #2720fixes#2720
---------
Co-authored-by: TachyonicBytes <support@tachyonicbytes.com>
#### Brief overview of PR changes/additions
Update the tr() annotation style, as discussed in #5522
#### Motivation for adding to Mudlet
Makes the code cleaner and also keeps Mudlet in tune with the latest
standards.
#### Other info (issues closed, discussion etc)
/claim #5522
---------
Co-authored-by: TachyonicBytes <support@tachyonicbytes.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Mark read-only variables as const - that is, not intended to change
after they've been declared
#### Motivation for adding to Mudlet
So we don't change them by accident later on, and also to clearly state
intentions for the variables
#### Other info (issues closed, discussion etc)
This is also recommended by the [C++ Core
Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es25-declare-an-object-const-or-constexpr-unless-you-want-to-modify-its-value-later-on)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Report any errors that happen while loading a profile
#### Motivation for adding to Mudlet
So if a profile is corrupted for whatever reason (ie, computer crash) -
folks will have a better experience understanding what's going on and
how can they address it
#### Other info (issues closed, discussion etc)
The one rare case of a `TODO` in the codebase actually being fixed :O
<!-- Keep the title short & concise so anyone non-technical can
understand it,
the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Use [QSaveFile](https://doc.qt.io/qt-5/qsavefile.html) for all cases
where Mudlet is writing to disk (profiles, maps, notes, ...). QSaveFile
does a few things under the hood to ensure a file can be written safely,
and gives a nice error if no.
#### Motivation for adding to Mudlet
I'm hoping this'll address some cases of folks' settings resetting or
some other weird things happening - which happens once in a blue moon,
but still does.
Doing disk IO on scale is something that is eventually bound to run into
issues, I had the same with the Svo system. Hopefully this'll cover
things off.
#### Other info (issues closed, discussion etc)
Fix https://github.com/Mudlet/Mudlet/issues/1342
---------
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: SlySven <SlySven@users.noreply.github.com>
#### Motivation for adding to Mudlet
In the referred to issue it was pointed out that the delete map button
was not accessible until a mapper has been created - which is not an
optimum situation.
#### Other info (issues closed, discussion etc)
Moves the handling of the `(bool) mShowDefaultArea` flag from the
`dlgMapper` class to the `TMap` one so it can be controlled even when
there is not a map widget loaded.
#### Brief overview of PR changes/additions
This will close#6549.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
#### Brief overview of PR changes/additions
This adds a `QComboBox` selector under the load map button in the mapper
tab on the "Profile preferences" dialogue to allow any map (Mudlet
`.dat` binary, `.json` or `.xml`) file stored in the "normal place" to
be chosen and loaded. Like the game save selection in the "Connect
profile" dialogue an icon is pre-pended to the "autosave" one, in
addition a (icon theme dependent) icon is pre-pended for `.json` and
`.xml` files so they can be distinguished from the "normal" binary one.
Like that game save list the entries are sorted into descending date and
time order.
#### Motivation for adding to Mudlet
It is a bounty issue.
#### Other info (issues closed, discussion etc)
This should close#656!
This PR originally ALSO added a similar `QComboBox` to the second tab of
the "Connect profile" dialogue - which I thought was a good idea but
which was declared to be outside of the scope of the original issue. I
will promulgate that option again in a future PR where we can discuss
how good an idea it really is! 😈
---------
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@hey.com>
Co-authored-by: mudlet-machine-account <39947211+mudlet-machine-account@users.noreply.github.com>
This is intended to close#2388.
This enables the 2D (only) map zoom amounts for each map area to be save
independently and restored when switching between areas in the mapper.
It also saves the data between session.
It extends the existing `setMapZoom(...)` API to take an optional second
argument to specify the map area ID to set the zoom (which is a floating
point number) for any existing area, not just the current one.
It also adds a `getMapZoom(...)` function that, without any arguments,
returns the currently used 2D map zoom value for the area currently
being shown in the 2D mapper. If an area ID is provided it instead
returns the value that was last used for that area - or the default
value that is used initially on starting the profile or for an area that
has not been viewed before.
Importantly when switching between the areas in the 2D mapper the values
are retained and applied so that one area can be zoomed in and another
zoomed out and switching from the first to the second and back to the
first means that the zoom level used in the first is reused when it is
returned to. Deleting an area will forget the stored zoom level so if it
is reused it starts from scratch.
Code to save the zoom level for each area has also been implemented
within the C++ core. It saves it in the Area User Data for current map
formats (but removes it on loading so the user never sees it there)
under a `system.fallback_map2DZoom` key but will save it directly in the
binary data (which is more efficient) in the next format version
whenever it is enabled.
A new Mudlet event, which has been called `sysMapAreaChanged` has
been added with two additional arguments being the area ID changed to
followed by the one that it was changed from. I originally thought I
would need it to handle saving the zoom level for each area via the Lua
system but I found that that was not practicable.
Also, in refactoring `T2DMap::paintEvent(...)` I:
Removed/combined some locals:
* `(TArea*) playerArea` and `pPlayerArea` and `pArea`==> `pDrawnArea`
* `(TRoom*) playerRoom` ==> `pPlayerRoom`
Remove unneeded (refactored out):
* `(qreal) ox`
* `(qreal) oy`
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
#### Brief overview of PR changes/additions
While working on #3576 and reading through TMap.cpp, trying to
understand the logic there, I made a few minor changes which should not
affect functionality much at all, but improve readability for the
generations to come. Also:
- Made two warning messages translatable where map download could not be
started properly
- Untangled four levels of mom's spaghetti in
`TMap::slot_replyFinished(QNetworkReply*)`
- Disabled "Cancel" button after downloading non-XML maps (just like XML
case did already)
#### Motivation for adding to Mudlet
- Improve internal code readability for future developers
- Align Mudlet behavior for different map download formats
- Have warnings display in player's selected UI language alright
#### Other info (issues closed, discussion etc)
These will last only for the duration of a session and will NOT be saved
into a binary or JSON format map file later. As far as possible the
creation, modification or deletion of such a label will also NOT cause
Mudlets's map "auto-save" functionality to be activated.
This should provide an alternative way to work around and close#6265.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
#### Brief overview of PR changes/additions
Refactored some code, removed whitespace from texts for translation.
#### Motivation for adding to Mudlet
Translators don't need to worry matching a number of empty lines at the
edge of a translated text.
#### Other info (issues closed, discussion etc)
Fix#3466
For classes from "T2*" to "TM*" (approximately)...
I have steered away from using `{}` to initialise simple, POD data types in
favour of explicitly stating what their default values are.
Also:
* remove unused `(QColor) TAction::mButtonColor` and it's associated
getter and setter. Also remove the save code from the `XMLexport`
class and ensure it is skipped and silently discarded in the load
code in `XMLimport`.
* Make `private` some members of the `TFlipButton` class that probably
weren't ever intended to be `public`
* Remove unneeded named argument for `lua_State*` type in many (but not
all) function declarations in `TLuaInterpreter.h` file - they aren't
needed and whether an `L` was present or not seems to entirely down to
the whim of the individual coder of each function...!
* Rejig some of the initiliasations in the `TLuaInterpreter` class
* Refactor a chunk of code n the `TMap` class used to (re)initialise the
16 colours user settable from the preferences dialogue to a method:
`(void) TMap::restore16ColorSet()` - so that it can be used in three
other places as well as the constuctor.
* Remove unused `(int) T2DMap::gzoom`.
* Add missing `TMediaData.h` file to qmake project file.
Note: `QPointer<T>` instances do NOT need initialisation, they are
automagically instantiated with a `nullptr` value.
Revised to change code to fit in with PR #6133
There were some pre-Qt 5.14.0 version checks that are no longer relevant.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
When the environmental variable `WITH_3DMAPPER` is set to `"NO"` for builds
on Raspberry Pis or other hardware which Mudlet cannot work a 3D mapper for
there are some arguments for some functions that are unused and which
provoke warnings. This PR silences those warnings for that case.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
#### Brief overview of PR changes/additions
Add a map autosave feature to prevent large losses of work when Mudlet/computer shut down unexpectedly.
#### Motivation for adding to Mudlet
Better player experience.
#### Other info (issues closed, discussion etc)
Closes https://github.com/Mudlet/Mudlet/issues/2121.
Works just like profile autosave which has been very successful since its introduction - autosaves the map every 2min if any changes have been done to it. Hopefully this won't be an issue for enormous maps - if it is, we'll need to look into making the save process hog the main thread less.
Adding this revealed that the internal mapper API is messy - ideally the 'mDirtyMap' flag should never be set within TLuaInterpreter.cpp!
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
This should close#5938.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
#### Release post highlight
Fix: saving a JSON format map file in a new profile should now created the needed default destination directory.
This was spotted here:
https://github.com/Mudlet/Mudlet/pull/5624#issuecomment-967998271
Also:
* rename a couple of local variables which had a `_` prefix as using that is
not a good idea.
* also arrange for the area selector to be disabled if there is less than
two area names to be shown in it (it also accounts for if the default area
name is set to hidden!)
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
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#499 and close#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>
This adds a `QPushButton` to allow the currently loaded/created map to be
completely removed. As a little protection against accident activation a
separate `QCheckBox` along side it must be checked first to enable it - a
bit like a guard over a physical toggle switch, a.k.a. a:
http://catb.org/~esr/jargon/html/M/molly-guard.html
It also adds a `deleteMap()` function (which takes no arguments) to the Lua
API - which returns `true` on success - or `nil` and an error message on
error.
This should close#5436 and #630, and thus:
https://bugs.launchpad.net/bugs/782843 from 2011.
Originally using the Lua function was going to produce an "[ OK ] - Xxx"
type message on the main console but this was removed following
peer-review.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* BugFix: try and make connectExitStub(...) work as per the API
This PR should enable connectExitStub(...) to work as close to the existing
published API as possible:
* connectExitStub((integer) fromRoomID, (integer)toRoomID,
(integer or string) direction)
where direction is the initial(s) or full, lower-case, un-hypenated ENGLISH
word for one of the 12 normal exit directions - this will make a two way
exit between the given direction of the fromRoomID room to the toRoomID
room AND the corresponding reverse direction exit from the toRoomID room.
The rooms need not be the same Area but they must BOTH have stub exits in
the required direction.
* `connectExitStub((integer) fromRoomID, (integer) toRoomID)` - this will
make a two way exit between the fromRoomID room to the toRoomID room AND
the corresponding reverse direction exit from the toRoomID room. The rooms
need not be the same Area but the fromRoomID must have only ONE stub exit
with an opposite (reverse) direction one in the toRoomID one - either room
can have other stub exits. Should there be more than one pair of stub exits
a nil + error message will be produced listing the choices for the
direction that can be passed to the three argument function call to make
the exits wanted.
* `connectExitStub((integer) fromRoomID, (integer or string) dirction)`
- this will make a two way exit between the stub exit in the fromRoomID
room to the NEAREST other room IN THE SAME AREA which has a stub exit in
the reverse direction and which lies in the correct relative position
(except for the `in`/`out` directions where this is not relevant). Should
the direction be given as an integer in the range 1 to 12 this will be
rejected (via a nil + error message) because it is ambiguous then whether
the number represents a direction or a toRoomID. Potentially unlike the
prior code, this version properly detects whether a string or number is
supplied as the direction argument.
Also:
* to allow the reporting of the direction as a number and a string in error
messages the `(QString) TRoom::dirCodeToString(const int)` method has been
made `static` so that it can be used in the `TLuaInterpreter` class.
* as indirectly mentioned above
`(int) TLuaInterpreter::dirToNumber(lua_State*, int)` has been revised to
check for a string or integer argument being examined - the prior code
may not work as anticipated because it used `lua_isxxxx(...)` functions
which can coerce the value they are dealing with (a number can be coerced
into a string) - which messes with the logic.
* in places in the revised methods the integer constant values have been
replaced with the `DIR_XXXXX` values defined in the `TRoom` class header
file.
* to simplify (!) the coding the three different forms of the Lua API are
implemented in three separate `(QString) TMap::connectExitStubByXxxx(...)
methods which collectively replace the original
`(void) TMap::connectExitStub(...)` one. They are responsible for
generating most of the Lua API error messages for this function and they
indicate success by returning an empty string.
This should close#2386.
Revise: add a suggestion to the user on how to proceed on a message
Signed-off by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
This should close#5295 by providing the code that is missing from
`(void) TRoom::readJsonSymbol(...)` - I think it was omitted because the
person who coded the ability to colourise the room symbol text was working
on that whilst I was coding the JSON map handling.
It also fixes:
* a Qt advisory (warning) to use a const reference when using a C++ `for`
loop to iterate through a QJsonArray of custom environements (colors).
* a failure to update the player room indicator when it is changed by
loading a Json Map file.
* a comment in `(void) Host::getPlayerRoomStyleDetails(...)` that is
redundant since we previously removed the mutex for accessors.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This is an **alternative** to #5022 - and *one* of them will be needed so
that #5016 is safe - though, TBH I do not think that the latter should be
dumping JSON format files into a folder which we had previously reserved
for binary map save files!
This will also close#4275 by checking for the map version number (the
first four bytes of the file) being between 1 and 127 and rejecting it if
that test is not met.
Revised to keep GHA Clang-tidy appeased by initialising some variables
that are immediately assigned a value in the next lines following them!
Revised to include JSON maps files as ones to try and load, had to add
something so that the (error) texts returned by
`TMap::readJsonMapFile(...)` are translated when used as part of error
messages on the main console.
It does mean that the user can abort the import of a (large) JSON map
file. Personally I'd have preferred to keep the UI more uniform for both
binary and JSON map file loading but it seems from the peer-review
that it was preferred to be able to abort the load. This will, I think, trigger
some no-map code if the user does abort the loading of a JSON file...
Revised to prevent double auditing of map when loaded from JSON file
Revised to remove iteration though potential map files so reverted to
only consider the *newest* file that *could* be a map file.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Add type prefixes to all the controls on the mapper form - and rename some
e.g. "dim2" becomes "pushButton_3D"; "bubbles", "checkBox_roundRooms".
Make the 2D/3D button be a checkable one that only shows 3D and is in that
mode when down - and hidden when the 3D map has been disabled during build.
Correspondingly, make `show2dView()`, now called `slot_toggle3DView(bool)`
note the state of its argument - so that it can respond to the button state
in the signal.
Remove unused second GLWidget constructor.
Move all POD-type constructor initialisers for GLWidget class to header
file. Also move some global variables to be class members instead.
Remove unused methods (including some slots and signals) and global
variables.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This is so that a crowd sourced map might be edited in a collaborative
manner. The first stage is to make sufficient of the entire map details
be exported/imported in a modular (by area) fashion.
Include Lua functions `exportJsonMap(pathFileName)` and
`importJsonMap(pathFileName)` to perform the whole map export and
import functions.
Also, rename `(QMultiMap<int, QPair<int, int>>) TArea::exits` to:
`TArea::mAreaExits` because the old name was such a common word in our
source code it was hard to find the uses of this member.
This format has been constructed so as to not mention the most common, or
default values for some items - so as to minimise details that have to be
included on the basis they can be assumed when reconstructing them on the
other end.
On the other hand the whole file is compressible so for storage (but not for
diff/git work) archiving / compressing the file is recommended! For
instance a binary map file I have is 18.6MB which produced a 25.8MB JSON
file which I was able to compress down to 2.9MB - obviously this is *very*
content dependent, so other's Miles-May-Vary...
As the export process is not that fast include a progress dialogue that
shows how many areas, map labels and rooms have been processed into the
JSON format. For a 20K room map with 40 odd areas and around 800 map labels
(which are awkward to convert to a text-like form) this can take 30
seconds on my 1.8GHz 4 Core PC!
CodeFactor had a recommendation about a constant that I was using to
set the dimension of a `char[]` (array) - it felt a compile time `constexpr` was
a better thing to use.
Revised to make Cancel button work in big areas:
Although the existing code would abort at the end of an area, for some
humongous maps with a few very large areas it is also a good idea to check
for the cancel button being pressed each time the progress bar is updated.
Renamed `(QMap<int, int>) TMap::envColors` to `TMap::mEnvColors`
and `(QMap<int, QColor>) Tmap::customEnvColors` to `TMap::mCustomEnvColors`
so that it is clearer that they are members of the `TMap` class.
Add alpha component to end of list of (now four) 0 to 255 integer values
returned by `getCustomEnvColorTable()` - as the corresponding setter does
allow one to be provided.
Move initialisers for TMap, TRoomDB, TRoom and TArea to header file where
possible. As per Issue #4578.
Move the default and unnamed area names from TRoomDB to TMap - as it made
setting them up easier (though one of them does need to be initialised
before the normal TRoomDB instance associated with the TMap is itself
initialised. This meant putting these private members near the top of the
header file even though we normally put private ones down the bottom.
Refactor: move JSON colour writing/reading code from TArea/TRoom to TMap
The code is common to all three classes so can be shared. At the same time
make it explicit in the key as to whether there is an alpha component so
the colour is a 24Bit opaque one or a 32Bit one with transparency.
Revise: peer-review items and other tweaks
Note that this revises the format version to be 1.000 (ready for release)
so, although the format has not changed, any recent files produced during
evaluation will need to be hand edited to change the line:
"formatVersion": 0.003,
to:
"formatVersion": 1.000,
in order to read them now.
Switch to "range based" for-loops for some of the JSON additions.
Fixup: ensure partially built new TRoomDB is destroyed if reading aborted
Not doing this would cause a resource leak if the abort button was clicked
during importation of a Json map file.
Revise: disable writing out Room highlighting details
It has been pointed out that the binary map format does not save the room
highlighting details either - so replicate that behaviour for the moment.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
* initial changes form map info overrides
* code styling fix
* fix code style
* add api to toggle map info providers
validation of arguments
turn off 2d buttons on 3d map
remove obsolte map info references
* change naming
make qmake build work
* set short map info as default
* use default color if wrong or not complete value is provided
* cr fixes
* replace toggle with enable and disable api
* order of contributors is order of insertion
* add missing changes
* apply code review changes
minor improvements
* legacy setting 'showInfo' will be stored according to contributors state
* fix seg fault
untangle includes
* fix another seg fault
fix reregistering map info contributor
* mapInfo will be based solely on map contributors
XmlImport will set legacy full info if first running old progile
* do not store map info unless mapContributors are empty
* cr adjustments
adjust to new validation in lua interpreter
make gap smaller between providers
* Update src/dlgMapper.cpp
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
* remove unintentional change
* add error handling for map info callback functions
Co-authored-by: Piotr Wilczynski <piotr.wilczynski@bisnode.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
This is an error that slipped in as a result of #4526 and resulted in the
exit room id being stored as the special exit name in the BGL graph that is
built for the A* search algorithm to work on. Consquently if that route was
used in a path the special exit command produced for that step was garbage
which also tripped off warnings about invalid characters being sent to the
MUD as an exit direction.
Thanks to @ryanstadther for bringing this to my attention!
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
BugFix: correct missing detail (map label position) from binary map files
This will cause serious data loss (because it throws off the whole
structure of the file) when reading existing files {because the label
position element is not read from the file so everything after the first
map label will not be at the expected offset} and writing new ones as they
would not be storing the position detail rendering all map labels at the
origin when read by the new code.
This defect was introduced in #4604 - ten days ago.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Due to some differences in local variable names I did not spot that I was
introducing two copies of the same functional code into the method that
scanned the existing map file in other inactive profiles for when a new
shared map was copied over to them. As such the code (in
`(bool) TMap::retrieveMapFileStats(...)` would not have been used very
much in the last couple of weeks when it was in the development branch code
and even then it may not have prevented the current usage of that method
from having functioned correctly. Nevertheless it is defective as it is
and this PR removes one copy of the duplicated code.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
It seems like PR #4573 introduced a bogus use of pointer access to a
`QColor` whereas the correct methodology is `QColor::isValid()` - a default
constructed `QColor` is itself equivalent to an RGBA specified colour of
`QColor(0,0,0,0)` and that will fail in that test. This PR fixes things so
that (instead of a `nullptr` test) is used.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This actually makes management of map labels a lot simpler.
I also need this to be in place for my JSON map file export/importer
PR #4546.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
* add way to color room characters
* accept new translations
* fix qmake build
* addSymbolToPixmapCache improve
* cr corrections
* Modernize design
* remove accidental hints
* remove not needed variable
* minor fixes
* room not exists will not throw error in room char color functions
* remove properties with auto suggestion
* remove not neede assignment
* prevent spawning multiple symbol char dialogs at once
* fix room symbol selection issues
Co-authored-by: Piotr Wilczynski <piotr.wilczynski@bisnode.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
This will enable some simplification of code.
During development it became clear that the Lua API `getSpecialExits(...)`
function was a bit defective and did not behave as documented in the Wiki:
it was only showing one special exit at random that led to a particular
exit room in the (admittedly unlikely) event of there being more than one.
It also used the special exit name/command as a key in a sub-table with the
special exit lock status of that exit as a "0" or "1" string value.
This PR repairs the above function by adding an optional boolean argument
that:
* if omitted or false, replicates the previous behaviour but if there is
more than one special exit to the same room it always picks one with the
lowest exit weight that is unlocked or if there is none it picks one with
the lowest weight that is locked. This will be compatible with old scripts.
* if true, returns ALL the exits in the sub-table that lead to the
particular room id that is the key in the main table, again those exit
commands are the keys with a value being a "0" or "1" depending on whether
the exit is unlocked or locked respectively.
For the record, the original implementation of special exits was introduced
in commit:
e0ba28d472 and that was supported by the
addition of map format version 6. Locking of Special Exits was added in
somewhere between:
19f8563b47
and:
070912ea7c
(which revised the map format to 11).
Also:
* use a couple of `const QString`s as templates in the `dlgRoomExit.cpp`
file to remove 95 duplicated `QStringLiterals` from the read-only code
segment of the compile object file.
* add `const` where relevant to some `TRoom` methods.
* work harder to ensure than when a special exit is deleted from a `TRoom`
then elements that were related to it are also cleaned up.
* prepare to save the new `TRoom` data structures in the next Mudlet map
file format (21) when it is enabled. In the meantime a workaround to
convert the in-game data to the current format is utilised for all current
map formats Mudlet can currently use. This will impact a little on the
save/loading speeds but that is the cost of simplifying the code that works
with special exits elsewhere in the application.
* revise and extend the error handling for the room special exit functions
generally so that they confirm to our throwing an error on argument type
issue (and reporting the faulty argument) and returning `nil` plus an error
message for a run-time value problem.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
Creating a font via a QFont(string) where string is the output from
a previous QFont::toString() is incorrect as each time it is done it
adds on the last nine of the ten comma-separated elements on in a manner
that the string will grow interminably. This is done for the Map font when
using the fall-back (pre-format 19) method and as an example I had one map
file that had over 15K comma separated elements.
The correct way to use such a string is with the
QFont::fromString(string) method - however that will reject a string that
has other than one element or ten comma separated ones. This PR will fix
up any cases it encounters.
Signed-off-by: Stephen Lyons <slysven@virginmedia.com>