PDA

View Full Version : Ideas on how to implement skinning system for my GUI



cronodragon
04-02-2007, 05:46 PM
Hello!

I´m reworking the 2D GUI system of my engine. I have arrived to a complex problem, where I want to implement a skinning system, and maybe I could get some ideas on how to do it.

First of all, my GUI system work's like Delphi's component system. I define in a file the graphical attributes of the components (x, y, width, height, font, color, etc.), and each component is wrapped in a package. If I load another file defining the same package, the component definitions will be replaced. Also components could have other components inside.

That's at the definition side. Now I have another class that is the "component instance". It imports the definitions from the component library, and executes all the drawing and logic.

I made it that way because it seems the most optimal way of dealing with components. In a later version I made the component instances to be the definitions themselves, the problem was that data had to be in string format to have enough flexibility. That made everything bigger in memory and too slow.

The problem I have now is how to deal with the skin replacement. If another skin is defined, I would have to destroy all the instances and rebuild them... any idea on how to address this problem will be appreciated.

Regards! :D