From a055a9a51e19273c6b0bc42fc09f0fd828c0f2bd Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 17 Nov 2009 21:07:03 +0000 Subject: [PATCH] Fix buggy drawing in menu when using shortcuts. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1211 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- engine.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/engine.c b/engine.c index 6b4d5125..4357d272 100644 --- a/engine.c +++ b/engine.c @@ -208,7 +208,7 @@ int Button_under_mouse(void) } #define Pixel_in_skinmenu(x,y,color) Menu_bars[current_menu].Skin[(y - y_off)*Menu_bars[current_menu].Skin_width + x] = color -#define Pixel_in_menu_and_skin(x,y,color) Pixel_in_skinmenu(x,y,color); Pixel_in_menu(x,y,color) +#define Pixel_in_menu_and_skin(x,y,color) Pixel_in_skinmenu(x,y,color); if(visible) Pixel_in_menu(x,y,color) ///Draw the frame for a menu button void Draw_menu_button_frame(byte btn_number,byte pressed) @@ -223,6 +223,7 @@ void Draw_menu_button_frame(byte btn_number,byte pressed) word x_pos; word y_pos; byte current_menu; + byte visible; word y_off = 0; // Find in which menu the button is @@ -231,8 +232,18 @@ void Draw_menu_button_frame(byte btn_number,byte pressed) if(Menu_bars[current_menu].Visible) { y_off += Menu_bars[current_menu].Height; - if (Menu_bars[current_menu].Last_button_index >= btn_number) + // We found the right bar ! + if (Menu_bars[current_menu].Last_button_index >= btn_number && (current_menu==0 || Menu_bars[current_menu -1].Last_button_index < btn_number)) + { + visible = 1; break; + } else + // We missed the bar, it's hidden ! But we still need to draw in the skin... + if (Menu_bars[current_menu].Last_button_index > btn_number) + { + current_menu--; // We can't enter the if with current_menu=0, so that's ok. + break; + } } }