diff --git a/buttons.c b/buttons.c index b368f470..170fc4e0 100644 --- a/buttons.c +++ b/buttons.c @@ -3613,6 +3613,13 @@ void Button_Grid_menu(void) Display_cursor(); } +void Button_Show_grid(void) +{ + Show_grid = !Show_grid; + Hide_cursor(); + Display_all_screen(); + Display_cursor(); +} // ----------------------- Modifications de brosse --------------------------- diff --git a/buttons.h b/buttons.h index a75b38de..65db64a1 100644 --- a/buttons.h +++ b/buttons.h @@ -353,6 +353,11 @@ void Button_Snap_mode(void); */ void Button_Grid_menu(void); +/*! + Callback to toggle the grid visible in the magnified view. +*/ +void Button_Show_grid(void); + // Mode trame (Sieve) /*! diff --git a/const.h b/const.h index 9b3b1596..ff6d5483 100644 --- a/const.h +++ b/const.h @@ -33,7 +33,7 @@ #define BETA1 98 ///< Version number for gfx2.cfg (3/4) #define BETA2 0 ///< Version number for gfx2.cfg (4/4) #define MAX_VIDEO_MODES 100 ///< Maximum number of video modes Grafx2 can propose. -#define NB_SHORTCUTS 158 ///< Number of actions that can have a key combination associated to it. +#define NB_SHORTCUTS 159 ///< Number of actions that can have a key combination associated to it. #define NB_ZOOM_FACTORS 12 ///< Number of zoom levels available in the magnifier. #define MENU_WIDTH 254 ///< Width of the menu (not counting the palette) #define MENU_HEIGHT 44 ///< Height of the menu. @@ -406,6 +406,7 @@ enum SPECIAL_ACTIONS SPECIAL_ZOOM_16, SPECIAL_ZOOM_18, SPECIAL_ZOOM_20, + SPECIAL_SHOW_GRID, NB_SPECIAL_SHORTCUTS ///< Number of special shortcuts }; diff --git a/engine.c b/engine.c index f4f104ab..20223d15 100644 --- a/engine.c +++ b/engine.c @@ -825,6 +825,10 @@ void Main_handler(void) Button_Grid_menu(); Key=0; break; + case SPECIAL_SHOW_GRID : + Button_Show_grid(); + Key=0; + break; case SPECIAL_SIEVE_MODE : Button_Sieve_mode(); Key=0; diff --git a/gfx2def.ini b/gfx2def.ini index 38b5d657..7fdc4d94 100644 --- a/gfx2def.ini +++ b/gfx2def.ini @@ -328,5 +328,16 @@ ; want to use. | 8x8 utilisée dans les menus. ; Default : (empty to let the program choose) Font_file = + + ; This determines the color value for the grid. Each pixel of + ; the grid will be displayed by XOR-ing the original color with + ; the value of this setting. + ; For example, if you always paint 16-color images, you can set it + ; to 16 so the color of the grid are 16 for 0, 17 for 1, etc. + ; Then you can set colors 16-31 as lighter/darker variants + ; of your original palette, resulting in a pretty grid ! + ; + ; Valid values are 1 to 255. + Grid_XOR_color = 255; (Default 255) ; end of configuration diff --git a/global.h b/global.h index 92395130..371f198e 100644 --- a/global.h +++ b/global.h @@ -138,7 +138,7 @@ GFX2_GLOBAL byte Cursor_in_menu; /// Boolean, means the cursor was hovering over a menu GUI element. GFX2_GLOBAL byte Cursor_in_menu_previous; /// Storage for the graphics under the mouse cursor. Used by ::Hide_cursor and ::Display_cursor -GFX2_GLOBAL byte CURSOR_BACKGROUND[CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH]; +GFX2_GLOBAL byte Cursor_background[CURSOR_SPRITE_HEIGHT][CURSOR_SPRITE_WIDTH]; // -- Paintbrush data @@ -645,6 +645,8 @@ GFX2_GLOBAL byte Stencil[256]; /// Boolean, true when the Grid mode is active. GFX2_GLOBAL byte Snap_mode; +/// Boolean, true when the Grid is displayed in zoomed view. +GFX2_GLOBAL byte Show_grid; /// Width of the grid in Grid mode. GFX2_GLOBAL word Snap_width; /// Height of the grid in Grid mode. diff --git a/graph.c b/graph.c index 7be0f8fe..d6947b8c 100644 --- a/graph.c +++ b/graph.c @@ -107,6 +107,7 @@ void Update_part_of_screen(short x, short y, short width, short height) if(effective_Y + effective_h > Menu_Y) effective_h = Menu_Y - effective_Y; + /* SDL_Rect r; r.x=effective_X; @@ -136,7 +137,7 @@ void Update_part_of_screen(short x, short y, short width, short height) } else effective_X += Main_separator_position + SEPARATOR_WIDTH*Menu_factor_X; - diff = effective_X+effective_w-Screen_width; + diff = effective_X+effective_w-Min(Screen_width, Main_X_zoom+(Main_image_width-Main_magnifier_offset_X)*Main_magnifier_factor); if (diff>0) { effective_w -=diff; @@ -153,7 +154,7 @@ void Update_part_of_screen(short x, short y, short width, short height) return; effective_Y = 0; } - diff = effective_Y+effective_h-Menu_Y; + diff = effective_Y+effective_h-Min(Menu_Y, (Main_image_height-Main_magnifier_offset_Y)*Main_magnifier_factor); if (diff>0) { effective_h -=diff; @@ -161,6 +162,7 @@ void Update_part_of_screen(short x, short y, short width, short height) return; } + // Très utile pour le debug :) /*SDL_Rect r; r.x=effective_X; @@ -169,6 +171,7 @@ void Update_part_of_screen(short x, short y, short width, short height) r.w=effective_w; SDL_FillRect(Screen_SDL,&r,3);*/ + Redraw_grid(effective_X,effective_Y,effective_w,effective_h); Update_rect(effective_X,effective_Y,effective_w,effective_h); } } @@ -999,6 +1002,16 @@ void Fill_general(byte fill_color) // par l'utilisation de "Display_pixel()", et que les autres... eh bein // on n'y a jamais touché à l'écran les autres: ils sont donc corrects. + if(Main_magnifier_mode) + { + short w,h; + + w=Min(Screen_width-Main_X_zoom, (Main_image_width-Main_magnifier_offset_X)*Main_magnifier_factor); + h=Min(Menu_Y, (Main_image_height-Main_magnifier_offset_Y)*Main_magnifier_factor); + + Redraw_grid(Main_X_zoom,0,w,h); + } + Update_rect(0,0,0,0); End_of_modification(); } @@ -2803,3 +2816,41 @@ byte Effect_smooth(word x,word y,__attribute__((unused)) byte color) Read_pixel_from_current_screen(x,y); // C'est bien l'écran courant et pas // l'écran feedback car il s'agit de ne } // pas modifier l'écran courant. + +void Horizontal_grid_line(word x_pos,word y_pos,word width) +{ + int x; + + for (x=!(x_pos&1);xFont_file = strdup("font_Classic.png"); + conf->Grid_XOR_color=255; + // Optional, XOR color for grid overlay (>2.0) + if (!Load_INI_get_values (file,buffer,"Grid_XOR_color",1,values)) + { + if ((values[0]>0) || (values[0]<=255)) + conf->Grid_XOR_color=values[0]; + } + fclose(file); free(filename); diff --git a/saveini.c b/saveini.c index 3305e2e0..39a153b6 100644 --- a/saveini.c +++ b/saveini.c @@ -644,6 +644,10 @@ int Save_INI(T_Config * conf) if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Font_file",conf->Font_file))) goto Erreur_Retour; + + values[0]=(conf->Grid_XOR_color); + if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Grid_XOR_color",1,values,0))) + goto Erreur_Retour; Save_INI_flush(Ancien_fichier,Nouveau_fichier,buffer); diff --git a/struct.h b/struct.h index 80c30523..7ffed0b4 100644 --- a/struct.h +++ b/struct.h @@ -308,6 +308,7 @@ typedef struct int Window_pos_y; ///< Last window y position (9999 if unsupportd/irrelevant for the platform) word Double_click_speed; ///< Maximum delay for double-click, in ms. word Double_key_speed; ///< Maximum delay for double-keypress, in ms. + byte Grid_XOR_color; ///< XOR value to apply for grid color. } T_Config; // Structures utilisées pour les descriptions de pages et de liste de pages. diff --git a/windows.c b/windows.c index e84d5244..ef3a558d 100644 --- a/windows.c +++ b/windows.c @@ -1663,7 +1663,7 @@ void Display_cursor(void) { if( x_pos < 0 ) continue; color=Gfx->Cursor_sprite[temp][counter_y][counter_x]; - CURSOR_BACKGROUND[counter_y][counter_x]=Read_pixel(x_pos,y_pos); + Cursor_background[counter_y][counter_x]=Read_pixel(x_pos,y_pos); if (color!=MC_Trans) Pixel(x_pos,y_pos,color); } @@ -1733,8 +1733,8 @@ void Display_cursor(void) if(x_pos<0) continue; if(x_pos>=Screen_width) break; color=Gfx->Cursor_sprite[temp][counter_y][counter_x]; - // On sauvegarde dans CURSOR_BACKGROUND pour restaurer plus tard - CURSOR_BACKGROUND[counter_y][counter_x]=Read_pixel(x_pos,y_pos); + // On sauvegarde dans Cursor_background pour restaurer plus tard + Cursor_background[counter_y][counter_x]=Read_pixel(x_pos,y_pos); if (color!=MC_Trans) Pixel(x_pos,y_pos,color); } @@ -1762,8 +1762,8 @@ void Display_cursor(void) if(x_pos<0) continue; if(x_pos>=Screen_width) break; color=Gfx->Cursor_sprite[shape][counter_y][counter_x]; - // On sauvegarde dans CURSOR_BACKGROUND pour restaurer plus tard - CURSOR_BACKGROUND[counter_y][counter_x]=Read_pixel(x_pos,y_pos); + // On sauvegarde dans Cursor_background pour restaurer plus tard + Cursor_background[counter_y][counter_x]=Read_pixel(x_pos,y_pos); if (color!=MC_Trans) Pixel(x_pos,y_pos,color); } @@ -1966,7 +1966,7 @@ void Hide_cursor(void) { if(x_pos < 0) continue; else if (x_pos>=Screen_width) break; - Pixel(x_pos,y_pos,CURSOR_BACKGROUND[counter_y][counter_x]); + Pixel(x_pos,y_pos,Cursor_background[counter_y][counter_x]); } } @@ -2035,7 +2035,7 @@ void Hide_cursor(void) { if(x_pos<0) continue; if(x_pos>=Screen_width) break; - Pixel(x_pos,y_pos,CURSOR_BACKGROUND[counter_y][counter_x]); + Pixel(x_pos,y_pos,Cursor_background[counter_y][counter_x]); } } Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y); @@ -2063,7 +2063,7 @@ void Hide_cursor(void) { if(x_pos<0) continue; if(x_pos>=Screen_width) break; - Pixel(x_pos,y_pos,CURSOR_BACKGROUND[counter_y][counter_x]); + Pixel(x_pos,y_pos,Cursor_background[counter_y][counter_x]); } } Update_rect(Max(start_x,0),Max(start_y,0),counter_x,counter_y);