Game Development Community

Can anyone tell me what really happens when you switch between editors?

by Chris Calef · in Torque 3D Professional · 11/06/2012 (11:33 am) · 5 replies

Hi, sorry for the vague generality of the question, but I'm having no end of problems trying to make Ecstasy Motion reliably switch between the main Ecstasy GUI and the other editors, especially the Material Editor but really all of them.

First off, Torque's Rollout controls seem to very desperately want to open up every time anything happens, such as switching to a different editor and then back to Ecstasy. I worked my way around that with a series of ugly hacks, but ... sigh.

More importantly, some of the critical windows in the Material Editor (specifically, MatEdPropertiesWindow) refuse to turn on when I switch to Material Editor from Ecstasy, and several of my windows refuse to turn off. I've written onActivated and onDeactivated functions and attempted to follow the same patterns as the other editors use, but with very unpredictable results.

I realize this isn't really enough information for anyone to tell me what I'm doing wrong, but if anyone can point to anywhere in the forums or docs where there is discussion about how to make a new editor and make it "play nice" with the other editors, I would be exceedingly grateful!

Cheers,
Chris

#1
11/07/2012 (2:59 pm)
Ooooh, the editor scripts and code are only documented in their comments as far as I know. Documentation on how to use them is fairly plentiful - on how to write them, not so much.

As far as opening the Material Editor from your tool, I'd look at how the Shape Editor does it. I'm guessing you've looked at tools/shapeEditor/shapeEditor.ed.cs in ShapeEdMaterials::editSelectedMaterial()?
#2
11/07/2012 (3:46 pm)
Hey Chris.

To add a new editor you'll want to create a new directory under tools/ and give it a main.cs that will automatically be executed by T3D. tools/shapeEditor/main.cs is a good example of the various callbacks you should support for your tool. You could also follow the flow in EditorGui::setEditor() to see how a tool is activated and deactivated.

Other than reading the script, I don't believe there are any docs on what to do, as Richard pointed out.

- Dave
#3
11/07/2012 (4:01 pm)
Thanks for the response, guys!

I actually hacked my way around most of my problems, but to do so I had to do things that were obviously not the Right Way.

I already had the tools/ directory thing figured out, I have a tools/EcstasyMotion directory with a main.cs and all my code & guis in there, that's been working for a while. And I don't need to call the material editor explicitly, like they do from shape editor (might be nice, but not necessary). Instead, I'm simply adding Ecstasy Motion as another icon in the bar across the top, and allowing users to click on any of the other editors and then click back to Ecstasy as needed.

The problem is a boatload of unexpected behaviors I get when I do this. For some reason my Ecstasy windows keep popping up again when I select other editors, even though I've told them to be invisible in onDeactivate for Ecstasy. The more serious problem was the Material Properties window from Material Editor refused to become visible at all in my build, unless commanded to from the console.

Finally, when switching back to Ecstasy from any other editor, all of my rollouts opened up on their own, which was quite undesirable. I believe this is a bug, having to do with the fact that when a control is made visible, it calls childResize, which for a rollout calls instantExpand every time, whether the rollout had previously been expanded or not. I'd love to submit a fix but mine was an ugly hack, as were most of my other "fixes" for these behaviors.

I have no idea why my windows kept getting reopened, but I actually had to write a function just for shutting Ecstasy windows and then call it from inside onActivate for each of the other editors, before it stopped happening. :-P

So anyway, the problem is "solved" for now, but the questions remain...

Thanks again for the help though!
#4
11/07/2012 (7:06 pm)
I've added a few custom editors on my side, and ran into some of the same issues you have.

It's bizarrely particular about the setup, and if something is a little off about your windows/editor arrangement, it seems to crap the bed. I was having the same problem with my in-editor script editor tool. It has a few windows that open to the side similar to the material editor or world editor, and it would have some issues opening my editors windows while safely hiding the current main editors'.

I think I ended up just hacking a solution from my side as well. I was getting more predictable behavior towards the end, but didn't completely crack exactly what it wanted out of it's setup, so I just went with a bit of a hackish approach. I wasn't sure if it was just me screwing up, or something with the editor setup.
Good to know I wasn't the only one. When I start jamming on my editor code again, I'll take a closer look and we can try and discern how it prefers the window/editor loading to happen and get it documented proper(if you don't find something out first ;) )
#5
11/07/2012 (7:10 pm)
Cool, nice to know I'm not alone or totally crazy anyway!