From dae1bc856bade97e0af2ef468b7cd1dc8eec75a8 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Sat, 26 Nov 2011 14:46:09 +0000 Subject: [PATCH] Tilemap mode: Undo and Redo only refresh tilemap when image size changes. Lua scripts that change image size also refresh tilemap git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1877 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/buttons.c | 2 -- src/factory.c | 12 ++++++++++++ src/pages.c | 13 ++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/buttons.c b/src/buttons.c index 5f5789df..011accd7 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -211,7 +211,6 @@ void Button_Undo(void) { Hide_cursor(); Undo(); - Tilemap_update(); Set_palette(Main_palette); Compute_optimal_menu_colors(Main_palette); @@ -226,7 +225,6 @@ void Button_Redo(void) { Hide_cursor(); Redo(); - Tilemap_update(); Set_palette(Main_palette); Compute_optimal_menu_colors(Main_palette); diff --git a/src/factory.c b/src/factory.c index 42b9fdd4..80757f7f 100644 --- a/src/factory.c +++ b/src/factory.c @@ -46,6 +46,8 @@ #include "filesel.h" // Read_list_of_drives() #include "realpath.h" #include "setup.h" +#include "tiles.h" + /// Lua scripts bound to shortcut keys. char * Bound_script[10]; @@ -1559,6 +1561,8 @@ void Run_script(const char *script_subdirectory, const char *script_filename) const char* message; byte old_cursor_shape=Cursor_shape; char buf[MAX_PATH_CHARACTERS]; + int original_image_width=Main_image_width; + int original_image_height=Main_image_height; // Some scripts are slow Cursor_shape=CURSOR_SHAPE_HOURGLASS; @@ -1728,6 +1732,14 @@ void Run_script(const char *script_subdirectory, const char *script_filename) Hide_cursor(); Display_all_screen(); + + // Update tilemap if image size has changed + if (original_image_width!=Main_image_width + || original_image_height!=Main_image_height) + { + Tilemap_update(); + } + // Update changed pen colors. if (Back_color!=Original_back_color || Fore_color!=Original_fore_color) { diff --git a/src/pages.c b/src/pages.c index 79a5794a..1466163c 100644 --- a/src/pages.c +++ b/src/pages.c @@ -33,6 +33,7 @@ #include "loadsave.h" #include "misc.h" #include "windows.h" +#include "tiles.h" // -- Layers data @@ -1155,6 +1156,9 @@ void Check_layers_limits() void Undo(void) { + int width = Main_image_width; + int height = Main_image_height; + if (Last_backed_up_layers) { Free_page_of_a_list(Main_backups); @@ -1179,11 +1183,16 @@ void Undo(void) Check_layers_limits(); Redraw_layered_image(); End_of_modification(); - + + if (width != Main_image_width || height != Main_image_height) + Tilemap_update(); } void Redo(void) { + int width = Main_image_width; + int height = Main_image_height; + if (Last_backed_up_layers) { Free_page_of_a_list(Main_backups); @@ -1208,6 +1217,8 @@ void Redo(void) Redraw_layered_image(); End_of_modification(); + if (width != Main_image_width || height != Main_image_height) + Tilemap_update(); } void Free_current_page(void)