Game Development Community

T2D Image DataBlock Tool *Version 1.2 Updated 7-25-05

by Chris Newman · in Torque Game Builder · 03/20/2005 (8:17 pm) · 40 replies

Update: New version 1.2 uploaded 7-25-04
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7484

After using Torque 2D for a bit, I thought that it was getting repetitive typing all those datablocks for images. So I started work on a small tool to take care of this task for me. The datablock name is the same name as the image but with "ImageMap" after it.

version 1.2
I updated the image preview function, it now uses a T2D Sprite. I used to use a guiBitmapControl. This allows you to see the image size in the menu bar and it now scales the images right. No more stretching an image to 200 x 200.

version 1.1
You can now start a new project and save the images.
If you add any new images to your image dir , you can now load all the new pics, since your last save, with a click of a button. Just click "Find New Images"
*Note : This feature only works with scriptfiles created with version 1.0 and above.

I just added in support for jpg and bmp images
and fixed 2 lil bugs, one with loading your script file and the other when you clicked on "load all new images



chazcross.phase9studios.com/files/torque/t2d/imagedatablockeditor/Image1.jpg

chazcross.phase9studios.com/files/torque/t2d/imagedatablockeditor/imagedatablocktoolload.jpg

To use it:
Open the dir that you have all your images in.
Select an image, the edit its properties on the right.
Click "save image info"
repeat for each image (except for the full type because it is the default)
Press "save to script" button
choose where you want to save the script file
add the script file to your game using the exec() function
enjoy your time from not typing all these datablocks out. :)




www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7484

Just unzip this to your main T2D dir.

Let me know of any bugs and feature requests.
Im open to suggestions on how to improve this tool further.
All the script code is included.
Ill be working on a better looking GUI in the near future.
Page «Previous 1 2
#1
03/21/2005 (9:09 pm)
Well i have my final gui design drawn out on paper, so ill be working on getting that into torques gui system. I made some progress doing that.
Im adding a pane to the right of the dir list to edit the properties of each image file. I also added a image preview to it too.

I did not update any of the main code, so it performs the same as before.

Im having on lil problem with the gui, i want each pane on a guiwindow control but when i add it and make the changes to add the buttons and stuff as children to it, none of them wants to show up.

Ill be fleshing out the rest of the main code tomorow. You will be able to save all your changes to the images ( image types, etc...) to a seperate file, so if you mess up you can just load up the file instead of starting over. Dont worry i have a lot of other functions im adding, this is just my start.
#2
03/22/2005 (7:39 am)
Very cool... like where your going with this :) Later I'll get a chance to test it out some more
#3
03/22/2005 (9:14 am)
Thanks Matt,
Maybe you can help me with this lil gui problem.
This program is already finished but its all in my head and on paper, all I need to do is turn it into script. Most of the code I did so far was just tests (can I do this or that) so its all real sloppy. Most of my time is spent on learning the gui system. Its hard for me to find good docs on it. I need to know all the methods for the gui controls and what they do, what they take and what they return. I found .dump() which shows the methods but not much else. Is there another function to show what I need? Do I need to look in the source code or am I just missing the docs I need? I found one that was somewhat useful but did not have the other info I need. Any help would be appriciated.
#4
03/22/2005 (9:45 am)
The best way to learn that is look t hrough the source code... go to Torque 2D/SDK/engine/gui

from there you can see a lot of good info, things to really look for are consolefunctions


also some of the .h files have a good paragraph or so describing the gui control
#5
03/22/2005 (10:42 am)
Freaky, were you just thinking this too?
"Torque community gui doc project"

We could make all this gui info easily avaiable.
Create a web page documenting all the gui controls. Have a detailed description of what the control is and what it does. Document all the methods. Have short example snippets on how to use each method. And also a "how to" section for each control. For example the gui list control.... "How do I add data to the list", "how do I know what entry I selected" etc.

This will make it a lot easier to find gui info instead of looking in the source and playing around with it in scripts.
#6
03/22/2005 (10:50 am)
Definately like the idea... in fact GG is working on something similar but more massive... heres a quote from Melv

"Ben Garney has posted in his plan about Torque Developer Network (similar to Unreal Dev Network) that will provide all the information you require."

Ben describes what hes working on his plan a bit... the biggest thing about T2D is a lot of it is restricted, so they need it to be onsite and restricted.... however when the TDN (Torque Developer Network) gets up and running we can start helping them set up things like this..

love the idea though

also... I know the EGTGE guide (the full one hes working on) that Ed is working on has a very detailed description of almost every Gui in Torque and an example, though not sure when EGTGE will be fully released
#7
03/22/2005 (12:29 pm)
Cool, that's the guide I was talking about a few post ago but I couldn't rember the name. The version I downloaded from a resource I seen didn't have that much info about the gui controls, so hopefully the full version does.

I didn't get a chance to read his plan before, but the developers network sounds nice, perhaps I should get to writing some gui docs that have the info I would want to use together, and submit them to the developers network when it gets going.
#8
03/22/2005 (1:58 pm)
Definately, will be some of the first T2D documentation... definately would be very helpful to new users.

Ed showed some demo pics of the EGTGE (E-book) interface, has sections for just about every GUI and examples/tutorials for them, its going to cover a huge ammount of stuff, though not sure when its planed to be released, haven't heard anything about it in a few weeks
#9
03/23/2005 (9:45 pm)
Dudes! Don't let the fact that we are creating a "container" for TDN stop you from making CONTENT with which to fill it up. Please continue:)

-Jeff Tunnell GG
#10
03/24/2005 (3:26 am)
@Jeff
Im on it after I get this lil tool done.
Do you think this tool will be useful to anyone making a game with T2D?
Im starting to wonder about this because so far the only person besides myself that sees any value in it, is matt.
#11
03/24/2005 (3:32 am)
Chirs, I will surely be using your tool as soon as I can get another chunk of free time to spend on T2D :)
#12
03/24/2005 (3:38 am)
Chris,

Don't be fooled, tools like this can prove to be invaluable.

There are lots of accessors for the imageMaps and there's even a central group where you can enumerate all datablocks and pick-out all the currently defined imageMaps.

What would be really neat would be to run this tool and for it to list these imageMaps. You can then select one (and you can read the current settings from T2D) via the object and fill in your boxes. You should even be able to get T2D to save the object definition.

I'll have a quick think about this but in the meantime, yes, any tool that helps visualise stuff like this is fantastic.

- Melv.
#13
03/24/2005 (1:05 pm)
Quote:Create a web page documenting all the gui controls. Have a detailed description of what the control is and what it does. Document all the methods. Have short example snippets on how to use each method. And also a "how to" section for each control.

Yes !!!! That would be quite a benefit to have.

I've completed all the tutorials (Basic and Matt's great Physics and GUI tutorials). Now I'm slowly working my way through the included examples, but I still have a long way to go before the script stuff really coalesces in my head. At this point I'm anxiously awaiting more "how to" type docs. The web resource sounds like a great idea, especially for a total newbie like me.

Ken

BTW DL your Image DataBlock Tool and will check it out this weekend, thanks.
#14
03/24/2005 (6:06 pm)
Love the tool Chris... keep at it, like Melv says any visual tools help...

on the documents, if you would like to coordinate our efforts on the GUI stuff, you could create a large reference doc ( like the one Melv did for T2D ) and if you want I can start making tutorials for the rest of them and we can share info.
#15
03/24/2005 (6:17 pm)
Awsome.
The GUI system is the same for T2D, TGE and TSE, so as long as there is nothing T2D specific and sticks to only to the GUI, we'll be helping everyone!

Did you run into any problems with the tool yet?
I dont have any free time till monday to work on it, but im ditching the project idea and going to just use the script file it creates to load from instead. So either "New" or "Use exsisting".

It has some restructing to go through before im happy with it. So far im using a 2D array to store the data and im not sure if its the best way...

// $filearray[%id, "textureName"]
// $filearray[%id, "mode"]
// $filearray[%id, "imageCount"]
// $filearray[%id, "cellWidth"]
// $filearray[%id, "cellHeight"]
// $filearray[%id, "cellCountX"]
// $filearray[%id, "cellCountY"]
#16
03/24/2005 (6:20 pm)
Yeah, definately will be help to a lot of people!

hmm, seems to work for me... only other thing I might do with it is make it a script object array... but I'm just stuck on script objects lol

I'll run it through some testing this weekend (will have a friend do the same)
#17
03/24/2005 (6:37 pm)
I was thinking about useing them, but havnt read enough about it yet.
One thing i need to test out is, if i can edit the data in the script object while it is in the array.
How would i access the data to do this.

array[0] = new ScriptObject() {
cellCount = 2;
}

do i need to do something like this?

%temp = array[0];
%temp.cellCount = 3;

would this ^ update the data in the array or do i have to add it back in like this?

array[0] = %temp;

Now this brings up a question about memory. Is the scriptobject in the array just being updated or is it being thrown away when i add %temp to it?

Is %temp = array[0]; Just getting a reference to the object or creating a new one and copying the values over?
#18
03/24/2005 (6:41 pm)
The array would only hold the ID to the scriptObject, so any changes you made to the scriptObject would be there instantly.
#19
03/24/2005 (6:46 pm)
Ah Yes I see. :)
So Torque Script is like many other languages (dealing with memory).

Thanks.
#20
03/24/2005 (6:48 pm)
Maybe I'm a bit tired, but will try to look at this some more

one of the most valuable things about a script object is it can be passed though


heres a layout of a Torque DB I did using script objects
layout
Page «Previous 1 2