MODULE: SpeechBubble v0.8.0

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

Previous topic - Next topic

Snarky

All development of this module is on hold while I'm working on the AGS Awards Ceremony client.

To do text in multiple colors you have to break it up into separate strings that you render individually (using DrawingSurface.DrawString()), with the appropriate x and y offsets. There's an outline of how you might do it here.

To see how you're meant to be changing the tail, check out this post. Unfortunately there's a bug in the module which means you have to edit the internal initSpeechBubble() function instead, as shown in the post above.

The tail flipping depending on character angle is a feature I've been meaning to add, but it's not implemented. Basically, in renderBubble32() there are two calls to drawPixelArray(). The last two arguments are whether to flip the array horizontally or vertically, and both are set to false. If you set the second-to-last to true in both calls, it will flip it. So I would add a bool argument to renderBubble32(), and pass that along to drawPixelArray(). Then in the calls to renderBubble32() in realSayAtBubble(), SayBubble() and SayBackgroundBubble() you would set the argument depending on which way the character is facing.

Narehop

How i can to set a custom background?

Snarky

You can set a background color with SpeechBubble.BackgroundColor. You cannot set a background graphic.

Narehop

Quote from: Snarky on Thu 08/03/2018 21:45:19
You can set a background color with SpeechBubble.BackgroundColor. You cannot set a background graphic.

you'll be update with this option?

Snarky

Sure, when I find time to work on it. I think TotalLipSync is first in line for an update, though.

bx83

#45
Snarky, can you give us an ETA on 'ThinkBubble' function?
I would guess you just run speechbubble, but with 1 parameter change: to display the 3 bubbles going to the rounded corner box, instead of the angled-line going from the round corner box.

bx83

#46
Too late, I wrote some shitty poorly tested code! :P

This is the same code as SayBubble, but with one parameter change (from true to false) on line 10:
Code: ags

void ThinkBubble(this Character*, String message, GUI* bubbleGui)
{
  if(message == null) return;
  if(!game.bgspeech_stay_on_display)
    _stopAllBackgroundBubbles();
  if((Speech.VoiceMode == eSpeechVoiceOnly && hasVoiceClip(message)) || message == "...")
    this.SB_sayImpl(message);
  else
  {
    DynamicSprite* bubbleSprite = this.renderBubble32(message, false);  //<--- SETTING THIS TO FALSE WAS ALL I HAD TO DO
    // Position bubble over character head
    int x = this.x - GetViewportX() - bubbleSprite.Width/2;
    x = _clampInt(x, 0, System.ViewportWidth - bubbleSprite.Width);
    int y = this.y - GetViewportY() - bubbleSprite.Height - this.GetHeight() - (_heightOverHead - _talkTailHeight + 1);
    y = _clampInt(y, 0, System.ViewportHeight - bubbleSprite.Height);

    this.realSayAtBubble(x, y, message, bubbleGui, bubbleSprite);
  }	
}

Snarky

Quote from: bx83 on Wed 27/06/2018 08:13:17
Snarky, can you give us an ETA on 'ThinkBubble' function?

Well, it's part of the API I outlined when you contracted me to develop this module, so if you really need it I will make it a priority.

Quote from: bx83 on Wed 27/06/2018 08:13:17
I would guess you just run speechbubble, but with 1 parameter change: to display the 3 bubbles going to the rounded corner box, instead of the angled-line going from the round corner box.

There's a little bit more to it than that if it's to work fully like AGS's Character.Think(), but a simple version shouldn't be too hard.

The main work is to complete and test the 8.9 rewrite, since I don't want to maintain two entirely separate branches going forward.

bx83

My code works, but perhaps not in all situations.
All good, I'm happy with it so far, take your time :)

Ray

Thank you very much! Definitely will see to use this module in my game :)

bulka_tarta

Hey! I really like this module, but I have a small hiccup with it recently. Occasionally, the dialogue skips lines waaaay too fast and it's very frustrating. Because it happens only every now and then, it's hard to determine why and when it occurs. I was wondering if anyone else has this issue, or if I messed something up at some stage.

In general settings I've set "Allow speech to be skipped by which events" to Mouse or keyboard. I've tried setting Game.IgnoreUserInputAfterTextTimeoutMs to ridiculous values, but it doesn't change anything. I also played around with some values in the module itself but to no avail.

The only settings I changed for the dialogues are below, although I highly doubt they would have an impact on skipping the lines since they're purely aesthetic changes.
Code: ags

  // Lowers the dialog options a little bit
  game.dialog_options_x = 10;
  game.dialog_options_y = 10;
  // Changes the colour of highlighted dialogue option
  game.dialog_options_highlight_color = 19695;
  // Edit the Speech Bubble Module
  SpeechBubble.BorderColor = Game.GetColorFromRGB(10,12,14);
  SpeechBubble.BackgroundColor = Game.GetColorFromRGB(10,12,14);
  SpeechBubble.BackgroundTransparency = 0;
  SpeechBubble.PaddingTop = 8;
  SpeechBubble.PaddingBottom = 8;
  SpeechBubble.PaddingLeft = 8;
  SpeechBubble.PaddingRight = 8;
  SpeechBubble.MaxTextWidth = 230;
  SpeechBubble.CornerRoundingRadius = 0;
  SpeechBubble.HeightOverHead = 8;
  SpeechBubble.TextAlign = eAlignCentre;


The only other thing I've changed in the module is this:
Code: ags

bool animateSpeech(this Character*, String message)
{
  if(this.Moving)
    this.StopMoving();
  
  if(this.SpeechView > 0)
  {
    this.LockView(this.SpeechView);
    if(Game.GetFrameCountForLoop(this.SpeechView, this.Loop) > 1)
      this.Animate(this.Loop, this.SpeechAnimationDelay, eRepeat, eNoBlock, eForwards);
  }
  
  int speechDuration = calculateDuration(message);
  if(BlockSpeech(speechDuration, true) == eBlockTimeOut)
  {
    //this.UnlockView();                          <---------------------- Commented this out
    int speechPause = calculateSpeechPause();
    return (BlockSpeech(speechPause, false) != eBlockTimeOut);
  }
  else
  {
    //this.UnlockView();                          <---------------------- Commented this out
    return false;
  }
}

When the above wasn't commented out, the characters would keep unlocking the view, so they always went back to idle/talking view when new line of dialogue appeared, so I couldn't get characters to talk while in a special animation (someone sitting on the ground and talking for example). Still, I don't think this would impact skipping the dialogue?

I'm using v0.8.0.

I'm really stuck with this issue and I'm not sure if this is AGS thing or the module or if there could be something else affecting the dialogues. If anyone has any ideas how to go about fixing the dialogue skipping problem, please let me know! Many thanks.

Snarky

Yes, I noticed this when I tested your game. ;)

I'm fairly sure it's a problem with the custom blocking script. I don't have time to look into it right now, but you should try setting a transparent font. That will bypass all the custom blocking code and rely on the normal AGS speech blocking instead.

bulka_tarta

You've given me quite a lot of feedback, so my Trello board is now full of things to change/fix/improve! (laugh)

I followed the instructions on the lip sync found in the Header of the script to find out how to set this up:
Code: ags

  /*
  Note that to get text-based lip sync to work, you need to provide an invisible font,
  and set the SpeechBubble.InvisibleFont property accordingly. You may download one here:
                                                                                         
  http://www.angelfire.com/pr/pgpf/if.html
  */


After importing the font to AGS I simply added this to game_start()
Code: ags
SpeechBubble.InvisibleFont = eFontInvisibleFont;


After some testing I didn't (yet) notice any line skipping, but I might have been just (un)lucky. There is definitely a noticeable change to the dialogue though. Before I've set the invisible font, you could have held down the left mouse button and the dialogue would skip automatically after around one second on each line. After setting the invisible font, nothing happens when you hold down the LMB, so hopefully things will be fixed now.

Is this all there is to it or did I miss something big time? It looks suspiciously too simple to bypass the custom blocking code. Thank you for the response!

Snarky

No, that's all there is to it.

If it works for you, great! If not... I'm not sure when I'll have time to look into it, I'm afraid. Others have had problems related to the same part of the code, but I don't have any immediate ideas about what the problem might be. The ideal solution would be to extend the AGS Wait() API to cover all the cases you need for dialogue blocking.

bulka_tarta

Great! Thank you for the help!

I will let you know if the problem persists. It's just hard to tell straight away.

Creamy

#55
Hi Snarky,

Great module you have here.
It's easy to set up and works like a charm...except for one room where my game crashes:

QuoteError: ScriptOverlay::Remove: overlay is not there

EDIT: nevermind, I've figured it out. If you change room before the bubble has disappeared, the game will crash as soon as you call Saybubble in the next room.
 

bx83

I'm having trouble with line 3:

Code: ags

int calculateDefaultTextWidth(Character* c)
{
  int w = System.ViewportWidth * 2/3;
  if(c.x - GetViewportX() <= System.ViewportWidth/4 || c.x - GetViewportX() >= System.ViewportWidth * 3/4)
    w -= System.ViewportWidth/5;
  return w;
}


error is: SpeechBubble_0.8.0.asc(1059): Error (line 1059): '.ViewportWidth' is not a public member of 'System'.

This is with AGS 3.5.0b5
Making a new version for this AGS?

bx83

Okay well I replaced everything it couldn't understand with Screen.Viewport.Width/Height/X/Y/etc. but now the speech bubbles just don't come up :/

Laura Hunt

#58
In 3.5.0, Viewport is replaced with Camera. Try replacing all instances of "Viewport" with "Camera" and see what happens. You'll  need to keep an eye out for differences such as using Camera.Height instead of ViewportHeight and stuff like that...

Crimson Wizard also gave me these links for documentation of these new features:

https://github.com/adventuregamestudio/ags-manual/wiki/Camera

https://github.com/adventuregamestudio/ags-manual/wiki/Viewport

Crimson Wizard

It's much easier to enable old functions in General Settings: set "Script compatibility level" to 3.4.1

SMF spam blocked by CleanTalk