Jump to content
  • Advertisement
Sign in to follow this  
chewbakka

Derived classes

This topic is 2720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Ahh, there it was hiding. Did not find/see it.
Thanks for pointing me. Have some rep.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!