Hi Everybody! I'm trying to show a window behind the texts when my actors or entities talk! Reading various topics on the forum I succedeed in showing the window as I wanted to, but I'm having a problem with the Height of the window. In fact I don't know how to resize the Height attribute according to the dimension of the text. This is my code, which is placed into an entity script:
method Talk(srcString,srcActor,xPosition)
{
var twin;
if (srcActor == null) twin = "normal"; // basic window with ghost
else
twin = srcActor; // NPC window
var tmpState = Game.Interactive;
Game.Interactive = false; // we save the interactivity state for later and turn it off
var dlgWin = Game.LoadWindow("riquadri\speechbubble.window"); // load the dialogue window
var tString = Game.ExpandString(srcString); // prepare the localized string to handle formatting
var tLength = tString.Length;
var lines = ToInt(tLength / 320) + 1; // find out how many lines will we need
if (xPosition != null) this.SubtitlesPosX = xPosition;
this.SubtitlesPosRelative = true;
xPosition = this.SubtitlesPosRelative;
this.SubtitlesWidth = 320;
dlgWin.X= 464;
dlgWin.Width=330;
this.SoundPanning = false; // make the sound centered
this.Talk(srcString, null, "", "", 0); // say the line
Game.UnloadObject(dlgWin); // dispose of the window
Game.Interactive = tmpState;
}
I was thinking I can simply solve this by changing dlgWin.Height according to how many times the text start a new line, but is there a way to count the number of lines?
I'll try and explain better... let's assume the text which is currently shown just occupies one line. I'll simply set the dlgWin.Height attribute to 20 px. If the text occupies two lines I'll set the attribute to 40 px and so on. It looks to me like it could work, but I'm not quite sure about the sintax...
If this can't be done, what can I do to obtain the same result?