[Tux4kids-commits] r1347 - branches/commonification/tuxtype/trunk/src

Bolesław Kulbabiński bolekk-guest at alioth.debian.org
Tue Aug 4 00:12:51 UTC 2009


Author: bolekk-guest
Date: 2009-08-04 00:12:50 +0000 (Tue, 04 Aug 2009)
New Revision: 1347

Modified:
   branches/commonification/tuxtype/trunk/src/SDL_extras.c
   branches/commonification/tuxtype/trunk/src/SDL_extras.h
   branches/commonification/tuxtype/trunk/src/funcs.h
   branches/commonification/tuxtype/trunk/src/globals.h
   branches/commonification/tuxtype/trunk/src/loaders.c
   branches/commonification/tuxtype/trunk/src/main.c
Log:
work on adapting tuxtype to work with loaders from t4kcommon

Modified: branches/commonification/tuxtype/trunk/src/SDL_extras.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/SDL_extras.c	2009-08-03 21:42:10 UTC (rev 1346)
+++ branches/commonification/tuxtype/trunk/src/SDL_extras.c	2009-08-04 00:12:50 UTC (rev 1347)
@@ -27,7 +27,20 @@
 /**************************************************************************/
 
 
-#ifndef HAVE_T4KCOMMON
+
+#ifndef HAVE_LIBT4KCOMMON
+
+SDL_Surface* screen;
+
+SDL_Surface* GetScreen()
+{
+  if (screen != SDL_GetVideoSurface() )
+  {
+    fprintf(stderr, "Video Surface changed from outside of SDL_Extras!\n");
+    screen = SDL_GetVideoSurface();
+  }
+  return screen;
+}
 /* DrawButton() creates and draws a translucent button with */
 /* rounded ends.  All colors and alpha values are supported.*/
 void DrawButton(SDL_Rect* target_rect,

Modified: branches/commonification/tuxtype/trunk/src/SDL_extras.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/SDL_extras.h	2009-08-03 21:42:10 UTC (rev 1346)
+++ branches/commonification/tuxtype/trunk/src/SDL_extras.h	2009-08-04 00:12:50 UTC (rev 1347)
@@ -18,7 +18,7 @@
 
 #include "SDL.h"
 
-#ifdef HAVE_T4KCOMMON
+#ifdef HAVE_LIBT4KCOMMON
 #include "t4kcommon.h"
 #else
 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
@@ -60,8 +60,9 @@
 } sprite;
 
 
-#ifndef HAVE_T4KCOMMON
+#ifndef HAVE_LIBT4KCOMMON
 /* "Public" function prototypes: */
+SDL_Surface* GetScreen();
 void DrawButton(SDL_Rect* target_rect, int radius, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
 #endif
 void RoundCorners(SDL_Surface* s, Uint16 radius);

Modified: branches/commonification/tuxtype/trunk/src/funcs.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/funcs.h	2009-08-03 21:42:10 UTC (rev 1346)
+++ branches/commonification/tuxtype/trunk/src/funcs.h	2009-08-04 00:12:50 UTC (rev 1347)
@@ -68,18 +68,38 @@
 
 
 /* In loaders.c: */
-int CheckFile(const char* file);
-sprite* FlipSprite(sprite* in, int X, int Y);
-void FreeSprite(sprite* gfx);
-SDL_Surface* LoadImage(const char* datafile, int mode);
-int LoadBothBkgds(const char* datafile);
+#define IMG_REGULAR         0x01
+#define IMG_COLORKEY        0x02
+#define IMG_ALPHA           0x04
+#define IMG_MODES           0x07
+
+#define IMG_NOT_REQUIRED    0x10
+#define IMG_NO_PNG_FALLBACK 0x20
+
+#ifndef HAVE_LIBT4KCOMMON
+int          LoadBothBkgds(const char* datafile);
 SDL_Surface* CurrentBkgd(void);
-void FreeBothBkgds(void);
-void LoadLang(void);
-Mix_Music* LoadMusic(const char* datafile);
-Mix_Chunk* LoadSound(const char* datafile);
-sprite* LoadSprite(const char* name, int MODE);
+void         FreeBothBkgds(void);
+void         LoadLang(void);
 
+int          CheckFile(const char* file);
+SDL_Surface* LoadImage(const char* file_name, int mode);
+SDL_Surface* LoadScaledImage(const char* file_name, int mode, int width, int height);
+SDL_Surface* LoadImageOfBoundingBox(const char* file_name, int mode, int max_width, int max_height);
+
+SDL_Surface* LoadBkgd(const char* file_name, int width, int height);
+
+sprite*      LoadSprite(const char* name, int mode);
+sprite*      LoadScaledSprite(const char* name, int mode, int width, int height);
+sprite*      LoadSpriteOfBoundingBox(const char* name, int mode, int max_width, int max_height);
+sprite*      FlipSprite(sprite* in, int X, int Y);
+void         FreeSprite(sprite* gfx);
+void         NextFrame(sprite* s);
+
+Mix_Chunk*   LoadSound(char* datafile);
+Mix_Music*   LoadMusic(char *datafile);
+
+#endif // HAVE_LIBT4KCOMMON
 /* In options.c: */
 void Opts_Initialize(void);
 

Modified: branches/commonification/tuxtype/trunk/src/globals.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/globals.h	2009-08-03 21:42:10 UTC (rev 1346)
+++ branches/commonification/tuxtype/trunk/src/globals.h	2009-08-04 00:12:50 UTC (rev 1347)
@@ -20,6 +20,36 @@
 
 #include "config.h"
 
+/* debug data (declared in options.c) */
+extern int debug_status;
+
+/* bitmasks for debugging options (declared in options.c) */
+#ifndef HAVE_LIBT4KCOMMON
+extern const int debug_loaders;
+extern const int debug_menu;
+extern const int debug_menu_parser;
+extern const int debug_sdl;
+#endif
+extern const int debug_setup;
+extern const int debug_fileops;
+extern const int debug_titlescreen;
+extern const int debug_game;
+extern const int debug_factoroids;
+extern const int debug_lan;
+extern const int debug_mathcards;
+extern const int debug_lessons;
+extern const int debug_highscore;
+extern const int debug_options;
+extern const int debug_convert_utf;
+extern const int debug_multiplayer;
+#ifndef HAVE_LIBT4KCOMMON
+extern const int debug_all;
+#endif
+
+/* debug macros */
+//#define DEBUGCODE(mask) if((mask) & debug_status)
+#define DEBUGMSG(mask, ...) if((mask) & debug_status){ fprintf(stderr, __VA_ARGS__); fflush(stderr); }
+
 #ifdef HAVE_LIBT4KCOMMON
 //#include <t4kcommon/tux4kids-common.h>
 #endif

Modified: branches/commonification/tuxtype/trunk/src/loaders.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/loaders.c	2009-08-03 21:42:10 UTC (rev 1346)
+++ branches/commonification/tuxtype/trunk/src/loaders.c	2009-08-04 00:12:50 UTC (rev 1347)
@@ -19,52 +19,34 @@
 
 #include "globals.h"
 #include "funcs.h"
+#include "compiler.h"
 #include "SDL_extras.h"
 #include "mysetenv.h"
 
-static SDL_Surface* win_bkgd = NULL;
-static SDL_Surface* fullscr_bkgd = NULL;
+#ifdef HAVE_RSVG
+#include<librsvg/rsvg.h>
+#include<librsvg/rsvg-cairo.h>
+#endif
 
-/* Local function prototypes: */
-static int max(int n1, int n2);
-//static SDL_Surface* flip(SDL_Surface *in, int x, int y);
+/* local functions */
 
-/* Returns 1 if valid file, 2 if valid dir, 0 if neither: */
-int CheckFile(const char* file)
-{
-  FILE* fp = NULL;
-  DIR* dp = NULL;
+#ifdef HAVE_RSVG
+SDL_Surface*    load_svg(const char* file_name, int width, int height, const char* layer_name);
+sprite*         load_svg_sprite(const char* file_name, int width, int height);
+SDL_Surface*    render_svg_from_handle(RsvgHandle* file_handle, int width, int height, const char* layer_name);
+void            get_svg_dimensions(const char* file_name, int* width, int* height);
+#endif
 
-  if (!file)
-  {
-    fprintf(stderr, "CheckFile(): invalid char* argument!");
-    return -1;
-  }
+SDL_Surface*    load_image(const char* file_name, int mode, int w, int h, bool proportional);
+void            fit_in_rectangle(int* width, int* height, int max_width, int max_height);
+SDL_Surface*    set_format(SDL_Surface* img, int mode);
+sprite*         load_sprite(const char* name, int mode, int w, int h, bool proportional);
 
-  DEBUGCODE {fprintf(stderr, "CheckFile() - checking: %s\n", file);} 
 
-  dp = opendir(file);
-  if (dp)
-  {
-    LOG("Opened successfully as DIR\n");
+static SDL_Surface* win_bkgd = NULL;
+static SDL_Surface* fullscr_bkgd = NULL;
 
-    closedir(dp);
-    return 2;
-  }
 
-  fp = fopen(file, "r");
-  if (fp)
-  {
-    LOG("Opened successfully as FILE\n");
-    fclose(fp);
-    return 1;
-  }
-
-  LOG("Unable to open as either FILE or DIR\n");
-  return 0;
-}
-
-
 /* FIXME not sure we need to call *textdomain() functions again here  */
 /* FIXME need to read language's font name, if needed - e.g. Russian. */
 /* also should have return value reflect success or failure.     */
@@ -108,57 +90,192 @@
   return;
 }
 
+/**********************
+LoadBothBkgds() : loads two scaled images: one for the user's native 
+resolution and one for 640x480 fullscreen. 
+Returns: the number of images that were scaled
+**********************/
+int LoadBothBkgds(const char* datafile)
+{
+  int ret = 0;
+  SDL_Surface* orig = NULL;
+  
+  //Avoid memory leak in case something else already loaded:
+  FreeBothBkgds();
 
-int max(int n1, int n2)
+  LOG("Entering LoadBothBkgds()\n");
+
+  orig = LoadImage(datafile, IMG_REGULAR);
+
+  DEBUGCODE
+  {
+     printf("Scaling %dx%d to: %dx%d, %dx%d\n", 
+           orig->w, orig->h, RES_X, RES_Y, fs_res_x, fs_res_y);
+  }
+
+  if (orig->w == RES_X && orig->h == RES_Y)
+  {
+    win_bkgd = orig;
+  }
+  else
+  {
+    win_bkgd = zoom(orig, RES_X, RES_Y);
+    ++ret;
+  }
+  
+  if (orig->w == fs_res_x && orig->h == fs_res_y)
+  {
+    fullscr_bkgd = orig;
+  }
+  else
+  {
+    fullscr_bkgd = zoom(orig, fs_res_x, fs_res_y);
+    ++ret;
+  }
+  
+  if (ret == 2) //orig won't be used at all
+    SDL_FreeSurface(orig);
+    
+  DEBUGCODE
+  {
+    printf("%d images scaled\nLeaving LoadBothBkgds()\n", ret);
+  }
+  return ret;
+}
+
+
+SDL_Surface* CurrentBkgd(void)
 {
-  return (n1 > n2 ? n1 : n2);
+  if (!screen)
+    return NULL;
+  if (screen->flags & SDL_FULLSCREEN)
+    return fullscr_bkgd;
+  else
+    return win_bkgd;
 }
 
+void FreeBothBkgds(void)
+{
+  if (win_bkgd)
+    SDL_FreeSurface(win_bkgd);
+  win_bkgd = NULL;
 
+  if (fullscr_bkgd)
+    SDL_FreeSurface(fullscr_bkgd);
+  fullscr_bkgd = NULL;
+}
+
+int CheckFile(const char* file)
+{
+  FILE* fp = NULL;
+
+  if (!file)
+  {
+    DEBUGMSG(debug_loaders, "check_file(): invalid char* argument!\n");
+    return 0;
+  }
+
+  DEBUGMSG(debug_loaders, "check_file(): checking: %s\n", file);
+
+  fp = fopen(file, "r");
+  if (fp)
+  {
+    DEBUGMSG(debug_loaders, "check_file(): Opened successfully as FILE\n");
+    fclose(fp);
+    return 1;
+  }
+
+  DEBUGMSG(debug_loaders, "check_file(): Unable to open '%s' as either FILE or DIR\n", file);
+  return 0;
+}
+
+
 #ifdef HAVE_RSVG
-/***********************
-    SVG related functions
-************************/
-#include<librsvg/rsvg.h>
-#include<librsvg/rsvg-cairo.h>
 
-/* Load an SVG file and resize it to given dimensions.
-   if width or height is set to 0 no resizing is applied
+/* Load a layer of SVG file and resize it to given dimensions.
+   If width or height is negative no resizing is applied.
+   If layer = NULL then the whole image is loaded.
+   layer_name must be preceded with a '#' symbol.
+   Return NULL on failure.
    (partly based on TuxPaint's SVG loading function) */
-SDL_Surface* LoadSVGOfDimensions(char* filename, int width, int height)
+SDL_Surface* load_svg(const char* file_name, int width, int height, const char* layer_name)
 {
-  cairo_surface_t* temp_surf;
-  cairo_t* context;
+  SDL_Surface* dest;
   RsvgHandle* file_handle;
-  RsvgDimensionData dimensions;
-  SDL_Surface* dest;
-  float scale_x;
-  float scale_y;
-  int bpp = 32;
-  Uint32 Rmask, Gmask, Bmask, Amask;
 
-  DEBUGCODE{
-    fprintf(stderr, "LoadSVGOfDimensions(): looking for %s\n", filename);
+  DEBUGMSG(debug_loaders, "load_svg(): loading %s\n", file_name);
+
+  rsvg_init();
+
+  file_handle = rsvg_handle_new_from_file(file_name, NULL);
+  if(NULL == file_handle)
+  {
+    DEBUGMSG(debug_loaders, "load_svg(): file %s not found\n", file_name);
+    rsvg_term();
+    return NULL;
   }
 
+  dest = render_svg_from_handle(file_handle, width, height, layer_name);
+
+  g_object_unref(file_handle);
+  rsvg_term();
+
+  return dest;
+}
+
+sprite* load_svg_sprite(const char* file_name, int width, int height)
+{
+  RsvgHandle* file_handle;
+  sprite* new_sprite;
+  char lay_name[20];
+  int i;
+
+  DEBUGMSG(debug_loaders, "load_svg_sprite(): loading sprite from %s\n", file_name);
+
   rsvg_init();
 
-  file_handle = rsvg_handle_new_from_file(filename, NULL);
-  if(file_handle == NULL)
+  file_handle = rsvg_handle_new_from_file(file_name, NULL);
+  if(NULL == file_handle)
   {
-    DEBUGCODE{
-      fprintf(stderr, "LoadSVGOfDimensions(): file %s not found\n", filename);
-    }
+    DEBUGMSG(debug_loaders, "load_svg_sprite(): file %s not found\n", file_name);
     rsvg_term();
     return NULL;
   }
 
-  rsvg_handle_get_dimensions(file_handle, &dimensions);
-  DEBUGCODE{
-    fprintf(stderr, "SVG is %d x %d\n", dimensions.width, dimensions.height);
+  new_sprite = malloc(sizeof(sprite));
+  new_sprite->default_img = render_svg_from_handle(file_handle, width, height, "#default");
+
+  /* get number of frames from description */
+  sscanf(rsvg_handle_get_desc(file_handle), "%d", &new_sprite->num_frames);
+  DEBUGMSG(debug_loaders, "load_svg_sprite(): loading %d frames\n", new_sprite->num_frames);
+
+  for(i = 0; i < new_sprite->num_frames; i++)
+  {
+    sprintf(lay_name, "#frame%d", i);
+    new_sprite->frame[i] = render_svg_from_handle(file_handle, width, height, lay_name);
   }
 
-  if(width <= 0 || height <= 0)
+  g_object_unref(file_handle);
+  rsvg_term();
+
+  return new_sprite;
+}
+
+/* render a layer of SVG file and resize it to given dimensions.
+   If width or height is negative no resizing is applied. */
+SDL_Surface* render_svg_from_handle(RsvgHandle* file_handle, int width, int height, const char* layer_name)
+{
+  RsvgDimensionData dimensions;
+  cairo_surface_t* temp_surf;
+  cairo_t* context;
+  SDL_Surface* dest;
+  float scale_x, scale_y;
+  Uint32 Rmask, Gmask, Bmask, Amask;
+
+  rsvg_handle_get_dimensions(file_handle, &dimensions);
+
+  /* set scale_x and scale_y */
+  if(width < 0 || height < 0)
   {
     width = dimensions.width;
     height = dimensions.height;
@@ -171,17 +288,21 @@
     scale_y = (float)height / dimensions.height;
   }
 
-  /* FIXME: We assume that our bpp = 32 */
+  /* set color masks */
+  Rmask = GetScreen()->format->Rmask;
+  Gmask = GetScreen()->format->Gmask;
+  Bmask = GetScreen()->format->Bmask;
+  if(GetScreen()->format->Amask == 0)
+    /* find a free byte to use for Amask */
+    Amask = ~(Rmask | Gmask | Bmask);
+  else
+    Amask = GetScreen()->format->Amask;
 
-  /* rmask, gmask, bmask, amask defined in SDL_extras.h do not work !
-     are those (taken from TuxPaint) dependent on endianness ? */
-  Rmask = 0x00ff0000;
-  Gmask = 0x0000ff00;
-  Bmask = 0x000000ff;
-  Amask = 0xff000000;
+  DEBUGMSG(debug_loaders, "render_svg_from_handle(): color masks: R=%u, G=%u, B=%u, A=%u\n",
+        Rmask, Gmask, Bmask, Amask);
 
   dest = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA,
-        width, height, bpp, Rmask, Gmask, Bmask, Amask);
+        width, height, GetScreen()->format->BitsPerPixel, Rmask, Gmask, Bmask, Amask);
 
   SDL_LockSurface(dest);
   temp_surf = cairo_image_surface_create_for_data(dest->pixels,
@@ -190,295 +311,401 @@
   context = cairo_create(temp_surf);
   if(cairo_status(context) != CAIRO_STATUS_SUCCESS)
   {
-    DEBUGCODE{
-      fprintf(stderr, "LoadSVGOfDimensions(): error rendering SVG from %s\n", filename);
-    }
-    g_object_unref(file_handle);
+    DEBUGMSG(debug_loaders, "render_svg_from_handle(): error rendering SVG\n");
     cairo_surface_destroy(temp_surf);
-    rsvg_term();
     return NULL;
   }
 
   cairo_scale(context, scale_x, scale_y);
-  rsvg_handle_render_cairo(file_handle, context);
 
+  /* render appropriate layer */
+  rsvg_handle_render_cairo_sub(file_handle, context, layer_name);
+
   SDL_UnlockSurface(dest);
-
-  g_object_unref(file_handle);
   cairo_surface_destroy(temp_surf);
   cairo_destroy(context);
-  rsvg_term();
 
   return dest;
 }
 
-#endif
-
-/***********************
-        LoadImageFromFile : Simply load an image from given file
-        or its SVG equivalent (if present). Return NULL if loading failed.
-************************/
-SDL_Surface* LoadImageFromFile(char *datafile)
+void get_svg_dimensions(const char* file_name, int* width, int* height)
 {
-  SDL_Surface* tmp_pic = NULL;
+  RsvgHandle* file_handle;
+  RsvgDimensionData dimensions;
 
-#ifdef HAVE_RSVG
-  char svgfn[PATH_MAX];
-#endif
+  rsvg_init();
 
-  DEBUGCODE{
-    fprintf(stderr, "LoadImageFromFile(): looking in %s\n", datafile);
+  file_handle = rsvg_handle_new_from_file(file_name, NULL);
+  if(file_handle == NULL)
+  {
+    DEBUGMSG(debug_loaders, "get_svg_dimensions(): file %s not found\n", file_name);
+    rsvg_term();
+    return;
   }
 
-#ifdef HAVE_RSVG
-  /* This is just an ugly workaround to test SVG
-     before any scaling routines are implemented */
+  rsvg_handle_get_dimensions(file_handle, &dimensions);
 
-  /* change extension into .svg */
-  char* dotpos = strrchr(datafile, '.');
-  if (dotpos) //will be NULL if '.' not found:
-  {
-    strncpy(svgfn, datafile, dotpos - datafile);
-    svgfn[dotpos - datafile] = '\0';
-    strcat(svgfn, ".svg");
+  *width = dimensions.width;
+  *height = dimensions.height;
 
-    /* try to load an SVG equivalent */
-    tmp_pic = LoadSVGOfDimensions(svgfn, 0, 0);
-  }
-#endif
+  g_object_unref(file_handle);
+  rsvg_term();
+}
 
-  if(tmp_pic == NULL)
-    /* Try to load image with SDL_image: */
-    tmp_pic = IMG_Load(datafile);
+#endif /* HAVE_RSVG */
 
-  return tmp_pic;
+/* Load an image without resizing it */
+SDL_Surface* LoadImage(const char* file_name, int mode)
+{
+  return LoadScaledImage(file_name, mode, -1, -1);
 }
 
-/***********************
-	LoadImage : Load an image and set transparent if requested
-************************/
-SDL_Surface* LoadImage(const char* datafile, int mode)
+/* LoadScaledImage : Load an image and resize it to given dimensions.
+   If width or height is negative no resizing is applied.
+   The loader (load_svg() or IMG_Load()) is chosen depending on file extension,
+   If an SVG file is not found try to load its PNG equivalent
+   (unless IMG_NO_PNG_FALLBACK is set) */
+SDL_Surface* LoadScaledImage(const char* file_name, int mode, int width, int height)
 {
-  SDL_Surface* tmp_pic = NULL, *final_pic = NULL;
-  char fn[FNLEN];
+  return load_image(file_name, mode, width, height, false);
+}
 
-  /* Look for image under theme path if desired: */
-  if (!settings.use_english && !(mode & IMG_NO_THEME))
+/* LoadImageOfBoundingBox : Same as LoadScaledImage but preserve image proportions
+   and fit it into max_width x max_height rectangle.
+   Returned surface is not necessarily max_width x max_height ! */
+SDL_Surface* LoadImageOfBoundingBox(const char* file_name, int mode, int max_width, int max_height)
+{
+  return load_image(file_name, mode, max_width, max_height, true);
+}
+
+
+/* load_image : helper function used by LoadScaledImage and LoadImageOfBoundingBox */
+SDL_Surface* load_image(const char* file_name, int mode, int w, int h, bool proportional)
+{
+  SDL_Surface* loaded_pic = NULL;
+  SDL_Surface* final_pic = NULL;
+  char fn[PATH_MAX];
+  int fn_len;
+  int width = -1, height = -1;
+  bool is_svg = true;
+
+  if(NULL == file_name)
   {
-    sprintf(fn, "%s/images/%s", settings.theme_data_path, datafile);
-
-    tmp_pic = LoadImageFromFile(fn);
-    if (tmp_pic != NULL)
-      {}
-    else
-      DEBUGCODE { fprintf(stderr, "Warning: graphics file %s could not be loaded\n", fn);}
+    DEBUGMSG(debug_loaders, "load_image(): file_name is NULL, exiting.\n");
+    return NULL;
   }
 
-  /* If we don't have a valid image yet, try the default path: */
-  if (!tmp_pic)
+  /* run loader depending on file extension */
+
+  /* add path prefix */
+  snprintf(fn, PATH_MAX, "%s/images/%s", settings.default_data_path, file_name);
+  fn_len = strlen(fn);
+
+  if(strcmp(fn + fn_len - 4, ".svg"))
   {
-    sprintf(fn, "%s/images/%s", settings.default_data_path, datafile);
+    DEBUGMSG(debug_loaders, "load_image(): %s is not an SVG, loading using IMG_Load()\n", fn);
+    loaded_pic = IMG_Load(fn);
+    is_svg = false;
+    if (NULL == loaded_pic)
+    {
+      is_svg = true;
+      DEBUGMSG(debug_loaders, "load_image(): Trying to load SVG equivalent of %s\n", fn);
+      sprintf(strrchr(fn, '.'), ".svg");
+    }
+  }
+  if (is_svg)
+  {
+#ifdef HAVE_RSVG
+    DEBUGMSG(debug_loaders, "load_image(): trying to load %s as SVG.\n", fn);
+    if(proportional)
+    {
+      get_svg_dimensions(fn, &width, &height);
+      if(width > 0 && height > 0)
+        fit_in_rectangle(&width, &height, w, h);
+    }
+    else
+    {
+      width = w;
+      height = h;
+    }
+    loaded_pic = load_svg(fn, width, height, NULL);
+#endif
 
-    tmp_pic = LoadImageFromFile(fn);
-    if (tmp_pic != NULL)
-      {}
-    else
-      DEBUGCODE { fprintf(stderr, "Warning: graphics file %s could not be loaded\n", fn);}
+    if(loaded_pic == NULL)
+    {
+#ifdef HAVE_RSVG
+      DEBUGMSG(debug_loaders, "load_image(): failed to load %s as SVG.\n", fn);
+#else
+      DEBUGMSG(debug_loaders, "load_image(): SVG support not available.\n");
+#endif
+      if(mode & IMG_NO_PNG_FALLBACK)
+      {
+        DEBUGMSG(debug_loaders, "load_image(): %s : IMG_NO_PNG_FALLBACK is set.\n", fn);
+      }
+      else
+      {
+        DEBUGMSG(debug_loaders, "load_image(): Trying to load PNG equivalent of %s\n", fn);
+        strcpy(fn + fn_len - 3, "png");
+
+        loaded_pic = IMG_Load(fn);
+        is_svg = false;
+      }
+    }
   }
 
-  /* NOTE changed this so we just return NULL instead of exiting - DSB   */
-  /* Couldn't load image - action depends on whether image is essential: */
-  if (!tmp_pic)
+  if (NULL == loaded_pic) /* Could not load image: */
   {
-    { 
-      DEBUGCODE { fprintf(stderr, "Warning - could not load graphics file %s\n", datafile);}
-      return NULL;
+    if (mode & IMG_NOT_REQUIRED)
+    {
+      DEBUGMSG(debug_loaders, "load_image(): Warning: could not load optional graphics file %s\n", file_name);
+      return NULL;  /* Allow program to continue */
     }
+    /* If image was required, exit from program: */
+    fprintf(stderr, "load_image(): ERROR could not load required graphics file %s\n", file_name);
+    fprintf(stderr, "%s", SDL_GetError() );
+    return NULL;
   }
+  else if(!is_svg && w > 0 && h > 0)
+  {
+    if(proportional)
+    {
+      width = loaded_pic->w;
+      height = loaded_pic->h;
+      fit_in_rectangle(&width, &height, w, h);
+    }
+    else
+    {
+      width = w;
+      height = h;
+    }
+    final_pic = zoom(loaded_pic, width, height);
+    SDL_FreeSurface(loaded_pic);
+    loaded_pic = final_pic;
+    final_pic = NULL;
+  }
 
+  final_pic = set_format(loaded_pic, mode);
+  SDL_FreeSurface(loaded_pic);
+  DEBUGMSG(debug_loaders, "Leaving load_image()\n\n");
 
-  /* If we get to here, success - setup the image in the proper format: */
+  return final_pic;
+}
 
+/* adjust width and height to fit in max_width x max_height rectangle
+   but preserve their proportion */
+void fit_in_rectangle(int* width, int* height, int max_width, int max_height)
+{
+  float scale_w, scale_h;
+
+  if(width != 0 && height != 0)
+  {
+    scale_w = (float) max_width / (*width);
+    scale_h = (float) max_height / (*height);
+    *width *= min(scale_w, scale_h);
+    *height *= min(scale_w, scale_h);
+  }
+}
+
+SDL_Surface* set_format(SDL_Surface* img, int mode)
+{
   switch (mode & IMG_MODES)
   {
     case IMG_REGULAR:
-    { 
-      final_pic = SDL_DisplayFormat(tmp_pic);
-      SDL_FreeSurface(tmp_pic);
-      break;
+    {
+      DEBUGMSG(debug_loaders, "set_format(): handling IMG_REGULAR mode.\n");
+      return SDL_DisplayFormat(img);
     }
 
     case IMG_ALPHA:
     {
-      final_pic = SDL_DisplayFormatAlpha(tmp_pic);
-      SDL_FreeSurface(tmp_pic);
-      break;
+      DEBUGMSG(debug_loaders, "set_format(): handling IMG_ALPHA mode.\n");
+      return SDL_DisplayFormatAlpha(img);
     }
 
     case IMG_COLORKEY:
     {
-      SDL_LockSurface(tmp_pic);
-      SDL_SetColorKey(tmp_pic,
-                      (SDL_SRCCOLORKEY | SDL_RLEACCEL),
-                      SDL_MapRGB(tmp_pic->format, 255, 255, 0));
-      final_pic = SDL_DisplayFormat(tmp_pic);
-      SDL_FreeSurface(tmp_pic);
-      break;
+      DEBUGMSG(debug_loaders, "set_format(): handling IMG_COLORKEY mode.\n");
+      SDL_LockSurface(img);
+      SDL_SetColorKey(img, (SDL_SRCCOLORKEY | SDL_RLEACCEL),
+                      SDL_MapRGB(img->format, 255, 255, 0));
+      return SDL_DisplayFormat(img);
     }
 
     default:
     {
-      LOG ("Image mode not recognized\n");
+      DEBUGMSG(debug_loaders, "set_format(): Image mode not recognized\n");
     }
   }
 
-//  LOG( "LoadImage(): Done\n" );
-
-  return (final_pic);
+  return NULL;
 }
 
 
-
-/**********************
-LoadBothBkgds() : loads two scaled images: one for the user's native 
-resolution and one for 640x480 fullscreen. 
-Returns: the number of images that were scaled
-**********************/
-int LoadBothBkgds(const char* datafile)
+/* LoadBkgd() : a wrapper for LoadImage() that optimizes
+   the format of background image */
+SDL_Surface* LoadBkgd(const char* file_name, int width, int height)
 {
-  int ret = 0;
   SDL_Surface* orig = NULL;
-  
-  //Avoid memory leak in case something else already loaded:
-  FreeBothBkgds();
+  SDL_Surface* final_pic = NULL;
 
-  LOG("Entering LoadBothBkgds()\n");
+  orig = LoadScaledImage(file_name, IMG_REGULAR, width, height);
 
-  orig = LoadImage(datafile, IMG_REGULAR);
-
-  DEBUGCODE
+  if (!orig)
   {
-     printf("Scaling %dx%d to: %dx%d, %dx%d\n", 
-           orig->w, orig->h, RES_X, RES_Y, fs_res_x, fs_res_y);
+    DEBUGMSG(debug_loaders, "In LoadBkgd(), LoadImage() returned NULL on %s\n",
+             file_name);
+    return NULL;
   }
 
-  if (orig->w == RES_X && orig->h == RES_Y)
-  {
-    win_bkgd = orig;
-  }
-  else
-  {
-    win_bkgd = zoom(orig, RES_X, RES_Y);
-    ++ret;
-  }
-  
-  if (orig->w == fs_res_x && orig->h == fs_res_y)
-  {
-    fullscr_bkgd = orig;
-  }
-  else
-  {
-    fullscr_bkgd = zoom(orig, fs_res_x, fs_res_y);
-    ++ret;
-  }
-  
-  if (ret == 2) //orig won't be used at all
-    SDL_FreeSurface(orig);
-    
-  DEBUGCODE
-  {
-    printf("%d images scaled\nLeaving LoadBothBkgds()\n", ret);
-  }
-  return ret;
+  /* turn off transparency, since it's the background */
+  SDL_SetAlpha(orig, SDL_RLEACCEL, SDL_ALPHA_OPAQUE);
+  final_pic = SDL_DisplayFormat(orig); /* optimize the format */
+  SDL_FreeSurface(orig);
+
+  return final_pic;
 }
 
 
-SDL_Surface* CurrentBkgd(void)
+sprite* LoadSprite(const char* name, int mode)
 {
-  if (!screen)
-    return NULL;
-  if (screen->flags & SDL_FULLSCREEN)
-    return fullscr_bkgd;
-  else
-    return win_bkgd;
+  return LoadScaledSprite(name, mode, -1, -1);
 }
 
-void FreeBothBkgds(void)
+sprite* LoadScaledSprite(const char* name, int mode, int width, int height)
 {
-  if (win_bkgd)
-    SDL_FreeSurface(win_bkgd);
-  win_bkgd = NULL;
+  return load_sprite(name, mode, width, height, false);
+}
 
-  if (fullscr_bkgd)
-    SDL_FreeSurface(fullscr_bkgd);
-  fullscr_bkgd = NULL;
+sprite* LoadSpriteOfBoundingBox(const char* name, int mode, int max_width, int max_height)
+{
+  return load_sprite(name, mode, max_width, max_height, true);
 }
 
+sprite* load_sprite(const char* name, int mode, int w, int h, bool proportional)
+{
+  sprite *new_sprite = NULL;
+  char fn[PATH_MAX];
+  int i, width, height;
 
-sprite* FlipSprite(sprite* in, int X, int Y ) {
-	sprite* out;
+#ifdef HAVE_RSVG
+  /* check if SVG sprite file is present */
+  sprintf(fn, "%s.svg", name);
+  if(1 == CheckFile(fn))
+  {
+    if(proportional)
+    {
+      get_svg_dimensions(fn, &width, &height);
+      if(width > 0 && height > 0)
+        fit_in_rectangle(&width, &height, w, h);
+    }
+    else
+    {
+      width = w;
+      height = h;
+    }
 
-	out = malloc(sizeof(sprite));
-	if (in->default_img != NULL)
-		out->default_img = Flip( in->default_img, X, Y );
-	else
-		out->default_img = NULL;
-	for ( out->num_frames=0; out->num_frames<in->num_frames; out->num_frames++ )
-		out->frame[out->num_frames] = Flip( in->frame[out->num_frames], X, Y );
-	out->cur = 0;
-	return out;
-}
+    new_sprite = load_svg_sprite(fn, width, height);
 
-sprite* LoadSprite(const char* name, int MODE ) {
-	sprite *new_sprite;
-	char fn[FNLEN];
-	int x;
+    if(new_sprite)
+    {
+      set_format(new_sprite->default_img, mode);
+      for(i = 0; i < new_sprite->num_frames; i++)
+        set_format(new_sprite->frame[i], mode);
+      new_sprite->cur = 0;
+    }
+  }
+#endif
 
-	/* JA --- HACK check out what has changed with new code */
+  if(!new_sprite)
+  {
+    /* SVG sprite was not loaded, try to load it frame by frame from PNG files */
+    new_sprite = malloc(sizeof(sprite));
 
-	new_sprite = malloc(sizeof(sprite));
+    sprintf(fn, "%sd.png", name);  // The 'd' means the default image
+    if(proportional)
+      new_sprite->default_img = LoadImageOfBoundingBox(fn, mode | IMG_NOT_REQUIRED, w, h);
+    else
+      new_sprite->default_img = LoadScaledImage(fn, mode | IMG_NOT_REQUIRED, w, h);
 
-	sprintf(fn, "%sd.png", name);
-	new_sprite->default_img = LoadImage( fn, MODE|IMG_NOT_REQUIRED );
-	for (x = 0; x < MAX_SPRITE_FRAMES; x++) {
-		sprintf(fn, "%s%d.png", name, x);
-		new_sprite->frame[x] = LoadImage( fn, MODE|IMG_NOT_REQUIRED );
-		if ( new_sprite->frame[x] == NULL ) {
-			new_sprite->cur = 0;
-			new_sprite->num_frames = x;
-			break;
-		}
-	}
+    if(!new_sprite->default_img)
+      DEBUGMSG(debug_loaders, "load_sprite(): failed to load default image for %s\n", name);
 
-	DEBUGCODE {
-		fprintf( stderr, "loading sprite %s - contains %d frames\n",
-		        name, new_sprite->num_frames );
-	}
+    for(i = 0; i < MAX_SPRITE_FRAMES; i++)
+    {
+      sprintf(fn, "%s%d.png", name, i);
+      if(proportional)
+        new_sprite->frame[i] = LoadImageOfBoundingBox(fn, mode | IMG_NOT_REQUIRED, w, h);
+      else
+        new_sprite->frame[i] = LoadScaledImage(fn, mode | IMG_NOT_REQUIRED, w, h);
 
-	return new_sprite;
+      if(new_sprite->frame[i] == NULL)
+      {
+        new_sprite->cur = 0;
+        new_sprite->num_frames = i;
+        break;
+      }
+      else
+        DEBUGMSG(debug_loaders, "load_sprite(): loaded frame %d of %s\n", i, name);
+    }
+  }
+
+  return new_sprite;
 }
 
-void FreeSprite(sprite* gfx )
+sprite* FlipSprite(sprite* in, int X, int Y)
 {
+  sprite *out;
+
+  out = malloc(sizeof(sprite));
+  if (in->default_img != NULL)
+    out->default_img = Flip( in->default_img, X, Y );
+  else
+    out->default_img = NULL;
+  for( out->num_frames=0; out->num_frames<in->num_frames; out->num_frames++ )
+    out->frame[out->num_frames] = Flip( in->frame[out->num_frames], X, Y );
+  out->cur = 0;
+  return out;
+}
+
+void FreeSprite(sprite* gfx)
+{
   int x;
-
   if (!gfx)
     return;
- 
+
+  DEBUGMSG(debug_loaders, "Freeing image at %p", gfx);
   for (x = 0; x < gfx->num_frames; x++)
   {
+    DEBUGMSG(debug_loaders, ".");
     if (gfx->frame[x])
+    {
       SDL_FreeSurface(gfx->frame[x]);
+      gfx->frame[x] = NULL;
+    }
   }
+
   if (gfx->default_img)
+  {
     SDL_FreeSurface(gfx->default_img);
+    gfx->default_img = NULL;
+  }
+
+  DEBUGMSG(debug_loaders, "FreeSprite() - done\n");
   free(gfx);
 }
 
+void NextFrame(sprite* s)
+{
+  if (s && s->num_frames)
+    s->cur = (s->cur + 1) % s->num_frames;
+}
+
+
+
 /***************************
 	LoadSound : Load a sound/music patch from a file.
 ****************************/
-Mix_Chunk* LoadSound(const char* datafile )
+Mix_Chunk* LoadSound(char* datafile )
 { 
   Mix_Chunk* tempChunk = NULL;
   char fn[FNLEN];
@@ -505,32 +732,26 @@
   return NULL;
 }
 
+/* LoadMusic : Load music from a datafile */
+Mix_Music* LoadMusic(char *datafile )
+{
+  char fn[PATH_MAX];
+  Mix_Music* tempMusic = NULL;
 
-/************************
-	LoadMusic : Load
-	music from a datafile
-*************************/
-Mix_Music* LoadMusic(const char* datafile )
-{ 
-  Mix_Music* temp_music = NULL;
-  char fn[FNLEN];
-
-  /* First look under theme path if desired: */
-  if (!settings.use_english)
+  sprintf(fn, "%s", datafile);
+  if (1 != CheckFile(fn))
   {
-    sprintf(fn , "%s/sounds/%s", settings.theme_data_path, datafile);
-    temp_music = Mix_LoadMUS(fn);
-    if (temp_music)
-      return temp_music;
+    fprintf(stderr, "LoadMusic(): %s not found\n\n", fn);
+    return NULL;
   }
 
-  /* If nothing loaded yet, try default path: */
-  if (!temp_music)
+  tempMusic = Mix_LoadMUS(fn);
+
+  if (!tempMusic)
   {
-    sprintf(fn , "%s/sounds/%s", settings.default_data_path, datafile);
-    temp_music = Mix_LoadMUS(fn);
-    return temp_music;
+    fprintf(stderr, "LoadMusic(): %s not loaded successfully\n", fn);
+    printf("Error was: %s\n\n", Mix_GetError());
   }
-  // We never want to get here...
-  return temp_music;
+  return tempMusic;
 }
+

Modified: branches/commonification/tuxtype/trunk/src/main.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/main.c	2009-08-03 21:42:10 UTC (rev 1346)
+++ branches/commonification/tuxtype/trunk/src/main.c	2009-08-04 00:12:50 UTC (rev 1347)
@@ -20,12 +20,165 @@
 #include "funcs.h"
 #include "SDL_extras.h"
 
-SDL_Surface* screen;
 SDL_Event  event;
 
+/* global debug masks */
+int debug_status;
 
+/* bitmasks for debugging options */
+#ifndef HAVE_LIBT4KCOMMON
+const int debug_loaders        = 1 << 0;
+const int debug_menu           = 1 << 1;
+const int debug_menu_parser    = 1 << 2;
+const int debug_sdl            = 1 << 3;
+#endif
+const int debug_setup          = 1 << 4;
+const int debug_fileops        = 1 << 5;
+const int debug_titlescreen    = 1 << 6;
+const int debug_game           = 1 << 7;
+const int debug_factoroids     = 1 << 8;
+const int debug_lan            = 1 << 9;
+const int debug_mathcards      = 1 << 10;
+const int debug_lessons        = 1 << 11;
+const int debug_highscore      = 1 << 12;
+const int debug_options        = 1 << 13;
+const int debug_convert_utf    = 1 << 14;
+const int debug_multiplayer    = 1 << 15;
+#ifndef HAVE_LIBT4KCOMMON
+const int debug_all            = ~0;
+#endif
 
+void handle_command_args(int argc, char* argv[])
+{
+  int i;
 
+  for (i = 1; i < argc; i++)
+  {
+    if (  (strcmp(argv[i], "-h") == 0)
+       || (strcmp(argv[i], "--help") == 0)
+       || (strcmp(argv[i], "-help") == 0))
+    {
+      fprintf(stderr, "\nUsage:\n tuxtype [OPTION]...");
+      fprintf(stderr, "\n\nOptions:\n\n\t-h, --help, -help");
+      fprintf(stderr, "\n\t\tPrints this help message");
+      fprintf(stderr, "\n\n\t-f, --fullscreen");
+      fprintf(stderr, "\n\t\tSelects fullscreen display (default)");
+      fprintf(stderr, "\n\n\t-w, --window");
+      fprintf(stderr, "\n\t\tSelects windowed display (not fullscreen)");
+      fprintf(stderr, "\n\n\t-s, --sound");
+      fprintf(stderr, "\n\t\tAllow in-game sounds (default)");
+      fprintf(stderr, "\n\n\t-ns, --nosound");
+      fprintf(stderr, "\n\t\tDisables in-game sounds");
+      fprintf(stderr, "\n\n\t-t {THEME}, --theme {THEME}");
+      fprintf(stderr, "\n\t\tUse theme named {THEME}, if it exists");
+      fprintf(stderr, "\n\n\t-sp, --speed");
+      fprintf(stderr, "\n\t\tSpeed up gameplay (for use on slower");
+      fprintf(stderr, "\n\t\tmachines)");
+      fprintf(stderr, "\n\n\t-d, --debug");
+      fprintf(stderr, "\n\t\tEnable debug mode (output)\n");
+      fprintf(stderr, "\n\n\t-v, --version");
+      fprintf(stderr, "\n\t\tDisplay version number and exit\n");
+      exit(0);
+    }
+    else if (  (strcmp(argv[i], "-v") == 0)
+            || (strcmp(argv[i], "--version") == 0))
+    {
+      fprintf(stderr, "\n%s, Version %s\n", PACKAGE, VERSION);
+      fprintf(stderr, "Copyright (C) Sam Hart <hart at geekcomix.com>, under the GPL\n");
+      fprintf(stderr, "-See COPYING file for more info... Thx ;)\n\n");
+      exit(0);
+    }
+    else if (  (strcmp(argv[i], "-f") == 0)
+            || (strcmp(argv[i], "--fullscreen") == 0))
+      settings.fullscreen = 1;
+    else if (  (strcmp(argv[i], "-w") == 0)
+            || (strcmp(argv[i], "--window") == 0))
+      settings.fullscreen = 0;
+    else if (  (strcmp(argv[i], "-sp") == 0)
+            || (strcmp(argv[i], "--speed") == 0))
+      settings.speed_up = 1;
+    else if (  (strcmp(argv[i], "-d") == 0)
+            || (strcmp(argv[i], "--debug") == 0))
+      settings.debug_on = 1;
+    else if (  (strcmp(argv[i], "-s") == 0)
+            || (strcmp(argv[i], "--sound") == 0))
+      settings.sys_sound = 1;
+    else if (  (strcmp(argv[i], "-ns") == 0)
+            || (strcmp(argv[i], "--nosound") == 0))
+      settings.sys_sound = 0;
+    else if (  (strcmp(argv[i], "--hidden") == 0)
+            || (strcmp(argv[i], "-hidden") == 0))
+      settings.hidden = 1;
+    else if (  (strcmp(argv[i], "-t") == 0)
+            || (strcmp(argv[i], "--theme") == 0))
+      SetupPaths(argv[++i]);
+    else if (strcmp(argv[i], "--debug-all") == 0)
+    {
+      debug_status |= debug_all;
+    }
+    else if (strcmp(argv[i], "--debug-setup") == 0)
+    {
+      debug_status |= debug_setup;
+    }
+    else if (strcmp(argv[i], "--debug-fileops") == 0)
+    {
+      debug_status |= debug_fileops;
+    }
+    else if (strcmp(argv[i], "--debug-loaders") == 0)
+    {
+      debug_status |= debug_loaders;
+    }
+    else if (strcmp(argv[i], "--debug-titlescreen") == 0)
+    {
+      debug_status |= debug_titlescreen;
+    }
+    else if (strcmp(argv[i], "--debug-menu") == 0)
+    {
+      debug_status |= debug_menu;
+    }
+    else if (strcmp(argv[i], "--debug-menu-parser") == 0)
+    {
+      debug_status |= debug_menu_parser;
+    }
+    else if (strcmp(argv[i], "--debug-game") == 0)
+    {
+      debug_status |= debug_game;
+    }
+    else if (strcmp(argv[i], "--debug-factoroids") == 0)
+    {
+      debug_status |= debug_factoroids;
+    }
+    else if (strcmp(argv[i], "--debug-lan") == 0)
+    {
+      debug_status |= debug_lan;
+    }
+    else if (strcmp(argv[i], "--debug-mathcards") == 0)
+    {
+      debug_status |= debug_mathcards;
+    }
+    else if (strcmp(argv[i], "--debug-sdl") == 0)
+    {
+      debug_status |= debug_sdl;
+    }
+    else if (strcmp(argv[i], "--debug-lessons") == 0)
+    {
+      debug_status |= debug_lessons;
+    }
+    else if (strcmp(argv[i], "--debug-highscore") == 0)
+    {
+      debug_status |= debug_highscore;
+    }
+    else if (strcmp(argv[i], "--debug-options") == 0)
+    {
+      debug_status |= debug_options;
+    }
+    else
+    {
+      fprintf(stderr, "Unknown option: %s\n", argv[i]);
+    }
+  }
+}
+
 /********************
   main : init stuff
 *********************/
@@ -34,8 +187,6 @@
   Uint32 lib_flags = 0;
   int i;
 
-
-
   srand(time(NULL));
 
   Opts_Initialize(); // First, initialize settings with hard-coded defaults 
@@ -43,81 +194,6 @@
   SetupPaths(NULL);
   LoadSettings();    // Second, read saved any saved settings
 
-  // Third, check command line args as these should override saved settings
-  if (argc > 1) /* FIXME this could go into something like HandleCommandArgs() */
-  { 
-    for (i = 1; i < argc; i++)
-    {
-      if (  (strcmp(argv[i], "-h") == 0)
-         || (strcmp(argv[i], "--help") == 0)
-         || (strcmp(argv[i], "-help") == 0))
-      {
-        fprintf(stderr, "\nUsage:\n tuxtype [OPTION]...");
-        fprintf(stderr, "\n\nOptions:\n\n\t-h, --help, -help");
-        fprintf(stderr, "\n\t\tPrints this help message");
-        fprintf(stderr, "\n\n\t-f, --fullscreen");
-        fprintf(stderr, "\n\t\tSelects fullscreen display (default)");
-        fprintf(stderr, "\n\n\t-w, --window");
-        fprintf(stderr, "\n\t\tSelects windowed display (not fullscreen)");
-        fprintf(stderr, "\n\n\t-s, --sound");
-        fprintf(stderr, "\n\t\tAllow in-game sounds (default)");
-        fprintf(stderr, "\n\n\t-ns, --nosound");
-        fprintf(stderr, "\n\t\tDisables in-game sounds");
-        fprintf(stderr, "\n\n\t-t {THEME}, --theme {THEME}");
-        fprintf(stderr, "\n\t\tUse theme named {THEME}, if it exists");
-        fprintf(stderr, "\n\n\t-sp, --speed");
-        fprintf(stderr, "\n\t\tSpeed up gameplay (for use on slower");
-        fprintf(stderr, "\n\t\tmachines)");
-        fprintf(stderr, "\n\n\t-d, --debug");
-        fprintf(stderr, "\n\t\tEnable debug mode (output)\n");
-        fprintf(stderr, "\n\n\t-v, --version");
-        fprintf(stderr, "\n\t\tDisplay version number and exit\n");
-        exit(0);
-      }
-
-      if (  (strcmp(argv[i], "-v") == 0)
-         || (strcmp(argv[i], "--version") == 0))
-      {
-        fprintf(stderr, "\n%s, Version %s\n", PACKAGE, VERSION);
-        fprintf(stderr, "Copyright (C) Sam Hart <hart at geekcomix.com>, under the GPL\n");
-        fprintf(stderr, "-See COPYING file for more info... Thx ;)\n\n");
-        exit(0);
-      }
-
-      if (  (strcmp(argv[i], "-f") == 0)
-         || (strcmp(argv[i], "--fullscreen") == 0))
-        settings.fullscreen = 1;
-
-      if (  (strcmp(argv[i], "-w") == 0)
-         || (strcmp(argv[i], "--window") == 0))
-        settings.fullscreen = 0;
-
-      if (  (strcmp(argv[i], "-sp") == 0)
-         || (strcmp(argv[i], "--speed") == 0))
-        settings.speed_up = 1;
-
-      if (  (strcmp(argv[i], "-d") == 0)
-         || (strcmp(argv[i], "--debug") == 0))
-        settings.debug_on = 1;
-
-      if (  (strcmp(argv[i], "-s") == 0)
-         || (strcmp(argv[i], "--sound") == 0))
-        settings.sys_sound = 1;
-
-      if (  (strcmp(argv[i], "-ns") == 0)
-         || (strcmp(argv[i], "--nosound") == 0))
-        settings.sys_sound = 0;
-
-      if (  (strcmp(argv[i], "--hidden") == 0)
-         || (strcmp(argv[i], "-hidden") == 0))
-        settings.hidden = 1;
-
-      if (  (strcmp(argv[i], "-t") == 0)
-         || (strcmp(argv[i], "--theme") == 0))
-        SetupPaths(argv[++i]);
-    }
-  }
-
   DEBUGCODE
   {
     fprintf(stderr, "\n%s, version %s BEGIN\n", PACKAGE, VERSION);




More information about the Tux4kids-commits mailing list