Skip to content

Enhance: add ability to set any glyph as a room symbol#1543

Merged
SlySven merged 18 commits intoMudlet:developmentfrom
SlySven:Enhance_better2DMapRoomIdAndNonAsciiRoomSymbols
Mar 28, 2018
Merged

Enhance: add ability to set any glyph as a room symbol#1543
SlySven merged 18 commits intoMudlet:developmentfrom
SlySven:Enhance_better2DMapRoomIdAndNonAsciiRoomSymbols

Conversation

@SlySven
Copy link
Copy Markdown
Member

@SlySven SlySven commented Feb 5, 2018

Brief overview of PR changes/additions

I have long wanted to use more than just ASCII letters for room symbols - this commit adds support for any glyph to be used and more than one - although there is a trade off in fitting the text into a square or round room symbol which means longer strings have to be smaller to fit. Each different symbol is resized to fit and this allows for the use of symbols with combining diacriticals and those from beyond the BMP.

Controls are added to the profile preference that allows a specific font to be used for room symbols - so a Server/Crowd source map could bundle up one that includes all the symbols needed; and there is also a check-box option to force just that font to be used if that is important. However if a map is shared it is not impossible for the end-using system not to have a particular font or indeed any font with a glyph in.

Therefore there is a secondary dialog available on the "Mapper" tab of the "Profile Preferences" that can be called up and which gives an informative display of what symbols are used where and from what Unicode codepoints they are composed as well as whether the current system can display each symbol in either the specified font or as a fall-back, any font available to a Qt Application - for simplicity a colour coded icon is displayed against each line in the table of symbols indicating whether it can be found in the selected font (dialog-ok-apply); only in another font (dialog-warning) or is missing altogether on the system (dialog-error). As this responds interactively as the selected font is changed it should enable the user to find a suitable choice for their case.

Motivation for adding to Mudlet

I want to be able to decorate my maps with the fine range of glyphs from George Douros' Public Domain Symbola font.

Other info (issues closed, discussion etc)

The revised data ideally would be stored directly into the Mudlet binary map format and I have incremented the version number to 19 to support this feature - however I have been able to provide a fall-back that silently uses the map and room user data areas and leave maps in the current default 18 format able to be read with the current versions of Mudlet without issue if only the currently supported symbols ("letters") are used - should a Mudlet version with this PR included set a symbol that cannot be displayed in the current versions in existence they will display a ? instead. Similarly, going forward from this PR the lua getRoomChar and setRoomChar should be deprecated, however they will still work with the previous range of characters - although both current versions and this code going forward will return a '?' for a room symbol that cannot be encoded as a single byte, additionally this code will include a second error message advising the use of the replacement getRoomSymbol which returns a UTF-8 encoded string. The companion setRoomSymbol will also accept an empty string (or a space) to clear a room symbol (as will the revised setRoomChar) which seems to have been a previous undocumented software feature i.e. it was not possible to clear a room symbol from a lua script... 😮

(Actually it is possible to use a short word as well as anything printable
from any of the Unicode Multiple Planes.)

Adds controls to the profile preference to set the (preferred) font to
use to set the room symbols from and a checkbox to only use that font.
Additionally a sub-dialog can be brought up which lists the details of all
the different symbols on the map - showing the Unicode codepoint(s) for
each and showing how they would be rendered if only the selected font is
used and if any font is permitted, along with a count of the usages and
the rooms that use each one...  A status icon is also displayed showing
whether the symbol can be rendered entirely with the selected font (green
tick), only by using glyphs from other fonts (yellow ! warning) or not with
the current fonts on the system (red/white cross).  This allows a user to
make a sensible selection of a font to use or whether they will have a
problem (and a replacement by the replacement character '�') for any
symbols.

Updates Lua setRoomChar and getRoomChar and adds replacement setRoomSymbol
and getRoomSymbol which handle the wider range of things that can be used.
getRoomChar will now return '?' and an error message if the symbol cannot
be represented by a single ASCII/ISO 8859-1 character - but will still work
for old maps as before - although it NOW allows for an existing character
to be cleared with an empty string or a space as the char attribute.

The map format version has been incremented to allow the data needed to be
saved directly into the binary file format but failback code is in place
that means that this feature can be carried in map and room user data
instead for map format versions down to 17 - the current default is 18 and
there is limited support to fail gracefully down to the 16 that Mudlet 2.1
uses (all the room letter markings that are not supported will become '?',
and the font data will be lost, but the correct room character data will
still be in the room user data.)

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven SlySven requested a review from a team as a code owner February 5, 2018 13:37
@SlySven SlySven requested review from a team and vadi2 February 5, 2018 13:37
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Feb 5, 2018

Note that this also works on round rooms - the pixmaps do have to be scaled down by a 0.707 factor to allow for them to fit inside the small extremes compared to the rectangle - but this code does not force rectangular/square rooms on those with letters/symbols as the prior code did.

Also note that Map Format 19 is not stable - I do have another separate PR in mind to give each room a persistent Uuid (Universally unique identification number) on creation which should make it easier to track changes between divergent versions of shared binary maps - as it will be easier to see which rooms have been added/modified/removed between two copies. However that will also need to store a QUuid for each room and although I can store it in the room user data for backward version compatibility it too, ideally, needs to be stored directly as an element of the binary data and it is my intention to also include that in the version 19 binary map format. The bottom line is that if someone tests this code and enables version 19 for testing the map data will not be readable if the format is changed again for that other feature - so do not use 19 for anything other than a test save that can be thrown away afterwards.

Anyhow - for an example in action, check out this:
screenshot_20180205_122736

So was causing compilation failures where used in T2DMap::painEvent(...)
for older Qt versions.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Feb 5, 2018

Logged a bug report QTBUG-66204 because they did not mention that QFont::PreferNoShaping was only introduced in Qt 5.10... 🙁

So to test for Qt 5.10.0 the value to test is 0x050a00 NOT 0x051000 ...!

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Copy link
Copy Markdown
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thing!

  1. could we call them emojis? That's the commonly known terminology for them these days
  2. the emoji use window came up with rows too small by default:
    map glyph usage - svof_057
  3. The rendering isn't really good:
    selection_058

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Feb 5, 2018

1). I think it would be fair to say eventually in the Wiki that Emojis can be used but that is not the right word to describe the massively huge proportions of other glyphs that can be used - Emojis are only one type of ideograms and they are separate from logograms and phonograms that make up the symbols for Chinese (and others) and Roman languages respectively.

2). What is happening on that dialog? I can't see anything and I'd expect to see some content in a normal font in the other columns - it is only the two that show the glyphs that have non-standard font setting! Stick some ordinary letters in your map. I don't suppose that you are using an XML map format which does not currently support room symbols/letters?

3). What font are you specifically selecting - I have got some really poor results from some ropey bitmap fonts because I suspect the font matching routine tries to use glyphs from "other" fonts to fill in for missing ones from the selected one based at least partly on size in some aspect... it is possible that we might want to experiment in using QFont::setBold(true) or QFont::setWeight(n) for a finer control.

}
}

int TLuaInterpreter::setRoomSymbol(lua_State* L)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just upgrade setRoomChar()? By introducing a separate function, we'll force everybody to migrate their calls to it, and then people will be getting confused between two very similar functions - not fun.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it is no longer a "char" a single ASCII/ISO 8859-1 byte/character - and that can break scripts using the getter which is also a no-no isn't it? I've provided backwards compatibility - getRoomChar will return ? if the symbol is not one that is expressible in that byte form...

Copy link
Copy Markdown
Member

@vadi2 vadi2 Feb 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the chances of breaking scripts are pretty minimal, because we're going from one character to many and I don't think anyone would be triple-checking that the character(s) they get back are strictly ISO 8859-1 and erroring if it's anything else. Your thoughts, @keneanung?

We make use of getRoomChar() in the IRE mapping script and I think that will still work fine. Searching on Github shows that our script is the only public script that actually makes use of that function.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still a point, I'm not a fan of telling people "yeah there's two ways you can set a symbol on a map good luck memorizing the right one"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the discussion was that "Symbol" was the most obvious/best term to use and setRoomChar is no longer a good fit for the term as - although neither implies a plural usage the way things are handled in the display usage does treat say the term where is it a word "shop" as a specific "symbol" and "cafe" and "café" as two different ones...

I would want to flag setRoomChar as deprecated in the Wiki and for the current usage by the IRE scripts it would continue to do what it says it does (although it is now possible to clear the symbol which was not before!) - and we'd follow the previous behaviour in that if the setRoomSymbol function exists use it (you've always said that scripter should "test for a function rather than relying on a version number" 😮 ) otherwise fall-back to setRoomChar but it only accepts a single ASCII character...

src/T2DMap.cpp Outdated
void T2DMap::addSymbolToPixmapCache( const QString key )
{
QPixmap * pix = new QPixmap(mapLetterPixmapSize,mapLetterPixmapSize);
pix->fill( QColor(0,0,0,0) ); // Fill with a *transparent* background!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qt::transparent can go here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, forgot that...!

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Feb 5, 2018

  1. The wiki can mention that they are glyphs, but I'd say that in general we should use terminology people use and can understand, not technical terminology which they don't know and alienates them. Keeping things simple as possible is good, otherwise people don't understand and say the program is far too complicated!

  2. "sag coun", see column 5

  3. that was one of the variants of the Ubuntu fonts. Here it is with Symbola - not much better...

selection_059

Is there any way to add colour to them?

selection_059

Replaced some colour specifications (white and transparent) with Qt
constants.

Use the same inline function flushSymbolPixmapCache() to clear the map
symbol pixmap cache in all places where it might be useful.

Simplify a couple of places where an if(...) {...} else {...} can be
replaced with the (...) ? (...) : (...) operator.

Limit the number of room numbers displayed for each symbol in the new
widget - to avoid complications where there are huge numbers of rooms using
a symbol.

Replace a use of QTableWidget::clearContents() with
QTableWidgets::setRowCount(0) as I was getting some odd, deep in the Qt
internal library issues {Fatal Seg. Faults!} with the former, which I
suspect, but could not prove, might have been a re-entrancy issue caused by
the method containing it being called indirectly by an asynchronous SIGNAL/
SLOT originating in the value change from the map symbol font selection
QFontComboBox...

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Feb 6, 2018

1). I am not happy to use a word that is less than twenty years old (according to Wikipedia) to represent a very small subset of what can be used. Character is one that people will recognise but unfortunately in this day and age, character has a degree of ambiguity; however glyphs and graphemes though not quite the same thing (the former is the representation of the latter in a particular font) are much better representations of what is involved - as it is, symbol is the replacement term I have put on the 2D mapper context menu and in the context where this is used as a specific mark or combination of marks used to designate something it is not an unreasonable choice either.

2). Ah, you said: "...with rows too small..." but you meant columns too small! I agree and I think I can fix that. I've also realised that it is not wise to include every room in the last column - because a wilderness map with symbols on every room will just make the rows very large when auto-sizing-to-contents, I'm proposing to clamp it to, say 32 rooms, with a more, not shown... ending if there are more than that number. Like this, whilst using Ssalis's Aetherspace map:

screenshot_20180206_051832

This will still allow the usage of odd glyphs to be detected which was the intention but means that it is not a full-blown search feature {unfortunately I haven't found a way to make it possible to (context-menu) select and copy data from the dialogue, e.g. by copying the symbols or individual room numbers} so this is probably okay.

3). It is not possible to colour emojis as the Qt widgets concerned do not support {which is not surprising, really} handling/rendering of the Variation selectors that control this i.e. U+FE0E {VARIATION SELECTOR-15 (VS15)} for text or U+FE0F {VARIATION SELECTOR-16 (VS16)} for emoji style.

For example of those selectors in use, one probably has to use a broswer (or perhaps QTextBrowser but that is just not realistic for this in the Mudlet application) "😐😠︎😄️ 😐︎😠︎😄︎ 😐️️😠️️😄️️" the first three icons here are plain, the middle three have VS15 and the last three have VS16 appended - and in my FireFox browser the third and the last three render as coloured emojis, the first, third and last three are a larger diameter compared to the second one and the middle middle three - but it is possible that they will not be the same for other viewers of this text.

Curiously, choosing the Symbola font shows those Variation Selectors as separate glyphs but as it does not contain them it is not easy to work out where those glyphs are coming from - for example, using DejaVu Sans:

screenshot_20180206_030557

Using Symbola:

screenshot_20180206_030646

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Feb 6, 2018

We've gotta think about the users here - I'd argue we're making the program for them. If we were making the program just for ourselves, yeah, we'd call everything the strictly 100% semantically correct terminology that very few users would understand. We're not working with a life-and-death situation here like I do at my work, I say we can relax the semantics in favour of people understanding.

That said emoji's are supposed to be coloured and if we can't get them to be coloured at all, then we shouldn't call them so. It'd be a big dissapointment. Can't we render the emoji in colour and then save that picture, and re-use it in the mapper?

Also, could you show me a screenshot of how your map looks like when this is working correctly? The results I've tried haven't rendered very well.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Feb 6, 2018

@Kebap @Ansrare @WackyWormer @keneanung you guys make use of the mapper as well, so if you could give your thoughts on this, that'd be great!

@WackyWormer
Copy link
Copy Markdown
Contributor

I vote for "symbol". I think both "emoji" and "character" both convey a much smaller set of options than are actually available. "Glyph" is a close second, and I think many english-speakers would be somewhat familiar with the term (e.g. Egyptian hieroglyphics), but IMO its a bit too esoteric for the average user.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Feb 7, 2018

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Feb 7, 2018

I think I am going to have to have a play with the various QFont::XXXX flags for the style strategy to review what each of them does - it looks like some are mutually exclusive and it is not so obvious that I have chosen the best ones - for instance I think I set things to prefer outline to bitmap fonts - but it may be at small sizes bitmaps actually work better - also with the anti-aliasing, I think I preferred that option as well, but again that may not be the optimum choice either... 🙁

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Feb 7, 2018

Okay, sure! Show us what you come up with.

@vadi2 vadi2 assigned SlySven and unassigned vadi2 Feb 7, 2018
I found that the existing triangular markings drawn on the room symbols to
indicate non-XY exits (i.e. up, down, in and out) mask any glyph drawn on
as a symbol because for the real exits they are completely filled in black.
This commit enhances the design so that a mid shade "brush" is used instead
for real exits and a light cross-hatch brush is used for stub exits.
Importantly the colour used for the brush is either a contrasting black or
white - the same as the pen used to draw the outline but it is now drawn
in the same colour as the door markings on XY plain exits - so that doors
can now be indicated on those up/down/in/out exits or stubs.

The tool-tips in the room exits dialogue have been amended to suit this
long-planned (by me) enhancement!

The pen used to draw the outline is also made a non-zero width size.

Stub in and out exits were not being properly drawn in the prior code as
there was a code limitation that ended up just drawing a horizontal line.
Now both stub and real exits of these types are now drawn as a PAIR of
triangles, with IN exits being an inward pointing pair each around half
the size of the prior one, and OUT exits being an outward pointing pair
outside the IN one.  I think it is more intuitive what the new versions are
indicating...!

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 9, 2018

Additionally, given an arbitrary map, how would I know which of the two functions to use? Getting a ? back is not correct, because it might also be an actual question mark.

The old one will return that '?' but also a second return which is a string saying that it should be changed to the new one - fair enough the user/scripter won't be looking for it - but if they start seeing a '?' instead of what is seen on the map one might guess that they'd RTFM.

I just dislike the naming anomaly getRoomChar/setRoomChar but realise we cannot get rid of them - so they just works in the way they worked before and should the user only use the single ASCII character they will not see any difference {other than that they can now delete the character from a script}. Don't forget that the return value from the new getRoomSymbol will be multiple bytes for anything that is not a single ASCII letter.

Though, if you @keneanung, as well as Vadim insist on only keeping one pair of functions i.e. getRoomChar/setRoomChar {instead of allowing the old ones to just be marked as obsolete from version 3.8 onwards and suggesting users use the new functions if they have them (which is one way but not the only way how we've added extra functionality in the past) - which is my preference} then I guess I will have to go along with the majority view - I just want to be sure we've covered all our bases before we finalise this...

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Mar 9, 2018

Yeah, I think so.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 10, 2018

How about a compromise: I note that there are some lua functions that are registered with a different name externally to what they are internally - and in one case this means there are two names that call the same function internally. As a bit of an aside I note that of the 303 functions that I can see declared in TLuaInterpreter right now, the following cases exist:

  • clearWindow(...) and clearUserWindow(...) both use the internal clearUserWindow(...) function {The former is used in the external GeyerMiniConsole.lua script, the latter is not mentioned}.
  • debugc(...) uses the internal debug(...) function {and is defined for both the main Lua instance and the indenter instances; debug is used in local function findStringEventHandler(existingHandlers, functionString) in the external Other.lua script and in some error handling for function mmp_mapping_newroom(_, num) in the script of the bundled mudlet-mapper.xml file}.
  • echo(...) uses the internal Echo(...) function and is used extensively
  • hideWindow(...) and showWindow(...) are mapped to hideUserWindow(...) and showUserWindow(...) internally respectively and are used in external GUIUtils.lua and GeyserContainer.lua files.
  • handleWindowResizeEvent(...) is mapped to the internal noop(...) function and has dummy (empty) replacements defined in GUIUtils.lua, LuaGlobal.lua and has a commented out work around in the Geyser.lua file for "VERSIONS PRIOR TO 1.1.0" - indeed that file is currently completely commented out now!
  • send(...) is mapped to the internal sendRaw(...) function and is used extensively in several external Lua files - however the internal TLuaInterpreter::sendRaw(...) which impliments it uses sendRaw in its error messages NOT send!
  • wait(...) is mapped to the internal Wait(...) function, it is not used by any external script that we provide - but the internal TLuaInterpreter::Wait(...) does run a msleep(argument) on the thread that is running it - of course this is an evil thing to do so it is just as well as we don't use it or document it. 😈

This being the case, would it be acceptable to I have map ped the old getRoomChar(...) and setRoomChar(...) onto the new getRoomSymbol(...) and setRoomSymbol(...) respectively ?. This would mean s that the old names would still work but the functionality (and error messages) would be the same as the new command - so that we do not add to the total number of functions by adding this change but the old names still operate though we prefer everyone to use the new ones going forward ?.

Edit, updated 2018/03/11 00:30

…ctions

Rather than have two sets of functions with one set only repeating the
reduced capabilities of the previous code this commit causes the use of the
old function names to be redirected to the new ones.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Copy link
Copy Markdown
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

"You may be able to correct this by installing an additional font using whatever "
"method is appropriate for this system or by editing the map to use a different "
"symbol. It may be possible to do the latter via a lua script using the "
"<i>getRoomSymbol</i> and <i>setRoomSymbol</i> functions.</p>")));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update this bit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below.

lua_register(pGlobalLua, "getRowCount", TLuaInterpreter::getRowCount);
lua_register(pGlobalLua, "getOS", TLuaInterpreter::getOS);
lua_register(pGlobalLua, "setRoomSymbol", TLuaInterpreter::setRoomSymbol);
lua_register(pGlobalLua, "getRoomSymbol", TLuaInterpreter::getRoomSymbol);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this bit anymore.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you do because that is what allows the better names using the word "symbol" to be used as well as (what I want to deprecate) "char" which isn't even really a word IMVHO - both work and call the same functions - in the same way as clearWindow and clearUserWindow do.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think clearWindow and clearUserWindow is a mistake we want to repeat again.

Let's look at it from the perspective of the users, and not a developer-centric purity point of view. It's a lot simpler for the users if there's one function that does one thing instead of two that do one thing?

Imagine this conversation: "What's this function B?" "Oh it does the same thing as function A." "Oh right... that makes total sense."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think clearWindow and clearUserWindow is a mistake we want to repeat again.

I am not sure what you mean by that - perhaps it predates my starting on the Mudlet project, but this does provide a means to get past the fact that the original functions were perhaps poorly named or at least not really appropriate when their scope had been expanded beyond their original target.

As the Wiki seems to be the goto documentation for the lua API it is well within the scope of things to have the original functions be stubs that say, see *etRoomSymbol(...) and to explain in the latter that since Mudlet 3.8.0 the functions' capability are extended.

You have always said that user/scripters should test for the presence of a function to determine it's availability and like this they can do so - without us having to have both. To work with just a single ASCII character in a backwards compatible manner they can use the old names - and existing stuff will continue to work (which is essential - I've learnt that by now!) but going forward new users/scripters in the future will be guided to use the more appropriately named "symbol" ones - and if anyone asks we can say that is why there are synonymous functions ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we already agreed there wouldn't be any backwards compatibility breaking already by upgrading roomchar's capability. What are you going for - to have roomchar be artificially limited to 1 ASCII character while roomsymbol is any unicode text?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is now no separate *etRoomChar(...) functions - only the new functions are in TLuaInterpreter.cpp but both sets are registered so that the old names still work in Lua scripts but called the new ones *etRoomSymbol(...) internally.

📖 I will edit the Wiki as required when this PR goes in - explaining that the revised functionality can be tested for against the new names (if that is really needed by scripters) but that the old names are left to preserve backwards compatibility...

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Mar 11, 2018

@keneanung could you review the changed as well?

@vadi2 vadi2 assigned SlySven and unassigned vadi2 Mar 26, 2018
@keneanung
Copy link
Copy Markdown
Member

I don't think clearWindow and clearUserWindow is a mistake we want to repeat again.

I am not sure what you mean by that - perhaps it predates my starting on the Mudlet project, but this does provide a means to get past the fact that the original functions were perhaps poorly named or at least not really appropriate when their scope had been expanded beyond their original target.

This is the case. But the problem is, that this renaming is confusing the users (whom we create this software for). I was contemplating this kind of compromise as well, but explaining to a user why we have a set of functions that do exactly the same is not making the interface more intuitive.

Another thing about renaming that function is making scripts work in multiple Mudlet versions becomes a PITA, especially if one function is deprecated and I don't know when it will be removed. It forces me to write stuff like local var = (getRoomSymbol or getRoomChar)() which doesn't make the code more readable or maintainable. Leaving it getRoomChar and be done with it, even if not precisely named, takes a huge burden off scripters backs. If you want an example of using such a changed interface, have a look at https://github.com/svof/svof/blob/master/raw-svo.defs.lua#L2360 and following until the end of the function. There are a lot of these cases, which make scripting newbies shy away. I had to answer a lot of questions about that part.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 26, 2018

Well I do not contemplate removing the old function names - until at least we have to redo things for Lua 5.2 or 5.3 because the Linux distributions no longer provide 5.1 (perhaps that will be needed for Mudlet 5.x where a major version number change would be mandated by such a backwards incompatible change)

Having both *etRoomChar and *etRoomSymbol still seem to me the best way to provide the backwards compatibility that existing scripts need whilst getting away from having to point out to new users that to get/set something that a reasonable person would call a symbol they have to use something that refers to a Char... 🙍‍♂️

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Mar 27, 2018

I'm not contemplating removing any function names either - breaking people's stuff is just not a cool thing to do, even on major upgrades!

Given my practical experience of working with a lot of users, the confusion of having two functions will be bigger than the confusion of having something that refers to char. We might think our functions have super intuitive and clear names but to many people it's all jibberish anyway and they can't tell the difference until they memorize what each does.

So I'm still in favour of just get/setRoomChar and no new functions for symbols even though we call them symbols now. Practical experience as keneanung demonstrated taught us that multiple functions confuse people.

Plus, in case we're wrong on this, we could introduce the symbol functions later on. We can't however undo removing a function.

@bbailey
Copy link
Copy Markdown

bbailey commented Mar 27, 2018

(If user commentary is inappropriate, I apologize in advance for polluting the comment stream and will happily accept admonitions.)

Speaking as a user and a developer, I've found it quite common to use character, glyph, and symbol interchangeably in everyday usage even among the developers in my communities, outside of specific technical discussion re: Unicode implementation and technical documentation.

As a developer I can appreciate more precise terminology and in this case I would agree that glyph is the most precise for this context, and this usage seems supported even in Unicode's own documentation and glossary where symbol isn't even elevated to a specific definition.

All in all, from a user perspective, it seems reasonable to me to simply retain *Char functions going forward, especially given that most platforms still provide (and most users seem to actually, er, use) a "character map" for browsing available unicode characters and glyphs.

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Mar 27, 2018 via email

SlySven added 2 commits March 27, 2018 23:07
…tions

Following extensive discussions it has been made clear that introducing
replacements for the lua [gs]etRoomChar(...) is not going to happen.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
…oomSymbols

Resolved conflicts in:
* src/TLuaInterpreter.cpp

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Copy link
Copy Markdown
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for this cool improvement!

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 28, 2018

⌚️ macOs builds are stalling (well starting then failing and re-queueing) at Travis at present - after around 12 hours one of the pair of them has succeeded but I'm having to wait for the second to conclude... 🙁

@SlySven SlySven merged commit 91a08c3 into Mudlet:development Mar 28, 2018
@SlySven SlySven deleted the Enhance_better2DMapRoomIdAndNonAsciiRoomSymbols branch March 28, 2018 13:06
@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Mar 28, 2018 via email

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Mar 28, 2018

Yeah, the next big thing is getting the text spacing/selection/highlighting working properly - I've got improvements so far but not a total solution - but it would be good to fix it for 2018/04/08 - (3.8.0 😀)

SlySven added a commit to SlySven/Mudlet that referenced this pull request Aug 16, 2019
…ault

This PR removes support for saving in the binary map file format of Mudlet
2.1 - i.e. format **16** (retaining the ability to read it) and adjusts the
format for new map files to be **20** by default - up from the previous
default of **18**. This should speed up map loading a little - as it will
remove the need to convert the data to the current forms used internally as
well as making some details more robust. It also allows the removal of some
warning code that would have fired if area or map user data features were
used and format *16* was selected for saving.

#### History of recent (last six years) changes to Map File Format:

* dfce0f0 (PR Mudlet#2106) - **20** Improved way
that custom exit line data was held internally (so that the keys are now
the same as the other exit details that are keyed by a string {doors, exit
weight}. The custom exit line style is stored as the shorter and easier to
code with `Qt::PenStyle enum`  instead of a English `QString` and the
custom exit line as a `QColor` instead of a `QList<int>` with 3 elements -
(so the custom exit line could have a alpha component in the future!) Code
is in place to support a workaround to work within map formats back to
include version 17.

* 91a08c3 (PR Mudlet#1543) - **19** Added support
for more than one of any grapheme for the 2D map room symbol. Code is
in place to support a workaround to work within map formats back to include
version 17.

* 94dd41b (associated with PR Mudlet#301) - **18**
Added support for multiple user rooms in map file copied to other profiles
- so that the original player room (in the other profile) is retained in a
map copied over. Also revised the `TArea::rooms` from being a `QList` to a
faster to look up in `QSet`. Code in place to support saving in previous
formats.

* fb79c62 (associated with PR Mudlet#280) - **17**
Added support for area and map user data features. Warnings are issued
should these be actually used and a lower map format is specified to save
the map in **as that data will then be lost from the map file**.

* 88ef649 - **16** Map format of Mudlet 2.1
dating back to 2013-01-02 .

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
SlySven added a commit that referenced this pull request Aug 21, 2019
…ault

This PR removes support for saving in the binary map file format of Mudlet
2.1 - i.e. format **16** (retaining the ability to read it) and adjusts the
format for new map files to be **20** by default - up from the previous
default of **18**. This should speed up map loading a little - as it will
remove the need to convert the data to the current forms used internally as
well as making some details more robust. It also allows the removal of some
warning code that would have fired if area or map user data features were
used and format *16* was selected for saving.

#### History of recent (last six years) changes to Map File Format:

* dfce0f0 (PR #2106) - **20** Improved way
that custom exit line data was held internally (so that the keys are now
the same as the other exit details that are keyed by a string {doors, exit
weight}. The custom exit line style is stored as the shorter and easier to
code with `Qt::PenStyle enum`  instead of a English `QString` and the
custom exit line as a `QColor` instead of a `QList<int>` with 3 elements -
(so the custom exit line could have a alpha component in the future!) Code
is in place to support a workaround to work within map formats back to
include version 17.

* 91a08c3 (PR #1543) - **19** Added support
for more than one of any grapheme for the 2D map room symbol. Code is
in place to support a workaround to work within map formats back to include
version 17.

* 94dd41b (associated with PR #301) - **18**
Added support for multiple user rooms in map file copied to other profiles
- so that the original player room (in the other profile) is retained in a
map copied over. Also revised the `TArea::rooms` from being a `QList` to a
faster to look up in `QSet`. Code in place to support saving in previous
formats.

* fb79c62 (associated with PR #280) - **17**
Added support for area and map user data features. Warnings are issued
should these be actually used and a lower map format is specified to save
the map in **as that data will then be lost from the map file**.

* 88ef649 - **16** Map format of Mudlet 2.1
dating back to 2013-01-02 .

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
vadi2 pushed a commit to vadi2/Mudlet that referenced this pull request Aug 21, 2019
* Refactor: extract a simple function that is used in several five places

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Refactor: eliminate shadowed variables in TTextEdit::mouseMoveEvent(...)

The use of `x` and `y` in nested code is confusing as the inner ones mask
the outer ones. This commit renames the inner copies.

It also makes a local reference to a section of the text attribute buffer:
`(std::deque<std::deque<TChar>>) TBuffere::buffer) that is used several
times.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* BugFix: cure the faulty selection when crossing an empty line.

The use of *manhattenLength()* was incorrect when determining whether it
was the start or end of the selection that was nearest to the mouse cursor,
instead it now (correctly) only considers the horizontal (x) offset when
the vertical offsets of the start and end point of the selection are equal.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* BugFix: finally cures the selection of text both with and without timestamps

Also:
* abstract the number of spaces for the timestamp on the left to a constant
`(int) TTextEdit::mTimeStampWidth`.

* renames `y` and `x` variables in the `TTextEdit::mouseMoveEvent(...)` to
`lineIndex` and `tCharIndex` as that more accurately describes them - and
also rename another pair of shadowing/masking `y` and `x` variables in the
SAME method to `yIndex` and `xIndex` respectively.

* convert a few remaining random C-style `(int)` casts in `TTextEdit` class
to C++ `static_cast<int>(...)` ones.

NOTE: An issue with deselection something in an upward direction against
the left margin remains - however the area is being correctly deselected
but code elsewhere that analyses which parts of the display actually
require repainting is missing that portion of the modified area of text.
It appears to be within the `TTextEdit::highlight()` method but it IS a
separate issue as the underlying text attribute buffer is being
correctly changed to clear the selection flags.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Revise: make time stamps show in lower pane as well as upper one

It is visually disturbing for the lower pane in the main, error and debug
consoles not to match the upper one when it is revealed by scrolling - or
by turning on the timestamps for the main console.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Revise: reduce space for time stamps from 15 to 13 (12 + space) characters

The use of 15 rather than 13 produced the need for an additional tweak when
trying to work out where the first actual game text start when trying to
deduce the position of it relative to the cursor!

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Fix insertPopup and echoPopup to accept "main" as an argument (Mudlet#3013)

* Update: drop support for saving to Mudlet 2.1 map format & update default

This PR removes support for saving in the binary map file format of Mudlet
2.1 - i.e. format **16** (retaining the ability to read it) and adjusts the
format for new map files to be **20** by default - up from the previous
default of **18**. This should speed up map loading a little - as it will
remove the need to convert the data to the current forms used internally as
well as making some details more robust. It also allows the removal of some
warning code that would have fired if area or map user data features were
used and format *16* was selected for saving.

#### History of recent (last six years) changes to Map File Format:

* dfce0f0 (PR Mudlet#2106) - **20** Improved way
that custom exit line data was held internally (so that the keys are now
the same as the other exit details that are keyed by a string {doors, exit
weight}. The custom exit line style is stored as the shorter and easier to
code with `Qt::PenStyle enum`  instead of a English `QString` and the
custom exit line as a `QColor` instead of a `QList<int>` with 3 elements -
(so the custom exit line could have a alpha component in the future!) Code
is in place to support a workaround to work within map formats back to
include version 17.

* 91a08c3 (PR Mudlet#1543) - **19** Added support
for more than one of any grapheme for the 2D map room symbol. Code is
in place to support a workaround to work within map formats back to include
version 17.

* 94dd41b (associated with PR Mudlet#301) - **18**
Added support for multiple user rooms in map file copied to other profiles
- so that the original player room (in the other profile) is retained in a
map copied over. Also revised the `TArea::rooms` from being a `QList` to a
faster to look up in `QSet`. Code in place to support saving in previous
formats.

* fb79c62 (associated with PR Mudlet#280) - **17**
Added support for area and map user data features. Warnings are issued
should these be actually used and a lower map format is specified to save
the map in **as that data will then be lost from the map file**.

* 88ef649 - **16** Map format of Mudlet 2.1
dating back to 2013-01-02 .

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* BugFix: handle empty SGR...m sequences so they are treated as SGR0m

The empty (no parameter) case is the same as the one with a single 0 which
is the reset attributes case. Mudlet was not handling it as that but it
will do after this commit.

This will close issue Mudlet#2993 .

Also clean up some tabs used for spaces in the same method:
`(void) TBuffer::translateToPlainText(...)`

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>

* Revise: some commented material in TTextExit::convertMouseXToBufferX

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
dicene pushed a commit to dicene/Mudlet that referenced this pull request Feb 19, 2020
…ault

This PR removes support for saving in the binary map file format of Mudlet
2.1 - i.e. format **16** (retaining the ability to read it) and adjusts the
format for new map files to be **20** by default - up from the previous
default of **18**. This should speed up map loading a little - as it will
remove the need to convert the data to the current forms used internally as
well as making some details more robust. It also allows the removal of some
warning code that would have fired if area or map user data features were
used and format *16* was selected for saving.

#### History of recent (last six years) changes to Map File Format:

* dfce0f0 (PR Mudlet#2106) - **20** Improved way
that custom exit line data was held internally (so that the keys are now
the same as the other exit details that are keyed by a string {doors, exit
weight}. The custom exit line style is stored as the shorter and easier to
code with `Qt::PenStyle enum`  instead of a English `QString` and the
custom exit line as a `QColor` instead of a `QList<int>` with 3 elements -
(so the custom exit line could have a alpha component in the future!) Code
is in place to support a workaround to work within map formats back to
include version 17.

* 91a08c3 (PR Mudlet#1543) - **19** Added support
for more than one of any grapheme for the 2D map room symbol. Code is
in place to support a workaround to work within map formats back to include
version 17.

* 94dd41b (associated with PR Mudlet#301) - **18**
Added support for multiple user rooms in map file copied to other profiles
- so that the original player room (in the other profile) is retained in a
map copied over. Also revised the `TArea::rooms` from being a `QList` to a
faster to look up in `QSet`. Code in place to support saving in previous
formats.

* fb79c62 (associated with PR Mudlet#280) - **17**
Added support for area and map user data features. Warnings are issued
should these be actually used and a lower map format is specified to save
the map in **as that data will then be lost from the map file**.

* 88ef649 - **16** Map format of Mudlet 2.1
dating back to 2013-01-02 .

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
@SlySven SlySven restored the Enhance_better2DMapRoomIdAndNonAsciiRoomSymbols branch June 22, 2020 18:01
@SlySven SlySven deleted the Enhance_better2DMapRoomIdAndNonAsciiRoomSymbols branch June 22, 2020 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants