Commit graph

286 commits

Author SHA1 Message Date
Tim Johnson
1b70fc49c4
fix: some UI messages that needs html escaping (#6859)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Fixed some more dynamic content that is displayed in a spot that handles
html but was not escaped for it. This batch is mostly file names and
folders and the blue warning about compile errors.

#### Motivation for adding to Mudlet
Progress toward #6795 

#### Other info (issues closed, discussion etc)
I pretty much only touched things that I could verify that I could put a
less than sign into. Someone else can probably figure out more.

Examples that are improved on:

![image](https://github.com/Mudlet/Mudlet/assets/29287358/2ae9af09-9a20-4f28-b3ae-b61727a3aa8c)

![image](https://github.com/Mudlet/Mudlet/assets/29287358/48b11a64-dc92-4f52-8fca-253b7ca9d76a)

![image](https://github.com/Mudlet/Mudlet/assets/29287358/cce34d33-94a9-4830-a935-e6fe64dab808)
2023-05-30 19:25:07 +02:00
TachyonicBytes
cda6fce778
Fix: Solve the case when two error messages are present (#6861)
#### 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 #2720
fixes #2720

---------

Co-authored-by: TachyonicBytes <support@tachyonicbytes.com>
2023-05-29 21:33:24 +02:00
TachyonicBytes
e0bab9363b
Infrastructure: update tr() annotation style (#6862)
#### 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>
2023-05-29 21:03:34 +02:00
Vadim Peretokin
ff3ae8de4c
Infrastructure: mark read-only variables as const (#6843)
<!-- 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)
2023-05-14 15:06:15 +02:00
Vadim Peretokin
6c31d41f91
Improve: report errors with loading the profile (#6735)
<!-- 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
2023-04-27 19:50:32 +02:00
Vadim Peretokin
97ec45d159
Improve: save files in a more reliable manner (#6738)
<!-- 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>
2023-04-25 19:28:34 +02:00
Stephen Lyons
fb04f6f9c1
Fix: make delete map button function better (#6789)
#### 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>
2023-04-24 21:09:49 +01:00
Stephen Lyons
21152cc163
Add: allow historical maps to be selected in settings (#6715)
#### 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>
2023-04-14 21:24:05 +01:00
Stephen Lyons
c6e3aa7f4c
Improve: remember 2D mapper zoom amounts between sessions (#6615)
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>
2023-03-16 15:00:33 +00:00
Kebap
a4d0fcc302
Infrastructure: Refactor TMap download code (#6437)
#### 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)
2022-11-24 08:42:28 +01:00
Stephen Lyons
a60167df74
Add: temporary map labels (#6285)
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>
2022-11-11 05:01:28 +00:00
Kebap
99f9160805
Infra: Remove stray whitespace (#6342)
#### 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
2022-10-03 07:43:55 +02:00
keneanung
2c0cc5b3f5
Fix: Read map UserData from JSON map files (#6191)
* Read map UserData from JSON map files

* Fix formatting

* Update src/TMap.cpp

Co-authored-by: Stephen Lyons <slysven@virginmedia.com>

Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2022-08-01 07:29:09 +00:00
Stephen Lyons
4655c93b2f
Infrastructure: move away from constructor initialisation lists - part 2 (#5937)
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>
2022-06-27 20:36:51 +01:00
Vadim Peretokin
f744b276ae
Infrastructure: increase minimum Qt to 5.14 (#6133) 2022-06-26 10:29:56 -04:00
Stephen Lyons
ce2475da35
Infrastructure: remove some unused variable warnings with no 3D mapper (#6121)
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>
2022-06-11 01:03:54 +01:00
Vadim Peretokin
9d4d31645f
Add: map autosaves (#6056)
#### 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>
2022-04-18 10:38:42 +02:00
Stephen Lyons
ee2671ab3b
Fix: ensure that map sub-directory exists when writing JSON map file there (#5955)
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.
2022-02-08 12:34:20 +01:00
Stephen Lyons
744d5fe07b
Fix: clear Mapper area selector QComboBox on map deletion (#5651)
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>
2021-12-21 03:03:24 +00:00
Stephen Lyons
7301bcdc45
Improve: add door symbol display to custom exits lines and to stubs (#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 #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>
2021-12-14 16:25:02 +00:00
Vadim Peretokin
39a91d3bdf
Infrastructure: Add short qsl macro to stand in for 'QStringLiteral' (#5640) 2021-12-07 06:21:39 +01:00
Stephen Lyons
1471a68dc9
Add: (Enhance) add map deletion functionality (#5627)
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>
2021-11-13 02:16:19 +00:00
Stephen Lyons
622878b3c2
BugFix: try and make connectExitStub(...) work as per the API (#5395)
* 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>
2021-10-02 21:09:23 +01:00
Richard Moffitt
68133f54b2
Replace Q_NULLPTR by nullptr. (#5417)
The original commit title/message was a bit confusing - but the intent was sound. 8-)
2021-09-18 17:21:29 +01:00
Vadim Peretokin
23a5443aa1
Allow optional fontName, text and background transparency in createMapLabel() (#5406) 2021-09-03 10:47:43 +02:00
Vadim Peretokin
b9cb18ca89
Fix 160 typos in C++ code (#5387) 2021-08-22 08:01:05 +02:00
Tomas Seniunas
63a50ea611
Adjusted the 256 color conversion to match other clients (#5328) 2021-08-08 09:42:38 +02:00
Stephen Lyons
61ed789838
BugFix: fix Json Map room symbol loading (#5312)
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>
2021-07-20 12:50:19 +01:00
Vadim Peretokin
ffd205468b
Fix error shown for map load on new profiles (#5177)
* Fix error shown for map load on new profiles

* Fix logic error - new profiles + login should show mmp map

* Peer review
2021-05-21 16:45:17 +02:00
Vadim Peretokin
75c79af5ae
Fix loadMap() to work again (#5210) 2021-05-11 21:26:47 +02:00
Kebap
b42921b6ee
Improve some texts for translations (#5186)
* Remove path/filename from translations

* "Remove packages" as plural

* untangle texts, settle "format version"

* Split more texts

* get rid of double "this"
2021-04-19 08:07:25 +02:00
Vadim Peretokin
0cd8a0e908
Use unique ptr which won't leak memory when JSON map load is aborted (#5129) 2021-04-11 07:53:43 +00:00
Vadim Peretokin
8665b177f3
Align saveJsonMap with saveMap() (#5016) 2021-04-05 15:49:30 +02:00
Stephen Lyons
bbd95792e4
BugFix: improve handling of non-map and too new files in profile's map dir (#5071)
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>
2021-04-02 19:10:16 +01:00
Andrew Waters
6b8c325eaa
Inverted check for special exit lock when looking for useable exits at start of path. (#4949) 2021-03-13 21:04:23 +01:00
Stephen Lyons
1f1a45b9cb
Refactor: rationalise control names and remove unneeded elements in mapper (#4863)
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>
2021-02-23 18:44:41 +00:00
Vadim Peretokin
7d9e5c7409
Internal: Remove unused variables (#4851)
* Remove unused qstrings

* Remove more unused variables
2021-02-22 21:05:57 +01:00
Vadim Peretokin
fff137e45e
Have consistent JSON map import messages (#4829) 2021-02-19 09:54:28 +01:00
Stephen Lyons
6d4046e5b6
Enhance: import/export map as JSON (#4546)
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>
2021-02-14 23:44:55 +00:00
Piotr
ce4362fe67
Map Info contributors - adjustable map info (#4718)
* 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>
2021-02-11 18:05:40 +01:00
Vadim Peretokin
3118f1275e
Revert "don't speak unless given text, ignore > and < (#4706)" (#4738)
This reverts commit faad4242e1.
2021-02-03 11:03:46 +01:00
Kebap
faad4242e1
don't speak unless given text, ignore > and < (#4706) 2021-02-02 10:14:12 +01:00
Stephen Lyons
f18e00095a
BugFix: repair special exits in speedwalks with corrupt names (#4722)
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>
2021-01-30 23:12:59 +00:00
Stephen Lyons
d546dd987f
Bugfix: don't corrupt map files (#4694)
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>
2021-01-27 09:32:33 +01:00
Stephen Lyons
f32e0fe266
BugFix: correct merge error from #4604 (#4693)
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>
2021-01-26 20:38:51 +00:00
Stephen Lyons
5dee468342
BugFix: correct mis-use of nullptr to denote no room symbol colour (#4679)
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>
2021-01-25 11:21:44 +00:00
Stephen Lyons
2806177c44
Refactor: move labels from TMap to each TArea instance. (#4604)
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>
2021-01-17 09:02:23 +00:00
Piotr
42f6c8cc5c
Add way to color room characters (#4573)
* 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>
2021-01-05 16:14:41 +01:00
Stephen Lyons
507aa217db
Refactor: store special exits and their lock status separately (#4526)
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>
2020-12-31 22:06:00 +00:00
Stephen Lyons
21c1026c30
BugFix: repair incorrect use of QFont(string) after QFont::toString() (#4545)
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>
2020-12-30 19:36:26 +00:00