From 69c2342c24b734fcbcd7c5ab2acfb2b3837f5c5a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 25 Nov 2000 21:10:50 +0100 Subject: [PATCH] rnd-20001125-4-src --- src/events.c | 12 +----- src/main.h | 2 +- src/msdos.h | 2 +- src/sdl.h | 2 +- src/system.c | 112 +++++++++++++++++++++++++++++++++------------------ src/system.h | 16 +++----- src/x11.h | 6 +-- 7 files changed, 84 insertions(+), 68 deletions(-) diff --git a/src/events.c b/src/events.c index 8d6cd621..da828b58 100644 --- a/src/events.c +++ b/src/events.c @@ -326,15 +326,8 @@ void HandleFocusEvent(FocusChangeEvent *event) void HandleClientMessageEvent(ClientMessageEvent *event) { -#ifdef TARGET_SDL - CloseAllAndExit(0); /* the only possible message here is SDL_QUIT */ -#else -#ifndef MSDOS - if ((event->window == window) && - (event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE))) + if (CheckCloseWindowEvent(event)) CloseAllAndExit(0); -#endif -#endif } void HandleButton(int mx, int my, int button) @@ -702,10 +695,7 @@ void HandleKey(Key key, int key_status) printf("ScrollStepSize == %d (1/1)\n", ScrollStepSize); break; -#ifndef MSDOS case KEY_Q: -#endif - case KEY_q: local_player->dynamite = 1000; break; diff --git a/src/main.h b/src/main.h index 24066a73..d38f529c 100644 --- a/src/main.h +++ b/src/main.h @@ -1656,7 +1656,7 @@ extern int num_element_info; #define PROGRAM_AUTHOR_STRING "Holger Schemel" #define PROGRAM_RIGHTS_STRING "Copyright ^1995-2000 by" #define PROGRAM_DOS_PORT_STRING "DOS port done by Guido Schulz" -#define PROGRAM_IDENT_STRING PROGRAM_VERSION_STRING " " PLATFORM_STRING +#define PROGRAM_IDENT_STRING PROGRAM_VERSION_STRING " " TARGET_STRING #define WINDOW_TITLE_STRING PROGRAM_TITLE_STRING " " PROGRAM_IDENT_STRING #define WINDOW_SUBTITLE_STRING PROGRAM_RIGHTS_STRING " " PROGRAM_AUTHOR_STRING diff --git a/src/msdos.h b/src/msdos.h index 111fabe6..9e93109d 100644 --- a/src/msdos.h +++ b/src/msdos.h @@ -21,7 +21,7 @@ /* system dependent definitions */ -#define PLATFORM_STRING "DOS" +#define TARGET_STRING "DOS" /* allegro defines TRUE as -1 */ #ifdef TRUE diff --git a/src/sdl.h b/src/sdl.h index 4d48f3d2..68007d76 100644 --- a/src/sdl.h +++ b/src/sdl.h @@ -34,7 +34,7 @@ /* system dependent definitions */ -#define PLATFORM_STRING "SDL" +#define TARGET_STRING "SDL" #define FULLSCREEN_STATUS FULLSCREEN_AVAILABLE diff --git a/src/system.c b/src/system.c index 08c2eb5d..54870c81 100644 --- a/src/system.c +++ b/src/system.c @@ -15,13 +15,10 @@ #include "main.h" #include "misc.h" -inline void InitEventFilter(EventFilter filter_function) -{ -#ifdef TARGET_SDL - /* set event filter to filter out certain events */ - SDL_SetEventFilter(filter_function); -#endif -} + +/* ========================================================================= */ +/* video functions */ +/* ========================================================================= */ inline void InitBufferedDisplay(DrawBuffer *backbuffer, DrawWindow *window) { @@ -201,6 +198,63 @@ inline boolean PointerInWindow(DrawWindow window) #endif } +inline boolean SetVideoMode(void) +{ +#ifdef TARGET_SDL + return SDLSetVideoMode(&backbuffer); +#else + boolean success = TRUE; + + if (setup.fullscreen && fullscreen_available) + { + Error(ERR_WARN, "fullscreen not available in X11 version"); + + /* display error message only once */ + fullscreen_available = FALSE; + + success = FALSE; + } + + return success; +#endif +} + +inline void ChangeVideoModeIfNeeded(void) +{ +#ifdef TARGET_SDL + if ((setup.fullscreen && !fullscreen_enabled && fullscreen_available) || + (!setup.fullscreen && fullscreen_enabled)) + SetVideoMode(); +#endif +} + + +/* ========================================================================= */ +/* audio functions */ +/* ========================================================================= */ + +inline boolean InitAudio(void) +{ +#ifdef TARGET_SDL + return SDLInitAudio(); +#else + return TRUE; +#endif +} + + +/* ========================================================================= */ +/* event functions */ +/* ========================================================================= */ + +inline void InitEventFilter(EventFilter filter_function) +{ +#ifdef TARGET_SDL + /* set event filter to filter out certain events */ + SDL_SetEventFilter(filter_function); +#endif +} + inline boolean PendingEvent(void) { #ifdef TARGET_SDL @@ -247,44 +301,22 @@ inline Key GetEventKey(KeyEvent *event, boolean with_modifiers) #endif } -inline boolean SetVideoMode(void) +inline boolean CheckCloseWindowEvent(ClientMessageEvent *event) { -#ifdef TARGET_SDL - return SDLSetVideoMode(&backbuffer); -#else - boolean success = TRUE; - - if (setup.fullscreen && fullscreen_available) - { - Error(ERR_WARN, "fullscreen not available in X11 version"); - - /* display error message only once */ - fullscreen_available = FALSE; - - success = FALSE; - } - - return success; + if (event->type != EVENT_CLIENTMESSAGE) + return FALSE; + +#if defined(TARGET_SDL) + return TRUE; /* the only possible message here is SDL_QUIT */ +#elif defined(PLATFORM_UNIX) + if ((event->window == window) && + (event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE))) + return TRUE; #endif -} -inline void ChangeVideoModeIfNeeded(void) -{ -#ifdef TARGET_SDL - if ((setup.fullscreen && !fullscreen_enabled && fullscreen_available) || - (!setup.fullscreen && fullscreen_enabled)) - SetVideoMode(); -#endif + return FALSE; } -inline boolean InitAudio(void) -{ -#ifdef TARGET_SDL - return SDLInitAudio(); -#else - return TRUE; -#endif -} inline void dummy(void) { diff --git a/src/system.h b/src/system.h index 1c3b8e20..f7cb3984 100644 --- a/src/system.h +++ b/src/system.h @@ -49,35 +49,29 @@ typedef int (*EventFilter)(const Event *); /* system-wide function definitions */ -inline void InitEventFilter(EventFilter); inline void InitBufferedDisplay(DrawBuffer *, DrawWindow *); - inline int GetDisplayDepth(void); - inline Bitmap CreateBitmap(int, int, int); inline void FreeBitmap(Bitmap); - inline void ClearRectangle(Bitmap, int, int, int, int); inline void BlitBitmap(Bitmap, Bitmap, int, int, int, int, int, int); inline void SetClipMask(GC, Pixmap); inline void SetClipOrigin(GC, int, int); inline void BlitBitmapMasked(Bitmap, Bitmap, int, int, int, int, int, int); inline void DrawSimpleWhiteLine(Bitmap, int, int, int, int); - inline void FlushDisplay(void); inline void SyncDisplay(void); inline void KeyboardAutoRepeatOn(void); inline void KeyboardAutoRepeatOff(void); inline boolean PointerInWindow(DrawWindow); - -inline boolean PendingEvent(void); -inline void NextEvent(Event *event); - -inline Key GetEventKey(KeyEvent *, boolean); - inline boolean SetVideoMode(void); inline void ChangeVideoModeIfNeeded(void); inline boolean InitAudio(void); +inline void InitEventFilter(EventFilter); +inline boolean PendingEvent(void); +inline void NextEvent(Event *event); +inline Key GetEventKey(KeyEvent *, boolean); + #endif /* SYSTEM_H */ diff --git a/src/x11.h b/src/x11.h index 767ae272..47c8b4f1 100644 --- a/src/x11.h +++ b/src/x11.h @@ -30,9 +30,9 @@ /* system dependent definitions */ -/* DOS version has already defined "PLATFORM_STRING" */ -#ifndef PLATFORM_STRING -#define PLATFORM_STRING "X11" +/* DOS version also defines "TARGET_STRING" */ +#ifndef TARGET_STRING +#define TARGET_STRING "X11" #endif #define FULLSCREEN_STATUS FULLSCREEN_NOT_AVAILABLE -- 2.34.1