[Tux4kids-commits] r508 - tuxtype/branches/tuxtype-1.5.17_soc1/src
sreyas-guest at alioth.debian.org
sreyas-guest at alioth.debian.org
Sat May 17 13:15:41 UTC 2008
Author: sreyas-guest
Date: 2008-05-17 13:15:39 +0000 (Sat, 17 May 2008)
New Revision: 508
Modified:
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:
BlackOutline_c,BlackOutline_w (can be used instead of BlackOutline and BlackOutline_Unicode or BlackOutline_SDL_Pango) with SDL_Pango support added
Modified: tuxtype/branches/tuxtype-1.5.17_soc1/src/alphabet.c
===================================================================
--- tuxtype/branches/tuxtype-1.5.17_soc1/src/alphabet.c 2008-05-16 20:33:36 UTC (rev 507)
+++ tuxtype/branches/tuxtype-1.5.17_soc1/src/alphabet.c 2008-05-17 13:15:39 UTC (rev 508)
@@ -262,19 +262,19 @@
/* Create a context which contains Pango objects.*/
SDLPango_Context* context = NULL;
- LOG("\nEntering BlackOutline_SDLPango()\n");
+ LOG("\nEntering BlackOutline()\n");
DEBUGCODE{ fprintf(stderr, "will attempt to render: %s\n", t); }
if (!t || !font || !c)
{
- fprintf(stderr, "BlackOutline_SDLPango(): invalid ptr parameter, returning.");
+ fprintf(stderr, "BlackOutline(): 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_SDLPango(): empty string arg - must return to avoid segfault.");
+ fprintf(stderr, "BlackOutline(): empty string arg - must return to avoid segfault.");
return NULL;
}
@@ -291,7 +291,7 @@
if (!context)
{
- fprintf (stderr, "In BlackOutline_SDLPango(), could not create context for %s", t);
+ fprintf (stderr, "In BlackOutline(), could not create context for %s", t);
return NULL;
}
@@ -299,7 +299,8 @@
if (!black_letters)
{
- fprintf (stderr, "Warning - BlackOutline_SDLPango() could not create image for %s\n", t);
+ fprintf (stderr, "Warning - BlackOutline() could not create image for %s\n", t);
+ SDLPango_FreeContext(context);
return NULL;
}
@@ -310,8 +311,9 @@
RMASK, GMASK, BMASK, AMASK);
if (!bg)
{
- fprintf (stderr, "Warning - BlackOutline()_SDLPango - bg creation failed\n");
+ fprintf (stderr, "Warning - BlackOutline() - bg creation failed\n");
SDL_FreeSurface(black_letters);
+ SDLPango_FreeContext(context);
return NULL;
}
@@ -342,12 +344,16 @@
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_SDLPango()\n\n");
+ LOG("Leaving BlackOutline()\n\n");
return out;
}
@@ -473,10 +479,14 @@
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_SDLPango()\n\n");
@@ -607,12 +617,12 @@
/* Create a context which contains Pango objects.*/
SDLPango_Context* context = NULL;
- LOG("\nEntering BlackOutline_SDLPango()\n");
+ LOG("\nEntering BlackOutline_w()\n");
DEBUGCODE{ fprintf(stderr, "will attempt to render: %s\n", t); }
if (!t || !c)
{
- fprintf(stderr, "BlackOutline_SDLPango(): invalid ptr parameter, returning.");
+ fprintf(stderr, "BlackOutline_w(): invalid ptr parameter, returning.");
return NULL;
}
@@ -624,7 +634,7 @@
/* SDLPango crashes on 64 bit machines if passed empty string - Debian Bug#439071 */
if (*t == '\0')
{
- fprintf(stderr, "BlackOutline_SDLPango(): empty string arg - must return to avoid segfault.");
+ fprintf(stderr, "BlackOutline_w(): empty string arg - must return to avoid segfault.");
return NULL;
}
@@ -641,7 +651,7 @@
if (!context)
{
- fprintf (stderr, "In BlackOutline_SDLPango(), could not create context for %s", t);
+ fprintf (stderr, "In BlackOutline_w(), could not create context for %s", t);
return NULL;
}
@@ -649,7 +659,8 @@
if (!black_letters)
{
- fprintf (stderr, "Warning - BlackOutline_SDLPango() could not create image for %s\n", t);
+ fprintf (stderr, "Warning - BlackOutline_w() could not create image for %s\n", t);
+ SDLPango_FreeContext(context);
return NULL;
}
@@ -660,8 +671,9 @@
RMASK, GMASK, BMASK, AMASK);
if (!bg)
{
- fprintf (stderr, "Warning - BlackOutline()_SDLPango - bg creation failed\n");
+ fprintf (stderr, "Warning - BlackOutline()_w - bg creation failed\n");
SDL_FreeSurface(black_letters);
+ SDLPango_FreeContext(context);
return NULL;
}
@@ -692,17 +704,131 @@
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_SDLPango()\n\n");
+ LOG("Leaving BlackOutline_w()\n\n");
return out;
}
+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-05-16 20:33:36 UTC (rev 507)
+++ tuxtype/branches/tuxtype-1.5.17_soc1/src/funcs.h 2008-05-17 13:15:39 UTC (rev 508)
@@ -29,6 +29,7 @@
SDL_Surface* BlackOutline(const unsigned char* t, const TTF_Font* font, const SDL_Color* c);
SDL_Surface* BlackOutline_Unicode(const Uint16* t, const TTF_Font* font, const SDL_Color* c);
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);
#ifndef WIN32
SDL_Surface* BlackOutline_SDLPango(const unsigned char* t, const TTF_Font* font, const SDL_Color* c);
Modified: tuxtype/branches/tuxtype-1.5.17_soc1/src/practice.c
===================================================================
--- tuxtype/branches/tuxtype-1.5.17_soc1/src/practice.c 2008-05-16 20:33:36 UTC (rev 507)
+++ tuxtype/branches/tuxtype-1.5.17_soc1/src/practice.c 2008-05-17 13:15:39 UTC (rev 508)
@@ -65,14 +65,15 @@
z = 0,
total = 0,
state = 0;
+ int next_line=0;
int key[100] = {0};
SDL_Rect dst, dst2, dst3, dst4, dst5;
char keytime[20],
totaltime[20];
+ SDL_Surface* tmp = NULL;
SDL_Surface* srfc = NULL;
-
-
+
if (!practice_load_media())
{
fprintf(stderr, "Phrases() - practice_load_media() failed, returning.\n");
@@ -122,7 +123,7 @@
dst5.h = 50;
dst.x = 40;
-
+ SDL_FreeSurface(srfc);
start = SDL_GetTicks();
do
@@ -195,84 +196,69 @@
}
else
{
- if (pphrase[c]==event.key.keysym.unicode)
- {
- state = 0;
- dst2.x = 40;
- dst4.x = 480;
- SDL_BlitSurface(bg, &dst3, screen, &dst2);
- SDL_BlitSurface(bg, &dst5, screen, &dst4);
- SDL_Flip(screen);
+/******************************************************/
+ if (pphrase[c]==event.key.keysym.unicode){
- srfc = GetWhiteGlyph(event.key.keysym.unicode);
- if (srfc)
- {
- SDL_BlitSurface(srfc, NULL, screen, &dst);
- dst.x = (dst.x + srfc->w) - 5;
- }
-
- for (z = 0; z < strlen(keytime); z++)
- {
- srfc = GetWhiteGlyph((int)keytime[z]);
- if (srfc)
- {
- SDL_BlitSurface(srfc, NULL, screen, &dst2);
- dst2.x = dst2.x + srfc->w - 2;
- }
- }
+ state=0;
+ dst2.x=40;
+ dst4.x=480;
+ SDL_BlitSurface(bg, &dst3, screen, &dst2);
+ SDL_BlitSurface(bg, &dst5, screen, &dst4);
+ SDL_Flip(screen);
- for (z = 0;z < strlen(totaltime); z++)
- {
- srfc = GetWhiteGlyph((int)totaltime[z]);
- if (srfc)
- {
- SDL_BlitSurface(srfc, NULL, screen, &dst4);
- dst4.x = dst4.x + srfc->w - 2;
- }
- }
+ tmp = BlackOutline_w(pphrase+((wp)*next_line), &white, (c)%wp+1);
+ SDL_BlitSurface(tmp, NULL, screen, &dst);
+ SDL_FreeSurface(tmp);
+
- if (c == (wcslen(pphrase) - 1))
- {
- //print_string_at(_("Great!"), 275, 200);
- wchar_t buf[10];
- ConvertFromUTF8(buf, _("Great!"));
- print_at(buf,6 ,275 ,200);
- SDL_Flip(screen);
- SDL_Delay(2500);
- quit = 1;
- }
+/*
+ print_at(keytime,wcslen(keytime),dst2.x,dst2.y);
+ print_at(totaltime,wcslen(keytime),dst4.x,dst4.y);
- if (c == wp)
- {
- c++;
- dst.x = 40;
- dst.y = 142;
- }
+*/
+ tmp=BlackOutline_c(keytime, &white);
+ SDL_BlitSurface(tmp, NULL, screen, &dst2);
+ SDL_FreeSurface(tmp);
+
+ tmp=BlackOutline_c(totaltime, &white);
+ SDL_BlitSurface(tmp, NULL, screen, &dst4);
+ SDL_FreeSurface(tmp);
- c++;
- }
- else
- {
- if (event.key.keysym.sym != SDLK_RSHIFT
- && event.key.keysym.sym != SDLK_LSHIFT)
- PlaySound(wrong);
- }
- }
- }
- }
- SDL_Flip(screen);
- SDL_Delay(30);
- }while (!quit);
-
- practice_unload_media();
-
- return 1;
+ if (c==(wcslen(pphrase)-1)){
+ wchar_t buf[10];
+ ConvertFromUTF8(buf, _("Great!"));
+ print_at(buf, wcslen(buf), 275, 200);
+ SDL_Flip(screen);
+ SDL_Delay(2500);
+ next_line=0;
+ quit=1;
+
+ }
+ if (c==wp){
+ //c++;
+ dst.x=40;
+ dst.y=140;
+ next_line=1;
+ }
+ c++;
+ } else {
+ if ( event.key.keysym.sym != SDLK_RSHIFT && event.key.keysym.sym != SDLK_LSHIFT )
+ PlaySound(wrong);
+ }
+ }
+ }
+ }
+ SDL_Flip(screen);
+ SDL_Delay(30);
+ }while (!quit);
+ practice_unload_media();
+ return 1;
}
+
-
/************************************************************************/
/* */
/* "Private" functions (local to practice.c) */
@@ -370,217 +356,126 @@
-static int get_phrase(const wchar_t* phr)
-{
- int pc = 0; // 'phrase count' (?)
- int pw[256] = { 0 };
- int wp = 0, i = 0, c = 0, z = 0;
- char fn[FNLEN];
+static int get_phrase(const wchar_t* wphrase)
+{ int pc=0,
+ pw[256] = { 0 },
+ wp=0,
+ i=0,
+// c=0
+ z=0;
+// char fn[FNLEN];
- /* If we didn't receive a phrase get the first one from the file...*/
- if (wcsncmp((wchar_t*)"", phr, 40) == 0)
- {
- FILE* pf; /* "phrase file" */
- /* set the phrases directory/file */
- /* FIXME I think the phrases should be under data or the theme */
-#ifdef WIN32
- snprintf(fn, FNLEN - 1, "userdata/phrases.txt");
-#else
- snprintf(fn, FNLEN - 1, (const char*)"%s/.tuxtype/phrases.txt", getenv("HOME"));
-#endif
+ /* If we didn't receive a phrase get the first one from the file...*/
+
+// if (strncmp("", phr, 40)==0){
+// FILE *pf;
+// /* set the phrases directory/file */
+/* #ifdef WIN32
+ snprintf( fn, FNLEN-1, "userdata/phrases.txt" );
+ #else
+ snprintf( fn, FNLEN-1, (const char*)"%s/.tuxtype/phrases.txt", getenv("HOME") );
+ #endif
- DEBUGCODE { printf("get_phrases(): phrases file is '%s'\n", fn ); }
- LOG("get_phrases(): trying to open phrases file\n");
- pf = fopen( fn, "r" );
- if (pf == NULL)
- return(wp); /* why not just 'return 0;' ??? */
+ DEBUGCODE { printf("get_phrases(): phrases file is '%s'\n", fn ); }
+ LOG("get_phrases(): trying to open phrases file\n");
+ pf = fopen( fn, "r" );
+ if (pf == NULL)
+ return(wp);
+ while (!feof(pf)) {
+ fscanf( pf, "%[^\n]\n", phrase[pc] );
+ pc++;
+ DEBUGCODE { printf( "%s", phrase[pc] ); }
+ }
+ fclose( pf );
+ pc--;
+ } else {
+ pc=1;
+ strncpy(phrase[0], phr, 80);
+ }
- /* So now copy each line into phrases array: */
- while (!feof(pf) && pc < 256)
- {
- fscanf( pf, "%[^\n]\n", phrase[pc] );
- pc++;
- DEBUGCODE {printf("%s", phrase[pc]);}
- }
- if (pc == 256)
- LOG("File contains more than max allowed phrases - stopping\n");
+ //Calculate and record pixel width of phrases
+ for (c=0;c<=pc;c++){
+ for(i=0; i<strlen(phrase[c]); i++){
+ if (letters[(int)phrase[c][i]] == NULL){
+ LOG("no letter defined in keyboard.lst\n");
+ }
+ else
+ pw[c]+= letters[(int)phrase[c][i]]->w-5;
+ }
+ }
- fclose(pf);
- pc--;
- }
- else
- {
- pc = 1;
- wcsncpy(phrase[0], phr, 80);
- }
+ //Find wrapping point
+ for ( c=0; c<=pc; c++ ){
+ if (pw[c]<598){
+ if ( c==0 ){
+ wp=strlen(phrase[c]);
+ print_at( phrase[0], wp, 40, 10 );
+ }
+ }else{
+ z=0;
+ wp=0;
+ for (i=0;i<strlen(phrase[c]);i++)
+ {
+ z += letters[(int)phrase[c][i]]->w-5;
+ if (wp == 0 && z > 598){
+ wp = i-1;
+ break;
+ }
+ }
+ for (i=wp;i>=0;i--){
+ if ( strncmp( " ", &phrase[c][i], 1 ) == 0 ){
+ wp=i-1;
+ break;
+ }
+ }
+ if ( c==0 ){
+ print_at( phrase[0], wp, 40, 10 );
+ }
+ }
+ }
+ LOG("Leaving get_phrase()\n");
+ return(wp);
+}
+*/
- /* FIXME maybe should verify that all chars in phrase are
-// /* Need to generate glyphs for all the needed Unicode chars: */
-//
-// ResetCharList();
-// /* 'A' (i.e. 65) always has to go into list because width used for layout */
-// /* HACK also need chars for "Great!" because of congrats message - this */
-// /* obviously is not a general solution. Numerals also needed for timers. */
-// {
-// char* let = "AGreat!0123456789.";
-// GenCharListFromString(let);
-// }
-//
-//
-// /* Scan through all the phrases and put needed chars into list: */
-// for (c = 0; c <= pc; c++)
-// GenCharListFromString(phrase[c]);
-//
-// /* Now render letters for glyphs in list: */
-// font = LoadFont(settings.theme_font_name, 32 );
-// if (!font)
-// {
-// fprintf(stderr, "get_phrase() - could not load font\n");
-// return 0;
-// }
-//
-// RenderLetters(font);
-//
-// TTF_CloseFont(font);
-// font = NULL;
- //Calculate and record pixel width of phrases
- {
- SDL_Surface* let = NULL;
- for (c = 0; c <= pc; c++)
- {
- for(i = 0; i < wcslen(phrase[c]); i++)
- {
- let = GetWhiteGlyph((int)phrase[c][i]);
- if (let)
- pw[c]+= let->w - 5;
- else
- {
- fprintf(stderr, "get_phrase() - needed glyph not available\n");
- return;
- }
- }
- }
- }
- //Find wrapping point
- for (c = 0; c <= pc; c++)
- {
- if (pw[c] < 598) // If the phrase is less than 598 pixels wide
- {
- if (c == 0)
- {
- wp = wcslen(phrase[c]);
- print_at(phrase[0], wp, 40, 10);
- }
- }
- else
- {
- z = 0;
- wp = 0;
+//Calculate and record pixel width of phrases
+ //Find wrapping point
+ if (wcslen(wphrase)<50)
+ {
+ wp=wcslen(wphrase);
+ print_at( wphrase, wp, 40, 10 );
+
+ }
+ else
+ {
+ z=0;
+ wp=0;
+ for (i=0;i<wcslen(wphrase);i++)
+ {
- for (i = 0; i < wcslen(phrase[c]); i++)
- {
- /* Should be safe (if no glyph, will have returned above) */
- z += GetWhiteGlyph((int)phrase[c][i])->w-5;
- if (wp == 0 && z > 598)
- {
- wp = i - 1;
- break;
- }
- }
-
- for (i = wp; i >= 0; i--)
- {
- if (wcsncmp((wchar_t*)" ", &phrase[c][i], 1) == 0)
- {
- wp = i-1;
- break;
- }
- }
-
- if (c == 0)
- {
- print_at(phrase[0], wp, 40, 10);
- }
- }
- }
- LOG("Leaving get_phrase()\n");
- return(wp);
+ z++;
+ if (wp == 0 && z > 50)
+ {
+ wp = i-1;
+ break;
+ }
+ }
+ for (i=wp;i>=0;i--){
+ if (wphrase[i] == ' ')
+ {
+ wp=i-1;
+ break;
+ }
+ }
+ print_at( wphrase, wp, 40, 10 );
+
+ }
+ return(wp);
}
-
-
-/*static void print_at(const wchar_t *pphrase, int wrap, int x, int y)
-{
- int z = 0;
- SDL_Surface* surf = NULL;
- letter_loc.x = x;
- letter_loc.y = y;
- letter_loc.w = GetWhiteGlyph(65)->w;
- letter_loc.h = GetWhiteGlyph(65)->h;
-
- LOG("Entering print_at()\n");
-
- if (wrap >= wcslen(pphrase)) // I think this means it fits on a single line
- {
- for (z = 0; z <wcslen(pphrase); z++)
- {
- surf = GetWhiteGlyph(pphrase[z]);
- if (surf)
- {
- DEBUGCODE{printf("surf not NULL for %C\n", pphrase[z]);}
- SDL_BlitSurface(surf, NULL, screen, &letter_loc);
- letter_loc.x = (letter_loc.x + surf->w) - 5;
- }
- else
- {
- fprintf(stderr, "print_at(): needed glyph for %C not found\n",
- pphrase[z]);
- }
- }
- }
- else /* Another line required - code only seems to support 1 or 2 lines! *//*
- {
- for (z = 0; z <= wrap; z++)
- {
- surf = GetWhiteGlyph(pphrase[z]);
- if (surf)
- {
- DEBUGCODE{printf("surf not NULL for %C\n", pphrase[z]);}
- SDL_BlitSurface(surf, NULL, screen, &letter_loc);
- letter_loc.x = (letter_loc.x + surf->w) - 5; }
- else
- {
- fprintf(stderr, "print_at(): needed glyph for %C not found\n",
- pphrase[z]);
- }
- }
-
- /* Move 'cursor' back to left and down one line: *//*
- letter_loc.x = 40;
- // - (letter_loc.h/4) to account for free space at top and bottom of rendered letters
- letter_loc.y = letter_loc.y + letter_loc.h - (letter_loc.h/4);
-
- for (z = wrap + 2; z <wcslen(pphrase); z++)
- {
- surf = GetWhiteGlyph(pphrase[z]);
- if (surf)
- {
- DEBUGCODE{printf("surf not NULL for %c\n", pphrase[z]);}
- SDL_BlitSurface(surf, NULL, screen, &letter_loc);
- letter_loc.x = (letter_loc.x + surf->w) - 5;
- }
- else
- {
- fprintf(stderr, "print_at(): needed glyph for %c not found",
- pphrase[z]);
- }
- }
- }
- LOG("Leaving print_at()\n");
-}*/
static void print_at(const wchar_t *pphrase, int wrap, int x, int y)
{
int z=0;
@@ -621,7 +516,7 @@
{
int i;
wchar_t buf[30];
- i=ConvertFromUTF8(buf, _("Next letter "));
+ i=ConvertFromUTF8(buf, _("Next letter : "));
buf[i]=t[c];
buf[i+1]=0;
print_at(buf,wcslen(buf),230 ,400);
More information about the Tux4kids-commits
mailing list