MODULE: Hypertext v1.3 - Change font mid-sentence, web-like pages, Speech bubble

Started by SSH, Fri 08/12/2006 17:07:08

Previous topic - Next topic

SSH

Requires AGS 2.72 or later

Inspired by the discussion in this thread, I have created a module that allows you to display marked-up text that can change font or colour in the middle and back again, also with Hyperlinks. v1.1 includes support for functions that work like character.Say() and Display(). Also, new strikethrough, bold, overline, etc. special effects. v1.2 fixes some bugs and adds speech bubbles. v1.21 fixes a problem where a GUI used for hypertext Display had to be set to non-Clickable. v1.3 works swimmingly with AGS 3.0+

e.g.
Code: ags

=Hypertext=[This is some cool hypertext, with *bold,* /italics/ and _index|links_


rendering as something like:


Hypertext
This is some cool hypertext, with bold, italics and links




Download the Hypertext module here
Hypertext module documentation
Hypertext module wiki page




12

GarageGothic

SSH, you're really becoming my arch nemesis. Every time I spend months and months on scripting something cool, someone pops up in the beginners forum asking for that particular functionality, and you whip something up in a day or two. Cursed be the day that CJ introduced modular scripting.

On a more upbeat note, cheers for another job well done.

SSH

 :P

You could just ask me yourself... ;)
12

Ali

This looks really useful! By the time I realised AGS lacked this feature, you'd already made a module for it.

If I complained being poor and unkempt in the technical forum, how long would I have to wait before 'SSH's Make Ali Rich and Sophisticated Module' was released?

SSH

Rich is do-able, but I fear that sophisticated is beyond the realms of possibility...  ;)
12

Maverick

Another excellent module.

I played around with the demo a bit and get a warning when I exit the game
(room1): Dynamic sprite 7 was never deleted
(room1):Dynamic sprite 8 was never deleted

Also if you do the mark up for hypertext using the last word in a string it wraps around to the next string and the whole block of text becomes the hyperlink.
Example:

Hypertext.Add("Test", "John and Joe played _Fred|Tic-Tac-Toe_.");
Hypertext.Add("Test", "After 10 games the score was tied at 5 each. ");

Renders as:

John and Joe played Tic-Tac-Toe_. After 10 games the score was tied at 5 each.

not as:

John and Joe played Tic-Tac-Toe. After 10 games the score was tied at 5 each.

I suppose you can always plan your text in such a way that you never use the last word in a string to create the hyperlink. Not a big issue.

Thanks again for your time and effortÃ,  ;D

Kweepa

#6
Quote from: Maverick on Sat 09/12/2006 17:16:25
Also if you do the mark up for hypertext using the last word in a string it wraps around to the next string and the whole block of text becomes the hyperlink.
Actually, it's the character after the underscore that causes the problem. If you write
Code: ags

Hypertext.Add("Test", "John and Joe played _Fred|Tic-Tac-Toe._ ");
Hypertext.Add("Test", "After 10 games the score was tied at 5 each. ");

it works fine.

Very cool module! I particularly like that the page history works.

[EDIT]
One feature that would be useful that wasn't in the TODO list (I think) would be a function to get the current page name. That way you could trigger game events from it, display images in a separate GUI, play music, end the game...
It might also be useful to be able to clear a page, so it can be altered slightly.
Still waiting for Purity of the Surf II

Rui 'Trovatore' Pires

Out of curiosity (and it's easy to see in the module, but it would be nice if it were mentioned here as well), are we talking about about Display messages, GUI labels, or both?
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Maverick

Quote from: SteveMcCrea on Sat 09/12/2006 18:08:23
actually, it's the character after the underscore that causes the problem. If you write
Code: ags

Hypertext.Add("Test", "John and Joe played _Fred|Tic-Tac-Toe._ ");
Hypertext.Add("Test", "After 10 games the score was tied at 5 each. ");

it works fine.

Steve ,
I tried it and the problem is still the same (AGS version 2.72)

Kweepa

Quote from: Maverick on Sat 09/12/2006 20:38:15
I tried it and the problem is still the same (AGS version 2.72)
You probably didn't put a space at the end of the first line, after the underscore.
The underscore (or asterisk, etc) has to be the last character in a word - the words are separated by spaces only.
Still waiting for Purity of the Surf II

SSH

Indeed, as Steve says, you have to remember to put the closing markup AFTER any punctuation for it to work.

If you do keep having a problem, though, Maverick, please upload your game directory as a zip and I'll take a look and try and sort it out.
12

Maverick

Thank you gentleman.
As you pointed out I did not include a space at then end of the first line of text.

SSH

Just a bump to highlight that I've added Speech bubbles to this. Look at the first post for screenshots of Roger and Mika's steamy conversation!
12

Maverick

Wow! This is getting better all the time. What are the chances of including images (like thumbnails on a web page) so it behaves like a "real" web page?

SSH

Updated to fix a bug Maverick found.

As for images, I do want to add it sometime, but I'm not sure when I'll have time...
12

Rui 'Trovatore' Pires

I'm still not sure I've undertood completely about this module, but anyway, SSH, tell me - is it possible to use it to change the colour of certain items in a Listbox? Just that - write something in a different colour, and then write back in a normal colour.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

GarageGothic

I haven't used SSH's module, but as I understand it (and if it's anything similar to my own html module), all the handling of mouseovers and links is handled by the module itself, without any GUI objects such as listboxes. Thus, you can't change the color of a Listbox item, but you can achieve a similar effect by creating a list of links similar to a listbox. Of course this means that some of the listbox specific commands related to savegames etc. can't be applied.

SSH

Yes, you're right GG.

If you tell me EXACTLY what you're trying to achieve, Rui, I can tell you the best way to do it or perhaps make a small change to the module to make it easier.
12

Rui 'Trovatore' Pires

Ah, no, nevermind then, thanks. I made, for a game, a text system similar to the one in SQ6 - all text gets displayed in a box at the bottom of the screen, and you can scroll up to see old messages. I used a listbox, and I was musing on changing the colour for when a character speaks.

Doesn't matter all that much anyway, I can change the colour when the character speaks, change it back afterwards and leave it "on record", as it were, in a normal colour - the player will have already seen it in a different colour during the conversation, which is where it matters.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

Dualnames

Kill me for digging this but it's very important if someone cares to use it for AGS 3.0

First if new-strings is set to true it means that you have to replace a lot of functions in the module. 780 lines is a lot..

Secondly when you add pages you have to make sure that the line of code isn;t bigger than 500.

Don;t do this:
Hypertext.Add("mypage","Get dead really
fast.");

Just make more pages and add more links.
Also the name of a page shouldn't contain any gaps for your personal convinience.You can;t link it like this _my page|more_.
Also leave a gap before each _ and after one_
ex:
Get dead or what _my page_ .


If you don;t folllow my advice you'll get a message I got. AGS failed in drawing... and some stuff.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk