[Tux4kids-commits] r520 - tuxmath/trunk/src

cheezmeister-guest at alioth.debian.org cheezmeister-guest at alioth.debian.org
Sun Jun 15 02:12:10 UTC 2008


Author: cheezmeister-guest
Date: 2008-06-15 02:12:09 +0000 (Sun, 15 Jun 2008)
New Revision: 520

Modified:
   tuxmath/trunk/src/loaders.c
   tuxmath/trunk/src/mathcards.c
   tuxmath/trunk/src/titlescreen.c
   tuxmath/trunk/src/titlescreen.h
Log:
Scaled backgrounds in the titlescreen.



Modified: tuxmath/trunk/src/loaders.c
===================================================================
--- tuxmath/trunk/src/loaders.c	2008-06-14 20:51:53 UTC (rev 519)
+++ tuxmath/trunk/src/loaders.c	2008-06-15 02:12:09 UTC (rev 520)
@@ -162,6 +162,7 @@
     }
     /* If image was required, exit from program: */
     fprintf(stderr, "ERROR could not load required graphics file %s\n", datafile);
+    fprintf(stderr, "%s", SDL_GetError() );
     cleanup_on_error();
   }
 
@@ -240,6 +241,43 @@
     return zoom(orig, screen->w, screen->h);
   }
 }
+/**********************
+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(char* datafile, SDL_Surface** fs_bkgd, SDL_Surface** win_bkgd)
+{
+  int ret = 0;
+  SDL_Surface* orig = NULL;
+  
+  orig = LoadImage(datafile, IMG_REGULAR);
+  
+  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)
+  {
+    *fs_bkgd = orig;
+  }
+  else
+  {
+    *fs_bkgd = zoom(orig, fs_res_x, fs_res_y);
+    ++ret;
+  }
+  
+  if (ret == 2) //orig won't be used at all
+    SDL_FreeSurface(orig);
+    
+  return ret;
+}
 
 
 sprite* FlipSprite( sprite *in, int X, int Y ) {

Modified: tuxmath/trunk/src/mathcards.c
===================================================================
--- tuxmath/trunk/src/mathcards.c	2008-06-14 20:51:53 UTC (rev 519)
+++ tuxmath/trunk/src/mathcards.c	2008-06-15 02:12:09 UTC (rev 520)
@@ -504,7 +504,7 @@
   questions_pending--;
 
   /* add question to wrong_quests list: */
-  {
+  
   MC_MathQuestion* ptr1;
   MC_MathQuestion* ptr2;
 
@@ -560,8 +560,8 @@
   #endif
 
   return 1;
+
 }
-}
 
 /* Tells user interface if all questions have been answered correctly! */
 /* Requires that at list contained at least one question to start with */

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2008-06-14 20:51:53 UTC (rev 519)
+++ tuxmath/trunk/src/titlescreen.c	2008-06-15 02:12:09 UTC (rev 520)
@@ -125,7 +125,7 @@
 	 beak;
 
 /* The background image scaled to fullscreen dimensions */
-SDL_Surface* scaled_bkgd = NULL;
+SDL_Surface* scaled_bkg = NULL;
 /* Set to images[IMG_MENU_BKG] if windowed, scaled_bkgd if fullscreen. */
 SDL_Surface* current_bkg = NULL; //DON'T SDL_Free()!
 /* "Easter Egg" cursor */
@@ -253,9 +253,9 @@
     return;
   }
 
-//  if (screen->flags & SDL_FULLSCREEN)
-//    current_bkg = scaled_bkgd;
-//  else
+  if (screen->flags & SDL_FULLSCREEN)
+    current_bkg = scaled_bkg;
+  else
     current_bkg = images[IMG_MENU_BKG];
   /* Draw background, if it loaded OK: */
   if (current_bkg)
@@ -432,7 +432,8 @@
   }
   egg = LoadImage("title/egg.png", 
                   IMG_COLORKEY | IMG_NOT_REQUIRED);
-  scaled_bkgd = zoom(images[IMG_MENU_BKG], fs_res_x, fs_res_y);
+  //scaled_bkg = zoom(images[IMG_MENU_BKG], fs_res_x, fs_res_y);
+  LoadBothBkgds("title/menu_bkg.jpg", &scaled_bkg, &bkg);
   return 1;
 }
 
@@ -457,7 +458,8 @@
   Tux = NULL;
   TitleScreen_unload_menu();
   SDL_FreeSurface(egg);
-  SDL_FreeSurface(scaled_bkgd);
+  SDL_FreeSurface(bkg);
+  SDL_FreeSurface(scaled_bkg);
 }
 
 
@@ -524,7 +526,7 @@
 #endif
 
   /* Redraw background: */
-  if (images[IMG_MENU_BKG])
+  if (current_bkg)
     SDL_BlitSurface( current_bkg, NULL, screen, &Backrect );
 
   /* Red "Stop" circle in upper right corner to go back to main menu: */
@@ -2148,10 +2150,10 @@
 /* Recalculate on-screen locations for title screen elements */
 void RecalcTitlePositions()
 {
-//  if (screen->flags & SDL_FULLSCREEN)
-//    current_bkg = scaled_bkgd;
-//  else
-    current_bkg = images[IMG_MENU_BKG];
+  if (screen->flags & SDL_FULLSCREEN)
+    current_bkg = scaled_bkg;
+  else
+    current_bkg = bkg;
   Backrect = current_bkg->clip_rect;
   Backrect.x = (screen->w - Backrect.w) / 2;
   Backrect.y = (screen->h - Backrect.h) / 2;

Modified: tuxmath/trunk/src/titlescreen.h
===================================================================
--- tuxmath/trunk/src/titlescreen.h	2008-06-14 20:51:53 UTC (rev 519)
+++ tuxmath/trunk/src/titlescreen.h	2008-06-15 02:12:09 UTC (rev 520)
@@ -113,7 +113,7 @@
 //extern TTF_Font  *font;
 extern SDL_Event  event;
 
-extern SDL_Surface *bkg;
+SDL_Surface *bkg;
 
 #define MUSIC_FADE_OUT_MS	80
 
@@ -157,7 +157,7 @@
 /*In titlescreen.c */
 void TitleScreen(void);
 int ChooseMission(void);  //FIXME really should be in fileops.c
-int choose_menu_item(const unsigned char**, sprite**, int, menu_options* menu_opts, void (*)(menu_options*) );
+int choose_menu_item(const unsigned char**, sprite**, int, menu_options*, void (*)(menu_options*) );
 void set_default_menu_options(menu_options *);
 
 
@@ -167,6 +167,7 @@
 Mix_Chunk   *LoadSound( char* datafile );
 SDL_Surface *LoadImage( char* datafile, int mode );
 SDL_Surface* LoadBkgd(char* datafile);
+int          LoadBothBkgds(char* datafile, SDL_Surface** fs_bkgd, SDL_Surface** win_bkgd);
 sprite      *LoadSprite( char* name, int MODE );
 sprite      *FlipSprite( sprite* in, int X, int Y );
 void         FreeSprite( sprite* gfx );




More information about the Tux4kids-commits mailing list