[Tux4kids-commits] r644 - in tuxtype/branches/tuxtype-1.5.17_soc1: data/images/keyboard src

sreyas-guest at alioth.debian.org sreyas-guest at alioth.debian.org
Sun Aug 17 16:59:33 UTC 2008


Author: sreyas-guest
Date: 2008-08-17 16:59:28 +0000 (Sun, 17 Aug 2008)
New Revision: 644

Removed:
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C13.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C13.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_NA01.png
Modified:
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/Makefile.am
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C08.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C09.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C10.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C11.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C12.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C08.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C09.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C10.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C11.png
   tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C12.png
   tuxtype/branches/tuxtype-1.5.17_soc1/src/alphabet.c
   tuxtype/branches/tuxtype-1.5.17_soc1/src/funcs.h
   tuxtype/branches/tuxtype-1.5.17_soc1/src/practice.c
Log:
Pango, rendering in practice game added

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/Makefile.am
===================================================================
--- tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/Makefile.am	2008-08-17 12:00:06 UTC (rev 643)
+++ tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/Makefile.am	2008-08-17 16:59:28 UTC (rev 644)
@@ -20,7 +20,6 @@
 	keyboard_E05.png \
 	keyboard_A01.png \
 	keyboard_B07.png \
-	keyboard_C13.png \
 	keyboard_E06.png \
 	keyboard_A02.png \
 	keyboard_B08.png \

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C08.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C09.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C10.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C11.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C12.png
===================================================================
(Binary files differ)

Deleted: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboardN_C13.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C08.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C09.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C10.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C11.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C12.png
===================================================================
(Binary files differ)

Deleted: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_C13.png
===================================================================
(Binary files differ)

Deleted: tuxtype/branches/tuxtype-1.5.17_soc1/data/images/keyboard/keyboard_NA01.png
===================================================================
(Binary files differ)

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/src/alphabet.c
===================================================================
--- tuxtype/branches/tuxtype-1.5.17_soc1/src/alphabet.c	2008-08-17 12:00:06 UTC (rev 643)
+++ tuxtype/branches/tuxtype-1.5.17_soc1/src/alphabet.c	2008-08-17 16:59:28 UTC (rev 644)
@@ -611,7 +611,7 @@
 
   return out;
 }
-SDL_Surface* BlackOutline_w(wchar_t* t, const SDL_Color* c, int size)
+SDL_Surface* BlackOutline_w(wchar_t* t, const TTF_Font* font, const SDL_Color* c, int size)
 {
 	wchar_t wchar_tmp[512];
 	char tmp[512];
@@ -620,106 +620,9 @@
 	wchar_tmp[size]=0;
 	i=ConvertToUTF8( wchar_tmp, tmp);
 	tmp[i]=0;
-	return BlackOutline_c( tmp, c);
+	return BlackOutline(tmp, font, c);
 }
-SDL_Surface* BlackOutline_c(const unsigned char* t, const SDL_Color* c)
-{
-  SDL_Surface* out = NULL;
-  SDL_Surface* black_letters = NULL;
-  SDL_Surface* white_letters = NULL;
-  SDL_Surface* bg = NULL;
-  SDL_Rect dstrect;
-  Uint32 color_key;
-  /* To covert SDL_Colour to SDLPango_Matrix*/
-  SDLPango_Matrix* colour = NULL;
-  /* Create a context which contains Pango objects.*/
-  SDLPango_Context* context = NULL;
 
-  LOG("\nEntering BlackOutline_c()\n");
-  DEBUGCODE{ fprintf(stderr, "will attempt to render: %s\n", t); }
-
-  if (!t || !c)
-  {
-    fprintf(stderr, "BlackOutline_c(): invalid ptr parameter, returning.");
-    return NULL;
-  }
-
-  /* SDLPango crashes on 64 bit machines if passed empty string - Debian Bug#439071 */
-  if (*t == '\0')
-  {
-    fprintf(stderr, "BlackOutline_c(): empty string arg - must return to avoid segfault.");
-    return NULL;
-  }
-  colour = SDL_Colour_to_SDLPango_Matrix(c);
-  
-  /* Create the context */
-  context = SDLPango_CreateContext();	
-  SDLPango_SetDpi(context, 125.0, 125.0);
-  /* Set the color */
-  SDLPango_SetDefaultColor(context, MATRIX_TRANSPARENT_BACK_BLACK_LETTER );
-  SDLPango_SetBaseDirection(context, SDLPANGO_DIRECTION_LTR);
-  /* Set text to context*/  
-  SDLPango_SetMarkup(context, t, -1); 
-
-  if (!context)
-  {
-    fprintf (stderr, "In BlackOutline_c(), could not create context for %s", t);
-    return NULL;
-  }
-  black_letters = SDLPango_CreateSurfaceDraw(context);
-  if (!black_letters)
-  {
-    fprintf (stderr, "Warning - BlackOutline_c() could not create image for %s\n", t);
-	SDLPango_FreeContext(context);
-    return NULL;
-  }
-  bg = SDL_CreateRGBSurface(SDL_SWSURFACE,
-                            (black_letters->w) + 5,
-                            (black_letters->h) + 5,
-                             32,
-                             RMASK, GMASK, BMASK, AMASK);
-  if (!bg)
-  {
-    fprintf (stderr, "Warning - BlackOutline()_c - bg creation failed\n");
-    SDL_FreeSurface(black_letters);
-	SDLPango_FreeContext(context);
-    return NULL;
-  }
-  /* Draw text on a existing surface*/ 
-  SDLPango_Draw(context, bg, 0, 0);
-  /* Use color key for eventual transparency:*/ 
-  color_key = SDL_MapRGB(bg->format, 10, 10, 10);
-  SDL_FillRect(bg, NULL, color_key);
-  /* Now draw black outline/shadow 2 pixels on each side: */
-  dstrect.w = black_letters->w;
-  dstrect.h = black_letters->h;
-
-  /* NOTE: can make the "shadow" more or less pronounced by */
-  /* changing the parameters of these loops.                */
-  for (dstrect.x = 1; dstrect.x < 4; dstrect.x++)
-    for (dstrect.y = 1; dstrect.y < 3; dstrect.y++)
-      SDL_BlitSurface(black_letters , NULL, bg, &dstrect );
-  SDL_FreeSurface(black_letters);
-  /* --- Put the color version of the text on top! --- */
-  SDLPango_SetDefaultColor(context, colour);
-  white_letters = SDLPango_CreateSurfaceDraw(context);
-  dstrect.x = 1;
-  dstrect.y = 1;
-  SDL_BlitSurface(white_letters, NULL, bg, &dstrect);
-  SDL_FreeSurface(white_letters);
-	/********************Free SDL_Pango context************/
-	SDLPango_FreeContext(context);
-
-  /* --- Convert to the screen format for quicker blits ---*/ 
-  SDL_SetColorKey(bg, SDL_SRCCOLORKEY|SDL_RLEACCEL, color_key);
-  out = SDL_DisplayFormatAlpha(bg);
-  SDL_FreeSurface(bg);
-	free(colour);
-  LOG("Leaving BlackOutline_c()\n\n");
-
-  return out;
-}
-
 /* FIXME dead code but could be useful*/
 static void show_letters(void)
 {

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/src/funcs.h
===================================================================
--- tuxtype/branches/tuxtype-1.5.17_soc1/src/funcs.h	2008-08-17 12:00:06 UTC (rev 643)
+++ tuxtype/branches/tuxtype-1.5.17_soc1/src/funcs.h	2008-08-17 16:59:28 UTC (rev 644)
@@ -57,8 +57,7 @@
 void updatekeylist(int key,char ch);
 void savekeyboard(void);
 wchar_t GetLastKey(void);
-SDL_Surface* BlackOutline_w(wchar_t* t, const SDL_Color* c, int size);
-SDL_Surface* BlackOutline_c(const unsigned char* t, const SDL_Color* c);
+SDL_Surface* BlackOutline_w(wchar_t* t, const TTF_Font* font, const SDL_Color* c, int size);
 int ConvertToUTF8(wchar_t* UTF32_word, char* word);
 
 //void UseAlphabet(void);

Modified: tuxtype/branches/tuxtype-1.5.17_soc1/src/practice.c
===================================================================
--- tuxtype/branches/tuxtype-1.5.17_soc1/src/practice.c	2008-08-17 12:00:06 UTC (rev 643)
+++ tuxtype/branches/tuxtype-1.5.17_soc1/src/practice.c	2008-08-17 16:59:28 UTC (rev 644)
@@ -130,7 +130,7 @@
   mydest.x = 0;
   mydest.y = dst.y;
   mydest.w = screen->w;
-  mydest.h = screen->h-80;
+  mydest.h = screen->h-mydest.y;
 
 
   start = SDL_GetTicks();
@@ -437,24 +437,37 @@
 /****************************************************/
           if (pphrase[c]==event.key.keysym.unicode)
           {
+		c++;
 		state = 0;
 		dst2.x = 40;
 		dst4.x = 480;
+		
+		if (c==wp+2){
+			//c++;
+			dst.x=40;
+			dst.y=140;
+			mydest.y=dst.y;
+			mydest.h=screen->h-mydest.y;
+			next_line=1;
+		}
 		SDL_BlitSurface(bg, &mydest, screen, &mydest);
 		SDL_Flip(screen);
-		tmpsurf = BlackOutline_w(pphrase+((wp)*next_line), &white, (c)%wp+1);
+		if(!next_line)
+			tmpsurf = BlackOutline_w(pphrase, font, &white, c);
+		else
+			tmpsurf = BlackOutline_w(pphrase+wp+1, font, &white, c-(wp+1));
 		SDL_BlitSurface(tmpsurf, NULL, screen, &dst);
 		SDL_FreeSurface(tmpsurf);
 		tmpsurf = NULL;
-		tmpsurf=BlackOutline_c(keytime, &white);
+		tmpsurf = BlackOutline(keytime, font, &white);
 		SDL_BlitSurface(tmpsurf, NULL, screen, &dst2);
 		SDL_FreeSurface(tmpsurf);
 		tmpsurf = NULL;	
-		tmpsurf=BlackOutline_c(totaltime, &white);
+		tmpsurf = BlackOutline(totaltime, font, &white);
 		SDL_BlitSurface(tmpsurf, NULL, screen, &dst4);
 		SDL_FreeSurface(tmpsurf);
 		tmpsurf = NULL;
-		if (c==(wcslen(pphrase)-1)){
+		if (c==(wcslen(pphrase))){
 				wchar_t buf[10];
 				ConvertFromUTF8(buf, _("Great!"));
 				print_at(buf, wcslen(buf), 275, 200);
@@ -463,16 +476,6 @@
 				next_line=0;
 				quit=1;
 		}
-		if (c==wp){
-			//c++;
-			dst.x=40;
-			dst.y=140;
-			mydest.y=dst.y;
-			mydest.x=0;
-			mydest.h-=40;
-			next_line=1;
-		}
-		c++;
 	}
 	else
 	{
@@ -565,8 +568,8 @@
 
   /* Now render letters for glyphs in alphabet: */
   RenderLetters(font);
-  TTF_CloseFont(font);  /* Don't need it after rendering done */
-  font = NULL;
+  //TTF_CloseFont(font);  /* Don't need it after rendering done */
+  //font = NULL;
   GenerateKeyboard(keyboard);
 
   LOG("DONE - Loading practice media\n");
@@ -591,7 +594,8 @@
 	}
 	SDL_FreeSurface(keyboard);
         keyboard = NULL;
-	//TTF_CloseFont(font);
+	TTF_CloseFont(font);
+	font = NULL;
 	for (i=0; i<10; i++) 
         {
           SDL_FreeSurface(hand[i]);
@@ -630,13 +634,13 @@
 	//font = LoadFont(settings.theme_font_name, 30);
 	DEBUGCODE { printf("\n\n\nEntering print_at with : %S\n",pphrase); }
 	if ( wrap == wcslen(pphrase) ){
-		tmp = BlackOutline_w(pphrase, &white, wrap);
+		tmp = BlackOutline_w(pphrase, font, &white, wrap);
 		letter_loc.w = tmp->w+5;
 		letter_loc.h = tmp->h+5;
 		SDL_BlitSurface(tmp, NULL, screen, &letter_loc);
 		SDL_FreeSurface(tmp);
 	}else{
-		tmp = BlackOutline_w(pphrase, &white, wrap+1);
+		tmp = BlackOutline_w(pphrase, font, &white, wrap+1);
 		letter_loc.w = tmp->w+5;
 		letter_loc.h = tmp->h+5;
 		SDL_BlitSurface(tmp, NULL, screen, &letter_loc);
@@ -645,7 +649,7 @@
                 // - (letter_loc.h/4) to account for free space at top and bottom of rendered letters
 		//SDL_FreeSurface(tmp);
 		letter_loc.y = letter_loc.y + letter_loc.h - (letter_loc.h/4);
-		tmp = BlackOutline_w(pphrase+wrap+2, &white, wcslen(pphrase));
+		tmp = BlackOutline_w(pphrase+wrap+2, font, &white, wcslen(pphrase));
 		letter_loc.w = tmp->w+5;
 		letter_loc.h = tmp->h+5;
 		SDL_BlitSurface(tmp, NULL, screen, &letter_loc);




More information about the Tux4kids-commits mailing list