Lua: added a message box. messagebox('message'), or messagebox('caption','message'). note that Lua supports concatenation (operator ..) and this function accepts backslash-n for carriage return. It performs word-wrapping if needed. Fixed the Hourglass cursor showing up in some error boxes, instead of the arrow cursor.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1340 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
683f8c6a18
commit
917847cdab
27
factory.c
27
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);
|
||||
|
||||
@ -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,6 +1123,8 @@ 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);
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user