Removing libRocket python bindings

Discussion about using Python with libRocket.

Removing libRocket python bindings

Postby rcdailey on Thu Aug 14, 2008 10:20 pm

Hi,

I'm in a situation where I need to remove a few various python bindings from libRocket. For example, I've created my own python binding to create Rocket::Core::ElementDocument objects. The reason for this is because our game does a lot of implementation detail when a new document is created that the original libRocket python binding could not provide us a way of performing. So, since we do not want our users creating documents through libRocket and we essentially want to force them to use our custom function, we need to remove the python binding from the Context::LoadDocument() function (All overloads).

Is it possible to do this right now? Keep in mind that there will definitely be needing to remove more bindings later as we develop new features and progress into the project.

Also, if there are better options to take than removing the binding, please do share it. Remember the goal here is to *prevent* the python scripts from being able to use certain libRocket functions. If that doesn't require removing python bindings, I'd be open ears to hearing alternatives. Thanks for your time.

::EDIT::
In order to create our own sort of "ElementDocument factory", we need to be able to return the specific boost::python wrapped ElementDocument object, which I do not believe has been exposed in the normal interfaces, which is understandable, because as far as you guys are concerned the python bindings you have made for libRocket are an implementation detail. We'd probably need the source code to the closed-source python bindings in order to return the python version of ElementDocument from our custom factory function?
rcdailey
 
Posts: 113
Joined: Mon Feb 04, 2008 8:04 pm

Re: Removing libRocket python bindings

Postby rcdailey on Mon Aug 18, 2008 1:11 am

Just bumping this topic. Would be great to get an opinion on the matter. Sorry for the rush!
rcdailey
 
Posts: 113
Joined: Mon Feb 04, 2008 8:04 pm

Re: Removing libRocket python bindings

Postby lloydw on Tue Aug 19, 2008 11:13 am

Hey Robert

The easiest way to remove the LoadDocument would be to simply overload it with your own version? In your python module simply do something like:

Code: Select all
original_loader = rocket.Context.LoadDocument
def MyLoadFunction(ctx, filename):
  doc = original_loader(ctx, filename)
  # Do other initialisation here
  return doc

rocket.Context.LoadDocument = MyLoadFunction


Hope that helps.

For rebinding the document, you could re-register the "body" tag (using rocket.RegisterTag). Thus forcing a completely different object to be instanced when the body XML tag is found. The only thing Rocket requires is this new type inherit from Rocket::Core::ElementDocument. There are however a few tricky points when it comes to document. As the document needs to provide support for compiling the script tags (see the LoadScript method of Rocket::Core::ElementDocument).

If you need help with this we can discuss it further.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: Removing libRocket python bindings

Postby rcdailey on Tue Aug 19, 2008 12:40 pm

I still want to use the original ElementDocument class, I was just looking for a way to return it from a function created with Boost.Python. I'm hoping I don't have to worry about deriving from ElementDocument or anything else so long as I still plan to use the original ElementDocument class. However, the example you gave is much easier. I can execute that code from the embedded interpreter and it would be concealed from the user. I'll try it out and see how it works. Thank you.
rcdailey
 
Posts: 113
Joined: Mon Feb 04, 2008 8:04 pm

Re: Removing libRocket python bindings

Postby rcdailey on Tue Aug 19, 2008 8:31 pm

So if I wanted to use Boost.Python to create my own embedded python function that returns the python version of ElementDocument, how would I do this? What type would it be in C++?
rcdailey
 
Posts: 113
Joined: Mon Feb 04, 2008 8:04 pm

Re: Removing libRocket python bindings

Postby lloydw on Wed Aug 20, 2008 1:08 am

Your function should return a Rocket::Core::Element*

You'd then expose the function to python and bind it to the body tag. You could then call the default C++ load function from it.
lloydw
Rocket Engineer
Rocket Engineer
 
Posts: 380
Joined: Tue Jan 15, 2008 10:56 pm

Re: Removing libRocket python bindings

Postby mariasam on Wed Sep 18, 2013 4:37 am

I actually did pretty much the exact same thing a few weeks ago. :) In this case I would add position: absolute; right: 0px; to div.healthbar. That'll anchor its right edge to its parent's edge. One catch though, absolute elements base their position on their closest ancestor with relative or absolute positioning. :)
000-596 000-596
000-597 000-597
000-598 000-598
000-600 000-600
000-603 000-603
mariasam
 
Posts: 1
Joined: Wed Sep 18, 2013 4:11 am


Return to libRocket and Python


cron