[Tux4kids-commits] r537 - in tuxmath/trunk: doc src

cheezmeister-guest at alioth.debian.org cheezmeister-guest at alioth.debian.org
Thu Jun 19 17:29:05 UTC 2008


Author: cheezmeister-guest
Date: 2008-06-19 17:29:04 +0000 (Thu, 19 Jun 2008)
New Revision: 537

Modified:
   tuxmath/trunk/doc/changelog
   tuxmath/trunk/src/highscore.c
   tuxmath/trunk/src/titlescreen.c
   tuxmath/trunk/src/titlescreen.h
Log:
Tweaked menu locations and fixed issues redrawing upon returning
from a game.


Modified: tuxmath/trunk/doc/changelog
===================================================================
--- tuxmath/trunk/doc/changelog	2008-06-19 02:56:27 UTC (rev 536)
+++ tuxmath/trunk/doc/changelog	2008-06-19 17:29:04 UTC (rev 537)
@@ -1,3 +1,10 @@
+2008.June.19 (svn.debian.org/tux4kids - revision 537)
+      Code:
+        Tweaked menu locations for larger screens and fixed a number of
+	issues redrawing upon returning to the menu from a game.
+
+      Brendan Luchen
+
 2008.June.14 (svn.debian.org/tux4kids - revision 521)
       Graphics:
         New 1280x1024 versions of background images (from Debian Etch at

Modified: tuxmath/trunk/src/highscore.c
===================================================================
--- tuxmath/trunk/src/highscore.c	2008-06-19 02:56:27 UTC (rev 536)
+++ tuxmath/trunk/src/highscore.c	2008-06-19 17:29:04 UTC (rev 537)
@@ -166,8 +166,8 @@
     if (diff_level != old_diff_level)
     {
       /* Draw background: */
-      if (current_bkg)
-        SDL_BlitSurface( current_bkg, NULL, screen, NULL );
+      if (current_bkg())
+        SDL_BlitSurface( current_bkg(), NULL, screen, NULL );
       /* FIXME maybe add image of trophy or similar pic */
       /* Draw Tux: */
       if (Tux && Tux->frame[0]) /* make sure sprite has at least one frame */
@@ -383,8 +383,8 @@
 
 
   /* Draw background: */
-  if (current_bkg)
-    SDL_BlitSurface(current_bkg, NULL, screen, NULL);
+  if (current_bkg())
+    SDL_BlitSurface(current_bkg(), NULL, screen, NULL);
 
   /* Red "Stop" circle in upper right corner to go back to main menu: */
   if (images[IMG_STOP])
@@ -524,7 +524,7 @@
             /* Redraw background and shading in area where we drew text last time: */ 
             if (!first_draw)
             {
-              SDL_BlitSurface(current_bkg, &redraw_rect, screen, &redraw_rect);
+              SDL_BlitSurface(current_bkg(), &redraw_rect, screen, &redraw_rect);
               DrawButton(&redraw_rect, 0, REG_RGBA);
               SDL_UpdateRect(screen,
                              redraw_rect.x,

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2008-06-19 02:56:27 UTC (rev 536)
+++ tuxmath/trunk/src/titlescreen.c	2008-06-19 17:29:04 UTC (rev 537)
@@ -127,12 +127,13 @@
 SDL_Surface* bkg = NULL;
 /* The background image scaled to fullscreen dimensions */
 SDL_Surface* scaled_bkg = NULL;
-/* Set to bkg if windowed, scaled_bkgd if fullscreen. */
-SDL_Surface* current_bkg = NULL; //DON'T SDL_Free()!
 /* "Easter Egg" cursor */
 SDL_Surface* egg = NULL; 
 int egg_active = 0; //are we currently using the egg cursor?
 
+SDL_Surface* current_bkg()
+  { return screen->flags & SDL_FULLSCREEN ? scaled_bkg : bkg; }
+  
 /* Local function prototypes: */
 void TitleScreen_load_menu(void);
 void TitleScreen_unload_menu(void);
@@ -254,22 +255,18 @@
     return;
   }
 
-  if (screen->flags & SDL_FULLSCREEN)
-    current_bkg = scaled_bkg;
-  else
-    current_bkg = bkg;
   /* Draw background, if it loaded OK: */
-  if (current_bkg)
+  if (current_bkg() )
   {
-    Backrect.x = (screen->w - current_bkg->w) / 2;
-    Backrect.y = (screen->h - current_bkg->h) / 2;
-    Backrect.w = current_bkg->w;
-    Backrect.h = current_bkg->h;
+    Backrect.x = (screen->w - current_bkg()->w) / 2;
+    Backrect.y = (screen->h - current_bkg()->h) / 2;
+    Backrect.w = current_bkg()->w;
+    Backrect.h = current_bkg()->h;
     /* FIXME not sure TransWipe() works in Windows: */
-    TransWipe(current_bkg, RANDOM_WIPE, 10, 20);
+    TransWipe(current_bkg(), RANDOM_WIPE, 10, 20);
     /* Make sure background gets drawn (since TransWipe() doesn't */
     /* seem to work reliably as of yet):                          */
-    SDL_BlitSurface(current_bkg, NULL, screen, &Backrect);
+    SDL_BlitSurface(current_bkg(), NULL, screen, &Backrect);
 
   }
   /* Red "Stop" circle in upper right corner to go back to main menu: */
@@ -286,7 +283,7 @@
   /* --- Pull tux & logo onscreen --- */
   /* NOTE we wind up with Tuxdest.y == (screen->h)  - (Tux->frame[0]->h), */
   /* and Titledest.x == 0.                                                */
-  if (current_bkg
+  if (current_bkg()
    && images[IMG_MENU_TITLE]
    && images[IMG_STOP]
    && Tux && Tux->frame[0])
@@ -319,9 +316,9 @@
       start = SDL_GetTicks();
 
       //Draw the entire background, over a black screen if necessary
-      if (current_bkg->w != screen->w || current_bkg->h != screen->h)
+      if (current_bkg()->w != screen->w || current_bkg()->h != screen->h)
         SDL_FillRect(screen, &screen->clip_rect, 0);
-      SDL_BlitSurface(current_bkg, NULL, screen, &Backrect);
+      SDL_BlitSurface(current_bkg(), NULL, screen, &Backrect);
 
       Tuxdest.y -= TuxPixSkip;
       //Tuxback.y -= Tux->frame[0]->h / (PRE_ANIM_FRAMES * PRE_FRAME_MULT);
@@ -515,8 +512,8 @@
 #endif
 
   /* Redraw background: */
-  if (current_bkg)
-    SDL_BlitSurface( current_bkg, NULL, screen, &Backrect );
+  if (current_bkg() )
+    SDL_BlitSurface( current_bkg(), NULL, screen, &Backrect );
 
   /* Red "Stop" circle in upper right corner to go back to main menu: */
   if (images[IMG_STOP])
@@ -684,6 +681,7 @@
 	if (Opts_MenuMusic())  //Turn menu music off for game
 	  {audioMusicUnload();}
 	game();
+	RecalcTitlePositions();
 	if (Opts_MenuMusic()) //Turn menu music back on
 	  {audioMusicLoad( "tuxi.ogg", -1 );}
 	Opts_SetHelpMode(0);
@@ -806,6 +804,7 @@
       audioMusicUnload();
 
     game();
+    RecalcTitlePositions();
     write_user_config_file();
 
     if (Opts_MenuMusic())
@@ -866,6 +865,7 @@
       {
 	audioMusicUnload();
 	game();
+	RecalcTitlePositions();
 	if (Opts_MenuMusic()) {
 	  audioMusicLoad( "tuxi.ogg", -1 );
 	}
@@ -1323,8 +1323,8 @@
   }
 
   /**** Draw background, title, and Tux:                            ****/
-  if (current_bkg)
-    SDL_BlitSurface(current_bkg, NULL, screen, &Backrect);
+  if (current_bkg() )
+    SDL_BlitSurface(current_bkg(), NULL, screen, &Backrect);
   if (images[IMG_MENU_TITLE])
     SDL_BlitSurface(images[IMG_MENU_TITLE], NULL, screen, &Titledest);
   if (Tux && Tux->frame[0])
@@ -1627,10 +1627,10 @@
       tmdprintf("Updating entire screen\n");
       /* This is a full-screen redraw */
       /* Redraw background, title, stop button, and Tux: */
-      if (!current_bkg || screen->flags & SDL_FULLSCREEN )
+      if (!current_bkg() || screen->flags & SDL_FULLSCREEN )
         SDL_FillRect(screen, &screen->clip_rect, 0); //clear to black
-      if (current_bkg)
-        SDL_BlitSurface(current_bkg, NULL, screen, &Backrect);
+      if (current_bkg())
+        SDL_BlitSurface(current_bkg(), NULL, screen, &Backrect);
       if (images[IMG_MENU_TITLE])
         SDL_BlitSurface(images[IMG_MENU_TITLE], NULL, screen, &Titledest);
       if (images[IMG_STOP])
@@ -1698,11 +1698,11 @@
 	use_sprite = (menu_sprites != NULL && old_loc >= title_offset && menu_sprites[old_loc-title_offset] != NULL);
         temp_rect = menu_button_rect[imod];
         SDL_FillRect(screen, &temp_rect, 0);
-	SDL_BlitSurface(current_bkg, &back_button_rect[imod], screen, &temp_rect);   // redraw background
+	SDL_BlitSurface(current_bkg(), &back_button_rect[imod], screen, &temp_rect);   // redraw background
 	if (use_sprite) {
 	  // Some of the sprites extend beyond the menu button, so we
 	  // have to make sure we redraw in the sprite rects, too
-	  SDL_BlitSurface(current_bkg, &back_sprite_rect[imod], screen, &temp_rect);
+	  SDL_BlitSurface(current_bkg(), &back_sprite_rect[imod], screen, &temp_rect);
 	}
 	DrawButton(&menu_button_rect[imod], 10, REG_RGBA);  // draw button
 	//temp_rect = menu_text_rect[imod];
@@ -1745,7 +1745,7 @@
 	imod = loc-loc_screen_start;
 	//SDL_BlitSurface(current_bkg, &menu_button_rect[imod], screen, &menu_button_rect[imod]);
 	temp_rect = menu_sprite_rect[imod];
-	SDL_BlitSurface(current_bkg, &back_sprite_rect[imod], screen, &temp_rect);
+	SDL_BlitSurface(current_bkg(), &back_sprite_rect[imod], screen, &temp_rect);
 	DrawButton(&menu_button_rect[imod], 10, SEL_RGBA);
 	//SDL_BlitSurface(menu_item_selected[loc], NULL, screen, &menu_text_rect[imod]);
 	// Note: even though the whole button was redrawn, we don't
@@ -1790,7 +1790,7 @@
     if (Tux && tux_frame)
     {
       /* Redraw background to keep edges anti-aliased properly: */
-      SDL_BlitSurface(current_bkg,&Tuxdest, screen, &Tuxdest);
+      SDL_BlitSurface(current_bkg(),&Tuxdest, screen, &Tuxdest);
       SDL_BlitSurface(Tux->frame[tux_frame - 1], NULL, screen, &Tuxdest);
       SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h);
       //SDL_UpdateRect(screen, 0, 0, 0, 0);
@@ -2125,8 +2125,8 @@
 void set_default_menu_options(menu_options *menu_opts)
 {
   menu_opts->starting_entry = 0;
-  menu_opts->xleft = screen->w / 2 - 60;
-  menu_opts->ytop = (screen->h - current_bkg->h) / 2 + 100;
+  menu_opts->xleft = screen->w / 2 - screen->w * 3 / 32;
+  menu_opts->ytop = screen->h / 2 - 140;
   // Leave room for arrows at the bottom:
   menu_opts->ybottom = screen->h - images[IMG_LEFT]->h - 20;
   menu_opts->buttonheight = -1;
@@ -2139,11 +2139,7 @@
 /* Recalculate on-screen locations for title screen elements */
 void RecalcTitlePositions()
 {
-  if (screen->flags & SDL_FULLSCREEN)
-    current_bkg = scaled_bkg;
-  else
-    current_bkg = bkg;
-  Backrect = current_bkg->clip_rect;
+  Backrect = current_bkg()->clip_rect;
   Backrect.x = (screen->w - Backrect.w) / 2;
   Backrect.y = (screen->h - Backrect.h) / 2;
   
@@ -2312,7 +2308,7 @@
       {
       SDL_ShowCursor(SDL_ENABLE);
       //SDL_FillRect(screen, &cursor, 0);
-      SDL_BlitSurface(current_bkg, NULL, screen, &Backrect); //cover egg up once more
+      SDL_BlitSurface(current_bkg(), NULL, screen, &Backrect); //cover egg up once more
       SDL_WarpMouse(cursor.x, cursor.y);
       SDL_UpdateRect(screen, cursor.x, cursor.y, cursor.w, cursor.h); //egg->x, egg->y, egg->w, egg->h);
       egg_active = 0;

Modified: tuxmath/trunk/src/titlescreen.h
===================================================================
--- tuxmath/trunk/src/titlescreen.h	2008-06-19 02:56:27 UTC (rev 536)
+++ tuxmath/trunk/src/titlescreen.h	2008-06-19 17:29:04 UTC (rev 537)
@@ -113,7 +113,7 @@
 //extern TTF_Font  *font;
 extern SDL_Event  event;
 
-extern SDL_Surface *current_bkg;
+SDL_Surface* current_bkg(); //appropriate background for current video mode
 
 #define MUSIC_FADE_OUT_MS	80
 
@@ -163,7 +163,7 @@
 
 /* in loaders.c (from tuxtype): */
 int         checkFile( const char *file );
-TTF_Font* LoadFont(const unsigned char* font_name, int font_size);
+TTF_Font*    LoadFont(const unsigned char* font_name, int font_size);
 Mix_Chunk   *LoadSound( char* datafile );
 SDL_Surface *LoadImage( char* datafile, int mode );
 SDL_Surface* LoadBkgd(char* datafile);




More information about the Tux4kids-commits mailing list