Okay, I've attempted to copy this function (now called oulinedMessage) from speechbubble, and transplant my own outlineDrawStringWrappedAA into the function:
I've reduced the number of arguments, and supplanted default values hard-coded - these items will never change:
GlobalScript.asc
// Draw a string with outline (make sure the canvas has at least outlineWidth pixels on each side of the string)
function outlinedMessage(this DrawingSurface*, int x, int y, int width, String message)
{
// This is what we draw on (because we might need to copy with transparency)
DynamicSprite* outlineSprite = DynamicSprite.Create(this.Width, this.Height, true);
DrawingSurface* outlineSurface = outlineSprite.GetDrawingSurface();
// This holds multiple horizontal copies of the text
// We copy it multiple times (shifted vertically) onto the outlineSprite to create the outline
DynamicSprite* outlineStripSprite = DynamicSprite.Create(this.Width, this.Height, true);
DrawingSurface* outlineStripSurface = outlineStripSprite.GetDrawingSurface();
// This is our "text stamp" that we use to draw the outline, we copy it onto outlineStripSprite
DynamicSprite* textSprite = DynamicSprite.Create(this.Width, this.Height, true);
DrawingSurface* textSurface = textSprite.GetDrawingSurface();
// Draw our text stamp
textSurface.DrawingColor = 682;
textSurface.DrawStringWrapped(x, y, width, 1, 2, message);
textSurface.Release();
// Draw Circular outline
int maxSquare = 2*2+1; // Add 1 for rounding purposes, to avoid "pointy corners"
int maxWidth = 0;
outlineStripSurface.DrawImage(0, 0, textSprite.Graphic);
// We loop from top and bottom to the middle, making the outline wider and wider, to form circular outline
for(int i = 2; i > 0; i--)
{
// Here's the circular calculation...
while(i*i + maxWidth*maxWidth <= maxSquare)
{
// Increase width of the outline if necessary
maxWidth++;
outlineStripSurface.DrawImage(-maxWidth, 0, textSprite.Graphic);
outlineStripSurface.DrawImage(maxWidth, 0, textSprite.Graphic);
outlineStripSurface.Release();
outlineStripSurface = outlineStripSprite.GetDrawingSurface();
}
// Draw outline strip above and below
outlineSurface.DrawImage(0, -i, outlineStripSprite.Graphic);
outlineSurface.DrawImage(0, i, outlineStripSprite.Graphic);
}
// Finally the middle strip
outlineSurface.DrawImage(0, 0, outlineStripSprite.Graphic);
textSprite.Delete();
outlineStripSurface.Release();
outlineStripSprite.Delete();
/// Now draw the text itself on top of the outline
outlineSurface.DrawingColor = this.DrawingColor;
//BEGIN OUTLINE DRAW STRING WRAPPED AA
DynamicSprite* atextSprite = DynamicSprite.Create(this.Width, this.Height, true);
DrawingSurface* atextSurface = atextSprite.GetDrawingSurface();
atextSurface.DrawingColor = this.DrawingColor;
atextSurface.DrawStringWrapped(x, y, width, 1, 2, message);
atextSurface.Release();
this.DrawImage(0, 0, atextSprite.Graphic, 0);
atextSprite.Delete();
//END OUTLINE DRAW STRING WRAPPED AA
outlineSurface.Release();
// ... And copy it onto our canvas
this.DrawImage(100, 100, outlineSprite.Graphic, 0);
outlineSprite.Delete();
}
GlobalScript.ash:
import function outlinedMessage(this DrawingSurface*, int x, int y, int width, String message);
in room2.asc:
function room_AfterFadeIn()
{
...
outlinedMessage(100, 100, 100, "checking this out");
}
But I get the error:
Failed to save room room2.crm; details below
room2.asc(5): Error (line 5): Undefined token 'outlinedMessage'
oulinedMessage() is at the top of GlobalScript.asc
The definition is at the top of the function definitions in GlobalScript.ash (after some #define's and enums)
...wtf has happened? It must be something incredibly obvious, but I can't see how room2 can't see GlobalScript.