I am trying to build a credits/intro page and need help with centering text. I have tried Densming's script (which works) but when I try to break the text into multiple lines using a '[' the text centers for the entire strings length rather than the longest line. Using AGS 3.2.1 r5.
Overlay* textOverlay;
function ShowTextCentered(String sText)
{
int iAbsCenterX = System.ViewportWidth / 2;
int iAbsCenterY = System.ViewportHeight / 2;
int iTextWidth = GetTextWidth(sText, Game.NormalFont);
int iTextHeight = GetTextHeight(sText, Game.NormalFont, iTextWidth + 7);
int iTextCenterX = iAbsCenterX - (iTextWidth / 2);
int iTextCenterY = iAbsCenterY - (iTextHeight / 2);
textOverlay = Overlay.CreateTextual(iTextCenterX, iTextCenterY, iTextWidth + 7, Game.NormalFont, 31734, sText);
}
function room_AfterFadeIn()
{
ShowTextCentered("v2.0 Coded By DCS78[Adapted from v1.3 By The DreamMaster");
Wait(120);
ShowTextCentered("Original (c)1987 Disney Interactive Studios");
Wait(120);
ShowTextCentered("Developed using AGS v3.2.1 by Chris Jones[http://www.adventuregamestudio.co.uk");
Wait(120);
ShowTextCentered("Game graphics ripped from the original Black Cauldron game using ScummVM v1.4.1[http://www.scummvm.org");
Wait(120);
ShowTextCentered("Texture overlays by DCS78");
Wait(120);
ShowTextCentered("Music from The Black Cauldron Soundtrack");
Wait(120);
ShowTextCentered("Game design by:[Al Lowe[Roberta Williams[Elaine Boulay[Nancy Casolaro[Melissa Haldeman");
Wait(120);
ShowTextCentered("Programming by:[Al Lowe[Scott Murphy[Sol Ackerman[Ken Williams[Jeff Stephenson[Chris Iden");
Wait(120);
ShowTextCentered("Computer graphics by:[Mark Crowe");
Wait(120);}
Help.