Text window position [SOLVED!]

Started by CorCAD, Mon 26/01/2004 19:47:52

Previous topic - Next topic

CorCAD

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
If you don't have time to do it right the first time, how are you going to find time to do it again?

Ishmael

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...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Ben

#2
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:

Code: ags

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

CorCAD

#3
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"]
If you don't have time to do it right the first time, how are you going to find time to do it again?

Ishmael

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.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

CorCAD

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
If you don't have time to do it right the first time, how are you going to find time to do it again?

Ishmael

#6
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...   :-[
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

CorCAD

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
If you don't have time to do it right the first time, how are you going to find time to do it again?

Ishmael

:) Edit the first post and add [SOLVED] to the title ;)
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SMF spam blocked by CleanTalk