Game Development Community

dev|Pro Game Development Curriculum

MinApp Tutorial #2 - Torque Tools Support

by John Vanderbeck · 01/22/2004 (10:10 am) · 25 comments

Download Code File

MinApp Tutorial #2 - Torque Tools Support

The purpose of this tutorial is to add in support for the built in Torque tools -- The GUI editor and Mission/Terrain Editor.

Originally this was going to be done in two steps, with the GUI editor and Mission/Terrain editor handled individually. This turned out to not be practical, as the "editors" are all wrapped together in code.

As with tutorial #1, this tutorial will use some pre-existing files from the stock Toqrue demo application. We are obviously not going to recreate the editors.

1) Copy files from stock Torque Demo Application to MinApp
Copy the directory "editor" from the example/common to minapp/common
Copy the following files from example/common/ui to minapp/common/ui:
guiEditorGui.gui
inspectDlg.gui
frameOverlayGui.gui
LoadFileDlg.gui
MessagePopupDlg.gui
MessageBoxYesNoDlg.gui
MessageBoxOkDlg.gui
MessageBoxOkCancelDlg.gui
SaveFileDlg.gui
InspectAddFieldDlg.gui
torqueCheck.png
torqueMenu.png
torqueRadio.png

Copy messageBox.cs from example/common/client to minapp/common/client

In tutorial #1 we added additional default profile code to the file defaultProfiles.cs. A large amount of the default profiles were still missing, and are needed for this step in the process. Instead of going through and adding in every single default profile, I determined it was just better to simply copy the file over, giving us all the default profiles. This really has no effect on us pulling things out later, as we can always leave the default profiles in. They are usefull for things other than our tools.

Copy defaultProfiles.cs from example/common/ui to minapp/common/ui

2) Modify minapp/common/client/canvas.cs

We need to add in the exec() statements for our new UIs as well as one helper script. In the function initCanvas() add the code signified in bold below.

// Commonly used helper scripts
   exec("./cursor.cs");
[b]   exec("./messageBox.cs");[/b]
   
   // Common GUI's
   exec("~/ui/ConsoleDlg.gui");
[b]   exec("~/ui/GuiEditorGui.gui");
   exec("~/ui/InspectDlg.gui");
   exec("~/ui/LoadFileDlg.gui");
   exec("~/ui/SaveFileDlg.gui");
   exec("~/ui/MessageBoxOkDlg.gui");
   exec("~/ui/MessageBoxYesNoDlg.gui");
   exec("~/ui/MessageBoxOKCancelDlg.gui");
   exec("~/ui/MessagePopupDlg.gui");[/b]

What does this do?
What we have done here is pretty much the same thing we did in tutorial #1. We are setting our gui files to be ran at startup. The messageBox.cs file is a helper script for using message boxes in our application.

3) Modify minapp/common/main.cs

In the initCommon() function, we need to add in the script file which sets up all the editor functions. Once again, the code to be added is in bold.

function initCommon()
{
   // All mods need the random seed set
   setRandomSeed();

   // Very basic functions used by everyone
   exec("./client/canvas.cs");
   
[b]   // Editor support
   exec("./editor/editor.cs");[/b]
   
}

What does this do?
The script editor.cs initializes and sets up the editor for use.
Page«First 1 2 Next»
#21
04/16/2007 (7:27 pm)
Are these outdated with TGE 1.5.1?

I am finding that the files this tutorial tell me to copy are actually not in common/ui but are in creator/ui

Am I doing something wrong?
#22
04/17/2007 (4:24 pm)
ok nm. You just have to hunt down the files . FYI to others with the same question I had.

Copy the directory "editor" from the example/creator to minapp/common

Copy the following files from example/common/ui to minapp/common/ui:
frameOverlayGui.gui
LoadFileDlg.gui
MessagePopupDlg.gui
MessageBoxYesNoDlg.gui
MessageBoxOkDlg.gui
MessageBoxOkCancelDlg.gui
SaveFileDlg.gui
torqueCheck.png
torqueMenu.png
torqueRadio.png

Copy the following files from example/creator/ui to minapp/common/ui:
guiEditorGui.gui
inspectDlg.gui
InspectAddFieldDlg.gui
#23
08/12/2007 (8:53 pm)
I have a comment to make that may simplify for people using a newer version. In my version 1.5.1 TGEA I have a folder named "creator" that contains the information that was apparently found in the "editor" folder before. In the main.cs starting directory (the file where program begins executing), simply append "creator;" to the mod string and make sure the creator folder is in that directory along with demo, common, and any other folders. This folder runs like a seperate mod but it contains all the editors and information (as well as the key binding). This is a simple way to integrate the tools if you have the newer folder hierarchy.
#24
08/17/2007 (7:40 am)
This article is mostly out of date. I tried following Sean's advice, but still not having any luck. Specifically, I did the following:

1. copied the entire creator directory into the project root (MiniApp)
2. updated line 8 of main.cs: $baseMods = "common;creator";
3. updated line 28 of main.cs: $modPath = $userMods @ ";" @ $baseMods;
(not much point of defining userMods and baseMods if you're not going to use them...)
4. Fired up the app and watched it crash :(

The log has few clues. I've copied parts of it below.

I can see that the changes to main.cs took effect:

--------- Loading MODS ---------
Entering loadMods(demo;creator;common)

There is a warning (I'm guessing it's a warning) as it loads the creator mod:

Loading compiled script creator/main.cs.
creator/main.cs (5): Unable to find function loadDir

Then the application terminates abnormally. This is what is logged at the end:

--------- Initializing: Torque Creator ---------
Compiling creator/editor/editor.cs...
creating path creator/editor/editor.cs.dso
creating path creator/editor/
Loading compiled script creator/editor/editor.cs.
Compiling creator/editor/particleEditor.cs...
creating path creator/editor/particleEditor.cs.dso
creating path creator/editor/
Loading compiled script creator/editor/particleEditor.cs.
Compiling creator/scripts/scriptDoc.cs...
creating path creator/scripts/scriptDoc.cs.dso
creating path creator/scripts/
Loading compiled script creator/scripts/scriptDoc.cs.
Compiling creator/ui/creatorProfiles.cs...
creating path creator/ui/creatorProfiles.cs.dso
creating path creator/ui/
Loading compiled script creator/ui/creatorProfiles.cs.
Compiling creator/ui/InspectDlg.gui...
creating path creator/ui/InspectDlg.gui.dso
creating path creator/ui/
Loading compiled script creator/ui/InspectDlg.gui.
Compiling creator/ui/GuiEditorGui.gui...
creating path creator/ui/GuiEditorGui.gui.dso
creating path creator/ui/

If you look at creator/main.cs, you can see the exec calls:

12 echo( "\n--------- Initializing: Torque Creator ---------" );
13
14 // Scripts
15 exec("./editor/editor.cs");
16 exec("./editor/particleEditor.cs");
17 exec("./scripts/scriptDoc.cs");
18
19 // Gui's
20 exec("./ui/creatorProfiles.cs");
21 exec("./ui/InspectDlg.gui");
22 exec("./ui/GuiEditorGui.gui");
23
24 exec("./ui/lightEditor.gui");
25 exec("./ui/lightEditorNewDB.gui");

If I comment out lines 22 and 24 (GuiEditorGui and lightEditor), the application will not crash - right away. Pressing F10 does nothing and F11 has become the abnormal termination key.
#25
10/31/2007 (3:06 pm)
I went through this tutorial and I could get the exe to start up, but when I would press F10 to get to the GUI editor it would always crash. Eventually I found out that I needed to copy over the images in /example/common/ui to the minapp/common/ui and that fixed my problem and now the GUI editor works and doesn't crash. The only thing I can figure is that the GUI editor was looking for an image that wasn't there and would just die when it couldn't find the image it wanted. I don't know what specific image or images are require to make it not crash, except that it is used by the GUI editor.

Maybe someone can find which specific images are needed for the GUI editor?

These tutorials need updated, however they still seem to be very useful.
Page«First 1 2 Next»