Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: CorCAD on Mon 26/01/2004 19:47:52

Title: Text window position [SOLVED!]
Post by: CorCAD on Mon 26/01/2004 19:47:52
Just wondering.... I've created a GUI to replace the text window. Only problem is the GUI doesn't have a x y position like the other GUI's have. I dont want the window to float around depending on where you click. I always want the text to be in a GUI placed at the bottom of the screen. Am I overlooking something, or is this a default setting that I need to deal with?
Thanks,

CorCAD
Title: Re:Text window position
Post by: Ishmael on Mon 26/01/2004 20:03:48
The custon text window GUIs are always placed in the center of the screen. There is something on the FUTURE.txt file that comes with AGS about this.

A workaround is to create a GUI, place it where you want the text window to be, and put a label to it, in the place where the text should be.

Then, creating a function in the main global script:

function DisplayBox(string text) {
SetLabelText(GUI#,LABEL#,text);
GUIOn(GUI#);
while (IsButtonDown(LEFT)) Wait(1);
GUIOff(GUI#);
SetLabelText(GUI#,LABEL#,"");
}

replaceing GUI# with the GUI name and LABEL# with the label number (normally would be 0).

This makes the displayboxes skipable with the Left mouse button only.

The last SetLabelText is not neccesary, but I have put it there for some reason...
Title: Re:Text window position
Post by: Ben on Mon 26/01/2004 20:07:31
By default, text windows display in the center of the screen. However, you can set the y postition of a box by using DisplayAtY (int y, string message).

To make the box always display at the bottom of the screen, I'd reccoment creating a new function like this:


function Display_B(string text, int height) {
 pos = system.screen_height - height
 DisplayAtY(pos, text);
}


Which you can use instead of the default DIsplay command. It will display the text at the bottom of the screen, as long as you enter the correct height of the text box. I don't think there's any way to find the height of a text box through the script, so you have to find it manually.

EDIT: Looks like TK beat me to it. He must be destroyed  :P
Title: Re:Text window position
Post by: CorCAD on Tue 27/01/2004 02:01:04
TK, I tried your code and I couldn't get it to work. I altered it to this.

function DisplayBox(string text) {
SetLabelText(TXTWINDOW,0,text);
GUIOn(TXTWINDOW);
while (IsButtonDown(LEFT)) Wait(1);
GUIOff(TXTWINDOW);
SetLabelText(TXTWINDOW,0,"");
}

It seemed to work fine, but it displayed the label text i.e. "New Label". Was I supposed to put @DisplayBox@ in the label? Also as soon as I tried it by clicking on a hotspot the game crashed... not sure what the error was. Got anymore suggestions, or did I miss something. Thanks for your time.

CorCAD

[Edit: The error said that the "GUI was set as a text window but is not actually a text window GUI"]
Title: Re:Text window position
Post by: Ishmael on Tue 27/01/2004 08:16:44
You got that a bit wrong... If you want to use the standart, customized text window, create it as a normal text window GUI. To use the Lower-screen text window, just leave it as it is, and every time you want to display something in it, use:

DisplayBox("Text displayed"):

And I forgot to mention:

import function DisplayBox(string);

into the script header.
Title: Re:Text window position
Post by: CorCAD on Wed 28/01/2004 01:28:59
TK, Great it works now. Looks good and is exactly what I was looking for except is there a way to make the GUI display continuously. At the moment it only displays while the mouse button is depressed. Thanks again for the help, it's greatly appreciated. I'm still learning the ins and outs of scripting so your little lesson has helped me with some other things.

CorCAD
Title: Re:Text window position
Post by: Ishmael on Wed 28/01/2004 08:02:51
whoops....

function DisplayBox(string text) {
SetLabelText(TXTWINDOW,0,text);
GUIOn(TXTWINDOW);
while (IsButtonDown(LEFT) == 0) Wait(1);
GUIOff(TXTWINDOW);
SetLabelText(TXTWINDOW,0,"");
}

I think I was typing that in a little hurry...   :-[
Title: Re:Text window position
Post by: CorCAD on Wed 28/01/2004 17:15:10
That works much better, I kinda figure out a way on my own last night and used waitmousekey (Think that's the right one) and that worked pretty good. Consider this one done and dusted. Thanks for your help.

CorCAD
Title: Re:Text window position
Post by: Ishmael on Wed 28/01/2004 19:57:31
:) Edit the first post and add [SOLVED] to the title ;)