Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: BatWitch on Mon 08/11/2010 03:22:37

Title: Displaying anti-aliased custom-font text at specified location.
Post by: BatWitch on Mon 08/11/2010 03:22:37
I'm trying to display a line of text at the bottom of the screen, kind of like this:
http://i.imgur.com/dMX1T.jpg (the font is Arial Rounded)

Using what I could understand from:
http://www.adventuregamestudio.co.uk/acintro8.htm
http://www.adventuregamestudio.co.uk/manual/Character.SayAt.htm

I tried this:
// Dialog script file
@S // Dialog startup entry point
return
@1
 cWendy.SayAt(100, 500, 600, "My name is Wendy!");
stop

but when I run the game, no text appears.


Eventually I would like to see the text appear like this: http://i.imgur.com/LfC2q.jpg

but for now, I'm simply trying to figure out how to display some text at the bottom...
Title: Re: Displaying text at the bottom.
Post by: Khris on Mon 08/11/2010 05:51:55
What resolution are you using?
Title: Re: Displaying text at the bottom.
Post by: Calin Leafshade on Mon 08/11/2010 06:16:48
that SayAt command has always been a little strange and it doesnt seem to render text below a certain level.

here is my solution (typed from memory without the editor so syntax errors are likely)

It requires you to use lucusarts style speech but with an entirely blank speech font.
So even though the characters are talking, you cant see the text so you can override it with your own function.

This has the added bonus of being able to have sierra style speech with speech animation on the characters themselves.


// make a gui label that represents where you want the text to appear
// in this case its called SpeechLabel

function iSay(this Character*, String what){

String textForLabel = what;
if (textForLabel.SubString(0,1) == "&"){
     int nextspace = textForLabel.IndexOf(" ");
     textForLabel = textForLabel.Substring(nextspace + 1, textForLabel.Length - nextspace - 1);
}

// you can also make your speech gui visible here if it has some background or something

SpeechLabel.Text = textForLabel;
this.Say(what);
SpeechLabel.Text = "";

//also make the gui invisible

}



The problem with this solution is that you have to type the iSay command into the dialog editor all the damn time and the editor doesnt allow you to auto number the speech lines for spoken dialog.

I am working on an editor plugin to fix those things but for now the problems remain.
Title: Re: Displaying text at the bottom.
Post by: BatWitch on Mon 08/11/2010 12:09:38
Quote from: Khris on Mon 08/11/2010 05:51:55
What resolution are you using?
I am using 800x600.
Title: Re: Displaying text at the bottom.
Post by: BatWitch on Mon 08/11/2010 21:51:17
Quote<Dualnames> you're good with the function, but you've placed it somewhere I doubt you'll ever trigger it.
<BatWitch> I placed it in dialog
<Dualnames> are you starting the dialog?
<BatWitch> but I don't know how to tell AGS editor to read that
<Dualnames> okay take that command
<BatWitch> it should appear on the screen right away, without interaction.
<Dualnames> you have a room i pressume right?
<Dualnames> i mean the game starts in a room, so go into that room interactions and search for after fade in.
<BatWitch> my room script has one line in it: // room script file
<BatWitch> I guess I put it in there?
<Dualnames> no
<Dualnames> see a thunder to the right?
<BatWitch> ... no
<Dualnames> sec
<BatWitch> I do not see a thunder icon in the right hand tree that starts with "General Settings"
<Dualnames> http://i133.photobucket.com/albums/q53/JustLedZep/Untitled-16.png
<Dualnames> you need to double click on your room
<Dualnames> and then you'll see that thunder like i did on the pic
<BatWitch> oh, I have to click "Edit Room"
<Dualnames> yes
<Dualnames> so now you see it?
<BatWitch> oh.. success
<BatWitch> the text loaded
<Dualnames> see, you created an instance
<BatWitch> How can I make it so that the text lingers on the screen until there's a click, enter, or space bar pressed?
<Dualnames> room After Fade in means that something will occur every time you see the room background (therefore the room has been loaded in game)
<Dualnames> yes, go to the general settings
<BrutalSlakt> this tutorial is good to help you get started http://www.youtube.com/watch?v=1Ml_DR76Cl4
<Dualnames> Then on the Dialog (bold) -> Allow speech to be skipped by which events -> Select mouse or key                                                                                                    
<Dualnames> you can only set one specific key to work as the only thing to skip speech + the mouse
<Dualnames> Also since you got your problem solved, edit the forum topic as solved
<BatWitch> Hmm... I see.

There you have it folks.

although, now I have another problem: how do I change how big, what color, and in what font the text appears on the screen?
Title: Re: Displaying text at the bottom.
Post by: Khris on Mon 08/11/2010 22:05:17
You have to import the font at the appropriate size.
In the project tree, add a new font by right clicking the Fonts node and selecting "New font". The new font will be opened. At the top, click on "Import over this font". Now navigate to your fonts folder or wherever you have the font and open it (the file dialog was broken for me; I had to type in the fonts name to open it). AGS then asks you what size it's supposed to use. Enter/change the font size and click ok.
You can now name the font it you want in the properties pane. (This name is appended to "eFont" and the result will show up in the auto-complete window in the script editor for your convenience.)

Now you'll want to set the font as the game's SpeechFont. To do this, open Global.asc in the Scripts node, navigate to game_start and add the following inside:

  Game.SpeechFont = eFontArial;

This should take care of font type and size; to change the color, do this:

  player.SpeechColor = Game.GetColorFromRGB(255, 0, 0);  // red

As you can see, the color isn't a global setting but can be specified for each character separately.
Title: Re: Displaying text at the bottom.
Post by: BatWitch on Sat 13/11/2010 03:23:30
Hmm.. I tried to change the font by pasting that line of code in GlobalScript.asc under game_start(), but I am getting an error message that ARoundB (the name of my imported font) is undefined:

http://i.imgur.com/zmGYJ.jpg
Title: Re: Displaying text at the bottom.
Post by: monkey0506 on Sat 13/11/2010 03:57:31
Fonts have "eFont" prepended to their name. So, eFontARoundB.
Title: Re: Displaying text at the bottom.
Post by: BatWitch on Sat 13/11/2010 04:29:40
Aha! That worked  ;D

Now I have a line of text on the bottom!
http://i.imgur.com/aLO4A.jpg

Is there a way to get the text smooth around the edges?
Right now it is very aliased.
I see an option in GlobalScript.asc for Anti-alias TTF fonts : true/false

I tried changing that to True and reimporting the font, but it did not yield success.
Title: Re: Displaying anti-aliased custom-font text at specified location.
Post by: mode7 on Sat 13/11/2010 07:41:32
Have you tried the general settings tab? There's an option for AA TT fonts. It worked for me
Title: Re: Displaying anti-aliased custom-font text at specified location.
Post by: BatWitch on Sat 13/11/2010 14:26:47
Whoops, by "GlobalSettings.asc" I meant "General Settings".

So yes, I did try that, but the font is still jagged.  :'(
Title: Re: Displaying anti-aliased custom-font text at specified location.
Post by: Sslaxx on Sat 13/11/2010 14:30:02
Quote from: BatWitch on Sat 13/11/2010 14:26:47
Whoops, by "GlobalSettings.asc" I meant "General Settings".

So yes, I did try that, but the font is still jagged.  :'(
I always had issue with the colour depth - for me, 32-bit colour is the only one that appears to do anti-aliasing satisfactorily. So it might be worth checking that?
Title: Re: Displaying anti-aliased custom-font text at specified location.
Post by: BatWitch on Sat 13/11/2010 15:30:57
I upgraded my copy of AGS (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41636.0), and now the font is displaying anti-aliased.

Thank you Calin Leafshade for all the support in IRC!


However, now I'm in an odd predicament:
The font is cut off at the top.
http://i.imgur.com/pbB8z.jpg (http://i.imgur.com/pbB8z.jpg)
My font is imported to be 32px tall.
I tried a smaller height (24px) but it was still cut off.

Ah, nevermind. It was because I was using a TrueType font.
(http://i.imgur.com/zOJGJ.jpg)
Converting the font to OpenType fixed the cut-off text issue.
Title: Re: Displaying anti-aliased custom-font text at specified location.
Post by: Sslaxx on Fri 24/12/2010 15:03:08
Quote from: BatWitch on Sat 13/11/2010 15:30:57
I upgraded my copy of AGS (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41636.0), and now the font is displaying anti-aliased.

Thank you Calin Leafshade for all the support in IRC!


However, now I'm in an odd predicament:
The font is cut off at the top.
http://i.imgur.com/pbB8z.jpg (http://i.imgur.com/pbB8z.jpg)
My font is imported to be 32px tall.
I tried a smaller height (24px) but it was still cut off.

Ah, nevermind. It was because I was using a TrueType font.
(http://i.imgur.com/zOJGJ.jpg)
Converting the font to OpenType fixed the cut-off text issue.
I know this is a bit of a necropost, but do the later versions Calin/Tzachs/ProgZMax made work any better? Is it all true type fonts/files?
Title: Re: Displaying anti-aliased custom-font text at specified location.
Post by: monkey0506 on Fri 24/12/2010 16:22:50
The versions made by Calin, tzachs, and ProgZMax were all modifications to the editor, not the engine. So they wouldn't affect anything at run-time, only design-time and (possibly) compile-time.