Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Alert box not tied to dialog

This thread is locked; no one can reply to it. rss feed Print
Alert box not tied to dialog
Kevin Epps
Member #5,856
May 2005
avatar

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
Member #2,981
December 2002
avatar

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
Member #2,815
October 2002
avatar

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

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Andrei Ellman
Member #3,434
April 2003

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.

--
Don't let the illegitimates turn you into carbon.

casey d
Member #4,901
August 2004
avatar

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.

--
Nightsticks, water cannons, tear gas, padlocks, molotov cocktails and rocks behind every curtain

Evert
Member #794
November 2000
avatar

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

Go to: