Disabling hyperlinks in 'Which [object] do you mean?' menu
Nathaniel.Spence
13 Apr 2020, 10:24Hello
An easy question, I think, but I've looked for the answer and I can't find it: how do I disable the 'Which [object] do you mean?' hyperlink menu that pops up when I'm using an ambiguous object (eg I'm holding two keys)? I don't mind it asking me which object, but I don't want the hyperlinks as they don't appear anywhere else in the game (I've disabled hyperlinks in the game settings) so they are incongruous here.
No doubt a template in the library somewhere, but I can't figure out which one...
mrangel
13 Apr 2020, 16:19Unfortunately, it's not so easy. The disambiguation menu uses ShowMenu
, which includes the line:
msg (count + ": <a class=\"cmdlink\" style=\"" + style + "\" onclick=\"ASLEvent('ShowMenuResponse','" + EscapeQuotes(optiontag) + "')\">" + optionText + "</a>")
If you're using the desktop version of Quest, you could modify that line. Possibly replace it with something like:
msg (count + ": " + optionText)
(although it might also be helpful to let players know that they can type the number to make a choice, so they don't feel like they've got to type long object names in full)
If you're on the web editor, or you don't want to modify the core functions, you could use javascript instead; removing the hyperlinks before showing them to the player.
This line of javascript will remove the hyperlinks from a menu that is currently on the screen:
$('#divOutput .cmdlink').removeClass('cmdlink').removeAttr('onclick');
So you could do:
ShowMenu ("Type a number to pick your favourite colour", Split("red;green;blue"), true) {
msg ("You picked: "+result)
}
JS.eval("$('#divOutput .cmdlink').removeClass('cmdlink').removeAttr('onclick');")
In the case of the disambiguation menu, the only script running is the parser itself. So you'd need to get a piece of javascript to run whenever a menu is output. To avoid running the script every turn (which could end up slowing the game down if there's a lot of output for it to process), I'd suggest making it run only at the end of a section. (menus are always put into their own section so that Quest can hide them after you made a choice).
You could do:
var original_EndOutputSection = EndOutputSection;
EndOutputSection = function (name) {
getCurrentDiv().find('.cmdlink').removeClass('cmdlink').removeAttr('onclick');
original_EndOutputSection(name);
};
Which basically replaces the function EndOutputSection
with one which removes all hyperlinks from the current section before calling the original function to end it.
Or, shrunk down so it's easier to include in Quest:
$(function () {
var i=EndOutputSection;
EndOutputSection = j => getCurrentDiv().find('.cmdlink').removeClass('cmdlink').removeAttr('onclick') && i(j)
});
TL,DR:
You can put the following line in your UI Initialisation script (On the game's "Advanced Scripts" tab, after you enabled it on the "Features" tab):
JS.eval ("$(function () {var i=EndOutputSection;EndOutputSection=j=>getCurrentDiv().find('.cmdlink').removeClass('cmdlink').removeAttr('onclick') && i(j)})")
(Note: This will remove the underline from links, and cause them to not respond when clicked on, but it won't change the colour because that's set manually for each link. Easier to set the link colour to be the same as your normal text colour)
Nathaniel.Spence
13 Apr 2020, 20:48Thanks, as ever, for a very comprehensive response. I'm using the desktop version, so I went for the first solution. Actually removed that line altogether and changed the disambiguate wording to just "which [object] do you mean?", with no menu (seems more in keeping with the rest of my game).