Timorg
Member #2,028
March 2002
|
According to the manual for d_menu_proc "the color is taken from the gui_*_color variables, and the width and height are calculated automatically (the w and h fields from the DIALOG are only used as a minimum size.)" When the minimum size is set to be larger than the area that the menu bar will take up, it doesn't fill the area completely, it only fills the area that the menu words cover. Where the outline for the menu outlines the complete area. This picture demonstrates the problem: {"name":"591981","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/8\/d8695c54cdcc5aabcc43ffcdc3ab6a68.png","w":646,"h":165,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/8\/d8695c54cdcc5aabcc43ffcdc3ab6a68"} The black area to the right should be filled, but its not, the below code demonstrates the problem. (it is also attached) 1 | #include <allegro.h> | 2 | | 3 | MENU file_menu[] = | 4 | { | 5 | /* { "Text\tsc", (callback), (Submenu), (flags), (dp) )*/ | 6 | { "Pause", NULL, NULL, 0, NULL }, | 7 | { "New Game", NULL, NULL, 0, NULL }, | 8 | { "End Game", NULL, NULL, 0, NULL }, | 9 | { "Quit", NULL, NULL, 0, NULL }, | 10 | { NULL, NULL, NULL, 0, NULL } | 11 | }; | 12 | | 13 | MENU edit_menu[] = | 14 | { | 15 | /* { "Text\tsc", (callback), (Submenu), (flags), (dp) )*/ | 16 | { "Game Options", NULL, NULL, 0, NULL }, | 17 | { "Control Options", NULL, NULL, 0, NULL }, | 18 | { NULL, NULL, NULL, 0, NULL } | 19 | }; | 20 | | 21 | MENU help_menu[] = | 22 | { | 23 | /* { "Text\tsc", (callback), (Submenu), (flags), (dp) )*/ | 24 | { "About", NULL, NULL, 0, NULL }, | 25 | { NULL, NULL, NULL, 0, NULL } | 26 | }; | 27 | | 28 | MENU game_menu[] = | 29 | { | 30 | /* { "Text\tsc", (callback), (Submenu), (flags), (dp) )*/ | 31 | { "Game", NULL, file_menu, 0, NULL }, | 32 | { "Options", NULL, edit_menu, 0, NULL }, | 33 | { "&Help", NULL, help_menu, 0, NULL }, | 34 | { NULL, NULL, NULL, 0, NULL } | 35 | }; | 36 | | 37 | DIALOG game_dialog[] = | 38 | { | 39 | /* (dialog proc) (x) (y) (w) (h) (fg)(bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ | 40 | { d_menu_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, game_menu, NULL, NULL }, | 41 | { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } | 42 | }; | 43 | | 44 | | 45 | int main(int argc, char *argv[]) | 46 | { | 47 | if (allegro_init() != 0) | 48 | { | 49 | allegro_message("Unable to start allegro. :("); | 50 | return 1; | 51 | } | 52 | | 53 | if (install_keyboard() != 0) | 54 | { | 55 | allegro_message("Unable to install keyboard driver. :("); | 56 | return 1; | 57 | } | 58 | | 59 | if (install_mouse() == -1) | 60 | { | 61 | allegro_message("Unable to install mouse driver. :("); | 62 | return 1; | 63 | } | 64 | | 65 | if (install_timer() != 0) | 66 | { | 67 | allegro_message("Unable to install interupt timers. :("); | 68 | return 1; | 69 | } | 70 | | 71 | if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0) != 0) | 72 | { | 73 | if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) | 74 | { | 75 | allegro_message("Unable to setup a gfx mode: \"%s\". :(", allegro_error); | 76 | return 1; | 77 | } | 78 | } | 79 | | 80 | gui_fg_color = makecol(255,255,255); | 81 | gui_bg_color = makecol(128,128,128); | 82 | | 83 | game_dialog[0].w = SCREEN_W; | 84 | | 85 | do_dialog(game_dialog, -1); | 86 | | 87 | set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); | 88 | } | 89 | END_OF_MAIN(); |
I will have a look at the allegro source and see if I can fix it, not sure of my chances though. Edit: I couldn't get 4.3 to build with mingw, so I had a ubuntu live cd floating about (6.2 edgy), getting allegro to build was painful, but after I got the right packages, I got it to compile. The patch is for the latest 4.3 svn WiP, I named it gui.c.patch (it is also attached to this message) --- gui.c 2007-04-21 23:18:52.609959750 +0000
+++ cgui.c 2007-04-21 23:20:22.235561000 +0000
@@ -1538,6 +1538,7 @@ static void draw_menu(MENU_PLAYER *m)
gui_menu_draw_menu(m->x, m->y, m->w, m->h);
else {
BITMAP *gui_bmp = gui_get_screen();
+ rectfill(gui_bmp, m->x, m->y, m->x+m->w-2, m->y+m->h-2, gui_bg_color);
rect(gui_bmp, m->x, m->y, m->x+m->w-2, m->y+m->h-2, gui_fg_color);
vline(gui_bmp, m->x+m->w-1, m->y+1, m->y+m->h-1, gui_fg_color);
hline(gui_bmp, m->x+1, m->y+m->h-1, m->x+m->w-1, gui_fg_color);
This solved the problem, by 'rectfill'ing the area, before the outline is drawn.  I guess I should probably send this to the developers mailing list. Edit: Yep the patch for 4.2 will be the same, as the code is identical.
____________________________________________________________________________________________ "c is much better than c++ if you don't need OOP simply because it's smaller and requires less load time." - alethiophile OMG my sides are hurting from laughing so hard... :D
|