Bizarre "Canvas.pushDialog" Problem!
by Melv May · in Torque Game Engine · 05/16/2004 (7:51 am) · 6 replies
Okay,
I admit defeat on this one. I've been fighting with it all afternoon and I simply cannot find what is wrong here.
I'm finding that no matter how many parameters I pass to the "Canvas.pushDialog()" function, it always reports only a single parameter e.g. the GuiControl (as well as the two system parameters) so 3 in total. The second function parameter is supposed to allow placement within a specific layer but if I debug it and look at the "argc" parameter count, it's always three.
So I thought it would be a good idea and put my own routine in for a sanity check and I set it to have a minimum of 3 and a maximum of 5 parameters and it works perfectly. If I pass too little/many paramters then I get an error and the correct range of parameters shows in the "argc" parameter count correctly.
If I do this in the "Canvas.pushDialog", I *always* get three!!!!
If I stick a breakpoint where it checks for the "layer" parameter being passed (something that the editor/console uses), it never gets there as the "argc" parameter count is always three!!
I've downloaded a completely new copy from CVS and built it and it's exactly the same. I'm completely out of ideas now.
Anyone offer any insight?
- Melv.
FYR: Line 115: guiCanvas.cc
... script call ...
Built with Visual Studio .Net 2003.
I admit defeat on this one. I've been fighting with it all afternoon and I simply cannot find what is wrong here.
I'm finding that no matter how many parameters I pass to the "Canvas.pushDialog()" function, it always reports only a single parameter e.g. the GuiControl (as well as the two system parameters) so 3 in total. The second function parameter is supposed to allow placement within a specific layer but if I debug it and look at the "argc" parameter count, it's always three.
So I thought it would be a good idea and put my own routine in for a sanity check and I set it to have a minimum of 3 and a maximum of 5 parameters and it works perfectly. If I pass too little/many paramters then I get an error and the correct range of parameters shows in the "argc" parameter count correctly.
If I do this in the "Canvas.pushDialog", I *always* get three!!!!
If I stick a breakpoint where it checks for the "layer" parameter being passed (something that the editor/console uses), it never gets there as the "argc" parameter count is always three!!
I've downloaded a completely new copy from CVS and built it and it's exactly the same. I'm completely out of ideas now.
Anyone offer any insight?
- Melv.
FYR: Line 115: guiCanvas.cc
ConsoleMethod( GuiCanvas, pushDialog, void, 3, 4, "(GuiControl ctrl, int layer)")
{
object;
GuiControl *gui;
if (! Sim::findObject(argv[2], gui))
{
Con::printf("%s(): Invalid control: %s", argv[0], argv[2]);
return;
}
//find the layer
S32 layer = 0;
if (argc == 4) // I'm always three, what's going on here??????
layer = dAtoi(argv[3]);
//set the new content control
Canvas->pushDialogControl(gui, layer);
}... script call ...
Canvas.pushDialog(MyTestGui, 10);
Built with Visual Studio .Net 2003.
About the author
#2
It was so simple! You were exactly right; I've know idea why that didn't even occur to me but you're definately on my "owe one to" list.
Damn script indirection strips off the final 'layer' parameter. This is a bug, it should be:-
You'll never know how critical this problem was to me; many thanks mate. :)
- Melv.
05/16/2004 (9:55 am)
Josh,It was so simple! You were exactly right; I've know idea why that didn't even occur to me but you're definately on my "owe one to" list.
Damn script indirection strips off the final 'layer' parameter. This is a bug, it should be:-
function GuiCanvas::pushDialog(%this, %ctrl, %layer)
{
Parent::pushDialog(%this, %ctrl, %layer);
%this.checkCursor();
}You'll never know how critical this problem was to me; many thanks mate. :)
- Melv.
#3
05/16/2004 (11:17 am)
No problem at all, expecially after all you've done for the community. I'm glad you got it working. :)
#4
05/16/2004 (11:44 am)
Got this fix checked in. Good eye, Josh!
#5
I cannot believe this one stumped me for 5 hours!!!!!!!!!!
- Melv.
05/17/2004 (8:24 am)
Thanks Ben/Josh,I cannot believe this one stumped me for 5 hours!!!!!!!!!!
- Melv.
#6
07/01/2005 (8:01 am)
While we are here, what does the "layer" parameter do? I understand layers reference to which draws on top of which but the numbers are a bit confusing. In the metrics.cs file Canvas.pushDialog(FrameOverlayGui, 1000); the layer value is 1000 and it gets displayed over all other things in my gui so the greater the number the more topmost layer? If you dont supply a value here it assumes 0 and renders below all other elements?
Torque Owner Josh Albrecht
// below, all functions which can alter which content controls are visible // are extended to call the checkCursor function. For package'd functions, // the Parent:: call refers to the original implementation of that function, // or a version that was declared in a previously activated package. // In this case the parent calls should point to the built in versions // of GuiCanvas functions. //some other functions here function GuiCanvas::pushDialog(%this, %ctrl) { Parent::pushDialog(%this, %ctrl); %this.checkCursor(); }So if you've implemented pushDialog in your testGui or accidentally set the parent incorrectly somehow, maybe this is causing the error.
I know that probably wont help very much, but I thought I'd at least try to give you a hand after all you give back to the community. :)
Good luck!