Game Development Community

GUI Window

by David Taylor · in Torque Game Builder · 03/24/2006 (3:01 pm) · 7 replies

Hello, it's me again, lol...

I've set up a GUI where, if the user clicks on a particular button, a window GUI opens up. The only problem is the window takes up the whol screen - the whole T2D screen, that is. ;)

So I have two questions:

1) Is it possible to resize the window in the GUI editor? I've altered the 'Extent' value in the 'Parent' subgroup from '1024 768' to '256 256', which resizes the window. But even after saving the GUI, it resets to '1024 768' if I reload the GUI or run the game.

2) Is it possible to use some form of graphical representation or the window background? Ideally, what I'd like to be able to do is make the window semi-transparent, but being able to use a graphical image for it would allow for even more flexibility.

Oh, and a third afterthought... I've set up the GUI as a GuiWindowCtrl - should I be using a different type of window GUI to get the above?

#1
03/24/2006 (3:25 pm)
For number 2, see common/gui/profiles.cs and look for:
if(!isObject(GuiWindowProfile)) new GuiControlProfile (GuiWindowProfile)
{
   opaque = true;
   border = 1;
   fillColor = "211 211 211";
   fillColorHL = "190 255 255";
   fillColorNA = "255 255 255";
   fontColor = "0 0 0";
   fontColorHL = "200 200 200";
   text = "GuiWindowCtrl test";
   bitmap = "./images/window";
   textOffset = "5 5";
   hasBitmapArray = true;
   justify = "center";
};
For a transparent background, add a number between 0 and 255 on the end of "fillColor".
For example:
fillColor = "211 211 211 125";
Could produce this:
www.stormdevelop.com/images/t2d/trans.gif
Hope that helps. :)
#2
03/24/2006 (3:33 pm)
Thanks again, Tom. Seems like it's just a matter of knowing where to look.

And it also seems like I can use an image if the 'bitmap = "./images/window";' line is anything to go by. Looking at the window image, though, I'd need to do some proper fiddling to get exactly what I wanted.

Thanks heaps, Tom. One question down, one to go! :D
#3
03/24/2006 (3:38 pm)
Glad to help. :)

If you look in common\gui\images you will see that window.png is not exactly for the background of the window, but defines the appearance of the border around the window. If you look at it you will see. :)
#4
04/05/2006 (11:58 am)
David,
The reason you're having problems with the window being set to the entire extent of the screen is because the GUI Canvas has no idea how to deal with GUI's that at their root are not the entire size of the screen. So if you use Canvas.SetContent it will take the very first control in your GUI and size it to the extent of the screen. It should be noted also that even Canvas.pushDialog will result in the same thing happening.

If you're looking to create a window that is not the size of the full screen you should create an invisible base GUI control that has a window as its child. This is how all popup GUI's need to be structure to work properly.

Also of note is that if the GUI you were creating was already a child of the current GUI you could just set it to visible/invisible to suit your needs if you need to be able to click back and forth from different 'windows'.

Hope this helps - Cheers,
-Justin
#5
03/16/2008 (5:31 am)
Resurrecting an old thread, I know, but...

In the latest version of TGB that allows behaviours, (I'm not sure where I can find the version number - sorry), I'm trying to make a semi-transparent window.

Here's the profile I've set up in guiProfiles.cs:
if(!isObject(GuiWindowTransparentProfile)) new GuiControlProfile (GuiWindowTransparentProfile)
{
   opaque = true;
   border = 1;
   fillColor = "211 211 211 1";
   fillColorHL = "190 255 255";
   fillColorNA = "255 255 255";
   fontColor = "0 0 0";
   fontColorHL = "200 200 200";
   text = "untitled";
   bitmap = "./images/window";
   textOffset = "5 5";
   hasBitmapArray = true;
   justify = "center";
};

That fourth number in fillColor has varied between 0, 1, 50 and 100, all with the same results - a non-transparent window. In other words, a window with a solid background.

Here is the window I'm using the profile on:
new GuiWindowCtrl(BackgroundWindow) {
      canSaveDynamicFields = "0";
      isContainer = "1";
      Profile = "GuiWindowProfile";
      HorizSizing = "right";
      VertSizing = "bottom";
      Position = "0 0";
      Extent = "1024 768";
      MinExtent = "8 2";
      canSave = "1";
      Visible = "1";
      tooltipprofile = "GuiWindowTransparentProfile";
      hovertime = "1000";
      maxLength = "1024";
      resizeWidth = "0";
      resizeHeight = "0";
      canMove = "0";
      canClose = "0";
      canMinimize = "0";
      canMaximize = "0";
      minSize = "50 50";
   };

Where have I gone wrong?
#6
03/16/2008 (5:57 am)
You probably want opaque = false;
#7
03/17/2008 (11:27 pm)
Hi Magnus. Thanks for that. I've changed it to opaque = false, but there's no visible change when I run the program.

I tried changing:
Profile = "GuiWindowProfile";

To:
Profile = "GuiWindowTransparentProfile";

But it didn't like that one bit. Any other ideas?