Game Development Community

Calling into the current active canvas - howto?

by Thomas \"Man of Ice\" Lund · in Torque Game Engine · 03/11/2006 (3:38 pm) · 2 replies

What I'm trying to do is having a C++ method call a onReceiveMessage() script method.

Thats a nobrainer with Con::executef()

But what I really want is for each GUI to have its own onReceiveMessage() in its namespace.

E.g. PlayGui::onReceiveMessage(), MainMenu::onReceiveMessage()

I've tried to search around, but I simply cannot find an example of how to do a "Canvas.getContent()" from the engine.

Does anyone have a clue how to do this?

#1
03/13/2006 (7:19 am)
The Canvas has a C++ method called getContentControl(). That's the one called by GetContent(). Maybe you can find the Canvas in C++ by using Sim::findObject?
#2
03/17/2006 (7:12 am)
If anyone ever searches for the same, then here is the info on how to do it. Its actually extremely simple

Just do this:
#include "gui/core/guiCanvas.h"

GuiControl* currentGui = Canvas->getContentControl();

Then you can use executef for something along this line:

Con::executef(Canvas->getContentControl(), 5, "onLoadBuddyData", Con::getIntArg(result), Con::getIntArg(buddyId), nameBuf, Con::getIntArg(statusCode), addressBuffer);

Which will call the onLoadBuddyData function into the namespace of the current active GUI