MODULE: SpeechBubble v0.8.0

Started by Snarky, Sun 03/12/2017 11:28:04

Previous topic - Next topic

CCrane

Hi,
great module you have here. Some questions I'd like to ask. First, if ...

  SpeechBubble.MaxTextWidth = 250;

... is determined by screen/native game resolution size, i.e. are these relative or absolute values? I would generally prefer dialog in at least two lines for a more proportionate appearance of the bubble but setting some value up for text width won't make much sense with absolute values if the target system has a greatly differing resolution.

Secondly, is it possible to change border width/line thickness of the bubble? I found no variable for that so I suspect it's kinda similar to automatic text outline which can't be adusted, either. My test game is 640x400 right now and I might go even higher but the border can barely be seen already.
If line thickness is hard-coded would it be possible to create two overlaying bubbles, eg. one smaller white and a bigger black one in the background? This won't really work with transparency obviously but some of us might be okay with that. Just a thought ... :)


Finally, you mentioned planning a think bubble. Will this only work for Sierra-style speech, like player.think seems to do currently, or also for LucasArts-style games? That would be great.


Thank you

@ChristophCrane_ (Indie author)

Snarky

Hi CCrane. I'm happy if the module is of use to you.

Quote from: CCrane on Wed 16/11/2022 16:17:34Some questions I'd like to ask. First, if ...

  SpeechBubble.MaxTextWidth = 250;

... is determined by screen/native game resolution size, i.e. are these relative or absolute values? I would generally prefer dialog in at least two lines for a more proportionate appearance of the bubble but setting some value up for text width won't make much sense with absolute values if the target system has a greatly differing resolution.

The values are in pixels, as are practically all AGS graphics functions. AGS games have a fixed (though customizable) game resolution that (almost) everything is rendered in, and if the screen or window resolution differs from that, the final image is simply scaled up or down. So the screen resolution it's played on should not make a difference to the layout logic: If your game is natively 640x400, then a width of 250 represents slightly less than 40% of the screen/window width.

Quote from: CCrane on Wed 16/11/2022 16:17:34Secondly, is it possible to change border width/line thickness of the bubble? I found no variable for that so I suspect it's kinda similar to automatic text outline which can't be adusted, either. My test game is 640x400 right now and I might go even higher but the border can barely be seen already.

No, this is not currently supported, because it would significantly complicate the logic for drawing rounded corners. However, there is an unofficial version of the module that allows you to assign sprites for the outline and background of the speech bubble. This would allow you to set a thicker outline.

Quote from: CCrane on Wed 16/11/2022 16:17:34If line thickness is hard-coded would it be possible to create two overlaying bubbles, eg. one smaller white and a bigger black one in the background? This won't really work with transparency obviously but some of us might be okay with that. Just a thought ... :)

It's an interesting idea for a workaround, but I think it would be quite complicated to make it work consistently, and that the outline would not look very nice. (Again, the rounded corners, which I think would get "blobby" and uneven.)

Quote from: CCrane on Wed 16/11/2022 16:17:34Finally, you mentioned planning a think bubble. Will this only work for Sierra-style speech, like player.think seems to do currently, or also for LucasArts-style games? That would be great.

Off the top of my head I see no reason why it shouldn't work for LucasArts speech too. However, from my side further development of the module is currently on hold, since I don't have the time or energy to devote to it.

CCrane

Quote from: Snarky on Wed 16/11/2022 17:41:46If your game is natively 640x400, then a width of 250 represents slightly less than 40% of the screen/window width.
Cool, just what I wanted to hear.

Quote from: Snarky on Wed 16/11/2022 17:41:46This would allow you to set a thicker outline.
So the outline could be made from sprites, eg. a 3px black dot. I'll check that out if I have my other stuff sorted.

Quote from: Snarky on Wed 16/11/2022 17:41:46the outline would not look very nice.
Oh, I see. It was just an idea. Two bubbles on top of each other with both having AGS's automatic black outlines might work to polish the edges somewhat but I'm not gonna pestering you with that. :grin:

Quote from: Snarky on Wed 16/11/2022 17:41:46Off the top of my head I see no reason why it shouldn't work for LucasArts speech too. However, from my side further development of the module is currently on hold, since I don't have the time or energy to devote to it.
Too bad but I know that. The reason I was asking is player.think doesn't work for me either so thought it was Sierra only.
Thanks for the explanations

@ChristophCrane_ (Indie author)

CCrane

#143
Hello there (again  :) ),

Sorry for being a nuisance but I get an error when I replace this
Code: ags
player.Say("Looks like ... %s.", passphraseA_Word);
with that piece of code
Code: ags
player.SayBubble("Looks like ... %s.", passphraseA_Word);
Failed to save room room1.crm; details below
room1.asc(310): Error (line 310): Type mismatch: cannot convert 'String*' to 'GUI*'


Another thing is the option text in dialog. While it's no problem to change the lines in dialog script to command style the options stay as they are. I don't even know where to look for them, actually. Is it possible to change them as well? That would be great.


There's also this little issue I have, a string named lookat in abstauber's tumbleweed module

Code: ags
    // PICKUP and make object invisible
    else if(Verbs.UsedAction(eGA_PickUp)) {
      Verbs.AnyClickWalkLookPick(160, 285, eDirectionLeft, "I'm a string named lookat ... anyway", oHandgun.ID, iHandgun);
      GiveScore(5);


I tried to change Say to SayBubble in abstauber's script, there seem to be only two places of player.Say(lookat) in VerbGui.asc actually, but then it just gave me this message.

SayBubble is not a public member of character

I asked him in his thread but maybe you have an idea too

@ChristophCrane_ (Indie author)

Snarky

#144
Quote from: CCrane on Thu 17/11/2022 09:36:20Hello there (again  :) ),

Sorry for being a nuisance

No worries.  ;-D

Quote from: CCrane on Thu 17/11/2022 09:36:20but I get an error when I replace this
Code: ags
player.Say("Looks like ... %s.", passphraseA_Word);
with that piece of code
Code: ags
player.SayBubble("Looks like ... %s.", passphraseA_Word);
Failed to save room room1.crm; details below
room1.asc(310): Error (line 310): Type mismatch: cannot convert 'String*' to 'GUI*'

SayBubble() doesn't support the string formatting capability that Say() does. When you want to insert dynamic variables in the string, what you'll have to do is to wrap the message argument in a String.Format() call, like so:

Code: ags
player.SayBubble(String.Format("Looks like ... %s.", passphraseA_Word));

Quote from: CCrane on Thu 17/11/2022 09:36:20Another thing is the option text in dialog. While it's no problem to change the lines in dialog script to command style the options stay as they are. I don't even know where to look for them, actually. Is it possible to change them as well? That would be great.

I'm not sure I understand what you mean. How do you want the dialog options to be displayed? In general, to change the look and feel of dialog options, you would have to write your own custom dialog options rendering. (Except for very simple things like the font and the background/text color, for which there are probably some property.)

Quote from: CCrane on Thu 17/11/2022 09:36:20I tried to change Say to SayBubble in abstauber's script, there seem to be only two places of player.Say(lookat) in VerbGui.asc actually, but then it just gave me this message.

SayBubble is not a public member of character

I asked him in his thread but maybe you have an idea too

This is probably an issue of module ordering. In the current AGS version, you can only call functions from modules higher up in the module list. So you would have to place SayBubble above the Tumbleweed module in order to use this function from Tumbleweed. (I don't remember if the module list lets you drag and drop to reorder, or if you have to right-click and choose move up/down.) This restriction will be removed in an upcoming AGS version—not sure whether it's 3.6 or 4.0.

CCrane

Quote from: Snarky on Thu 17/11/2022 11:33:03wrap the message argument in a String.Format() call,
Worked like a charm!

Quote from: Snarky on Thu 17/11/2022 11:33:03m not sure I understand what you mean.
Badly worded on my part. I don't mean to change the list box (or whatever it is called) where you choose a line. My issue is that after selection that line is repeated/said on screen, which is done using .Say command. (Pic 1a).
In the dialog editor I can only change character replies from .Say to .SayBubble, like this:

Code: ags
  Torres: I was in a plane and now I ...
  cTorres.SayBubble("I was in a plane and now I ...");

H9jdjrN.md.jpg" border="0
Quote from: Snarky on Thu 17/11/2022 11:33:03obably an issue of module ordering
Ohh, I see. I was already wondering why the scripts weren't sorted alphabetically. Tumbleweed is at the top because its scripts are in a folder while the other scripts are not (Pic 1b).
  Maybe ordering would work if I put all scripts in an own folder. Would that break something?

@ChristophCrane_ (Indie author)

Snarky

Quote from: CCrane on Thu 17/11/2022 14:12:54My issue is that after selection that line is repeated/said on screen, which is done using .Say command. (Pic 1a).
In the dialog editor I can only change character replies from .Say to .SayBubble, like this:

Code: ags
  Torres: I was in a plane and now I ...
  cTorres.SayBubble("I was in a plane and now I ...");

Ah. No, I'm afraid that is hardcoded to use .Say() (see the release notes for v3.5.0.P3, under Added "Custom Say/Narrate function in dialog scripts"). The workaround is to uncheck the "Say" checkbox and put a copy of the line in the dialog script instead.

However, that "Custom Say/Narrate function in dialog scripts" could probably save you from having to change the lines in the dialog script, if you can set the function that dialog lines are converted to to .SayBubble(). (I haven't actually tried it, but it ought to work.)

Quote from: CCrane on Thu 17/11/2022 14:12:54Maybe ordering would work if I put all scripts in an own folder. Would that break something?

The folders are merely for keeping things tidy. When compiled it's flattened into a simple list, from top-down. So you can make a folder and put whatever scripts you want in it (except the GlobalScript, which can't be moved) without trouble. You could have one folder just for SpeechBubble, or for any other modules.

In general, it's probably a good idea to keep third-party modules at the top of the list, and put any custom scripts you create below them, whether in a folder or not.

glurex

#147
Hi, Snarky.

I use your module and modified it a bit to "erase" the tail of the speech bubble for a game i'm developing.

Speech-Bubble-WOT" border="0


Is it ok? Of course I'll credite you and the module.

Snarky

Sure. It's open source; feel free to make changes. (Just note that I can't really offer support for code that has been heavily modified.)

CCrane

#149
Hi Snarky,
I've gotten along quite nicely with my game. SpeechBubble will now be part of it and I think it suits the classic comic style I'm roughly going for just fine.
I had to sacrifice the generic interaction replies from abstauber's Tumbleweed module because I just couldn't get them to be rendered in SayBubble but that's just a minor issue in the bigger scheme of things.

One thing I found a little inconvenient was placement of the bubbles. I had some instances where I used Character.SayAtBubble(), eg. for a radio and a character talking through a spyhole (see image). Getting the bubble in the right position took me quite some time and I would suggest that, if possible, the position of the bubble would rather be defined by the end of the tail.
I think also the module would profit from an offset function for the regular SayBubble function.



Yeah, so this is more of a feature request but don't get me wrong. I like your module very much. It's great! :smiley:

best regards

@ChristophCrane_ (Indie author)

glurex

Hi, @Snarky!

I've found a strange behaviour with the module (I just realize). With the default language it works perfect, but when I use the translation AGS system, the lines with .SayBubble don't get translated, but they are generated in the 'English.trs' file. (other things like labels, characters names... works well. The problem is only with the .SayBubble lines). I'm using AGS 3.5.1.22.

Alternatively I could write, in each SayBubble, something like:

Code: ags
if (Game.TranslationFilename=="")
{
player.SayBubble("Me pregunto si habrá algún poblado cerca...");
}
else if (Game.TranslationFilename=="English")
{
player.SayBubble("I wonder if there's a town nearby...");
}

but that would be tedious compared with the AGS translation System.

Crimson Wizard

#151
@glurex: you can use GetTranslation instead, that automatically returns the line in the current language:

Code: ags
player.SayBubble(GetTranslation("original text goes here"));

I think, this call to GetTranslation could be done right inside SayBubble. The problem here is that the message could be made using String.Format, and therefore not translatable. So it's a question of how to design the module...

Maybe there could be separate functions for automatically translated messages and not.

EDIT: you may write a helper function yourself:
Code: ags
void SayBubbleTra(this Character*, String message, GUI* bubbleGui)
{
  this.SayBubble(GetTranslation(message), bubbleGui);
}
and then use it like
Code: ags
player.SayBubbleTra("original text goes here");

glurex

Wow, many thanks @Crimson Wizard! That saves me a lot of time!

In my case I declare this function in the SpeechBubble script (obviously under void SayBubble):

Code: ags
void SayBubbleTra(this Character*, String message)
{
  this.SayBubble(GetTranslation(message));
}


without "GUI* bubbleGui" and "bubbleGui", and later Import it in the Header (of SpeechBubble script):

Code: ags
import void SayBubbleTra(this Character*, String message);


Dave Gilbert

Hello! Apologies if this was answered in the thread already, but I was wondering if there was a way to make the bubble always appear over the character's head? Specifically, in the following situations:

1 - the character is walking and I want them to talk using the sayBackgroundBubble command. I'd like the bubble to move with the character. Right now, it stays in place where it is drawn.
2 - the character is on a scrolling background and I want to move the "camera" left or right while they are talking. The bubble stays in the same screen position while the rest of the graphics move.

Also, is there a way to have TWO bubbles on screen at the same time? My game has a number of background conversations (using background bubbles), and if my player character says anything it stops the background bubbles from playing.

Snarky

Quote from: Dave Gilbert on Tue 25/07/2023 16:04:16Hello! Apologies if this was answered in the thread already, but I was wondering if there was a way to make the bubble always appear over the character's head? Specifically, in the following situations:

1 - the character is walking and I want them to talk using the sayBackgroundBubble command. I'd like the bubble to move with the character. Right now, it stays in place where it is drawn.
2 - the character is on a scrolling background and I want to move the "camera" left or right while they are talking. The bubble stays in the same screen position while the rest of the graphics move.

The short answer is no, not at the moment.
I started a major rewrite of the module that would include this, but I got bogged down in a lot of complications, and it's not currently in progress, and nowhere near finished.

Quote from: Dave Gilbert on Tue 25/07/2023 16:04:16Also, is there a way to have TWO bubbles on screen at the same time? My game has a number of background conversations (using background bubbles), and if my player character says anything it stops the background bubbles from playing.

Also no, though @Grundislav has made a version that supports background conversation, so perhaps you can ask hem. But I'm not sure that AGS allows SayBackground calls while Say is running in the first place?

Crimson Wizard

#155
Quote from: Snarky on Sun 30/07/2023 11:05:00Also no, though @Grundislav has made a version that supports background conversation, so perhaps you can ask hem. But I'm not sure that AGS allows SayBackground calls while Say is running in the first place?

I don't remember details about SayBackground, but I believe that you should be able to create textual overlays during blocking commands from rep-exec-always, because the game update and redraw is still run during blocking actions.

Note I said "from rep-exec-always", as that's the only callback that runs during blocking commands; this is also something to keep in mind.

Overall, I've never researched how SpeechBubble works, but I imagine that in ideal world it should support running multiple non-blocking bubbles, and optionally running one at a time as blocking.

Snarky

Quote from: Crimson Wizard on Sun 30/07/2023 11:46:59Overall, I've never researched how SpeechBubble works, but I imagine that in ideal world it should support running multiple non-blocking bubbles, and optionally running one at a time as blocking.

It was designed to work as much like Character.Say() as possible. From the feedback from actual users, it turns out that it would be useful to further decompose the different parts (sizing, bubble/frame formatting and rendering, text formatting and rendering, layout/positioning, display, repositioning, use with Say/SayBackground) to be able to use it more flexibly. This is a lot more work, though (especially as everything interacts in interesting ways, particularly if you have more than one bubble visible at a time).

Grundislav

I'm not using this module, I just coded my own dialogue display UI. And I do have a SayBackground, but I don't ever display more than one "bubble" at a time.

Dave Gilbert

I used to cheat this by having a .Say and a .SayBackground running at the same time, but that doesn't work with the bubble. Ah well. I can probably cheat by making a bubble image GUI and place it where I need, just for the few instances where I need it. No big! Thanks anyway.

Dave Gilbert

Hello! Sorry for the double post. Is there a way to manually change the X position of the tail? Specifically for situations like this where my character is close to the edge of the screen:



I'd like the tail to be on top of the character, as opposed to just the center of the bubble. I looked through the script and found variables for the height and width, but not position.

Thanks in advance!

-Dave

SMF spam blocked by CleanTalk