Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: DazJ on Sun 08/09/2013 14:49:40

Title: Custom Thinking/Speech GUI [SOLVED]
Post by: DazJ on Sun 08/09/2013 14:49:40
I've created a 'Thinking' GUI named gThink.

The Globalscript code is as follows:

Code (ags) Select

void Thinking(this Character*, String message) {
  lblThink.Text = message;
  gThink.Visible = true;
  int delay = (message.Length * GetGameSpeed()) / Game.TextReadingSpeed;
  int min_delay = (Game.MinimumTextDisplayTimeMs * GetGameSpeed()) / 1000;
  if (delay < min_delay) delay = min_delay;
  int ignore_delay = (Game.IgnoreUserInputAfterTextTimeoutMs * GetGameSpeed()) / 1000;
  mouse.Visible = false;
  Wait(ignore_delay);
  delay -= ignore_delay;
  if (delay > 0) WaitMouseKey(delay);
  mouse.Visible = true;
  gThink.Visible = false;
}


The Thinking action is called with the following line:

Code (ags) Select

cPeter.Thinking("&33 The woman was clearly upset.");


The GUI works flawlessly except it's not playing the associated sound files. The sound files are all in the correct Speech folder and play absolutely fine with the standard Character.Say functions.

Is there something wrong that's preventing the Thinking speech sound files from being played?
Title: Re: Custom Thinking/Speech GUI
Post by: Ghost on Sun 08/09/2013 14:54:33
I haven't checked yet, but I think I remember that the automated speech only workd with the "say" command. In that case you'd need some custom scripting to play a sound file with your thinking GUI.

edit:
I read it up in the manual. Speech linking via the & tag seems to work only in dialog lines and with the say command. I never did it myself though, so I may be wrong.

Title: Re: Custom Thinking/Speech GUI
Post by: DazJ on Sun 08/09/2013 14:57:12
It worked fine with the original Character.Think, but when I used my custom Character.Thinking script via gThinking (so I can position the thought box wherever I wish) it just won't play the sounds.

Does anyone know what the actual code should be to make the associated sound files play when used with Character.Thinking ?

Any help here would be much appreciated here, cheers guys.
Title: Re: Custom Thinking/Speech GUI
Post by: Calin Leafshade on Sun 08/09/2013 18:48:33
The problem you have here is that you arent calling Say or Think at all so theres no opportunity to play the sound file.

Before the days of Lua, I got around this kind of restriction by changing my speech font to a blank one and running say/think as normal.
All the think logic, including mouse catching, runs as normal but you can display it on a GUI however you like just by enabling it before the think call and disabling it after.
Title: Re: Custom Thinking/Speech GUI
Post by: DazJ on Sun 08/09/2013 19:49:30
Cheers Calin, could you please give me an example of what you mean, code-wise? This is the one thing I really seem to be having a problem with :/
Title: Re: Custom Thinking/Speech GUI
Post by: Calin Leafshade on Sun 08/09/2013 19:59:02
just like this

Code (ags) Select

void Thinking(this Character*, String message) {
  lblThink.Text = message;
  gThink.Visible = true;
  this.Think(message) // your think font is blank so no text is displayed but ags will still catch all the clicks and handle the timing.
  gThink.Visible = false;
}
Title: Re: Custom Thinking/Speech GUI
Post by: DazJ on Sun 08/09/2013 20:03:24
But I want the text to appear on the Thinking GUI, along with the speech. Or am I being extremely thick and missing something, haha!
Title: Re: Custom Thinking/Speech GUI
Post by: Calin Leafshade on Sun 08/09/2013 21:10:34
You put the message on the gui:

lblThink.Text = message;

This line displays the text on the gui.
Title: Re: Custom Thinking/Speech GUI
Post by: DazJ on Sun 08/09/2013 21:19:14
Ok...But I'm confused as to why I need to remove the font and use a blank one...Plus, if I remove the font, surely it'll be blank for when the characters are speaking normally?

Also, I receive the error "GUI set as text window but is not actually a text window GUI". I've had to use a normal GUI as you can't add labels to TextGUIs.

EDIT: You've cracked it, Calin. Thanks a lot pal, you're a life-saver. Making the speech font invisible worked a treat :)