Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: TerranRich on Tue 23/06/2009 19:05:13

Title: SayAt() not working right? Or just me? [WORKAROUND]
Post by: TerranRich on Tue 23/06/2009 19:05:13
So I'm using a custom function to display subtitle-type speech (on a 1024x768 screen):


function SaySubtitle(this Character*, const string sText)
{
   this.SayAt(5, 730, 1014, sText);
}


It's simple enough. If the speech text takes up one line of text, it shows up fine. However, if there are two lines of text, it moves upward. Basically, the bottom line of text is fine, but the top line is moved upward. It looks more like the X/Y coordinate is the bottom-left corner of the text, instead of the top-left, as specified in the manual.

And if I increase the Y value (to something like 735), ONLY text with two lines shows up, while single-line text is invisible.

What is going on here? Is it something I'm missing?

EDIT:

Some images to help with illustration:

(http://img29.imageshack.us/img29/8725/btsfbug01a.jpg)

(http://img200.imageshack.us/img200/6140/btsfbug01b.jpg)
Title: Re: SayAt() not working right? Or just me?
Post by: GuyAwesome on Tue 23/06/2009 20:31:07
From those screenshots, it looks like it's either using the bottom-left coord - as you said - or possibly the top-left coord OF THE LOWEST LINE ONLY, which has essentially the same effect but is a lot more confusing ;). Not sure why it would be doing either, though. (Maybe the answer is that the manual entry for SayAt is just wrong?)

Although you've probably considered this already; as a possible solution, what if you use GetTextHeight to figure out if it's a one- or two-line string, and adjust the y coord accordingly? Or, if you don't need to see the character's speech animation, use a text overlay instead of SayAt. Text overlays actually use the top-left coord as far as I can see, apparently even for multi-line strings...
Title: Re: SayAt() not working right? Or just me?
Post by: TerranRich on Tue 23/06/2009 23:35:14
Thanks for your input, GuyAwesome, but I've decided to instead use a GUI label. I found an invisible font to use for character speech, so there aren't duplicate lines (one from Say() and the other from the label). :)

Here's the function for those who are interested:


function SaySubtitle(this Character*, const string sText)
{
   lblDialog.TextColor = this.SpeechColor;
   lblDialog.Text = sText;
   this.Say(sText);
   while (this.Speaking == true) {
       Wait(1);
   }
   lblDialog.Text = "";
}


AGS even auto-numbers the dialog correctly (affecting the custom SaySubtitle() functions), and skips the global function's Say() command shown above, as it should! It's amazing. ;D
Title: Re: SayAt() not working right? Or just me? [WORKAROUND]
Post by: Trent R on Thu 25/06/2009 03:49:58
Terran, I like your idea of using .Say and .Speaking. I probably would've suggested overlays as well, but you are such a genius!

~Trent
Title: Re: SayAt() not working right? Or just me? [WORKAROUND]
Post by: GuyAwesome on Thu 25/06/2009 10:56:34
Quote
AGS even auto-numbers the dialog correctly (affecting the custom SaySubtitle() functions)
I guess you'll be having voice acting, then? (Actually, thinking about it, I read that in your GiP thread.) In which case, finding a way to use the inbuilt Say/At functions makes a lot more sense than fiddling round with Overlays and having to 'dummy up' playing the speech somehow. SetVoiceMode(eSpeechVoiceOnly) might've been easier than an invisible font, but if it's working now that doesn't really matter.
Title: Re: SayAt() not working right? Or just me? [WORKAROUND]
Post by: Khris on Thu 25/06/2009 12:26:36
Maybe SayAt makes use of Say and thus always places the bottom line at the same y coord.
Title: Re: SayAt() not working right? Or just me? [WORKAROUND]
Post by: GuyAwesome on Thu 25/06/2009 12:39:36
That seems to be what it's doing, and it makes a degree of sense in relation to Character.Say where the text always needs to be above the player - but it definitely looks to be using the BOTTOM left corner of the displayed text, rather than the TOP left as the manual says (or even the slightly bizarre 'top left of the lowest line' option).

EDIT after TerranRich:
That's what I meant by "the slightly bizarre 'top left of the lowest line' option", but look at this:
(http://www.2dadventure.com/ags/GuysSayAtExample.png)
The green cross is centred on the same coords as used for the SayAt, and looks to be just in from bottom left (even allowing for the 'centring' being off by pixel or two).
Title: Re: SayAt() not working right? Or just me? [WORKAROUND]
Post by: TerranRich on Thu 25/06/2009 17:03:14
It behaves more like the top-left coords of the bottom-most line of text. See how the bottom line of the two-line text is at the same position as the entire one-line text? I don't know if it's meant to do that. And GuyAwesome, I totally forgot about SetVoiceMode(). I shall use that as well, just to be consistent and correct. :)