Alert box not tied to dialog
Kevin Epps

Can an alert box be called with out it being tied to a dialog(i.e. calling do_dialog) without any problems?

I'm trying to create an "are you sure?" quit sequence with my game. I took this example from exgui.c

int quit(void)
{
   if (alert("Really Quit?", NULL, NULL, "&Yes", "&No", 'y', 'n') == 1)
      return 0;
   else
      return 1;
}

And call it like this:

1if(key[KEY_ESC])
2 {
3
4 if(quit() == 1)
5 {
6 //bool that's running the game loop
7 run = false;
8 }
9 else
10 {
11 //return back to the game
12 }
13 
14
15 }

My problem is that sometimes the words comes up and sometimes it doesn't. Also I don't have the mouse showing during the game. But when I call this, the mouse shows on it's own, but it's not the allegro mouse. Should I draw the allegro mouse in the quit function to ensure an accurate click? Because the only way for me get a successful yes, is hitting "Esc" again, which is the default button 1 action.

Any help is appreciated? Also, if I messed up with my post in some way. Please don't focus on that as I'm already busy as it is and don't want to see a reply and it's all about the way I posted.

Thanks!!

BAF

I'd just do:

int quit(void)
{
   int ret;
   show_mouse(screen); // assumes mouse has been installed
   ret = !(alert("Really Quit?", NULL, NULL, "&Yes", "&No", 'y', 'n') == 1);
   show_mouse(NULL);
   return ret;
}

Kitty Cat

Adding enable_hardware_cursor(); before show_mouse(screen); would be benficial, too.

Andrei Ellman
Quote:

My problem is that sometimes the words comes up and sometimes it doesn't.

Are you using page-flipping or triple-buffering by any chance? This might explain why the words do not always come up. Allegro's GUI only likes to display itself on one of the pages when using page-flipping, and if the page it displays on is not the page being shown, then you wil not see it.

AE.

casey d
Quote:

Are you using page-flipping or triple-buffering by any chance? This might explain why the words do not always come up. Allegro's GUI only likes to display itself on one of the pages when using page-flipping, and if the page it displays on is not the page being shown, then you wil not see it.

I get the same problem with page-flipped and triple-buffering, but only in windowed mode. I've never had this problem in fullscreen.

Evert

Have a look at gui_set_screen() if you want to use the GUI along with triple or double buffering.

Thread #563103. Printed from Allegro.cc