Game Development Community

RTS Tutorial Broken or Need TGB GUI Editor Explanation

by Damon Slye · in Torque Game Builder · 07/07/2006 (5:43 pm) · 5 replies

I'm going through this tutorial, and am stuck here:
http://tdn.garagegames.com/wiki/Torque_2D/GenreTutorials/StrategyMouseSelections#Create_a_dialog_that_changes_upon_selecting_units

This part of the tutorial no longer seems to match the current version of tgb.

Simply, I want to resize the tile window to make room for a menu bar at the bottom, and have the menu bar display.

I'm not sure which GUI I should be editing. Originally I was editing the default set of GUIs that comes up when entering the gui editor from TGB, which has a structure something like this:
-GuiScriptNotifyCtrl
......+GuiStackControl
......-GuiFrameSetCtrl - levelBuilderContentFrame
......-GuiControl - levelBuilderViewContainer
............-GuiFormCtrl[]
..................GuiMenuBar
..................LevelBuilderSceneWindow[LevelBuilderSceneView]
......+GuiScriptNotifyCtrl - sideBarContentContainer

Changes in here would work temporarily, then reset to odd #s after running the level (like negative y positions). So I instead started editing mainScreen.gui (which I selected from the center selection box at the top). mainScreen.gui has this form:
-GuiChunkedBitmapCtrl - mainScreenGui
......t2dSceneWindow - sceneWindow2D

I was able to resize the sceneWindow2D, and add a menuBar at the bottom as per tutorial instructions (new control -- > guiControl etc....)

and this seemed to work better, but the same reversion problem would occur. I was able to get the scenewindow to resize smaller, and remain resized smaller, but after running the level, the y position of my added gui object, a menu bar at the bottom, would change to a negative #.

The real issue, is I want to be able to add in-game menus during play to a simple 2d tile game through the gui editor that will stay in a 2d tile game, and would like to use the gui editor to do this. There must be a very trivial way to accomplish this.

Any ideas?
Damon

#1
07/07/2006 (5:43 pm)
What problem did you have with the tutorial? I'm having some trouble too.
#2
07/07/2006 (6:00 pm)
Unrelated to my prior post, but in response to Chip Lambert's post:
I also had a problem earlier with this tutorial. I followed the tutorial carefully and verbatim, but I couldn't get the selection box to draw.

After some debugging I found the problem. At one point in the tutorial you create a dynamic field for your selectable sprite objects. The field is called isSelectable. In the level builder you are instructed to set isSelectable to true.

However in mouse.cs in function getSelections(%pos) there is the following conditional:
if( %obj.isSelectable )

This would always evaluate false, even though echo( %obj.isSelectable ) will display true. Apparently the level builder was setting the field to the string "true" (which evaluated to 0) and not to the keyword true (which evaluates to 1).

I'm not sure why it worked before, or what has changed since the tutorial was written. Anyway I changed the value in the isSelectable field from true to 1 and it worked after that.
-- Damon
#3
07/07/2006 (6:04 pm)
I had trouble and still have trouble with the selection... my selection never works. I've even copied the scripts straight form the article but it doesn't work.... I was able to get the box to show up, however the object was never actually being selected.
#4
07/07/2006 (7:00 pm)
Chip-- Other than replacing true with 1 in the dynamic field isSelectable with the level builder, I had a few other problems as I recall.

In one instance I think I didn't set the border box image map datablock up properly and that caused a problem. This was something that had to be done from the editor so having scripts wouldn't solve this problem.

Another problem I had was that in a couple of places in the tutorial the author slips in a quick comment that you have to call initSuchandSuch() in function soAndSo()... and these comments weren't formatted with the standard code highlight the rest of the tutorial uses when displaying code, so late at night my bleary eyes glossed over this instruction-- but I guess if you're using the code they supplied this wouldn't be the problem.
#5
07/09/2006 (6:06 pm)
After spending more time exploring this, it's clear to me that it is the mainScreenGui that should be editted. So the first step when starting on this part of the tutorial, when starting the gui editor, is to select the mainScreenGui using the center selection button (there are three of these at the top, the left-most reads "New Control", and the right-most reads "640x480" (or whatever resolution you are in).

The Level Builder / Gui Editor is different than when the doc was written as the doc seems to assume that when you enter the Gui Editor the mainScreenGui will already be highlighted. Further when you do select mainScreenGui, my tilemap disappears from the background, different than the screenshots in the tutorial.

However, I am still having the 'reversion' problem I referred to in my original post:
I was able to get the sceneWindow to resize smaller, and remain resized smaller. However after I "Play Level", the y position of my menuBarGui, would change to a negative # in the level builder, though not in the saved mainScreen.gui file. So I can do a work-around by always exitting the level builder and restarting it, but this sort of defeats the purpose of having an interactive development environment (and using interpreted script instead of compiled code, etc...).

Perhaps there is a more trivial way to do this that works... ?

Damon