Messagebox request

i dunno how “requests” for SDL are handled…

i am thinking it would be nice for some sort of
cross platform error messagebox type functionality.

i know this starts to tread on the ground of UI,
but i think a simple messagebox type thing would
really help out the x-platform ability.

on linux you can pretty simply spit errors to
stdout and have them accepted. but targetting
the win/mac crowd, i think it would be much more
acceptable for errors to come up in a message box
(i’m sure Be and X users would also like this)

that way i can send the user messages like
"Data Files Not Found. Blah, blah" and still
have things visible for the user.
(ie, how would the win user see this message
unless they brought up the game from the
command prompt. and mac users??)

anyways, it seems all platforms that would
benefit already offer some simple API calls
to put a messagebox on the screen. i was just
wondering if SDL could wrap it up in a cross
platform way

ideas?

Pete Shinners wrote:

i am thinking it would be nice for some sort of
cross platform error messagebox type functionality.
[snip]

I’ve been down this road too, and I agree that it’s really nice to have
a simple messagebox function available.
However, after thinking about it for I while, I decided that I’d rather
not have it as part of SDL:

It’s easy to implement for win32 using MessageBox(), and I’d guess that
MacOS and Beos have similar calls available, but under unix-style
systems it gets a bit muddier.

Here are some options (assuming X windows and ignoring SVGAlib, AALib
and other display targets):

  1. Output to stdout - useful and unixy, but a little un-userfriendly.
    The user will be focused on your app window, not the terminal window.
    The app will just appear to freeze up and it might take a while before
    the message on stdout is spotted.

  2. Implement a messagebox using a widget set like GTK+ or QT. Will look
    nice, pop up in a way that draws the users attention and will probably
    respect the look and feel the user has chosen for their desktop. The
    downside is that it’d tie SDL in to that particular widget library,
    which I think is probably unacceptable.

  3. Implement a messagebox using vanilla X calls. Doesn’t tie SDL to
    anything extra, but will probably look like crap and not observe
    user-selected look and feel.

  4. Implement a messagebox entirely within SDL, using the existing SDL
    window. Nicely cross-platform, works in fullscreen mode, but hard to
    implement in a way that will keep all apps happy (eg what if the app
    doesn’t open a display?). Also, looks very different to messageboxes
    popped up by other apps - eg under windows, most errors appear in the
    same way - ie a small window in the middle of your screen demanding your
    attention.

None of these options will suit all programs. Depends on the type of
app, target audience etc etc…

I think you’re probably best to just write your own function eg:

void ShowMessage( const char* title, const char* message )
{
#if defined( WIN32 )
MessageBox( message, title, MB_OK );
#elif defined( BEOS )
BFunkyModalMessageBox dlg( title, message ); // I’m making this up!
dlg.Display();
#elif defined( MACOS )
ShowMessageThing( title,message ); // I’m making this up too!
#elif defined( X11_AND_GTK )
ShowMyHomemadeGtkDlg( title, message );
#else
printf( “%s: %s\n”, title, message ); // fallback for all other
display types
#endif
}

For the (commercial) game I’m hacking about on, I had the following
requirements for messageboxes:

  • must work on win32 and X11+Linux (x86).
  • must be user friendly and fit in with desktop appearances.

The win32 version was already using MessageBox(), and for the Linux port
I just rolled my own Gtk+ messagebox.
If the game is running in fullscreen mode, it pops itself out into
windowed mode before invoking the messagebox.

Ben.–
Ben Campbell (Antipodean Straggler)
Programmer, Creature Labs
ben.campbell at creaturelabs.com
www.creaturelabs.com

maby someone could throw together a small crossplatform lib for doing this, just like
something small that people could include in there programs so everyone doesnt have to code
it themselves(which isnt good because most programers dont know all of the targets)

Jess

Ben Campbell wrote:> Pete Shinners wrote:

i am thinking it would be nice for some sort of
cross platform error messagebox type functionality.
[snip]

I’ve been down this road too, and I agree that it’s really nice to have
a simple messagebox function available.
However, after thinking about it for I while, I decided that I’d rather
not have it as part of SDL:

It’s easy to implement for win32 using MessageBox(), and I’d guess that
MacOS and Beos have similar calls available, but under unix-style
systems it gets a bit muddier.

Here are some options (assuming X windows and ignoring SVGAlib, AALib
and other display targets):

  1. Output to stdout - useful and unixy, but a little un-userfriendly.
    The user will be focused on your app window, not the terminal window.
    The app will just appear to freeze up and it might take a while before
    the message on stdout is spotted.

  2. Implement a messagebox using a widget set like GTK+ or QT. Will look
    nice, pop up in a way that draws the users attention and will probably
    respect the look and feel the user has chosen for their desktop. The
    downside is that it’d tie SDL in to that particular widget library,
    which I think is probably unacceptable.

  3. Implement a messagebox using vanilla X calls. Doesn’t tie SDL to
    anything extra, but will probably look like crap and not observe
    user-selected look and feel.

  4. Implement a messagebox entirely within SDL, using the existing SDL
    window. Nicely cross-platform, works in fullscreen mode, but hard to
    implement in a way that will keep all apps happy (eg what if the app
    doesn’t open a display?). Also, looks very different to messageboxes
    popped up by other apps - eg under windows, most errors appear in the
    same way - ie a small window in the middle of your screen demanding your
    attention.

None of these options will suit all programs. Depends on the type of
app, target audience etc etc…

I think you’re probably best to just write your own function eg:

void ShowMessage( const char* title, const char* message )
{
#if defined( WIN32 )
MessageBox( message, title, MB_OK );
#elif defined( BEOS )
BFunkyModalMessageBox dlg( title, message ); // I’m making this up!
dlg.Display();
#elif defined( MACOS )
ShowMessageThing( title,message ); // I’m making this up too!
#elif defined( X11_AND_GTK )
ShowMyHomemadeGtkDlg( title, message );
#else
printf( “%s: %s\n”, title, message ); // fallback for all other
display types
#endif
}

For the (commercial) game I’m hacking about on, I had the following
requirements for messageboxes:

  • must work on win32 and X11+Linux (x86).
  • must be user friendly and fit in with desktop appearances.

The win32 version was already using MessageBox(), and for the Linux port
I just rolled my own Gtk+ messagebox.
If the game is running in fullscreen mode, it pops itself out into
windowed mode before invoking the messagebox.

Ben.


Ben Campbell (Antipodean Straggler)
Programmer, Creature Labs
ben.campbell at creaturelabs.com
www.creaturelabs.com

Pete Shinners wrote:

i am thinking it would be nice for some sort of
cross platform error messagebox type functionality.
[snip]

I’ve been down this road too, and I agree that it’s really nice to have
a simple messagebox function available.
However, after thinking about it for I while, I decided that I’d rather
not have it as part of SDL:

[snipped]

These are very good points, which is why I think it’s a great idea to
have this in a separate library that people can use if they want. I’d
make it freeware, just so people could use it however they want.

I don’t know if people have seen it, but SDL_Console on the library page
might be helpful: http://www.libsdl.org/libraries.html

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Here are some options (assuming X windows and ignoring SVGAlib, AALib
and other display targets):
(snip)
None of these options will suit all programs. Depends on the type of
app, target audience etc etc…

Here is an option you didn’t consider. How about calling an external program to
display the message, such as xmessage (which came installed on my system,
although I’m not sure if everyone has it)? This would be incredibly easy to
implement, and wouldn’t muck up the X side of SDL.On Sat, 01 Jul 2000, Ben Campbell wrote:


Andy Hefner (vector7 at crosswinds.net)