Hi,
I downloaded this engine yesterday and having looked through the tutorial source I am very impressed but there are one or two things I don't understand.
In the GameMenu GUI example there is code like...
Code:
struct MenuLoad // load-game menu
{
Window window;
Text text;
Button close;
static void Close(Ptr){Ml.window.fadeOut();}
void create()
{
Gui +=window.create(Rect_C(0,0,0.9,0.5)).barVisible(false).hide();
window+=text .create(Vec2 (window.crect.w()/2,-0.15),"Load Game");
window+=close .create(Rect_C(window.crect.w()/2,-window.crect.h()/2-0.1,0.4,0.08),"Close").func(Close);
}
}Ml;
My main question is what does "Ptr" correspond to in the Close function arguments? When I run this with the debugger it shows in the watch list as "Ptr CXX0030: Error: expression cannot be evaluated".
The logical guess would be a reference to the control that was activated.
My second question is suppose I wanted to define a class that implements a GUI window for a console like...
Code:
class Console
{
private:
Window mWnd;
Button mBtnClose;
//Other components...
void Close();
public:
void create();
};
and implemented like
Code:
void Console::create()
{
Gui += mWnd.create(Rect_C(0,0,0.9,0.5)).barVisible(false).hide();
mWnd += mBtnClose.create(Rect_C(mWnd.crect.w()/2,-mWnd.crect.h()/2-0.1,0.4,0.08),"Close").func(Close);
//Init other controls and add...
}
void Console::Close()
{
this->mWnd.fadeOut();
}
So I could have two instances like...
Code:
//...
Console mainConsole;
mainConsole.create();
Console altConsole;
altConsole.create();
//...
Can I do this? and if so what would I need to change about the code above to facilitate it?
Any help on this greatly appreciated.
EvilNoodle
OK I have looked at this a bit more and it seems that user data for the callback is passed through using the "func(void(*func)(TYPE *), TYPE *user)" function assuming that TYPE can be an arbitrary struct. Am I right on this and if so does anybody have an example?
If this is correct then the missing link in what I want to do is what is required to use a non-static function for the button callback.
Any ideas?