// Draw a speech bubble in 32-bit (using transparency)
DynamicSprite* renderBubble32(this Character*, String message, bool talkTail)
{
// Calculate text dimensions
int textWidth = _maxTextWidth;
if(textWidth <= 0)
textWidth = calculateDefaultTextWidth(this);
textWidth = _minInt(textWidth, System.ViewportWidth - _paddingLeft - _paddingRight);
int textHeight = GetTextHeight(message, Game.SpeechFont, textWidth);
textWidth = calculateExactTextWidth(message, Game.SpeechFont, textWidth, textHeight);
// Calculate bubble dimensions
int totalWidth = textWidth + _paddingLeft + _paddingRight;
int bubbleHeight = textHeight + _paddingTop + _paddingBottom;
int totalHeight;
if(talkTail)
totalHeight = bubbleHeight + _talkTailHeight;
else
totalHeight = bubbleHeight + _thinkTailHeight;
// Set up the canvases
DynamicSprite* bubbleSprite = DynamicSprite.Create(totalWidth, totalHeight, true);
DrawingSurface* bubbleSurface = bubbleSprite.GetDrawingSurface();
//bubbleSurface.Clear();
DynamicSprite* bgSprite; DrawingSurface* bgSurface;
DynamicSprite* borderSprite; DrawingSurface* borderSurface;
bgSprite = DynamicSprite.Create(totalWidth, totalHeight, true);
bgSurface = bgSprite.GetDrawingSurface();
borderSprite = DynamicSprite.Create(totalWidth, totalHeight, true);
borderSurface = borderSprite.GetDrawingSurface();
int bgColor = mixColors(this.SpeechColor, _backgroundColor, _backgroundSpeechTint);
int borderColor = mixColors(this.SpeechColor, _borderColor, _borderSpeechTint);
// Draw!
bgSurface.DrawingColor = bgColor;
borderSurface.DrawingColor = borderColor;
bgSurface.DrawRectangle(0, 0, totalWidth-2, bubbleHeight-2);
borderSurface.DrawRectangle(1, 1, totalWidth-1, bubbleHeight-1);
if(_cornerRoundingRadius > 0)
{
drawRoundedCorners32(bgSurface, 0, 0, totalWidth-2, bubbleHeight-2);
drawRoundedCorners32(borderSurface, 1, 1, totalWidth-1, bubbleHeight-1);
}
String tail[]; int tailWidth; int tailHeight;
if(talkTail)
{
tail = _talkTail; tailWidth = _talkTailWidth; tailHeight = _talkTailHeight;
}
else
{
tail = _thinkTail; tailWidth = _thinkTailWidth; tailHeight = _thinkTailHeight;
}
bgSurface.drawPixelArray(tail, totalWidth/2-tailWidth, bubbleHeight-1, tailWidth, tailHeight, 'O', false, false);
borderSurface.drawPixelArray(tail, totalWidth/2-tailWidth+1, bubbleHeight, tailWidth, tailHeight, 'O', false, false);
borderSurface.Release();
bubbleSurface.DrawImage(0, 0, borderSprite.Graphic, _borderTransparency);
borderSprite.Delete();
bgSurface.Release();
bubbleSurface.DrawImage(0, 0, bgSprite.Graphic, _backgroundTransparency);
bgSprite.Delete();
bubbleSurface.DrawingColor = this.SpeechColor;
int outlineColor = mixColors(this.SpeechColor, _textOutlineColor, _textOutlineSpeechTint);
if(_textOutlineWidth > 0)
bubbleSurface.drawStringWrappedOutline(_paddingLeft, _paddingTop, textWidth, _textOutlineStyle, Game.SpeechFont, _textAlign, message, _textTransparency, outlineColor, _textOutlineWidth);
else
bubbleSurface.drawStringWrappedAA(_paddingLeft, _paddingTop, textWidth, Game.SpeechFont, _textAlign, message, _textTransparency);
bubbleSurface.Release();
return bubbleSprite;
}