Skip to content

Commit fb79c62

Browse files
committed
Enhance: add Area & Map user data structures & Lua script access commands
Whilst working on the XML importer for Map files I found that I wanted some where to store the data from attributes for tags that we don't use in Mudlet directly. For room related details I could use the TRoom::userData member but then I realised that there is nothing corresponding to Areas or for the Map overall. This separate commit provides these and the lua commands to interact with them - with functionality the same as the Room based one. Of course, as there is only ONE map there is no argument needed to select an instance for those commands. Of all the "room" user data commands replicated for "area" and "map" the only one NOT so done are get????UserDataKeys() as this is a bit pointless with a getAll????UserData() one from which the keys could be extracted from the returned table {???? being "Area" or "Map"}. Added to TLuaInterpreter class to provide following user script commands: searchAreaUserData((string)<key>[, (string)<value>]) setAreaUserData((number)<area Id>, (string)<key>, (string)<value>) clearAreaUserData((number)<area Id>) clearAreaUserDataItem((number)<area Id>, (string)<key>) getAreaUserData((number)<area Id>, (string)<key>) getAllAreaUserData((number)<area Id>) setMapUserData((string)<key>, (string)<value>) clearMapUserData((string)<key>) clearMapUserDataItem() getMapUserData((string)<key>) getAllMapUserData() Refactored TMap::serialize() to allow saving in different map file formats as defined by the constants TMap::mDefaultVersion, mMinVersion and mMaxVersion - if either of the last pair are less than or more than the first value respectively then a control on the "Special Options" tab of the profile preferences dialog will be enabled - the state of each value that is allowed is clearly indicated and it is defaulted appropriately. At present: TMap::mDefaultVersion is 16 (replaces #define CURRENT_MAP_VERSION) TMap::mMinVersion is also 16 TMap::mMaxVersion is 17 This means that the new user data areas will only persist (be saved) if that control is manually adjusted to 17 FOR EACH SESSION in this development version. When we get to a release version mDefaultVersion should be upped to 17 so that the release version uses the new format but can be manually downgraded to current (16) for those who want to share a map with users who have not upgraded - with the less of those new user data items - such users can do this by opening the profile preferences, downing this setting THEN using the SAVE MAP button and then restoring to the default value and SAVING AGAIN to a different name in the recommend format. Also renamed TMap::version to TMap::mVersion... ========================================================================== As this code requires the revision to the map file format that is coded for but only enabled manually the setter commands setAreaUserData(...) and setMapUserData(...) will both emit a warning message that the data written will not CURRENTLY be saved with the map the FIRST (and only the first) time they are used when the preference control has not been manually adjusted. ========================================================================== Also: Tweaked a recent, previous merged commit that set an optional minimum time for a Timer NOT to display it's contents every time it fires in debug output screen in value: Host::mTimerDebugOutputSuppressionInterval so that the QTimeEdit that controls it defaults to adjusting the "Seconds" time field rather than the default "Hours" one as that is the one that is most likely the one the user might wist to use. Also: The control this commit adds to the Profile Preferences dialog makes use of the QComboBox::currentData() method that was introduced in Qt5.2 - the minimum Qt library requirement in the qmake project file was revised to accomodate this - if builders wish to use a Qt5.x before this they will need to manually provide extra code to allocate an integer value from the range of values wanted/offered. Also: whilst cross-checking for the cmake project file I found the top level one was missing from the qmake project file - so have added it to that. HOWEVER I HAVE NOT FOUND A WAY TO REQUIRE THE CMAKE SYSTEM TO REQUIRE QT5.2 AS A MINIMUM WHICH THIS COMMIT REQUIRES. Signed-off-by: Stephen Lyons <slysven@virginmedia.com> Conflicts: src/src.pro
1 parent c3b9ec0 commit fb79c62

9 files changed

Lines changed: 1238 additions & 232 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020

2121
PROJECT(mudlet)
2222

23+
# FIXME: We need a check (for Qt 5.2 or greater) it is needed (at least) because
24+
# of: using QComboBox::currentData() introduced in 5.2, in dlgProfilePreferences
25+
# class
26+
27+
# Windows builds need 2.8.11, but for other platforms 2.8.9 should be enough
2328
IF(MSVC)
2429
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
2530
ELSE()

src/TArea.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class TArea
7979
int zoneAreaRef;
8080
TRoomDB * mpRoomDB;
8181
bool mIsDirty;
82+
QMap<QString, QString> mUserData;
8283

8384

8485
private:

0 commit comments

Comments
 (0)