Page 1 of 1

Basic dialog boxes (another wheel reinvented)

Posted: Mon Feb 02, 2009 3:53 pm
by Peter Hickman
When I finished the pairs game I posted earlier I was dissatisfied with the way that dialogs were handled. To many magic numbers being thrown around - which is never a good sign. So here's a simple dialog system that uses an image as a dialog and puts it to the centre of the screen and awaits a click on one of the buttons (which are just designated rectangles in the image). It also casts a transparent shadow.

Designed to handle nothing more than "new game / resume game / quit" style dialogs. See the dialog and click on a button.

There is a variable, dialogs_debug, which when set to true will draw a red box around the button and print the button's name.

I realise that this is the umpteenth half arsed implementation of a dialog box but that's what I like about Lua. It's easy to knock out your own tools :megagrin:

Re: Basic dialog boxes (another wheel reinvented)

Posted: Mon Feb 02, 2009 4:12 pm
by osuf oboys
It's a good start!

American English is the usual naming convention though, e.g. initialising -> initializing.

I believe that you may want to write a class for dialogs and write the system so that multiple ones can be active at once. e.g. by having the draw function call the draw of every active dialog, and similar for mouse clicks.

Take a look at Leif GUI: http://love2d.org/forum/viewtopic.php?f=5&t=261

Re: Basic dialog boxes (another wheel reinvented)

Posted: Mon Feb 02, 2009 4:23 pm
by Peter Hickman
Leif certainly looks good. I'll keep that one squirrelled away for when I need something more sophisticated.