From a61bb9893c7fc7f0cfb7d6cb9d71a5d8c5d4129e Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Thu, 2 Sep 2010 00:06:57 +0000 Subject: [PATCH] Gradient menu: palette now resets when you release speed slider, this fixes bad menu colors when they are in the shift. Lua: messagebox() and inputbox() now recompute menu colors before opening, this fixes bad menu colors if the script had altered the palette earlier. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1602 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/buttons.c | 4 ++++ src/factory.c | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/buttons.c b/src/buttons.c index 65f76a1f..eb1d6d1e 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -2607,7 +2607,11 @@ void Button_Gradients(void) clicked_button=Window_clicked_button(); if (Input_sticky_control!=8 || !Mouse_K) + { Allow_colorcycling=0; + // Restore palette + Set_palette(Main_palette); + } switch(clicked_button) { diff --git a/src/factory.c b/src/factory.c index c0db6871..9eafbf28 100644 --- a/src/factory.c +++ b/src/factory.c @@ -121,7 +121,17 @@ do { \ return luaL_error(L, "%s: Expected %d arguments, but found %d.", func_name, (num), nb_args); \ } while(0) - +// Updates the screen colors after a running screen has modified the palette. +void Update_colors_during_script(void) +{ + if (Palette_has_changed) + { + Set_palette(Main_palette); + Compute_optimal_menu_colors(Main_palette); + Display_menu(); + Palette_has_changed=0; + } +} // Wrapper functions to call C from Lua @@ -598,6 +608,7 @@ int L_InputBox(lua_State* L) if (max_label_length>25) max_label_length=25; + Update_colors_during_script(); Open_window(115+max_label_length*8,44+nb_settings*17,window_caption); // Normally this index is unused, but this initialization avoids @@ -795,6 +806,7 @@ int L_MessageBox(lua_State* L) return luaL_error(L, "messagebox: Needs one or two arguments."); } + Update_colors_during_script(); Verbose_message(caption, message); return 0; } @@ -1042,6 +1054,9 @@ void Run_script(char *scriptdir) { int stack_size; stack_size= lua_gettop(L); + + Update_colors_during_script(); + if (stack_size>0 && (message = lua_tostring(L, stack_size))!=NULL) Verbose_message("Error running script", message); else @@ -1051,12 +1066,7 @@ void Run_script(char *scriptdir) // Cleanup free(Brush_backup); Brush_backup=NULL; - if (Palette_has_changed) - { - Set_palette(Main_palette); - Compute_optimal_menu_colors(Main_palette); - Display_menu(); - } + Update_colors_during_script(); End_of_modification(); lua_close(L);