Jibble

Author Topic: MODULE: Hypertext v1.3 - Change font mid-sentence, web-like pages, Speech bubble  (Read 14599 times)

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
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: Adventure Game Studio
  1. =Hypertext=[This is some cool hypertext, with *bold,* /italics/ and _index|links_
  2.  

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



« Last Edit: 21 Mar 2008, 14:24 by SSH »

Re: MODULE: Hypertext v1.0
« Reply #1 on: 08 Dec 2006, 17:31 »
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

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.0
« Reply #2 on: 08 Dec 2006, 18:10 »
 :P

You could just ask me yourself... ;)

Ali

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.0
« Reply #3 on: 09 Dec 2006, 10:19 »
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

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.0
« Reply #4 on: 09 Dec 2006, 11:30 »
Rich is do-able, but I fear that sophisticated is beyond the realms of possibility...  ;)

Maverick

  • The Trinity is on its way!
    • I can help with story design
Re: MODULE: Hypertext v1.0
« Reply #5 on: 09 Dec 2006, 17:16 »
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

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    • Kweepa worked on one or more games that won an AGS Award!
    •  
    • Kweepa worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.0
« Reply #6 on: 09 Dec 2006, 18:08 »
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: Adventure Game Studio
  1. Hypertext.Add("Test", "John and Joe played _Fred|Tic-Tac-Toe._ ");
  2. Hypertext.Add("Test", "After 10 games the score was tied at 5 each. ");
  3.  
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.
« Last Edit: 09 Dec 2006, 18:26 by SteveMcCrea »
Still waiting for Purity of the Surf II

Rui 'Trovatore' Pires

  • Lunge da lei per me non v'ha diletto!
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with proof reading
    • I can help with scripting
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
Re: MODULE: Hypertext v1.0
« Reply #7 on: 09 Dec 2006, 20:10 »
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

  • The Trinity is on its way!
    • I can help with story design
Re: MODULE: Hypertext v1.0
« Reply #8 on: 09 Dec 2006, 20:38 »
actually, it's the character after the underscore that causes the problem. If you write
Code: Adventure Game Studio
  1. Hypertext.Add("Test", "John and Joe played _Fred|Tic-Tac-Toe._ ");
  2. Hypertext.Add("Test", "After 10 games the score was tied at 5 each. ");
  3.  
it works fine.

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

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    • Kweepa worked on one or more games that won an AGS Award!
    •  
    • Kweepa worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.0
« Reply #9 on: 09 Dec 2006, 20:57 »
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

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.0
« Reply #10 on: 09 Dec 2006, 21:25 »
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.

Maverick

  • The Trinity is on its way!
    • I can help with story design
Re: MODULE: Hypertext v1.0
« Reply #11 on: 10 Dec 2006, 09:49 »
Thank you gentleman.
As you pointed out I did not include a space at then end of the first line of text.

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.2
« Reply #12 on: 14 Dec 2006, 13:16 »
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!

Maverick

  • The Trinity is on its way!
    • I can help with story design
Re: MODULE: Hypertext v1.2 - Change font mid-sentence
« Reply #13 on: 05 Feb 2007, 20:01 »
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

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.21 - Change font mid-sentence
« Reply #14 on: 16 Feb 2007, 09:44 »
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...

Rui 'Trovatore' Pires

  • Lunge da lei per me non v'ha diletto!
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with proof reading
    • I can help with scripting
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
Re: MODULE: Hypertext v1.21 - Change font mid-sentence
« Reply #15 on: 16 Feb 2007, 10:16 »
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.

Re: MODULE: Hypertext v1.21 - Change font mid-sentence
« Reply #16 on: 16 Feb 2007, 10:36 »
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

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.21 - Change font mid-sentence
« Reply #17 on: 16 Feb 2007, 10:49 »
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.

Rui 'Trovatore' Pires

  • Lunge da lei per me non v'ha diletto!
    • I can help with AGS tutoring
    • I can help with play testing
    • I can help with proof reading
    • I can help with scripting
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
Re: MODULE: Hypertext v1.21 - Change font mid-sentence
« Reply #18 on: 17 Feb 2007, 00:13 »
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

  • Local Moderator
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: MODULE: Hypertext v1.21 - Change font mid-sentence
« Reply #19 on: 11 Mar 2008, 10:50 »
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.
No more military army stuff. I'm alive and back.