Game Development Community

How Do I Bundle My Game Assets?

by James Jacoby · in Torque Game Engine · 10/30/2005 (3:13 pm) · 15 replies

What do I have to modify so that my application will treat the "app_bundle/contents/resources" folder inside the application bundle as the working directory? If I put all my game assets in that folder and try to run the application, I get an error "Cannot find main.cs". Everything works find if I put the application bunlde in the folder with the game assets. However, I'd like all the files to be inside the app.

Thanks!

#1
10/30/2005 (4:28 pm)
You might have to change something in the source code.
#2
10/30/2005 (5:11 pm)
I think I found it. In the File::Open() function, I am trying to change the code to reference the application's resources folder. I was hoping there was some kind of build setting... More to come.
#3
10/30/2005 (8:06 pm)
If you're going to use TGE 1.4, then it's a very simple thing to do; just set a single #define and rebuild the engine. They've already built the functionality in (along with a pretty nice doc on it).
#4
10/31/2005 (12:10 pm)
Bundle them in a zip. There's a resource for encryption as well.
#5
11/03/2005 (12:36 pm)
As of the latest 1.4,

Torque will automagically detect whether you put your files inside the .app package or not.
This has been out for a couple of weeks, but an updated readme has not been pushed to the public CVS server yet. I think Ben has the CVS pony...

Share and Enjoy.
#6
11/06/2005 (10:18 am)
Does that apply to T2D as well?
#7
11/06/2005 (10:21 am)
T2D isn't spawned from TGE 1.4, so no. You could always incorporate the change yourself... Just track down the conditionals through the code (should actually be pretty simple).
#8
11/06/2005 (10:28 am)
I'll give that a shot. Thanks!
#9
11/06/2005 (2:08 pm)
There doesn't seem to be any difference between the T2D version and TGE 1.4 in the file macCarbWindow.cc. Any idea what file it would be in? Maybe I didn't get the head version. It is "torque" in CVS right? Is this change actually checked in and available?
#10
11/06/2005 (3:51 pm)
Doing a search for TORQUE_SHIPPING (the define for bundling), I see references in ~/engine/console/console.h and ~/engine/core/resManager.cc. Nowhere else. Check those.
#11
11/14/2005 (11:33 pm)
@James: I just checked, the automagic stuff is in cvs HEAD, in macCarbFileIO.cc, in Platform::getWorkingDirectory().

@Scott: TORQUE_SHIPPING no longer controls this behavior.


This will be in T2D shortly. It was added specifically with some T2D features in mind, in fact.

/Paul
#12
11/20/2005 (2:31 pm)
Thank you all for your help. I managed to get this working by changing the "working directory" of the application. I had a change several thigns in macCarbFileio.cc and a few others. Basicall, the app no longer uses the folder the bundle is in as the working directory. Instead, it uses a folder inside the bundle( "contents/resources"). I don't have time to turn this into a resource, but if anyone need to know how I did this, I'd be happy to email you my code.
#13
11/20/2005 (3:54 pm)
I'd like to know if you don't mind. I think this definitely ought to at least be put up on TDN
#14
11/20/2005 (9:15 pm)
@James: Sounds cool, but please tell me that you're talking about patching some new TGE 1.4 code into T2D? Because if you've just written a bunch of new code to do this, then you've just re-implemented the wheel... Most things in the TGE 1.4 platform layer can be just dropped straight into any Torque game, based off any version of the engine. Most things.
#15
11/21/2005 (10:40 am)
Correct me if I'm wrong, but I don't think the stuff in HEAD is exactly what I'm after. If you use that, then getWorkingDirectory will work as desired. However, when you request a file from script, it doesn't use that function to locate the file. The real working directory is decided by a function called macGetWorkingDirectory (I think that is the name) that is called when the app starts up. This is the function that sets up the global platstate variable which all the file related functions use to determine the top most app folder. When I get back to my office, I'll post my code.