Custom Thinking/Speech GUI [SOLVED]

Started by DazJ, Sun 08/09/2013 14:49:40

Previous topic - Next topic

DazJ

I've created a 'Thinking' GUI named gThink.

The Globalscript code is as follows:

Code: ags

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

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?

Ghost

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


DazJ

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.

Calin Leafshade

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.

DazJ

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 :/

Calin Leafshade

just like this

Code: ags

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;
}

DazJ

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!

Calin Leafshade

You put the message on the gui:

lblThink.Text = message;

This line displays the text on the gui.

DazJ

#8
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 :)

SMF spam blocked by CleanTalk