Author Topic: Speech Bubble Module (v0.7.6)  (Read 518 times)

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Speech Bubble Module (v0.7.6)
« on: 03 Dec 2017, 11:28 »
Here's a module to do comic book-style speech bubbles. It's an alternative to Phylactere, because the older module doesn't work properly with 32-bit color. This module requires AGS 3.4, and for now it only works in 32-bit mode (or rather, transparency only works in 32-bit mode).

To use, you call Character.SayBubble():

Code: Adventure Game Studio
  1.   player.SayBubble("This line will be said in a speech bubble.");

To configure, you set the SpeechBubble properties:

Code: Adventure Game Studio
  1.   SpeechBubble.BorderColor = Game.GetColorFromRGB(0,128,0);
  2.   SpeechBubble.BackgroundColor = Game.GetColorFromRGB(128,255,128);
  3.   SpeechBubble.BackgroundTransparency = 33;
  4.   SpeechBubble.PaddingTop = 5;
  5.   SpeechBubble.PaddingBottom = 5;
  6.   SpeechBubble.PaddingLeft = 15;
  7.   SpeechBubble.PaddingRight = 15;

(You should probably do this in game_start() in GlobalScript.)

This module is still under development, and is currently missing some functionality (in particular support for background speech). Please report any bugs you experience.

The module is available on GitHub.

Download SpeechBubble v0.7.6

Change Log:

0.7.6
-Fixed an issue with lines with speech clips in text-only mode
« Last Edit: 04 Dec 2017, 21:01 by Snarky »

CaptainD

    • I can help with play testing
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
  • CaptainD worked on a game that was nominated for an AGS Award!CaptainD worked on a game that won an AGS Award!
Re: Speech Bubble Module (v0.7.5)
« Reply #1 on: 03 Dec 2017, 14:26 »
Thanks Snarky!

Definitely think I will be using this at some point.

Bavolis

  • Just past the Gnarled Scar.
  • Bavolis worked on a game that was nominated for an AGS Award!
Re: Speech Bubble Module (v0.7.5)
« Reply #2 on: 03 Dec 2017, 14:31 »
Awesome! Definitely going to play with this one. Thank you! :)

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Re: Speech Bubble Module (v0.7.5)
« Reply #3 on: 03 Dec 2017, 15:38 »
Finally someone did it :).


Although, Phylactere sounds so much nicer than Bubble, after all French is such a refined language, compared to the barbaric ones.

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Speech Bubble Module (v0.7.5)
« Reply #4 on: 03 Dec 2017, 18:41 »
Although, Phylactere sounds so much nicer than Bubble, after all French is such a refined language, compared to the barbaric ones.

"Phylactere" always makes me think of "prophylactic". This module, in contrast, is 100% condom-free.

Bavolis

  • Just past the Gnarled Scar.
  • Bavolis worked on a game that was nominated for an AGS Award!
Re: Speech Bubble Module (v0.7.5)
« Reply #5 on: 04 Dec 2017, 00:28 »
Everything's working very smoothly with only a couple of minor hiccups I'm trying to sort out. They may be on my end:

1. I have one cinematic scene where a floating head is in the middle of the screen. For some reason, it keeps shifting the SayBubble between above and below the character. I thought maybe it was a text length thing, but it puts some short ones on the bottom right next to long ones and then go back to the top for the next line. I don't seem to have any other characters with this problem. In the following example, all the SnipShadow lines play above his head, but cWinfillowFace alternates (but not in any kind of pattern) Here's what it looks like:

Code: Adventure Game Studio
  1. function room_AfterFadeIn()
  2. {
  3. cWinfillowFace.SayBubble("&1 You'll have a much bigger name than that.");
  4. cSnipShadow.SayBubble("&10 Gah! Spooky voice has a spooky face. Perfect.");
  5. cWinfillowFace.SayBubble("&2 We have much to discuss.");
  6. cSnipShadow.SayBubble("&11 Who are you? Are you me?");
  7. cWinfillowFace.SayBubble("&3 No. You are me. Now listen...");
  8. cWinfillowFace.SayBubble("&4 You must meet me at the peak of the Knobbly Crook.");
  9. cSnipShadow.SayBubble("&12 Right. Sure.");
  10. cSnipShadow.SayBubble("&13 Um. I'm just going to head back home now.");
  11. cWinfillowFace.SayBubble("&5 O'Sirus the Could Have Been...");
  12. cWinfillowFace.SayBubble("&6 O'Sirus the Never-Was...");
  13. cWinfillowFace.SayBubble("&7 Both are apt names.");

2. The text displays fine when I've got voices turned on, but if I turn them off in the game options, the larger text boxes close way too fast, even if I set my game text speed to 1 (which should be 1 character per second, if I'm not mistaken. The default 15 closes extremely fast. I'm not sure if this is due to AGS 3.4 or this module.

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Speech Bubble Module (v0.7.5)
« Reply #6 on: 04 Dec 2017, 07:15 »
1. I have one cinematic scene where a floating head is in the middle of the screen. For some reason, it keeps shifting the SayBubble between above and below the character.

Thanks! I'll look into it.

It'd be helpful to have some more info:

-What is your game resolution, room resolution, and position of your characters during this dialog?
-In the dialog, which lines display in the wrong location?
-What SpeechBubble settings are you using?
-Have you changed SB_sayImpl() (or any other part of the module)?

Quote
2. The text displays fine when I've got voices turned on, but if I turn them off in the game options, the larger text boxes close way too fast, even if I set my game text speed to 1 (which should be 1 character per second, if I'm not mistaken. The default 15 closes extremely fast. I'm not sure if this is due to AGS 3.4 or this module.

Ah yes. This is a known issue that is actually a bit difficult to solve properly. (It's because AGS relies on the speech clip length to determine how long to play spoken lines, so the module sends a line containing just the speech clip code and no text (because we're already displaying the speech bubble and don't want the text to appear twice) to Character.Say(). However, if speech is turned off, it falls back to using String length, and since the String is so short it goes away almost immediately.)

The easiest workaround is to set an invisible font (SpeechBubble.InvisibleFont). Here is one you can use: http://www.angelfire.com/pr/pgpf/if.html

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Speech Bubble Module (v0.7.6)
« Reply #7 on: 04 Dec 2017, 21:00 »
I haven't been able to reproduce the first issue with the speech bubble positions. Maybe if I could get those details I asked for.

2. The text displays fine when I've got voices turned on, but if I turn them off in the game options, the larger text boxes close way too fast, even if I set my game text speed to 1 (which should be 1 character per second, if I'm not mistaken. The default 15 closes extremely fast. I'm not sure if this is due to AGS 3.4 or this module.

Ah yes. This is a known issue that is actually a bit difficult to solve properly.

This turned out to be embarrassingly easy to fix, and the solution embarrassingly obvious. Updated in first post.

Bavolis

  • Just past the Gnarled Scar.
  • Bavolis worked on a game that was nominated for an AGS Award!
Re: Speech Bubble Module (v0.7.6)
« Reply #8 on: 04 Dec 2017, 23:36 »
Great news on the first solution! Sorry, I've been at work all day, so just now getting to answer. Here are the details:

1024x768 is my game resolution and the room size.

These are the settings I changed (in the global script):

Code: Adventure Game Studio
  1.   SpeechBubble.BorderColor = Game.GetColorFromRGB(255,255,255);
  2.   SpeechBubble.BackgroundColor = Game.GetColorFromRGB(0,0,0);
  3.   SpeechBubble.BackgroundTransparency = 20;
  4.   SpeechBubble.PaddingTop = 8;
  5.   SpeechBubble.PaddingBottom = 5;
  6.   SpeechBubble.PaddingLeft = 15;
  7.   SpeechBubble.PaddingRight = 15;

I didn't change any of the code outside of the global script settings.

The two speaking characters are at:

397, 752 <--working fine
552, 483  <--this is the one having problems. The character's top Y coordinate is at 185.

Line positions (Winfillow only because Snipshadow is working fine):

Code: Adventure Game Studio
  1. cWinfillowFace.SayBubble("&1 You'll have a much bigger name than that."); <--BOTTOM
  2. cWinfillowFace.SayBubble("&2 We have much to discuss.");<--TOP
  3. cWinfillowFace.SayBubble("&3 No. You are me. Now listen..."); <--TOP
  4. cWinfillowFace.SayBubble("&4 You must meet me at the peak of the Knobbly Crook."); <--BOTTOM
  5. cWinfillowFace.SayBubble("&5 O'Sirus the Could Have Been...");<--TOP
  6. cWinfillowFace.SayBubble("&6 O'Sirus the Never-Was..."); <--BOTTOM
  7. cWinfillowFace.SayBubble("&7 Both are apt names."); <--BOTTOM
  8. cWinfillowFace.SayBubble("&8 Horse."); <--TOP
  9.  


I had some problem with the first room being corrupt and had to recreate it. If you don't see any reason for this bug, I can go ahead and redo this one too and see if that fixes it. This is my second oldest room that's gone through a few AGS updates.

Dave Gilbert

  • Mittens Vassal
  • AGS Baker
  • Hi. Our names are FRIGGING ADORABLE.
    • Lifetime Achievement Award Winner
    •  
  • Dave Gilbert worked on a game that was nominated for an AGS Award!Dave Gilbert worked on a game that won an AGS Award!
Re: Speech Bubble Module (v0.7.6)
« Reply #9 on: 05 Dec 2017, 15:21 »
This is so cool! Is there any way to make these bubbles non-blocking?

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Speech Bubble Module (v0.7.6)
« Reply #10 on: 05 Dec 2017, 15:39 »
Thanks Dave! I haven't implemented non-blocking speech yet, but it's next on my TODO list, after I figure out the bug Bavolis is experiencing.

Bavolis, please don't redo the room: I don't see any legitimate reason why it should screw up the module, and it's better to have a bug that can be reliably reproduced than one that we don't know how to trigger any more. Thanks for the additional details, BTW! I'll see if I can recreate the problem with a similar setup. If all else fails I might ask you to send me your project for me to test (or I could make a special debug version of the module for you that would help me nail down where it goes wrong).
« Last Edit: 05 Dec 2017, 15:41 by Snarky »

Bavolis

  • Just past the Gnarled Scar.
  • Bavolis worked on a game that was nominated for an AGS Award!
Re: Speech Bubble Module (v0.7.6)
« Reply #11 on: 06 Dec 2017, 02:11 »
Bavolis, please don't redo the room:

I'll wait to see what you can find out - any way I can help, let me know. I thought maybe it was a screen position thing and tried moving the character all the way to the bottom of the screen and the bubble still appeared below him. It's worth pointing out that there's nothing complex going on in this room, too - it's just a straightforward cinematic with lots of says.

EDIT: Snarky solved my problem - it was due to a normal view being tiny when what was being displayed in the idle view was proper sized. It comes as no surprise that the issue was on my end, but I appreciate the troubleshooting to help me find my mistake!
« Last Edit: 06 Dec 2017, 13:10 by Bavolis »

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Speech Bubble Module (v0.7.6)
« Reply #12 on: 06 Dec 2017, 20:15 »
Though it's worth noting that the SpeechBubble module behaves a little differently from AGS Character.Say() in this respect:

With Character.Say(), as near as I can tell, the text positioning is always based on the height of the (first frame in the) NormalView – unless it has been Locked to some other view – even if speech starts while an Idle view is playing. Character.SayBubble(), on the other hand, uses the current view at the time when speech starts, so if the idle animation is playing at that moment, it goes by the height of the Idle view. (I believe it can also be the SpeechView, if the character it already speaking.)

I can't see any way to determine whether the current view (if different from the NormalView) has been set with LockView() or is playing for some other reason, so I'm not sure it's possible to completely match the AGS behavior here.

Bavolis

  • Just past the Gnarled Scar.
  • Bavolis worked on a game that was nominated for an AGS Award!
Re: Speech Bubble Module (v0.7.6)
« Reply #13 on: 09 Dec 2017, 05:41 »
Another small hiccup I'm having... if I have an inventory window open and look at an item, the saybubble appears behind the GUI(whereas the say function would appear in front of it). IS there a way to set an always in front priority? I don't see ever wanting to have the speech bubbles behind anything. Maybe it's already there and I missed it.

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Speech Bubble Module (v0.7.6)
« Reply #14 on: 09 Dec 2017, 08:02 »
This is an AGS limitation. It renders things in a certain order that cannot be changed, back-to-front:

-The room and Objects and Characters in it
-Overlays, including SayBackground() overlays
-GUIs
-The Say() Overlay (and as of 3.4.1, the speech portrait)
-The cursor

So only by using Say() will text always show up in front of the GUIs. (Personally I think it would be more logical for speech to display behind GUIs by default, but it is what it is. The best thing would be if we could manipulate the Z-order freely.) By default, the SpeechBubble module displays the speech bubbles on Overlays, so they'll appear behind any GUIs.

However, there is a way to work around that limitation: you can pass a GUI to SayBubble() as an optional argument, and the module will display the bubble on that GUI instead of on an overlay. (The GUI should be empty and set to a transparent background and border.) If you set the GUI.ZOrder property higher than any of your other GUIs, it will display on top.

Also, as a pro-tip, if want to always use that GUI and don't want to add the argument every time you call SayBubble(), you can edit the SayBubble() function in the module to add this line at the very top (should be line 967):

Code: Adventure Game Studio
  1.   bubbleGui = gSpeechBubble; // Replace gSpeechBubble with the name of the GUI you want to use

(In an upcoming version I'll add a default-GUI property to the module so that you won't have to do this.)
« Last Edit: 09 Dec 2017, 08:08 by Snarky »

Re: Speech Bubble Module (v0.7.6)
« Reply #15 on: 09 Dec 2017, 13:49 »
Really like that Module!

What would I have to do to make it wqork in the Tumbleweed Dialogues?

Greetings

Loslem

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Speech Bubble Module (v0.7.6)
« Reply #16 on: 09 Dec 2017, 14:29 »
Thanks!

You mean this template? I haven't used it, but as far as I can tell it doesn't really change anything to do with speech, so you should be able to use both the Tumbleweed Verbs template and the SpeechBubble module at the same time without issue. So you just import the module into your game project. (Save the scm file to your computer, and from the AGS "Explore Project" pane, right-click on "Scripts" and choose "Import Script...")

To get the speech bubble effect, you have to call Character.SayBubble(). So you should put that wherever you had Character.Say() before (where Character is replaced by the name of some character, or the special player variable).

So instead of this:

Code: Adventure Game Studio
  1.   cRoger.Say("It's a blue cup.");

You write this:

Code: Adventure Game Studio
  1.   cRoger.SayBubble("It's a blue cup.");

In dialog scripts, you must use the command instead of the simple "name: line" format, and have to indent the line with spaces or tabs. So instead of this:

Code: Adventure Game Studio
  1. player: What we have here is a failure to communicate.
  2. Davy: What was that?

Put this (Notice that the lines start with two spaces):

Code: Adventure Game Studio
  1.   player.SayBubble("What we have here is a failure to communicate");
  2.   cDavy.SayBubble("What was that?");

There's not much more to it. Hope that answers your question!

Re: Speech Bubble Module (v0.7.6)
« Reply #17 on: 09 Dec 2017, 15:19 »
Ah right it workes! I tried putting the commands in the dialog before and I got an error, but that was because I used the Hologram character from the template, and it had no Talking view. Error was "SetCharacterView: invalid view number (You said 0, max is 10)"

So, Characters seem to need to have a talking view assigned. I don't know if that is of any help :)

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Speech Bubble Module (v0.7.6)
« Reply #18 on: 09 Dec 2017, 16:00 »
Yeah, I just came across that issue as well. I've put in a check for it. Thanks!

Bavolis

  • Just past the Gnarled Scar.
  • Bavolis worked on a game that was nominated for an AGS Award!
Re: Speech Bubble Module (v0.7.6)
« Reply #19 on: 09 Dec 2017, 23:15 »

Also, as a pro-tip, if want to always use that GUI and don't want to add the argument every time you call SayBubble(), you can edit the SayBubble() function in the module to add this line at the very top (should be line 967):

(In an upcoming version I'll add a default-GUI property to the module so that you won't have to do this.)

Thanks for the quick help yet again!