Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Dialog Not Working Correctly

Credits go to Dustin Dettmer and Edgar Reynaldo for helping out!
This thread is locked; no one can reply to it. rss feed Print
Dialog Not Working Correctly
Ron Rider
Member #8,208
January 2007

Within the past week or two, I have been learning how to use Allegro Dialogs, and I thought I had the hang of them. That was until one of my DIALOG arrays stopped working correctly. I had declared the following DIALOG:

1int game_button_proc(int msg, DIALOG *d, int c)
2{
3 int ret = d_button_proc(msg, d, c);
4 if (ret == D_CLOSE && d->dp3)
5 return ((int (*)(void))d->dp3)();
6 return ret;
7}
8 
9DIALOG your_char_dialog[] =
10{
11 /* (dialog proc) (x) (y) (w) (h) (fg)(bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
12 { game_button_proc, 15, 575, 160, 16, 0, 0, 0, 0, 0, 0, (void*)"&Save Character",NULL, (void*)SaveChar },
13 { game_button_proc, 325, 575, 160, 16, 0, 0, 0, D_EXIT, 0, 0, (void*)"&Go to Town", NULL, (void*)GoToTown },
14 { game_button_proc, 625, 575, 160, 16, 0, 0, 0, D_EXIT, 0, 0, (void*)"&Exit", NULL, (void*)gameExit },
15 { d_yield_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17};

And I am calling it with do_dialog:

do_dialog(your_char_dialog, -1);

The 2nd and 3rd buttons both work, and do their job; however, the first one(which calls (void*)SaveChar) does not do anything. When I click the button it only gets selected, but does not call SaveChar(). This button used to work since the beginning of my game, but it just stopped working, and I am not sure why. I have tried moving the do_dialog() call to the beginning of my program, but that doesn't work. I have even tried putting another button in front of the faulty button, that doesn't work either. My code compiles fine the button just doesn't do anything.

Can anyone help me with this?

Dustin Dettmer
Member #3,935
October 2003
avatar

Did you do a total recompile?

Ron Rider
Member #8,208
January 2007

Yes, I rebuilt the whole program before I ran it.

Edgar Reynaldo
Member #8,592
May 2007
avatar

Ron - Check the flags field of your first game_button_proc.

D_EXIT is not set, so when you click on your first button , the D_CLOSE message is never sent to the dialog (which is what calls your function)

Hope this helps

Dustin Dettmer
Member #3,935
October 2003
avatar

Add a D_EXIT flag to the first button.

Ron Rider
Member #8,208
January 2007

That did it. Thanks a lot guys.

Go to: