Derived classes

Started by
3 comments, last by NicoG 13 years ago
Hi All,

I'm building my little game engine around AngelScript. Right now my whole UI can be scripted. The users can build the whole UI from AS and can script different events (button press, etc.). So far as a proof of concept that the games can be almost fully modded I've already managed to add a calculator to the test game, by only using AS. Now I want to do some more complex things. I want to make a little windowing system (taskbar, minimizing, etc.) from script. I'm making good progress, but I need your help with this one.

I want to make something to make creating windows simplier. Right now my window class supports the close button by default. For the windowing system windows, I want them to have a minimize and maximize/restore buttons by default.
In C++ I would derive a window class from the basic window class, so the new class would support creating theese buttons by default. But I can't derive from a class registered from C++, so now I have a create function that adds theese buttons.

So now I'm doing this:

Window @ window = CreateWSWindow( "windowName" ); // creates a window and adds the two buttons

and I'm looking for a solution to do this:

Window @ window = WSWindow( "windowName" );

where WSWindow would be the derived one.

I want to do this only by scripting and without modifying any C++ code.

Maybe you have some more cleverer solution for this.
Advertisement
What ou could do is create a class in angelscript that wraps the functionality of the C++ class into something you can inherit from.

class Actor
{
Core_Actor@ m_coreActor; // C++ class registered as Core_Actor
Actor(string@ name)
{
@m_coreActor = Core_Actor(name);
}

void Foo()
{
m_coreActor.Foo();
}
};


In fact, with the rendering engine I am using for my engine, the only way I could expose it is through proxy classes.
I hope you don't mind throwing my Question into this Thread.
Never had this case for AngelScript and could not find something on google.
Maybe I see just too many trees to see the forest:

C++ Side

class BoundingBox
{
// a lot of transform functions
};

class BatchedSprite : public BoundingBox
{
// a lot of drawing functions
};

class AnimatedSprite : public BatchedSprite
{
// some more Functions
};


How would one register that in AngelScript without having to re-register all functions from bounding box in sprite again?
It is been a while since I used AngelScript and I am a bit lost right now :D.

The only way I see right now is to export each class on its own and use proxy classes in angelscript then.
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/
See class hierarchies in the AngelScript documentation.
Ahh, there it was hiding. Did not find/see it.
Thanks for pointing me. Have some rep.
If you say "pls", because it is shorter than "please", I will say "no", because it is shorter than "yes"
http://nightlight2d.de/

This topic is closed to new replies.

Advertisement