Game Development Community

OnRelease: GUIs don't show up (TGB 1.7)

by amaranthia · in Torque Game Builder · 03/30/2008 (7:46 pm) · 10 replies

This is a strange little problem that I've run into. It looks like it could be a bug. When I play my game in debug mode, my GUIs (all generated in script) show up just fine (close button, options button). However, when I build the game in release mode, the GUIs don't show up.

(Note: it appears that the problem isn't the GUIs. It has something to do with scene objects and a class being defined in a datablock.)

#1
03/31/2008 (9:15 am)
That is very strange. Make double sure there isn't some release build configuration setting missing ( not sure what this would be though ). Perhaps your working directory is getting messed up? I have seen TGB load/run the wrong project before, even from the level editor.

A few questions... are you getting any console errors when this occurs? Are other parts of your game working properly? Do the 'missing' gui controls exist at all or just not visible ( try 'optionsbutton'.dump )? How are you running your game in release/debug and where are your building your exe's to?
#2
03/31/2008 (10:29 am)
I found something interesting that may be of use...

Nope, no console errors, but I did test around and found that the class for the GUI wasn't getting hit.

In debug mode, I can use a datablock to declare the class for a gui object, but in release mode this doesn't seem to work. To get it to work in release mode, I have to declare the class in the level file.

I hope this helps!
#3
03/31/2008 (2:04 pm)
Guis do not have or use datablocks.

Profiles are guicontrol's sortof datablock equivalent if thats what you meant? Profiles do need to be created in script. And a missing profile could definitely cause your gui/control to not render.
#4
04/01/2008 (10:19 am)
I'll re-phrase, since it looks like the problem isn't with GUIs, but with a scene object and its class. (I'll make a note above.)

I can assign a class to a t2dStaticSprite, using a datablock in debug mode, but not in release mode. The problem only happens when t2dStaticSprite is defined in a t2d file.

Here is the code that wasn't working in release mode:

village.t2d file:
new t2dStaticSprite(event) {
      imageMap = "eventImageMap";
      config = "MenuDatablock";
   };

datablock.cs file:
datablock t2dSceneObjectDatablock(MenuDatablock) 
{
    Class = "menu";
    Layer = "19";   
    Size = "15 15";
    id = "0";
    name = "0";
};
#5
04/01/2008 (10:59 am)
Perhaps, for some reason, your datablock is not getting created before your level is loaded. Since your datablock is created when datablock.cs is executed, you should investigate when it is getting executed, and if it is happening differently for your different builds.

If you are using the game/gamescripts/datablock.cs file, then that is normally executed before startGame() is called and therefore before the level is loaded, but you might want to make double sure of it.

You can put a breakpoint anywhere in your file ( are you using torsion? ), and see if it hits for both of your builds. If it doesn't, look up the chain from where it is usually called and see whats going on.

Making use of torsion's "goto definition" heres how the user datablock's file seems to get executed... ( I think its fun to look at the scripts written by GG )

the highest level "root" main.cs calls _initializeProject on line 51
_initializeProject executes the "user datablocks" (usually game/gamescripts/datablock.cs) on line 91

Let me know if you find anything.
#6
04/01/2008 (11:17 am)
Oh, you might already know this, but I just noticed you aren't specifying a position for your "event" object. You could do that in its declaration, or inside the config datablock ( which will copy it over ), or maybe you already are setting its position at some point later.
#7
04/01/2008 (1:24 pm)
In this case, the object is hidden. I'm using it as a call center for my GUI controls. Er, I know, I'm weird. :-)

Yep, I'm using Torison. I'll go and test now.
#8
04/01/2008 (2:15 pm)
Okay, I think I found something suspicious in projectManagement.cs:

//---------------------------------------------------------------------------
   // User Defined Datablocks
   //---------------------------------------------------------------------------
   addResPath( %userDatablockFile );   
   if( isFile( %userDatablockFile ) )
   {
      exec( %userDatablockFile );
   }

In debug mode, the if statement gets hit and %userDatablockFile (in this case datablocks.cs) is executed.

However, when I build my game for release mode, the if statement comes back false and %userDatablockFile isn't executed.

In both release and debug mode, %userDatablockFile = game/gameScripts/datablocks.cs

The only thing that I can think of is that in release mode, all of my files end with dso. There aren't any cs files in my directories at that point. However, I've never had a problem referencing cs files before.
#9
04/01/2008 (2:28 pm)
Okay, I think I found something suspicious in projectManagement.cs:

//---------------------------------------------------------------------------
   // User Defined Datablocks
   //---------------------------------------------------------------------------
   addResPath( %userDatablockFile );   
   if( isFile( %userDatablockFile ) )
   {
      exec( %userDatablockFile );
   }

In debug mode, the if statement gets hit and %userDatablockFile (in this case datablocks.cs) is executed.

However, when I build my game for release mode, the if statement comes back false and %userDatablockFile isn't executed.

In both release and debug mode, %userDatablockFile = game/gameScripts/datablocks.cs

The only thing that I can think of is that in release mode, all of my files end with dso. There aren't any cs files in my directories at that point. However, I've never had a problem referencing cs files before.
#10
04/01/2008 (3:40 pm)
My guess is the working directory is wrong in one of your builds. The file is there, so it must be looking in the wrong relative path.

In visual studio right click on your project -> properties.

Click on the Debugging tab under Configuration Properties.

You can see your Working Directory in the central window.

You can switch between your Configuration ( debug/release) using the drop down menu at the top left. You might find that one of them is blank '-)

Note: When you 'exec' a file it will look for dso and cs files.