Non-underlined Hyperlinks

Zesc
14 Nov 2019, 19:24Greetings fellow Quest users!
Todays question will be most likely yet another "Basically simple, but impossible in Quest withotu rewritting everything"-thing:
Can i create hyperlinks (or general "clickables") in text that are not underlined? If yes, how so?

DavyB
14 Nov 2019, 20:42Not sure exactly what you have in mind but going to the 'display' tab for the game and deselecting "Underline hyperlinks", plus setting "Link colour" to Black, should work for a complete game. This can also be done through the game attributes in a script, allowing the change to be dynamic.
mrangel
14 Nov 2019, 22:29A few different methods come to mind. I don't have Quest to hand right now to test these, but I'm sure someone else will be able to help iron out any bugs.
If this is something you're doing a lot, then you could add something like:
<style>
.nounderline a {text-decoration: none !important}
</style>
That will make all <a>
elements within a .nounderline
element not underlined (it will also stop them being crossed out or overlined). The !important
means that it overrules any other style rules that aren't also important. So even if a specific link has underlining hardcoded, this will take priority.
(You only need to print the above line once)
Then when you want to output a link without underlining it, you could do:
msg ("<span class=\"nounderline\">" + some_string_variable_that_contains_links + "</span>")
Alternative method:
JS.eval("$('#divOutput a').last().css({textDecoration: 'none'});")
When run, this command will remove underlining from the last link you displayed.
Another alternative method:
string_with_a_link_in = ProcessText(string_with_a_link_in)
string_with_a_link_in = Replace (string_with_a_link_in, "<a style=\"", "<a style=\"text-decoration: none;")
msg (string_with_a_link_in)

Zesc
15 Nov 2019, 06:35going to the 'display' tab for the game and deselecting "Underline hyperlinks"
...i probably should have said i'm working in gamebook mode.
Eh, yeah, nice to know it's juct the GB editor showing all it's "strenghts" again.
Thanks for the code mrangel, i'll try that as soon as i have time.. probably i could just import some TA-library (which apparently can do all this) and work from there.
Sorry for bothering you, i should have checked better first. My fault.
mrangel
15 Nov 2019, 11:13Thanks for the code mrangel, i'll try that as soon as i have time.. probably i could just import some TA-library (which apparently can do all this) and work from there.
Depends what you want to do.
In text adventures there's a box to untick. If it's unticked at startup, it sends the javascript to disable underlining. Note that changing it once the game is running won't do anything.
If you just want to disable underlining for all links, you can call the javascript manually:
JS.TurnOffHyperlinksUnderline()
However, this will not apply when loading a saved game. This code should be put in the UI Initialisation script, but Gamebook mode doesn't have that for some reason.
To disable hyperlinks permanently in gamebook (so that they don't reappear when loading a saved game), you'd have to override one of the built-in functions and add a line to it:
<function name="InitInterface">
if (game.setcustomwidth) {
JS.setGameWidth(game.customwidth)
}
if (not game.showborder) {
JS.hideBorder()
}
if (game.setcustompadding) {
JS.setGamePadding(game.custompaddingtop, game.custompaddingbottom, game.custompaddingleft, game.custompaddingright)
}
SetBackgroundColour(game.defaultbackground)
SetForegroundColour(game.defaultforeground)
SetLinkForegroundColour(game.defaultlinkforeground)
JS.SetMenuBackground(game.menubackground)
JS.SetMenuForeground(game.menuforeground)
JS.SetMenuHoverBackground(game.menuhoverbackground)
JS.SetMenuHoverForeground(game.menuhoverforeground)
JS.SetMenuFontName(game.menufont)
JS.SetMenuFontSize(game.menufontsize + "pt")
JS.panesVisible(false)
JS.uiHide("#location")
JS.uiHide("#txtCommandDiv")
JS.TurnOffHyperlinksunderline()
</function>
(My earlier post was based on the assumption that you wanted to create a hyperlink without underlining, but leave the rest of the game links underlined. For example if you wanted to make a link in your body text less obvious)
This has got me thinking about other ways to make a stealth link.
stealthscript => {
contents = ProcessTextCommand ("{"+LTrim(Mid(section,8))+"}", data)
if (IsRegexMatch ("<a[^>]+style=\"(?<rules>[^\"]*)\"", contents, "linkstyle")) {
params = Populate ("<a[^>]+style=\"(?<rules>[^\"]*)\"", contents, "linkstyle")
game.textprocessorcommandresult = Replace (contents, DictionaryItem (params, "rules"), "all: inherit; display: inline")
}
else {
game.textprocessorcommandresult = Replace (contents, "<a ", "<a style=\"all: inherit; display: inline\" ")
}
}
dictionary add (game.textprocessorcommands, "stealth", stealthscript)
I think if I've got that right, it will allow you to use {stealthobject:somename}
or {stealthexit:exit609}
to create a link with no formatting hints to suggest that it's a link; the player won't know unless they try clicking on it. This could be an interesting way to allow GUI interaction with scenery objects without the links being distracting :)

Zesc
16 Nov 2019, 14:23Thank you mrangel, this is just what i've been looking for.
Luckily i am already using functions per page that initialize every page's visuals (i have a set of themes including font, colours and background) so i can just add this piece of script there.
The more interesting thing: how do i re-enable underlining? I tried it with JS.TurnOnHyperlinksUnderline ()
or giving the function arguments, which isn't exactly working for me.
mrangel
16 Nov 2019, 14:42The more interesting thing: how do i re-enable underlining? I tried it with JS.TurnOnHyperlinksUnderline () or giving the function arguments, which isn't exactly working for me.
Unfortunately there isn't a corresponding turn on function. By default Quest runs TurnOffHyperlinksUnderline once, at startup, if it's needed; they never accounted for people who want to turn it on and off.
Off the top of my head, to turn hyperlinks on again after they've been turned off:
JS.eval("getCSSRule('a.cmdlink').style.textDecoration = 'underline'")
I think it would make more sense if the defaultgame
type (defined in the CoreTypes.aslx
library) had a script attribute:
<attr name="changedunderlinehyperlinks" type="script">
switch (this.underlinehyperlinks) {
case (true) {
value = "underline"
}
case (false, null) {
value = "none"
}
default {
value = ToString (this.underlinehyperlinks)
}
}
JS.eval("getCSSRule('a.cmdlink').style.textDecoration = '" + value + "';")
</attr>
Then you could turn the underlinehyperlinks
attribute on and off whenever you want and the javascript would fire automatically. (and if you really want to, you could set game.underlinehyperlinks = "overline red dotted"
to mess about with it)
Similar could be done for all the other style attributes that are currently only checked by InitInterface
; because I've lost count of the number of posts on the forum by people surprised that changing game.defaultbackground
or game.menufontsize
during the game doesn't do anything.

Zesc
16 Nov 2019, 19:46Your code does not work. I totally don't blame you, you#re already taking away all the JavaScript coding work from me, but i thought i better say this.
Oh yeah, and trying to use CoreTypes.aslx on a Gamebook results in an error. Since it seems to care about the genus of stuff, i guess it's because i'm using my editor in german? Or is this reproducable in english too?
Failed to load game due to the following errors:
* Invalid Boolean specified 'namedmale.usedefaultprefix = [UseDefaultPrefixIfNamed]'
* Invalid Boolean specified 'namefedmale.usedefaultprefix = [UseDefaultPrefixIfNamed]'
mrangel
16 Nov 2019, 21:29I'll give it another try later, see if I can work out what's wrong with it. Probably a typo or something that'll be easy to find when I have Quest in front of me.
trying to use CoreTypes.aslx on a Gamebook
You don't want to do that.
I was suggestion a modification to the core that would make the messing around with javascript unnecessary.
The TA version of the defaultgame
type is in CoreTypes.aslx
. Gamebook has a very different defaultgame
type, which is found in GamebookCore.aslx
(though it would be nice if the option was in there)

Zesc
18 Nov 2019, 10:57I've been using the TA libraries for quite some time in gamebooks now, pretty much whenever something is not included for them (for whatever reason); for example i got popups working under gamebooks too this way.
All issuess i experienced this way were when trying to save a game - it was looking for functions like OnRoomEnter
which i simply added as empty functions.
mrangel
18 Nov 2019, 11:07It won't work so cleanly with types; because defaultgame
exists in both TA and Gamebook but has different properties.
If you're adding something to it, you need to add it to the right version for your game type.
But in any case, I was suggesting a change to the core that would make this stuff happen automatically. If you're changing it just for one game, it's easier to add the script attribute to the game
element.