SayAt() not working right? Or just me? [WORKAROUND]

Started by TerranRich, Tue 23/06/2009 19:05:13

Previous topic - Next topic

TerranRich

So I'm using a custom function to display subtitle-type speech (on a 1024x768 screen):

Code: ags

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:



Status: Trying to come up with some ideas...

GuyAwesome

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...

TerranRich

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:

Code: ags

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
Status: Trying to come up with some ideas...

Trent R

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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

GuyAwesome

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.

Khris

Maybe SayAt makes use of Say and thus always places the bottom line at the same y coord.

GuyAwesome

#6
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:

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).

TerranRich

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. :)
Status: Trying to come up with some ideas...

SMF spam blocked by CleanTalk