From e59a8e5e758978341d5410f09b705c4e969dc9a0 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Mon, 22 Mar 2004 10:33:16 +0000 Subject: [PATCH] commited Matzes Win32 patch SVN-Revision: 309 --- autogen.sh | 2 +- configure.ac | 56 ++++++++++++++----------------------------- data/Makefile.am | 1 + src/button.cpp | 24 +++++++++---------- src/button.h | 6 ++--- src/intro.cpp | 2 -- src/leveleditor.cpp | 38 +++++++++++++++--------------- src/setup.cpp | 42 ++++++++++----------------------- src/sound.cpp | 68 ----------------------------------------------------- src/sound.h | 28 ---------------------- src/supertux.cpp | 4 ---- src/supertux.h | 3 --- src/texture.h | 5 ++-- src/worldmap.h | 2 ++ 14 files changed, 71 insertions(+), 210 deletions(-) diff --git a/autogen.sh b/autogen.sh index e89258c27..ae946de0a 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,6 +1,6 @@ #!/bin/sh -aclocal-1.7 +aclocal-1.7 -I mk/autoconf automake-1.7 --copy --add-missing autoconf diff --git a/configure.ac b/configure.ac index 659a864d2..0b8b1f3f0 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,6 @@ SDL_VERSION=1.2.4 AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL -AC_LANG(C++) dnl Checks for header files. AC_HEADER_DIRENT @@ -44,70 +43,52 @@ AC_MSG_CHECKING(for debug mode) AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [enable debugging mode]),, enable_debug="yes") if test "x${enable_debug}" != "xno"; then - CXXFLAGS="$CXXFLAGS -DDEBUG" + CXXFLAGS="$CXXFLAGS -Wall -W -DDEBUG" AC_MSG_RESULT([enabled]) else AC_MSG_RESULT([disabled]) fi -AC_MSG_CHECKING(weather OpenGL should be used) +AC_MSG_CHECKING(wether OpenGL should be used) AC_ARG_ENABLE(opengl, AC_HELP_STRING([--disable-opengl], [disable OpenGL support]),, enable_opengl="yes") if test "x${enable_opengl}" != "xno"; then - CXXFLAGS="$CXXFLAGS -D__OPENGL" AC_MSG_RESULT([yes]) else - CXXFLAGS="$CXXFLAGS -DNOOPENGL" - AC_MSG_RESULT([no]) -fi - -AC_MSG_CHECKING(weather Sound should be supported) -AC_ARG_ENABLE(sound, - AC_HELP_STRING([--disable-sound], [disable sound support]),, enable_sound="yes") -if test "x${enable_sound}" != "xno"; then - CXXFLAGS="$CXXFLAGS -D__SOUND" - AC_MSG_RESULT([yes]) -else - CXXFLAGS="$CXXFLAGS -DNOSOUND" AC_MSG_RESULT([no]) fi dnl =========================================================================== dnl Check for SDL -AC_LANG_PUSH(C) AM_PATH_SDL($SDL_VERSION, :, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])) CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" -LDFLAGS="$LDFLAGS $SDL_LIBS" +CFLAGS="$CFLAGS $SDL_CFLAGS" +LIBS="$LIBS $SDL_LIBS" dnl Checks for additional libraries. -if test "x${enable_sound}" != "xno"; then - AC_CHECK_LIB(SDL_mixer, SDL_OpenAudio,, - [CXXFLAGS="$CXXFLAGS -DNOSOUND" - enable_sound="no"]) -fi +AC_CHECK_LIB(SDL_mixer, Mix_OpenAudio,, + AC_MSG_ERROR([SDL_mixer library required])) -AC_CHECK_LIB(SDL_image, IMG_Load, ,AC_MSG_ERROR(SDL_image library required)) +AC_CHECK_LIB(SDL_image, IMG_Load,, + AC_MSG_ERROR([SDL_image library required])) if test "x${enable_opengl}" != "xno"; then - # grumbel: xlib path is needed on my system to get OpenGL right, - # else I end up with a black screen, might be a debian issue or a - # local issue on my system, not sure - AC_PATH_XTRA - CXXFLAGS="$CXXFLAGS $X_CFLAGS" - LDFLAGS="$LDFLAGS $X_LIBS" - - AC_CHECK_LIB(GL, glBegin,, - [CXXFLAGS="$CXXFLAGS -DNOOPENGL" - enable_opengl="no"]) + AX_CHECK_GL +fi +if test "x$no_gl" = "xyes" -o "x$enable_opengl" = "xno"; then + CXXFLAGS="$CXXFLAGS -DNOOPENGL" + enable_opengl="no" +else + CFLAGS="$CFLAGS $GL_CFLAGS" + CXXFLAGS="$CXXFLAGS $GL_CFLAGS" + LIBS="$LIBS $GL_LIBS" fi -AC_LANG_POP() AC_CHECK_LIB(z, gzopen,, AC_MSG_ERROR([*** zlib is missing])) -# FIXME: Evil -CXXFLAGS="$CXXFLAGS -DDATA_PREFIX='\"$datadir/supertux/\"' -DLINUX" +CXXFLAGS="$CXXFLAGS -DDATA_PREFIX='\"$datatdir/supertux\"'" dnl Checks for library functions. AC_CHECK_FUNCS(mkdir strdup strstr) @@ -120,7 +101,6 @@ echo "=========" echo " Profile Mode: $enable_gprof" echo " Debug Mode: $enable_debug" echo " OpenGL Support: $enable_opengl" -echo " Sound Support: $enable_sound" echo "" # EOF # diff --git a/data/Makefile.am b/data/Makefile.am index 4ac226482..5cbbdbf4c 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -10,6 +10,7 @@ EXTRA_DIST = \ $(wildcard images/shared/*.png) \ $(wildcard images/status/*.png) \ $(wildcard images/themes/*/*.png) \ + $(wildcard images/worldmap/*.png) \ $(wildcard images/title/*.png) \ levels/default/info.png \ levels/default/info \ diff --git a/src/button.cpp b/src/button.cpp index 157dd6577..7dfbee480 100644 --- a/src/button.cpp +++ b/src/button.cpp @@ -103,9 +103,9 @@ void button_draw(button_type* pbutton) sprintf(str,"(%s)", SDL_GetKeyName(pbutton->shortcut)); text_draw(&white_small_text, str, i + pbutton->x - strlen(str) * white_small_text.w, pbutton->y + white_small_text.h+2, 1, NO_UPDATE); } - if(pbutton->state == BN_PRESSED) + if(pbutton->state == BUTTON_PRESSED) fillrect(pbutton->x,pbutton->y,pbutton->w,pbutton->h,75,75,75,200); - else if(pbutton->state == BN_HOVER) + else if(pbutton->state == BUTTON_HOVER) fillrect(pbutton->x,pbutton->y,pbutton->w,pbutton->h,150,150,150,128); } @@ -126,7 +126,7 @@ void button_event(button_type* pbutton, SDL_Event *event) { if(event->button.button == SDL_BUTTON_LEFT) { - pbutton->state = BN_PRESSED; + pbutton->state = BUTTON_PRESSED; } else { @@ -135,19 +135,19 @@ void button_event(button_type* pbutton, SDL_Event *event) } else if(event->type == SDL_MOUSEBUTTONUP) { - if(event->button.button == SDL_BUTTON_LEFT && pbutton->state == BN_PRESSED) + if(event->button.button == SDL_BUTTON_LEFT && pbutton->state == BUTTON_PRESSED) { - pbutton->state = BN_CLICKED; + pbutton->state = BUTTON_CLICKED; } - else if(event->button.button != SDL_BUTTON_LEFT && pbutton->state != BN_PRESSED) + else if(event->button.button != SDL_BUTTON_LEFT && pbutton->state != BUTTON_PRESSED) { pbutton->show_info = YES; } } - if(pbutton->state != BN_PRESSED && pbutton->state != BN_CLICKED) + if(pbutton->state != BUTTON_PRESSED && pbutton->state != BUTTON_CLICKED) { - pbutton->state = BN_HOVER; + pbutton->state = BUTTON_HOVER; } } else if(event->type != SDL_KEYDOWN && event->type != SDL_KEYUP) @@ -162,12 +162,12 @@ void button_event(button_type* pbutton, SDL_Event *event) if(event->type == SDL_KEYDOWN) { if(key == pbutton->shortcut) - pbutton->state = BN_PRESSED; + pbutton->state = BUTTON_PRESSED; } else if(event->type == SDL_KEYUP) { - if(pbutton->state == BN_PRESSED && key == pbutton->shortcut) - pbutton->state = BN_CLICKED; + if(pbutton->state == BUTTON_PRESSED && key == pbutton->shortcut) + pbutton->state = BUTTON_CLICKED; } else if(event->type == SDL_MOUSEMOTION) { @@ -182,7 +182,7 @@ void button_event(button_type* pbutton, SDL_Event *event) int button_get_state(button_type* pbutton) { int state; - if(pbutton->state == BN_CLICKED) + if(pbutton->state == BUTTON_CLICKED) { state = pbutton->state; pbutton->state = -1; diff --git a/src/button.h b/src/button.h index 183d9fe10..5e306a05e 100644 --- a/src/button.h +++ b/src/button.h @@ -16,9 +16,9 @@ #include "texture.h" enum { - BN_CLICKED, - BN_PRESSED, - BN_HOVER + BUTTON_CLICKED, + BUTTON_PRESSED, + BUTTON_HOVER }; typedef struct button_type diff --git a/src/intro.cpp b/src/intro.cpp index 2318ec22f..18f818de4 100644 --- a/src/intro.cpp +++ b/src/intro.cpp @@ -18,10 +18,8 @@ #include #include -#ifndef LINUX #include #include -#endif #include "defines.h" #include "globals.h" diff --git a/src/leveleditor.cpp b/src/leveleditor.cpp index aa6ce1438..2350385ce 100644 --- a/src/leveleditor.cpp +++ b/src/leveleditor.cpp @@ -1043,13 +1043,13 @@ void le_checkevents() { /* Check for button events */ button_event(&le_test_level_bt,&event); - if(button_get_state(&le_test_level_bt) == BN_CLICKED) + if(button_get_state(&le_test_level_bt) == BUTTON_CLICKED) le_testlevel(); button_event(&le_save_level_bt,&event); - if(button_get_state(&le_save_level_bt) == BN_CLICKED) + if(button_get_state(&le_save_level_bt) == BUTTON_CLICKED) level_save(le_current_level,le_level_subset.name.c_str(),le_level); button_event(&le_next_level_bt,&event); - if(button_get_state(&le_next_level_bt) == BN_CLICKED) + if(button_get_state(&le_next_level_bt) == BUTTON_CLICKED) { if(le_level < le_level_subset.levels) { @@ -1095,23 +1095,23 @@ void le_checkevents() } } button_event(&le_previous_level_bt,&event); - if(button_get_state(&le_previous_level_bt) == BN_CLICKED) + if(button_get_state(&le_previous_level_bt) == BUTTON_CLICKED) { if(le_level > 1) le_goto_level(--le_level); } button_event(&le_rubber_bt,&event); - if(button_get_state(&le_rubber_bt) == BN_CLICKED) + if(button_get_state(&le_rubber_bt) == BUTTON_CLICKED) le_current_tile = '.'; button_event(&le_select_mode_one_bt,&event); - if(button_get_state(&le_select_mode_one_bt) == BN_CLICKED) + if(button_get_state(&le_select_mode_one_bt) == BUTTON_CLICKED) le_selection_mode = CURSOR; button_event(&le_select_mode_two_bt,&event); - if(button_get_state(&le_select_mode_two_bt) == BN_CLICKED) + if(button_get_state(&le_select_mode_two_bt) == BUTTON_CLICKED) le_selection_mode = SQUARE; button_event(&le_bad_bt,&event); - if(button_get_state(&le_bad_bt) == BN_CLICKED) + if(button_get_state(&le_bad_bt) == BUTTON_CLICKED) { le_bad_panel.hidden = NO; le_fgd_panel.hidden = YES; @@ -1119,21 +1119,21 @@ void le_checkevents() } button_event(&le_fgd_bt,&event); - if(button_get_state(&le_fgd_bt) == BN_CLICKED) + if(button_get_state(&le_fgd_bt) == BUTTON_CLICKED) { le_bad_panel.hidden = YES; le_fgd_panel.hidden = NO; le_bkgd_panel.hidden = YES; } button_event(&le_bkgd_bt,&event); - if(button_get_state(&le_bkgd_bt) == BN_CLICKED) + if(button_get_state(&le_bkgd_bt) == BUTTON_CLICKED) { le_bad_panel.hidden = YES; le_fgd_panel.hidden = YES; le_bkgd_panel.hidden = NO; } button_event(&le_settings_bt,&event); - if(button_get_state(&le_settings_bt) == BN_CLICKED) + if(button_get_state(&le_settings_bt) == BUTTON_CLICKED) { if(show_menu == NO) { @@ -1149,7 +1149,7 @@ void le_checkevents() } if((pbutton = button_panel_event(&le_bkgd_panel,&event)) != NULL) { - if(button_get_state(pbutton) == BN_CLICKED) + if(button_get_state(pbutton) == BUTTON_CLICKED) { char c = '\0'; if(pbutton->tag >= 0 && pbutton->tag <= 3) @@ -1166,7 +1166,7 @@ void le_checkevents() } if((pbutton = button_panel_event(&le_fgd_panel,&event)) != NULL) { - if(button_get_state(pbutton) == BN_CLICKED) + if(button_get_state(pbutton) == BUTTON_CLICKED) { char c = '\0'; if(pbutton->tag == 0) @@ -1211,7 +1211,7 @@ void le_checkevents() } if((pbutton = button_panel_event(&le_bad_panel,&event)) != NULL) { - if(button_get_state(pbutton) == BN_CLICKED) + if(button_get_state(pbutton) == BUTTON_CLICKED) { char c = '\0'; if(pbutton->tag >= 0 && pbutton->tag <= 2) @@ -1224,7 +1224,7 @@ void le_checkevents() else { button_event(&le_settings_bt,&event); - if(button_get_state(&le_settings_bt) == BN_CLICKED) + if(button_get_state(&le_settings_bt) == BUTTON_CLICKED) { if(show_menu == NO) { @@ -1254,20 +1254,20 @@ void le_checkevents() } if(show_menu == NO) { - if(button_get_state(&le_move_left_bt) == BN_PRESSED) + if(button_get_state(&le_move_left_bt) == BUTTON_PRESSED) { pos_x -= 192; } - else if(button_get_state(&le_move_left_bt) == BN_HOVER) + else if(button_get_state(&le_move_left_bt) == BUTTON_HOVER) { pos_x -= 96; } - if(button_get_state(&le_move_right_bt) == BN_PRESSED) + if(button_get_state(&le_move_right_bt) == BUTTON_PRESSED) { pos_x += 192; } - else if(button_get_state(&le_move_right_bt) == BN_HOVER) + else if(button_get_state(&le_move_right_bt) == BUTTON_HOVER) { pos_x += 96; } diff --git a/src/setup.cpp b/src/setup.cpp index 0210d045d..5e90b15b8 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -22,13 +22,13 @@ #include #endif -#ifndef WIN32 #include #include #include +#ifndef WIN32 #include -#include #endif +#include #include "defines.h" #include "globals.h" @@ -38,6 +38,13 @@ #include "menu.h" #include "gameloop.h" +#ifdef WIN32 +#define mkdir(dir, mode) mkdir(dir) +// on win32 we typically don't want LFS paths +#undef DATA_PREFIX +#define DATA_PREFIX "./data" +#endif + /* Local function prototypes: */ void seticon(void); @@ -271,22 +278,16 @@ void st_directory_setup(void) strcat(st_save_dir,"/save"); /* Create them. In the case they exist they won't destroy anything. */ -#ifndef WIN32 mkdir(st_dir, 0755); mkdir(st_save_dir, 0755); sprintf(str, "%s/levels", st_dir); mkdir(str, 0755); -#else - mkdir(st_dir); - mkdir(st_save_dir); - sprintf(str, "%s/levels", st_dir); - mkdir(str); -#endif // User has not that a datadir, so we try some magic if (datadir.empty()) { +#ifndef WIN32 // Detect datadir char exe_file[PATH_MAX]; if (readlink("/proc/self/exe", exe_file, PATH_MAX) < 0) @@ -308,6 +309,9 @@ void st_directory_setup(void) } } } +#else + datadir = DATA_PREFIX; +#endif } printf("Datadir: %s\n", datadir.c_str()); } @@ -849,17 +853,9 @@ void parseargs(int argc, char * argv[]) show_fps = NO; use_gl = NO; -#ifndef NOSOUND - use_sound = YES; use_music = YES; audio_device = YES; -#else - - use_sound = NO; - use_music = NO; - audio_device = NO; -#endif /* Parse arguments: */ @@ -914,26 +910,14 @@ void parseargs(int argc, char * argv[]) else if (strcmp(argv[i], "--disable-sound") == 0) { /* Disable the compiled in sound feature */ -#ifndef NOSOUND printf("Sounds disabled \n"); use_sound = NO; -#else - - printf("Warning: Sound capability has not been compiled into this build.\n"); -#endif - } else if (strcmp(argv[i], "--disable-music") == 0) { /* Disable the compiled in sound feature */ -#ifndef NOSOUND printf("Music disabled \n"); use_music = NO; -#else - - printf("Warning: Music feature is not compiled in \n"); -#endif - } else if (strcmp(argv[i], "--debug-mode") == 0) { diff --git a/src/sound.cpp b/src/sound.cpp index 412f3c0f0..cec212fa5 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -43,8 +43,6 @@ char * soundfilenames[NUM_SOUNDS] = { }; -#ifndef NOSOUND - #include Mix_Chunk * sounds[NUM_SOUNDS]; @@ -240,69 +238,3 @@ void free_music(Mix_Music *music) /* use halt_music whenever you want to stop it */ } -#else - -void* sounds[NUM_SOUNDS]; -void* level_song, * level_song_fast, * herring_song; - -int open_audio (int frequency, int format, int channels, int chunksize) -{ - return -1; -} - - -void close_audio(void) -{} - - -void* load_sound(void* file) -{ - return NULL; -} - - -void play_sound(void * snd, enum Sound_Speaker whichSpeaker) -{} - - -void* load_song(void* file) -{ - return NULL; -} - - -int playing_music() -{ - return 0; -} - - -void halt_music() -{} - - -int play_music(void *music, int loops) -{ - return 0; -} - - -void free_music(void *music) -{} - - -void free_chunk(void *chunk) -{} - -int get_current_music() -{ -} - -void set_current_music(int music) -{ -} - -void play_current_music(void) -{} - -#endif diff --git a/src/sound.h b/src/sound.h index a2cae9992..1a867b2f6 100644 --- a/src/sound.h +++ b/src/sound.h @@ -67,8 +67,6 @@ enum { extern char* soundfilenames[NUM_SOUNDS]; -#ifndef NOSOUND - #include #include @@ -94,30 +92,4 @@ int get_current_music(); void set_current_music(int music); void play_current_music(); -#else - -/* fake variables */ -extern void* sounds[NUM_SOUNDS]; -extern void * level_song, * level_song_fast, * herring_song; - -/* fake sound handlers */ -int open_audio (int frequency, int format, int channels, int chunksize); -void close_audio( void ); - -void* load_sound(void* file); -void play_sound(void * snd, enum Sound_Speaker whichSpeaker); -void* load_song(void* file); - -int playing_music(); -void halt_music(); -int play_music(void *music, int loops); -void free_music(void *music); -void free_chunk(void *chunk); - -int get_current_music(); -void set_current_music(int music); -void play_current_music(void); - -#endif - #endif /*SUPERTUX_SOUND_H*/ diff --git a/src/supertux.cpp b/src/supertux.cpp index 555495a7b..dd105e832 100644 --- a/src/supertux.cpp +++ b/src/supertux.cpp @@ -15,11 +15,7 @@ /* --- MAIN --- */ -#ifdef WIN32 -main(int argc, char * argv[]) -#else int main(int argc, char * argv[]) -#endif { int done; diff --git a/src/supertux.h b/src/supertux.h index 77a645588..1c498f519 100644 --- a/src/supertux.h +++ b/src/supertux.h @@ -1,11 +1,8 @@ #ifndef SUPERTUX_SUPERTUX_H #define SUPERTUX_SUPERTUX_H -#ifdef LINUX -#include #include #include -#endif #include "defines.h" #include "globals.h" diff --git a/src/texture.h b/src/texture.h index 329ff781c..7b83befa6 100644 --- a/src/texture.h +++ b/src/texture.h @@ -13,11 +13,10 @@ #ifndef SUPERTUX_TEXTURE_H #define SUPERTUX_TEXTURE_H +#include #include - -#include "SDL.h" #ifndef NOOPENGL -#include "SDL_opengl.h" +#include #endif #include "screen.h" diff --git a/src/worldmap.h b/src/worldmap.h index 388b1a34b..9968ce048 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -23,6 +23,8 @@ #include #include +#include + namespace WorldMapNS { struct Point -- 2.11.0