Notes for QML contrinbutors

Notes for QML contrinbutors

bart's picture

The basic QML UI I've built is on top of an element called "Box", which is in turn built on top of an element called "HideShowContainer".

  • HideShowContainer is a QML element with nothing inside it.  All it really does is implement two states ("Hide" and "Show") and a snazzy transition between them (so that they fade in and kind of pop up when they appear, and then fade out and shrink a bit when they disappear).
  • Box is an element that's just a blue box with a white border.  Pretty much all the UI windows are based on top of this.  This element uses HideShowContainer as a base, so as to get the nifty hide/show behavior.

The base of the acutal user interface is called Ui, and it contains all of the other UI elements (pause screen, battle screen, etc). If you're adding a completely new screen (such as a shop interface), start in Ui.qml and take a look at how the BattleScreen element is added.

Finally, as I've mentioned previously, there's some unfortunate ugliness in the code, because right now the QML engine doesn't function as a normal script engine, so I've got a separate QtScript engine and some hacks going on to allow me to access data across them.  It appears as if Qt5 will alleviate this, but for now we're stuck with Qt 4.x, so the hacks will have to remain in place until the issue is fixed.

Eventually it would be good to move all of the game-related data structures (items, abilities, etc) into QML.  This was written a while ago, but I think it was due to the fact that QML can't access QObjects the way QtScript can.  Regardless, at this point I want to get the engine completely working rather than rewrite the ability and item handling stuff. :)

That being said, the Character data structure is built in QML, which allows for snazzy things to happen (like having the character status interface bound automatically to the character's status without any extra code).

I hope this helps at least a little bit.  Feel free to post any questions you might have.