[Tux4kids-commits] r1395 - in branches/commonification: tux4kids-common/trunk/src tuxmath/trunk/src tuxtype/trunk/src

Bolesław Kulbabiński bolekk-guest at alioth.debian.org
Sat Aug 8 10:46:47 UTC 2009


Author: bolekk-guest
Date: 2009-08-08 10:46:47 +0000 (Sat, 08 Aug 2009)
New Revision: 1395

Modified:
   branches/commonification/tux4kids-common/trunk/src/t4k-menu.c
   branches/commonification/tuxmath/trunk/src/SDL_extras.h
   branches/commonification/tuxmath/trunk/src/compiler.h
   branches/commonification/tuxmath/trunk/src/game.c
   branches/commonification/tuxmath/trunk/src/menu.c
   branches/commonification/tuxmath/trunk/src/pixels.c
   branches/commonification/tuxmath/trunk/src/titlescreen.c
   branches/commonification/tuxtype/trunk/src/funcs.h
   branches/commonification/tuxtype/trunk/src/menu.c
   branches/commonification/tuxtype/trunk/src/titlescreen.c
   branches/commonification/tuxtype/trunk/src/titlescreen.h
Log:
re-rendering titlescreen and menu if resolution changed while running game

Modified: branches/commonification/tux4kids-common/trunk/src/t4k-menu.c
===================================================================
--- branches/commonification/tux4kids-common/trunk/src/t4k-menu.c	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tux4kids-common/trunk/src/t4k-menu.c	2009-08-08 10:46:47 UTC (rev 1395)
@@ -327,6 +327,7 @@
   int i;
   int stop = 0;
   int items;
+  int old_w, old_h;
 
   int action = NONE;
 
@@ -675,6 +676,8 @@
                   }
                   else
                   {
+                    old_w = GetScreen()->w;
+                    old_h = GetScreen()->h;
                     if(handle_activity(tmp_node->activity, tmp_node->param) == QUIT)
                     {
                       DEBUGMSG(debug_menu, "run_menu(): handle_activity() returned QUIT message, exiting.\n");
@@ -682,6 +685,8 @@
                       FreeSurfaceArray(menu_item_selected, items);
                       return QUIT;
                     }
+                    if(old_w != GetScreen()->w || old_h != GetScreen()->h)
+                      PrerenderAll();
                   }
                 }
               }

Modified: branches/commonification/tuxmath/trunk/src/SDL_extras.h
===================================================================
--- branches/commonification/tuxmath/trunk/src/SDL_extras.h	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxmath/trunk/src/SDL_extras.h	2009-08-08 10:46:47 UTC (rev 1395)
@@ -72,6 +72,8 @@
 int             EraseSprite(sprite* img, SDL_Surface* curr_bkgd, int x, int y);
 int             EraseObject(SDL_Surface* surf, SDL_Surface* curr_bkgd, int x, int y);
 
+#endif //HAVE_LIBT4KCOMMON
+
 /*Text rendering functions: */
 int             Setup_SDL_Text(void);
 void            Cleanup_SDL_Text(void);
@@ -80,4 +82,3 @@
 SDL_Surface*    SimpleTextWithOffset(const char *t, int size, SDL_Color* col, int *glyph_offset);
 
 #endif
-#endif

Modified: branches/commonification/tuxmath/trunk/src/compiler.h
===================================================================
--- branches/commonification/tuxmath/trunk/src/compiler.h	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxmath/trunk/src/compiler.h	2009-08-08 10:46:47 UTC (rev 1395)
@@ -32,7 +32,7 @@
   code, with blessings of Bill Kendrick.
 
 */
-
+#include "config.h"
 #ifndef HAVE_LIBT4KCOMMON
 #ifdef WIN32
 /* Horrible, dangerous macros. */

Modified: branches/commonification/tuxmath/trunk/src/game.c
===================================================================
--- branches/commonification/tuxmath/trunk/src/game.c	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxmath/trunk/src/game.c	2009-08-08 10:46:47 UTC (rev 1395)
@@ -220,7 +220,7 @@
       return 0;
   }
 
-  rt.w = 100000; /* these images may be long */
+  rt.w = 10000; /* these images may be long */
   rt.h = CONSOLE_SCREEN_H * images[IMG_CONSOLE_LED]->h;
   if(!SetImage(IMG_LEDNUMS, &rt))
     return 0;

Modified: branches/commonification/tuxmath/trunk/src/menu.c
===================================================================
--- branches/commonification/tuxmath/trunk/src/menu.c	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxmath/trunk/src/menu.c	2009-08-08 10:46:47 UTC (rev 1395)
@@ -11,7 +11,6 @@
   Copyright: See COPYING file that comes with this distribution.
 */
 
-#ifndef HAVE_LIBT4KCOMMON
 #include "globals.h"
 #include "menu.h"
 #include "loaders.h"
@@ -22,6 +21,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifndef HAVE_LIBT4KCOMMON
+
 struct mNode {
   struct mNode* parent;
 
@@ -336,6 +337,7 @@
   int i;
   int stop = 0;
   int items;
+  int old_w, old_h;
 
   int action = NONE;
 
@@ -684,6 +686,8 @@
                   }
                   else
                   {
+                    old_w = GetScreen()->w;
+                    old_h = GetScreen()->h;
                     if(handle_activity(tmp_node->activity, tmp_node->param) == QUIT)
                     {
                       DEBUGMSG(debug_menu, "run_menu(): handle_activity() returned QUIT message, exiting.\n");
@@ -691,6 +695,8 @@
                       FreeSurfaceArray(menu_item_selected, items);
                       return QUIT;
                     }
+                    if(old_w != GetScreen()->w || old_h != GetScreen()->h)
+                      PrerenderAll();
                   }
                 }
               }

Modified: branches/commonification/tuxmath/trunk/src/pixels.c
===================================================================
--- branches/commonification/tuxmath/trunk/src/pixels.c	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxmath/trunk/src/pixels.c	2009-08-08 10:46:47 UTC (rev 1395)
@@ -27,10 +27,10 @@
   $Id: pixels.c,v 1.3 2006/08/27 21:00:55 wkendrick Exp $
 */
 
-#ifndef HAVE_LIBT4KCOMMON
+#include "tuxmath.h"
 #include "pixels.h"
 #include "compiler.h"
-//#include "debug.h"
+#ifndef HAVE_LIBT4KCOMMON
 
 /* Draw a single pixel into the surface: */
 void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel)

Modified: branches/commonification/tuxmath/trunk/src/titlescreen.c
===================================================================
--- branches/commonification/tuxmath/trunk/src/titlescreen.c	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxmath/trunk/src/titlescreen.c	2009-08-08 10:46:47 UTC (rev 1395)
@@ -346,6 +346,7 @@
 
 void DrawTitleScreen(void)
 {
+  RenderTitleScreen();
   SDL_BlitSurface(current_bkg(), NULL, GetScreen(), &bkg_rect);
   SDL_BlitSurface(Tux->frame[0], NULL, GetScreen(), &tux_rect);
   SDL_BlitSurface(title, NULL, GetScreen(), &title_rect);

Modified: branches/commonification/tuxtype/trunk/src/funcs.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/funcs.h	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxtype/trunk/src/funcs.h	2009-08-08 10:46:47 UTC (rev 1395)
@@ -76,6 +76,10 @@
 #define IMG_NOT_REQUIRED    0x10
 #define IMG_NO_PNG_FALLBACK 0x20
 
+
+char*        GetSpriteFullPath(const char* file);
+char*        GetFullPath(const char* file);
+
 SDL_Surface* LoadImageNoPrefix(const char* file_name, int mode);
 sprite*      LoadSpriteNoPrefix(const char* file_name, int mode);
 Mix_Chunk*   LoadSoundNoPrefix( char *datafile);

Modified: branches/commonification/tuxtype/trunk/src/menu.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/menu.c	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxtype/trunk/src/menu.c	2009-08-08 10:46:47 UTC (rev 1395)
@@ -11,7 +11,6 @@
   Copyright: See COPYING file that comes with this distribution.
 */
 
-#ifndef HAVE_LIBT4KCOMMON
 #include "globals.h"
 #include "menu.h"
 #include "funcs.h"
@@ -21,6 +20,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifndef HAVE_LIBT4KCOMMON
+
 struct mNode {
   struct mNode* parent;
 
@@ -335,6 +336,7 @@
   int i;
   int stop = 0;
   int items;
+  int old_w, old_h;
 
   int action = NONE;
 
@@ -683,6 +685,8 @@
                   }
                   else
                   {
+                    old_w = GetScreen()->w;
+                    old_h = GetScreen()->h;
                     if(handle_activity(tmp_node->activity, tmp_node->param) == QUIT)
                     {
                       DEBUGMSG(debug_menu, "run_menu(): handle_activity() returned QUIT message, exiting.\n");
@@ -690,6 +694,8 @@
                       FreeSurfaceArray(menu_item_selected, items);
                       return QUIT;
                     }
+                    if(old_w != GetScreen()->w || old_h != GetScreen()->h)
+                      PrerenderAll();
                   }
                 }
               }
@@ -770,11 +776,9 @@
   SDL_Surface** menu_items = NULL;
   SDL_Rect curr_rect;
   SDL_Surface* tmp_surf = NULL;
-  int i, items;
+  int i;
+  int items = min(menu->entries_per_screen, menu->submenu_size - menu->first_entry);
 
-  DEBUGMSG(debug_menu, "Entering render_buttons()\n");
-
-  items = min(menu->entries_per_screen, menu->submenu_size - menu->first_entry);
   menu_items = (SDL_Surface**) malloc(items * sizeof(SDL_Surface*));
   if(NULL == menu_items)
   {
@@ -808,7 +812,6 @@
     SDL_FreeSurface(tmp_surf);
   }
 
-  DEBUGMSG(debug_menu, "Leaving render_buttons()\n");
   return menu_items;
 }
 

Modified: branches/commonification/tuxtype/trunk/src/titlescreen.c
===================================================================
--- branches/commonification/tuxtype/trunk/src/titlescreen.c	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxtype/trunk/src/titlescreen.c	2009-08-08 10:46:47 UTC (rev 1395)
@@ -83,16 +83,8 @@
          cursor;
 
 
-
-
 /* --- media for menus --- */
 
-/* images of regular and selected text of menu items: */
-static SDL_Surface* reg_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {{NULL}};
-static SDL_Surface* sel_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {{NULL}};
-/* this will contain pointers to all of the menu 'icons' */
-static sprite* menu_gfx[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] = {{NULL}};
-
 /* --- other media --- */
 static SDL_Surface* speaker = NULL;
 static SDL_Surface* speakeroff = NULL;
@@ -100,25 +92,15 @@
 static Mix_Chunk* snd_select = NULL;
 static Mix_Chunk* snd_welcome = NULL; 
 
-/* --- locations we need --- */
-static SDL_Rect text_dst[TITLE_MENU_ITEMS + 1];     // location of menu text
-static SDL_Rect menu_gfxdest[TITLE_MENU_ITEMS + 1]; // location of menu sprite
-static SDL_Rect menu_button[TITLE_MENU_ITEMS + 1];  // menu mouse event buttons
-/* keep track of the width of each menu: */
-static int menu_width[TITLE_MENU_DEPTH + 1];
-
 /* Local function prototypes: */
-static void show_logo(void);
-static int load_media(void);
-static void load_menu(void);
-static void recalc_rects(void);
-static int chooseWordlist(void);
-static void ChooseWord(char* words_file);
-static void ChooseFile(void);
-static void unload_media(void);
-static void unload_menu(void);
-static void not_implemented(void);
+static void    show_logo(void);
+static int     chooseWordlist(void);
+static void    ChooseWord(char* words_file);
+static void    ChooseFile(void);
+static void    not_implemented(void);
 
+int            handle_activity(int act, int param);
+void           run_main_menu(void);
 /* --- menu text --- */
 
 
@@ -136,27 +118,15 @@
 */
 void TitleScreen(void)
 {
-
-  Uint32 frame = 0;
   Uint32 start_time = 0;
   Uint32 start = 0;
 
   char fn[1000];
   SDL_Rect tux_anim, title_anim;
   int tux_pix_skip, title_pix_skip, curr_time;
-  /* NOTE for 'depth', think pages like a restaurant menu, */
-  /* not heirarchical depth - choice of term is misleading */
-  int menu_depth; // how deep we are in the menu
 
-  int i, j, tux_frame = 0;
-  int done = 0;
-  int firstloop = 1;
-  int update_locs = 1;
-  int redraw = 0;
-  int key_menu = 1;
-  int old_key_menu = 5;
+  int i;
 
-
   if (settings.sys_sound)
   {
     settings.menu_sound = 1;
@@ -298,6 +268,7 @@
 void DrawTitleScreen(void)
 {
   DEBUGMSG(debug_titlescreen, "Entering DrawTitleScreen()\n");
+  RenderTitleScreen();
   SDL_BlitSurface(CurrentBkgd(), NULL, screen, &bkg_rect);
   SDL_BlitSurface(Tux->frame[0], NULL, screen, &tux_rect);
   SDL_BlitSurface(title, NULL, screen, &title_rect);

Modified: branches/commonification/tuxtype/trunk/src/titlescreen.h
===================================================================
--- branches/commonification/tuxtype/trunk/src/titlescreen.h	2009-08-08 00:45:18 UTC (rev 1394)
+++ branches/commonification/tuxtype/trunk/src/titlescreen.h	2009-08-08 10:46:47 UTC (rev 1395)
@@ -21,3 +21,9 @@
 #define TUX4                            124
 #define TUX5                            127
 #define TUX6                            130
+
+
+void   DrawTitleScreen(void);
+int    RenderTitleScreen(void);
+int    HandleTitleScreenEvents(SDL_Event* evt);
+void   HandleTitleScreenAnimations();




More information about the Tux4kids-commits mailing list