commited Matzes Win32 patch
authorIngo Ruhnke <grumbel@gmx.de>
Mon, 22 Mar 2004 10:33:16 +0000 (10:33 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Mon, 22 Mar 2004 10:33:16 +0000 (10:33 +0000)
SVN-Revision: 309

14 files changed:
autogen.sh
configure.ac
data/Makefile.am
src/button.cpp
src/button.h
src/intro.cpp
src/leveleditor.cpp
src/setup.cpp
src/sound.cpp
src/sound.h
src/supertux.cpp
src/supertux.h
src/texture.h
src/worldmap.h

index e89258c..ae946de 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-aclocal-1.7
+aclocal-1.7 -I mk/autoconf
 automake-1.7 --copy --add-missing
 autoconf
 
index 659a864..0b8b1f3 100644 (file)
@@ -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 #
index 4ac2264..5cbbdbf 100644 (file)
@@ -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 \
index 157dd65..7dfbee4 100644 (file)
@@ -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;
index 183d9fe..5e306a0 100644 (file)
@@ -16,9 +16,9 @@
 #include "texture.h"
 
 enum {
-  BN_CLICKED,
-  BN_PRESSED,
-  BN_HOVER
+  BUTTON_CLICKED,
+  BUTTON_PRESSED,
+  BUTTON_HOVER
 };
 
 typedef struct button_type
index 2318ec2..18f818d 100644 (file)
 #include <SDL.h>
 #include <SDL_image.h>
 
-#ifndef LINUX
 #include <sys/types.h>
 #include <ctype.h>
-#endif
 
 #include "defines.h"
 #include "globals.h"
index aa6ce14..2350385 100644 (file)
@@ -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;
         }
index 0210d04..5e90b15 100644 (file)
 #include <SDL_opengl.h>
 #endif
 
-#ifndef WIN32
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <dirent.h>
+#ifndef WIN32
 #include <libgen.h>
-#include <ctype.h>
 #endif
+#include <ctype.h>
 
 #include "defines.h"
 #include "globals.h"
 #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)
         {
index 412f3c0..cec212f 100644 (file)
@@ -43,8 +43,6 @@ char * soundfilenames[NUM_SOUNDS] = {
                                     };
 
 
-#ifndef NOSOUND
-
 #include <SDL_mixer.h>
 
 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
index a2cae99..1a867b2 100644 (file)
@@ -67,8 +67,6 @@ enum {
 
 extern char* soundfilenames[NUM_SOUNDS];
 
-#ifndef NOSOUND
-
 #include <string>
 #include <SDL_mixer.h>
 
@@ -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*/
index 555495a..dd105e8 100644 (file)
 
 /* --- MAIN --- */
 
-#ifdef WIN32
-main(int argc, char * argv[])
-#else
 int main(int argc, char * argv[])
-#endif
 {
   int done;
   
index 77a6455..1c498f5 100644 (file)
@@ -1,11 +1,8 @@
 #ifndef SUPERTUX_SUPERTUX_H
 #define SUPERTUX_SUPERTUX_H
 
-#ifdef LINUX
-#include <pwd.h>
 #include <sys/types.h>
 #include <ctype.h>
-#endif
 
 #include "defines.h"
 #include "globals.h"
index 329ff78..7b83bef 100644 (file)
 #ifndef SUPERTUX_TEXTURE_H
 #define SUPERTUX_TEXTURE_H
 
+#include <SDL.h>
 #include <string>
-
-#include "SDL.h"
 #ifndef NOOPENGL
-#include "SDL_opengl.h"
+#include <SDL_opengl.h>
 #endif
 
 #include "screen.h"
index 388b1a3..9968ce0 100644 (file)
@@ -23,6 +23,8 @@
 #include <vector>
 #include <string>
 
+#include <SDL_mixer.h>
+
 namespace WorldMapNS {
 
 struct Point