From d47e40b7cb18b1edb037a14010ee764605e1c596 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 24 Jul 2009 08:34:20 +0000 Subject: [PATCH] Fix crashing bug when using pipette on a software-zoomed video mode from the palette menu. Fixes issue 196. Warning! Version 2.0 needs a new build! git-svn-id: svn://pulkomandy.tk/GrafX2/branches/release@951 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- engine.c | 178 +++++++++++++++++++++++++------------------------------ 1 file changed, 82 insertions(+), 96 deletions(-) diff --git a/engine.c b/engine.c index 24c71e0e..7d371f10 100644 --- a/engine.c +++ b/engine.c @@ -1835,109 +1835,95 @@ short Wait_click_in_palette(T_Palette_button * button) // -------------- Récupération d'une couleur derrière un menu ---------------- void Get_color_behind_window(byte * color, byte * click) { - short width=Window_width*Menu_factor_X; - short height=Window_height*Menu_factor_Y; short old_x=-1; short old_y=-1; short index; short a,b,c,d; // Variables temporaires et multitâches... - byte * buffer; + byte * buffer = NULL; char str[25]; byte cursor_was_hidden; + Hide_cursor(); - if ((buffer=(byte *) malloc(width*height))) + cursor_was_hidden=Cursor_hidden; + Cursor_hidden=0; + + Save_background(&buffer,Window_pos_X,Window_pos_Y,Window_width,Window_height); + a=Menu_Y; + Menu_Y=Menu_Y_before_window; + b=Menu_is_visible; + Menu_is_visible=Menu_is_visible_before_window; + Display_all_screen(); + Display_menu(); + Menu_Y=a; + Menu_is_visible=b; + + Cursor_shape=CURSOR_SHAPE_COLORPICKER; + b=Paintbrush_hidden; + Paintbrush_hidden=1; + c=-1; // color pointée: au début aucune, comme ça on initialise tout + if (Menu_is_visible_before_window) + Print_in_menu(Menu_tooltip[BUTTON_CHOOSE_COL],0); + + Display_cursor(); + + do { - Hide_cursor(); + if(!Get_input())SDL_Delay(20); - cursor_was_hidden=Cursor_hidden; - Cursor_hidden=0; + if ((Mouse_X!=old_x) || (Mouse_Y!=old_y)) + { + Hide_cursor(); + a=Read_pixel(Mouse_X,Mouse_Y); + if (a!=c) + { + c=a; // Mise à jour de la couleur pointée + if (Menu_is_visible_before_window) + { + sprintf(str,"%d",a); + d=strlen(str); + strcat(str," ("); + sprintf(str+strlen(str),"%d",Main_palette[a].R); + strcat(str,","); + sprintf(str+strlen(str),"%d",Main_palette[a].G); + strcat(str,","); + sprintf(str+strlen(str),"%d",Main_palette[a].B); + strcat(str,")"); + a=24-d; + for (index=strlen(str); index