Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Dialogue Box problem  (Read 3178 times)

0 Members and 1 Guest are viewing this topic.

The Man

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Posts: 67
    • View Profile
Dialogue Box problem
« on: October 13, 2014, 10:23:19 AM »

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:

Code: [Select]
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?
Logged

The Man

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Posts: 67
    • View Profile
Re: Dialogue Box problem
« Reply #1 on: October 14, 2014, 10:10:00 AM »

No idea? I tried using a fixed-width font, counting how many characters are there in a single line, but it won't work. I'd solve it in a while if there was a Subtitles.Height attribute, but I don't think it exists!
Logged
 

Page created in 0.019 seconds with 19 queries.