diff --git a/factory.c b/factory.c index 6688a41b..46c1f21e 100644 --- a/factory.c +++ b/factory.c @@ -569,6 +569,32 @@ int L_InputBox(lua_State* L) return 1 + nb_settings; } +int L_MessageBox(lua_State* L) +{ + int nb_args = lua_gettop (L); + const char * caption; + const char * message; + + if (nb_args == 1) + { + caption = "Script message"; + message = lua_tostring(L,1); + } + else if (nb_args == 2) + { + caption = lua_tostring(L,1); + message = lua_tostring(L,2); + } + else + { + return luaL_error(L, "MessageBox: Needs one or two arguments."); + } + + Verbose_message(caption, message); + return 0; +} + + // Handlers for window internals T_Fileselector Scripts_list; @@ -758,6 +784,7 @@ void Button_Brush_Factory(void) lua_register(L,"matchcolor",L_MatchColor); lua_register(L,"getbrushtransparentcolor",L_GetBrushTransparentColor); lua_register(L,"inputbox",L_InputBox); + lua_register(L,"messagebox",L_MessageBox); lua_register(L,"getforecolor",L_GetForeColor); lua_register(L,"getbackcolor",L_GetBackColor); lua_register(L,"gettranscolor",L_GetTransColor); diff --git a/windows.c b/windows.c index c240a83e..ff8a9738 100644 --- a/windows.c +++ b/windows.c @@ -1113,7 +1113,9 @@ void Warning_message(char * message) Display_cursor(); } -/// Window that shows a big message (up to 34x12), and waits for a click on OK +/// Window that shows a big message (up to 34x12), and waits for a click on OK. +/// On call: Cursor must be displayed +/// On exit: Cursor is displayed void Verbose_message(const char *caption, const char * message ) { short clicked_button; @@ -1121,7 +1123,9 @@ void Verbose_message(const char *caption, const char * message ) int last_space; int nb_char; char buffer[36]; + byte original_cursor_shape = Cursor_shape; + Open_window(300,160,caption); // Word-wrap the message @@ -1160,6 +1164,7 @@ void Verbose_message(const char *caption, const char * message ) Window_set_normal_button(300/2-20,160-23,40,14,"OK",1,1,SDLK_RETURN); // 1 Update_window_area(0,0,Window_width,Window_height); + Cursor_shape=CURSOR_SHAPE_ARROW; Display_cursor(); do @@ -1168,6 +1173,7 @@ void Verbose_message(const char *caption, const char * message ) Key=0; Close_window(); + Cursor_shape=original_cursor_shape; Display_cursor(); }