Page 1 of 1

GUI state machine

Posted: Mon Mar 01, 2010 11:34
by madeinsoviets
I have another (this time much more) noobish question...)
We have an option to define GUI sheet through the layout editor - are there any ways to define whole state machine of GUI through the facilities of CEGUI?
For example we have an XML with predefined actions - if this button pressed - we setting this sheet if another - another sheed...

Image

Re: GUI state machine

Posted: Mon Mar 01, 2010 17:01
by CrazyEddie
Hi,

At the present time there is no way to specify automatic transitions from one sheet to another; it always requires user code of some kind :)

There are some things you could try though to get an automated sheet switching system in place with a minimum of code and some property support (which should expose it to the editor). The basic recipe would be something like this:

1) In the looknfeel for your button type, add a PropertyDefinition that will hold the name of the target sheet (called "TargetSheet" in this example)
2) Subscribe a handler to the global event set for "PushButton/Clicked"
3) In the handler code, check to see if the "TargetSheet" property exists, if so read the value.
4) If the target sheet is not empty and not == to the current sheet, set it as the new sheet.
5) ???
6) Profit!

I think that's a really simple way to provide automated sheet switching based on button clicks, with a minimal amount of code (i.e. about 6 lines or so).

HTH

CE.