Extending the TGB editor
by Rob Segal · in Torque Game Builder · 12/17/2006 (7:22 pm) · 5 replies
Looking for documentation/examples on extending the TGB editor. I remember seeing somewhere some info on doing this I just can't seem to find it anymore. Anyone done this before or looked into it?
#2
12/18/2006 (8:00 pm)
Hey Joe thanks for the info. I'm pleased you were able to get extensions to work. However I am unsure how I should set stuff up in the resources folder. Do you have a template for how you got stuff to work from there? I welcome your Christmas gift hacks and all. Sparking the discussion and sharing information is worth more to me. I'm willing to battle through some hacky code.
#3
If you go into the resources directory you can see some "example code" in the form of the HOW_ProjectReloader. That's a pretty bare-bones editor resource. Basically, for a resource to be loaded with the editor, you need a few functions:
Resources are great because you should be able to just drop them into that folder when you upgrade TGB. They're also easier to distribute than a series of patches.. As for myself I pretty much went into several editor source files and applied hacks to get things working my way.. I mainly added to the "Edit" menu (some checkboxes and buttons). I've learned a lot by just messing around in the tools source over the past couple of weeks.
12/18/2006 (8:18 pm)
Hi Rob,If you go into the resources directory you can see some "example code" in the form of the HOW_ProjectReloader. That's a pretty bare-bones editor resource. Basically, for a resource to be loaded with the editor, you need a few functions:
// Create Resource Descriptor
$instantResource = new ScriptObject()
{
//Note: Minor detail, these names MUST match the name of the directory to show up in your TGB "loaded resources" list
Class = "HOW_ProjectReloader";
Name = "HOW_ProjectReloader";
User = "TGB";
LoadFunction = "HOW_ProjectReloader::LoadResource";
UnloadFunction = "HOW_ProjectReloader::UnloadResource";
};
$instantResource.Data = new SimGroup()
{
canSaveDynamicFields = "1";
};
// Load Resource Function - Hooks into game
function HOW_ProjectReloader::LoadResource( %this )
{
AddRLCPButton(); //But this can be whatever you want! exec some custom gui file(s) or etc.
}
// Unload Resource Function - Remove from game Sim.
function HOW_ProjectReloader::UnloadResource( %this )
{
// We must clean up all the mess we've made in the Sim.
if( isObject( %this.Data ) && %this.Data.GetCount() > 0 )
{
while( %this.Data.getCount() > 0 )
{
%datablockObj = %this.Data.getObject( 0 );
%this.Data.remove( %datablockObj );
if( isObject( %datablockObj ) )
%datablockObj.delete();
}
}
}Resources are great because you should be able to just drop them into that folder when you upgrade TGB. They're also easier to distribute than a series of patches.. As for myself I pretty much went into several editor source files and applied hacks to get things working my way.. I mainly added to the "Edit" menu (some checkboxes and buttons). I've learned a lot by just messing around in the tools source over the past couple of weeks.
#4
12/19/2006 (7:58 am)
Great thanks for the info Joe. I looked in my resource folder and I didn't notice any example code. Are you running TGB 1.1.3? It's possible I could have deleted the sample files by mistake but I'm thinking that's pretty unlikely.
#5
12/19/2006 (1:36 pm)
Well, it's not example code per se... it's in the HOW_ProjectReloader folder. Which I'm pretty sure was packed into the latest distribution of TGB, unless I'm mistaken. If you can't find it you can get it here: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=11167
Torque Owner Joe Rossi
Indri Games
No, there are no docs to help with this yet. So you have to randomly hack at the tools sources until you get things to happen. (Hint: object.dump() is your friend, and so is editing the level editor in the GUI builder ).
Edit - there are no docs or examples that I know of that will walk you through extending the editor. I'm not bashing the docs in the distribution or on TDN, those are also great places to get hints :)