mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
sdlayer: Clean up wm_msgbox and wm_ynbox and fix them under GTK. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@5976 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
346f391d4a
commit
b107d3e0de
5 changed files with 63 additions and 91 deletions
|
@ -7,8 +7,8 @@ extern "C" {
|
|||
|
||||
extern void gtkbuild_init(int32_t *argc, char ***argv);
|
||||
extern void gtkbuild_exit(int32_t r);
|
||||
extern int32_t gtkbuild_msgbox(const char *name, const char *msg);
|
||||
extern int32_t gtkbuild_ynbox(const char *name, const char *msg);
|
||||
extern int gtkbuild_msgbox(const char *name, const char *msg);
|
||||
extern int gtkbuild_ynbox(const char *name, const char *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t osx_msgbox(const char *name, const char *msg);
|
||||
int32_t osx_ynbox(const char *name, const char *msg);
|
||||
int osx_msgbox(const char *name, const char *msg);
|
||||
int osx_ynbox(const char *name, const char *msg);
|
||||
|
||||
char *osx_gethomedir(void);
|
||||
char *osx_getsupportdir(int32_t local);
|
||||
|
|
|
@ -16,7 +16,7 @@ int32_t gtkenabled = 0;
|
|||
|
||||
static GdkPixbuf *appicon = NULL;
|
||||
|
||||
int32_t gtkbuild_msgbox(const char *name, const char *msg)
|
||||
int gtkbuild_msgbox(const char *name, const char *msg)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
|
@ -34,7 +34,7 @@ int32_t gtkbuild_msgbox(const char *name, const char *msg)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int32_t gtkbuild_ynbox(const char *name, const char *msg)
|
||||
int gtkbuild_ynbox(const char *name, const char *msg)
|
||||
{
|
||||
int32_t r;
|
||||
GtkWidget *dialog;
|
||||
|
|
|
@ -170,39 +170,39 @@ int32_t wm_msgbox(const char *name, const char *fmt, ...)
|
|||
|
||||
#if defined EDUKE32_OSX
|
||||
return osx_msgbox(name, buf);
|
||||
#elif defined HAVE_GTK2
|
||||
if (gtkbuild_msgbox(name, buf) >= 0) return 1;
|
||||
#elif defined _WIN32
|
||||
MessageBox(win_gethwnd(),buf,name,MB_OK|MB_TASKMODAL);
|
||||
return 0;
|
||||
#elif defined EDUKE32_TOUCH_DEVICES
|
||||
initprintf("wm_msgbox called. Message: %s: %s",name,buf);
|
||||
return 0;
|
||||
#elif SDL_MAJOR_VERSION==2
|
||||
# if !defined _WIN32
|
||||
// Replace all tab chars with spaces because the hand-rolled SDL message
|
||||
// box diplays the former as N/L instead of whitespace.
|
||||
{
|
||||
size_t i;
|
||||
for (i=0; i<sizeof(buf); i++)
|
||||
if (buf[i] == '\t')
|
||||
buf[i] = ' ';
|
||||
}
|
||||
# endif
|
||||
return SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, name, buf, NULL);
|
||||
#elif defined GEKKO
|
||||
puts(buf);
|
||||
return 0;
|
||||
#else
|
||||
# if defined HAVE_GTK2
|
||||
if (gtkbuild_msgbox(name, buf) >= 0)
|
||||
return 0;
|
||||
# endif
|
||||
# if SDL_MAJOR_VERSION > 1
|
||||
# if !defined _WIN32
|
||||
// Replace all tab chars with spaces because the hand-rolled SDL message
|
||||
// box diplays the former as N/L instead of whitespace.
|
||||
for (size_t i=0; i<sizeof(buf); i++)
|
||||
if (buf[i] == '\t')
|
||||
buf[i] = ' ';
|
||||
# endif
|
||||
return SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, name, buf, NULL);
|
||||
# else
|
||||
puts(buf);
|
||||
puts(" (press Return or Enter to continue)");
|
||||
getchar();
|
||||
|
||||
return 0;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SDL_MAJOR_VERSION != 1
|
||||
int32_t wm_ynbox(const char *name, const char *fmt, ...)
|
||||
{
|
||||
char buf[2048];
|
||||
|
@ -211,56 +211,65 @@ int32_t wm_ynbox(const char *name, const char *fmt, ...)
|
|||
UNREFERENCED_PARAMETER(name);
|
||||
|
||||
va_start(va,fmt);
|
||||
vsprintf(buf,fmt,va);
|
||||
vsnprintf(buf,sizeof(buf),fmt,va);
|
||||
va_end(va);
|
||||
|
||||
#if defined EDUKE32_OSX
|
||||
return osx_ynbox(name, buf);
|
||||
#elif defined HAVE_GTK2
|
||||
{
|
||||
int32_t r = gtkbuild_ynbox(name, buf);
|
||||
|
||||
return r >= 0 ? r : 0;
|
||||
}
|
||||
#elif defined _WIN32
|
||||
return (MessageBox(win_gethwnd(),buf,name,MB_YESNO|MB_ICONQUESTION|MB_TASKMODAL) == IDYES);
|
||||
#elif defined EDUKE32_TOUCH_DEVICES
|
||||
initprintf("wm_ynbox called, this is bad! Message: %s: %s",name,buf);
|
||||
initprintf("Returning false..");
|
||||
return 0;
|
||||
#elif defined GEKKO
|
||||
puts(buf);
|
||||
puts("Assuming yes...");
|
||||
return 1;
|
||||
#else
|
||||
{
|
||||
int32_t r = -1;
|
||||
# if defined HAVE_GTK2
|
||||
int ret = gtkbuild_ynbox(name, buf);
|
||||
if (ret >= 0)
|
||||
return ret;
|
||||
# endif
|
||||
# if SDL_MAJOR_VERSION > 1
|
||||
int r = -1;
|
||||
|
||||
const SDL_MessageBoxButtonData buttons[] = {
|
||||
{
|
||||
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT,
|
||||
0,
|
||||
"No"
|
||||
},{
|
||||
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT,
|
||||
1,
|
||||
"Yes"
|
||||
},
|
||||
};
|
||||
const SDL_MessageBoxButtonData buttons[] = {
|
||||
{
|
||||
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT,
|
||||
0,
|
||||
"No"
|
||||
},{
|
||||
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT,
|
||||
1,
|
||||
"Yes"
|
||||
},
|
||||
};
|
||||
|
||||
SDL_MessageBoxData data = {
|
||||
SDL_MESSAGEBOX_INFORMATION,
|
||||
NULL, /* no parent window */
|
||||
name,
|
||||
buf,
|
||||
2,
|
||||
buttons,
|
||||
NULL /* Default color scheme */
|
||||
};
|
||||
SDL_MessageBoxData data = {
|
||||
SDL_MESSAGEBOX_INFORMATION,
|
||||
NULL, /* no parent window */
|
||||
name,
|
||||
buf,
|
||||
2,
|
||||
buttons,
|
||||
NULL /* Default color scheme */
|
||||
};
|
||||
|
||||
SDL_ShowMessageBox(&data, &r);
|
||||
SDL_ShowMessageBox(&data, &r);
|
||||
|
||||
return r;
|
||||
}
|
||||
return r;
|
||||
# else
|
||||
char c;
|
||||
|
||||
puts(buf);
|
||||
puts(" (type 'Y' or 'N', and press Return or Enter to continue)");
|
||||
do c = getchar(); while (c != 'Y' && c != 'y' && c != 'N' && c != 'n');
|
||||
return c == 'Y' || c == 'y';
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void wm_setapptitle(const char *name)
|
||||
{
|
||||
|
|
|
@ -2,43 +2,6 @@
|
|||
|
||||
#include <SDL/SDL_events.h>
|
||||
|
||||
int32_t wm_ynbox(const char *name, const char *fmt, ...)
|
||||
{
|
||||
char buf[2048];
|
||||
char c;
|
||||
va_list va;
|
||||
|
||||
UNREFERENCED_PARAMETER(name);
|
||||
|
||||
va_start(va, fmt);
|
||||
vsprintf(buf, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
#if defined __APPLE__
|
||||
return osx_ynbox(name, buf);
|
||||
#elif defined HAVE_GTK2
|
||||
{
|
||||
int32_t r = gtkbuild_ynbox(name, buf);
|
||||
if (r >= 0)
|
||||
return r;
|
||||
}
|
||||
#elif defined _WIN32
|
||||
return (MessageBox(win_gethwnd(),buf,name,MB_YESNO|MB_ICONQUESTION|MB_TASKMODAL) == IDYES);
|
||||
#elif defined GEKKO
|
||||
puts(buf);
|
||||
puts("Assuming yes...");
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
// NOTE: this is dead code for most #ifdef cases above.
|
||||
puts(buf);
|
||||
puts(" (type 'Y' or 'N', and press Return or Enter to continue)");
|
||||
do c = getchar(); while (c != 'Y' && c != 'y' && c != 'N' && c != 'n');
|
||||
if (c == 'Y' || c == 'y') return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
HWND win_gethwnd(void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue