[Tux4kids-commits] r663 - in tuxtype/branches/soc-sreyas: data/images/keyboard src

sreyas-guest at alioth.debian.org sreyas-guest at alioth.debian.org
Thu Aug 21 14:33:39 UTC 2008


Author: sreyas-guest
Date: 2008-08-21 14:33:38 +0000 (Thu, 21 Aug 2008)
New Revision: 663

Modified:
   tuxtype/branches/soc-sreyas/data/images/keyboard/Makefile.am
   tuxtype/branches/soc-sreyas/src/Makefile.am
   tuxtype/branches/soc-sreyas/src/alphabet.c
   tuxtype/branches/soc-sreyas/src/funcs.h
   tuxtype/branches/soc-sreyas/src/gettext.c
   tuxtype/branches/soc-sreyas/src/globals.h
   tuxtype/branches/soc-sreyas/src/loaders.c
   tuxtype/branches/soc-sreyas/src/options.c
   tuxtype/branches/soc-sreyas/src/pause.c
   tuxtype/branches/soc-sreyas/src/playgame.c
   tuxtype/branches/soc-sreyas/src/practice.c
   tuxtype/branches/soc-sreyas/src/setup.c
   tuxtype/branches/soc-sreyas/src/titlescreen.c
   tuxtype/branches/soc-sreyas/src/titlescreen.h
Log:


Modified: tuxtype/branches/soc-sreyas/data/images/keyboard/Makefile.am
===================================================================
--- tuxtype/branches/soc-sreyas/data/images/keyboard/Makefile.am	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/data/images/keyboard/Makefile.am	2008-08-21 14:33:38 UTC (rev 663)
@@ -3,11 +3,137 @@
 
 images_keyboarddir = $(pkgdatadir)/data/images/keyboard
 
-dist_images_keyboard_DATA = keyboard.png \
-  keyboard-us.png \
+dist_images_keyboard_DATA = esc.png \
+  keyboard_A00.png \
+  keyboard_A01.png \
+  keyboard_A02.png \
+  keyboard_A03.png \
+  keyboard_A04.png \
+  keyboard_A05.png \
+  keyboard_A06.png \
+  keyboard_A07.png \
+  keyboard_A08.png \
+  keyboard_A09.png \
+  keyboard_A10.png \
+  keyboard_A11.png \
+  keyboard_A12.png \
+  keyboard_A13.png \
+  keyboard_B00.png \
+  keyboard_B01.png \
+  keyboard_B02.png \
+  keyboard_B03.png \
+  keyboard_B04.png \
+  keyboard_B05.png \
+  keyboard_B06.png \
+  keyboard_B07.png \
+  keyboard_B08.png \
+  keyboard_B09.png \
+  keyboard_B10.png \
+  keyboard_B11.png \
+  keyboard_B12.png \
+  keyboard_B13.png \
+  keyboard_C00.png \
+  keyboard_C01.png \
+  keyboard_C02.png \
+  keyboard_C03.png \
+  keyboard_C04.png \
+  keyboard_C05.png \
+  keyboard_C06.png \
+  keyboard_C07.png \
+  keyboard_C08.png \
+  keyboard_C09.png \
+  keyboard_C10.png \
+  keyboard_C11.png \
+  keyboard_C12.png \
+  keyboard_D00.png \
+  keyboard_D01.png \
+  keyboard_D02.png \
+  keyboard_D03.png \
+  keyboard_D04.png \
+  keyboard_D05.png \
+  keyboard_D06.png \
+  keyboard_D07.png \
+  keyboard_D08.png \
+  keyboard_D09.png \
+  keyboard_D10.png \
+  keyboard_D11.png \
+  keyboard_D12.png \
+  keyboard_E00.png \
+  keyboard_E01.png \
+  keyboard_E02.png \
+  keyboard_E03.png \
+  keyboard_E04.png \
+  keyboard_E05.png \
+  keyboard_E06.png \
+  keyboard_E07.png \
   keyboard.eps \
+  keyboardN_A00.png \
+  keyboardN_A01.png \
+  keyboardN_A02.png \
+  keyboardN_A03.png \
+  keyboardN_A04.png \
+  keyboardN_A05.png \
+  keyboardN_A06.png \
+  keyboardN_A07.png \
+  keyboardN_A08.png \
+  keyboardN_A09.png \
+  keyboardN_A10.png \
+  keyboardN_A11.png \
+  keyboardN_A12.png \
+  keyboardN_A13.png \
+  keyboardN_B00.png \
+  keyboardN_B01.png \
+  keyboardN_B02.png \
+  keyboardN_B03.png \
+  keyboardN_B04.png \
+  keyboardN_B05.png \
+  keyboardN_B06.png \
+  keyboardN_B07.png \
+  keyboardN_B08.png \
+  keyboardN_B09.png \
+  keyboardN_B10.png \
+  keyboardN_B11.png \
+  keyboardN_B12.png \
+  keyboardN_B13.png \
+  keyboardN_C00.png \
+  keyboardN_C01.png \
+  keyboardN_C02.png \
+  keyboardN_C03.png \
+  keyboardN_C04.png \
+  keyboardN_C05.png \
+  keyboardN_C06.png \
+  keyboardN_C07.png \
+  keyboardN_C08.png \
+  keyboardN_C09.png \
+  keyboardN_C10.png \
+  keyboardN_C11.png \
+  keyboardN_C12.png \
+  keyboardN_D00.png \
+  keyboardN_D01.png \
+  keyboardN_D02.png \
+  keyboardN_D03.png \
+  keyboardN_D04.png \
+  keyboardN_D05.png \
+  keyboardN_D06.png \
+  keyboardN_D07.png \
+  keyboardN_D08.png \
+  keyboardN_D09.png \
+  keyboardN_D10.png \
+  keyboardN_D11.png \
+  keyboardN_D12.png \
+  keyboardN_E00.png \
+  keyboardN_E01.png \
+  keyboardN_E02.png \
+  keyboardN_E03.png \
+  keyboardN_E04.png \
+  keyboardN_E05.png \
+  keyboardN_E06.png \
+  keyboardN_E07.png \
+  keyboardN_None.png \
+  keyboard_None.png \
+  keyboard.png \
   keyboard-us.eps \
-  esc.png \
+  keyboard-us.png \
   larrow.png \
   space.png \
   rarrow.png\
@@ -20,7 +146,6 @@
 	keyboard_E05.png \
 	keyboard_A01.png \
 	keyboard_B07.png \
-	keyboard_C13.png \
 	keyboard_E06.png \
 	keyboard_A02.png \
 	keyboard_B08.png \
@@ -74,4 +199,69 @@
 	keyboard_E02.png \
 	keyboard_B04.png \
 	keyboard_C10.png \
-	keyboard_E03.png
+	keyboard_E03.png \
+	keyboardN_B05.png \
+	keyboardN_C11.png \
+	keyboardN_E04.png \
+	keyboardN_A00.png \
+	keyboardN_B06.png \
+	keyboardN_C12.png \
+	keyboardN_E05.png \
+	keyboardN_A01.png \
+	keyboardN_B07.png \
+	keyboardN_E06.png \
+	keyboardN_A02.png \
+	keyboardN_B08.png \
+	keyboardN_D00.png \
+	keyboardN_E07.png \
+	keyboardN_A03.png \
+	keyboardN_B09.png \
+	keyboardN_D01.png \
+	keyboardN_A04.png \
+	keyboardN_B10.png \
+	keyboardN_D02.png \
+	keyboardN_None.png \
+	keyboardN_A05.png \
+	keyboardN_B11.png \
+	keyboardN_D03.png \
+	keyboardN_A06.png \
+	keyboardN_B12.png \
+	keyboardN_D04.png \
+	keyboardN_A07.png \
+	keyboardN_B13.png \
+	keyboardN_D05.png \
+	keyboardN_A08.png \
+	keyboardN_C00.png \
+	keyboardN_D06.png \
+	keyboardN_A09.png \
+	keyboardN_C01.png \
+	keyboardN_D07.png \
+	keyboardN_A10.png \
+	keyboardN_C02.png \
+	keyboardN_D08.png \
+	keyboardN_A11.png \
+	keyboardN_C03.png \
+	keyboardN_D09.png \
+	keyboardN_A12.png \
+	keyboardN_C04.png \
+	keyboardN_D10.png \
+	keyboardN_A13.png \
+	keyboardN_C05.png \
+	keyboardN_D11.png \
+	keyboardN_B00.png \
+	keyboardN_C06.png \
+	keyboardN_D12.png \
+	keyboardN_B01.png \
+	keyboardN_C07.png \
+	keyboardN_E00.png \
+	keyboardN_B02.png \
+	keyboardN_C08.png \
+	keyboardN_E01.png \
+	keyboardN_B03.png \
+	keyboardN_C09.png \
+	keyboardN_E02.png \
+	keyboardN_B04.png \
+	keyboardN_C10.png \
+	keyboardN_E03.png \
+  rarrow.png \
+  space.png 

Modified: tuxtype/branches/soc-sreyas/src/Makefile.am
===================================================================
--- tuxtype/branches/soc-sreyas/src/Makefile.am	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/Makefile.am	2008-08-21 14:33:38 UTC (rev 663)
@@ -29,4 +29,10 @@
 	funcs.h 	\
 	scripting.h	\
 	snow.h		\
-	ConvertUTF.h
+	ConvertUTF.h	\
+	i18n.h
+
+tuxtype_LDFLAGS = $(LTLIBINTL)
+
+localedir = $(datadir)/locale
+DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@

Modified: tuxtype/branches/soc-sreyas/src/alphabet.c
===================================================================
--- tuxtype/branches/soc-sreyas/src/alphabet.c	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/alphabet.c	2008-08-21 14:33:38 UTC (rev 663)
@@ -612,6 +612,17 @@
   return out;
 }
 
+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];
+	int i;
+	wcsncpy( wchar_tmp, t, size);
+	wchar_tmp[size]=0;
+	i=ConvertToUTF8( wchar_tmp, tmp);
+	tmp[i]=0;
+	return BlackOutline(tmp, font, c);
+}
 
 /* FIXME dead code but could be useful*/
 static void show_letters(void)
@@ -1114,28 +1125,27 @@
 
 /******************To be used for savekeyboard*************/
 /***Converts wchar_t string to char string*****************/
-int ConvertToUTF8(wchar_t* UTF32_word, char* word)
+int ConvertToUTF8(wchar_t* wide_word, char* UTF8_word)
 {
   int i = 0;
   ConversionResult result;
   UTF8 temp_UTF8[FNLEN];
   UTF32 temp_UTF32[FNLEN];
 
-  const UTF8* UTF8_Start = temp_UTF8;
-  const UTF8* UTF8_End = &temp_UTF8[FNLEN-1];
-  UTF32* UTF32_Start = temp_UTF32;
-  UTF32* UTF32_End = &temp_UTF32[FNLEN-1];
+  UTF8* UTF8_Start = temp_UTF8;
+  UTF8* UTF8_End = &temp_UTF8[FNLEN-1];
+  const UTF32* UTF32_Start = temp_UTF32;
+  const UTF32* UTF32_End = &temp_UTF32[FNLEN-1];
 
-  strncpy(temp_UTF32, UTF32_word, FNLEN);
+  wcsncpy(temp_UTF32, wide_word, FNLEN);
 
-  ConvertUTF32toUTF8(&UTF32_Start, UTF32_End,
-                     &UTF8_Start, UTF8_End, 0);
+  ConvertUTF32toUTF8(&UTF32_Start, UTF32_End, &UTF8_Start, UTF8_End, 0);
 
-  word[0] = '\0';
+  UTF8_word[0] = 0;
 
-  while ((i < FNLEN) && (temp_UTF8[i] != '\0'))
+  while ((i < FNLEN) && (temp_UTF8[i] != 0))
   {
-    word[i] = temp_UTF8[i];
+    UTF8_word[i] = temp_UTF8[i];
     i++; 
   }
 
@@ -1146,12 +1156,13 @@
   }
   else  //need terminating null:
   {
-    word[i] = '\0';
+	for(i;i<FNLEN;i++)
+	    UTF8_word[i] = 0;
   }
 
-  DEBUGCODE {fprintf(stderr, "word = %s\n", word);}
+  DEBUGCODE {fprintf(stderr, "UTF8_word = %s\n", UTF8_word);}
 
-  return strlen(word);
+  return strlen(UTF8_word);
 }
 
 /******************************************************************/
@@ -1584,7 +1595,7 @@
 		}
 		if(!render)
 			continue;
-		new.x+=30*col;
+		new.x+=31*col;
 		if(keyboard_list[i].shift>0)
 		{
 					new.x-=9;
@@ -1615,15 +1626,16 @@
 void savekeyboard(void)
 {
 	unsigned char fn[FNLEN];
+	FILE *fp;
+	int i;
+	wchar_t tmp[2];
+	char buf[FNLEN];
+	tmp[1]=0;
 	if(!settings.use_english)
 		sprintf(fn , "%s/keyboard.lst", settings.theme_data_path);
 	else
 		sprintf(fn , "%s/keyboard.lst", settings.default_data_path);
-	FILE *fp;
-	int i;
-	wchar_t tmp[2];
-	char buf[10];
-	tmp[1]='\0';
+
 	fp=fopen(fn,"w");
 	if (fp == NULL)
 	{

Modified: tuxtype/branches/soc-sreyas/src/funcs.h
===================================================================
--- tuxtype/branches/soc-sreyas/src/funcs.h	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/funcs.h	2008-08-21 14:33:38 UTC (rev 663)
@@ -57,6 +57,7 @@
 void updatekeylist(int key,char ch);
 void savekeyboard(void);
 wchar_t GetLastKey(void);
+SDL_Surface* BlackOutline_w(wchar_t* t, const TTF_Font* font, const SDL_Color* c, int size);
 
 //void UseAlphabet(void);
 
@@ -69,8 +70,8 @@
 
 
 /* In gettext.c:  */
-unsigned char* gettext(const unsigned char* in);
-int Load_PO_File(const char* file);
+//unsigned char* gettext(const unsigned char* in);
+//int Load_PO_File(const char* file);
 
 
 /* In laser.c:        */

Modified: tuxtype/branches/soc-sreyas/src/gettext.c
===================================================================
--- tuxtype/branches/soc-sreyas/src/gettext.c	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/gettext.c	2008-08-21 14:33:38 UTC (rev 663)
@@ -1,198 +0,0 @@
-/***************************************************************************
-gettext.c 
--  description: a crossplatform minimal gettext library
--------------------
-begin                : Sunday Feb 23, 2003
-copyright            : (C) 2003 by Jesse Andrews
-email                : jdandr2 at uky.edu
-***************************************************************************/
-
-/***************************************************************************
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-***************************************************************************/
-
-#include "stdio.h"
-#include "globals.h"
-
-/* we will store our list in a linked list since
- * we don't expect too large of a list (famous last words!)
- */
-
-/* FIXME not sure if this file's code is UTF-8/Unicode compatible DSB */
-
-struct node {
-	unsigned char *in;          // the english
-	unsigned char *out;         // the translation
-	struct node *next; // ptr to next in list, NULL if last
-};
-
-typedef struct node item; 
-
-static item* HEAD = NULL;
-
-/* Local function prototypes: */
-static void add_word(unsigned char* in, unsigned char* out);
-
-/* --- add a word to the linked list --- */
-
-void add_word(unsigned char* in, unsigned char* out) {
-	item* cur;
-	/* -- allocate space for the node in the list -- */
-	cur = (item *)malloc(sizeof(item));
-
-	/* -- allocate space for strings, and copy over -- */
-	cur->in = (unsigned char *)malloc(strlen(in)+2);
-	strncpy(cur->in, in, strlen(in)+1);
-	cur->out = (unsigned char *)malloc(strlen(out)+2);
-	strncpy(cur->out, out, strlen(out)+1);
-
-	/* -- add to the front of the list -- */
-	cur->next = HEAD;
-	HEAD = cur;
-}
-
-int Load_PO_File(const char* file) {
-	/* this function will load the passed file (a .po file)
-	 * if need be, it should erase any previously loaded
-	 * translations.
-	 *
-	 * the filename passed must exist!
-	 *
-	 * returns: 0 if ok
-	 * 	-1 if file could not be located
-	 * 	-2 if file has errors in it
-	 */
-
-	item* ptr;
-	FILE* f;
-	unsigned char str[FNLEN];
-	unsigned char in[FNLEN];
-	unsigned char out[FNLEN];
-
-	LOG( "Clearing previous translation list\n" );
-
-	while(HEAD != NULL) {
-		ptr = HEAD->next;
-		free(HEAD);
-		HEAD = ptr;
-	}
-
-	/* Yes, I know, I should use YACC/LEX
-	 * but, until you provide an GPL YACC/LEX 
-	 * implimentation on Mac OS _CLASSIC_, we have
-	 * to do things so they are portable, which
-	 * means, we have to parse our files by hand
-	 * using "state machines"
-	 */
-
-
-	LOG( "Loading translation file\n" );
-	f = fopen( file, "r" );
-
-	if (f == NULL)
-        {
-          DEBUGCODE
-          {
-            fprintf(stderr, "Load_PO_File() - could not open %s\n", file);
-          }
-          return -1;
-	}
-	/* ### ADD ERROR CHECKING ### */
-
-	do {
-		fscanf(f, "%[^\n]\n", str);
-
-		/* get rid of any comments! */
-		{
-			unsigned char mode='O';
-			int i;
-			for (i = 0; i < strlen(str); i++) {
-				if (mode == 'O') {
-					switch (str[i]) {
-						case '"': mode = 'I'; break;
-						case '#': str[i]='\0'; break;
-					}
-				} else {
-					switch (str[i]) {
-						case '\\': 
-							if (mode != 'S') mode = 'S';
-							else mode = 'I';
-							break;
-						case '"': 
-							if (mode != 'S') mode ='O'; 
-							break;
-						default:
-							mode = 'I'; // get rid of any /
-					}
-				}
-			}
-		}
-
-		/* we force msgid or msgstr to be at the begining of the line! */
-
-		if (strncmp(str, "msgid", 5) == 0) {
-			int start=0, endloc=0, i;
-			for (i=0; i<strlen(str); i++)
-				if (str[i] == '"') {
-					if (!start)
-						start = i;
-					else
-						endloc = i;
-				}
-			str[endloc]='\0';
-			strcpy(in, str+start+1);
-		}
-		if (strncmp(str, "msgstr", 6) == 0) {
-			int start=0,endloc=0, i;
-			for (i=0; i<strlen(str); i++)
-				if (str[i] == '"') {
-					if (!start)
-						start = i;
-					else
-						endloc = i;
-				}
-			str[endloc]='\0';
-			strcpy(out, str+start+1);
-			add_word(in, out);
-		}
-
-	} while( !feof(f) );
-
-	LOG( "Completed loading of translation file\n" );
-
-	return 0;
-}
-
-unsigned char* gettext(const unsigned char* in ) {
-	/* this function will attempt to translate the string
-	 * "in" to an "translation of in" if one exists.
-	 * if it doesn't exist in the translation set, it 
-	 * returns "in".
-	 */
-
-	/* go through each time until we find what we want...
-	 * if the number of translated words we use increases, 
-	 * we should move to a hash table.
-	 */
-
-	item* cur = HEAD;
-
-	if (settings.use_english)
-		// the cast is to keep the compiler from complaining
-                // about "discarded qualifiers"
-		return (unsigned char*)in;
-
-	while (cur != NULL) 
-		if (strcmp(cur->in, in) == 0)
-			return cur->out;
-		else
-			cur = cur->next;
-
-	/* if we didn't find anything return what we were asked */
-	return (unsigned char*)in;
-}

Modified: tuxtype/branches/soc-sreyas/src/globals.h
===================================================================
--- tuxtype/branches/soc-sreyas/src/globals.h	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/globals.h	2008-08-21 14:33:38 UTC (rev 663)
@@ -35,6 +35,9 @@
 
 #define MAX_SPRITE_FRAMES 30
 
+
+//#define LOCALEDIR "/usr/local/share"
+
 #include <string.h>
 #include <wchar.h>
 #include <math.h>
@@ -52,6 +55,11 @@
 #include <SDL/SDL_mixer.h>
 #include <SDL/SDL_ttf.h>
 
+//#include "i18n.h"
+#include <libintl.h>
+
+
+
 #endif //  __GLOBALS_H__
 
 #define NEXT_FRAME(SPRITE) if ((SPRITE)->num_frames) (SPRITE)->cur = (((SPRITE)->cur)+1) % (SPRITE)->num_frames;
@@ -70,6 +78,7 @@
   char theme_name[FNLEN];
   char lang[FNLEN];
   char theme_font_name[FNLEN];
+  char theme_locale_name[FNLEN];
   int use_english;
   int fullscreen;
   int sys_sound;
@@ -89,6 +98,7 @@
 /* They can be changed in the struct to other values at run-time */
 #define DEFAULT_MENU_FONT       "AndikaDesRevG.ttf"
 #define DEFAULT_GAME_FONT       "AndikaDesRevG.ttf" 
+#define DEFAULT_LOCALE		"en_GB.UTF-8"
 #define DEFAULT_USE_ENGLISH 1
 #define DEFAULT_FULLSCREEN 1
 #define DEFAULT_SYS_SOUND 1
@@ -112,9 +122,10 @@
   int cur;
 } sprite;
 
-#define _(str) gettext (str)
-#define gettext_noop(str) (str)
+#define _(String) gettext(String)
+#define gettext_noop(String) (String)
 
+
 /* LOGGING works as such:
  *
  * - Use LOG if you want to output a string LOG( "Hello World");

Modified: tuxtype/branches/soc-sreyas/src/loaders.c
===================================================================
--- tuxtype/branches/soc-sreyas/src/loaders.c	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/loaders.c	2008-08-21 14:33:38 UTC (rev 663)
@@ -64,36 +64,12 @@
 /* also should have return value reflect success or failure.     */
 void LoadLang(void)
 {
-  char fn[FNLEN];
 
-  /* we only need to load a lang.po file if we
-   * are actually using a theme, so this is a little
-   * different than the other loaders 
-   */ 
+	setlocale(LC_ALL,settings.theme_locale_name);
+	bindtextdomain(PACKAGE,"/usr/local/share/locale");
+        textdomain(PACKAGE);
+	return;
 
-  if (settings.use_english)
-  {
-    /* We need to set the locale to something supporting UTF-8: */
-    if (!setlocale(LC_CTYPE, "en_US.UTF-8"))
-      fprintf(stderr, "Cannot support UTF-8, ASCII-only words will be used\n");
-    return;
-  }
-
-  /* --- create full path to the lang.po file --- */
-  sprintf( fn, "%s/lang.po", settings.theme_data_path);
-
-  /* FIXME should have program try to setlocale() to lang-specific locale -  */
-  /* for now, at least get a default UTF-8 encoding set: */
-  if (!setlocale(LC_CTYPE, "en_US.UTF-8"))
-    fprintf(stderr, "Cannot support UTF-8, ASCII-only words will be used\n");
-
-  /* This function confusingly returns 0 if successful! */
-  if (0 != Load_PO_File( fn ))  /* Meaning it failed! */
-  {
-    /* failed to find a lang.po file, clear gettext & return */
-    fprintf(stderr, "LoadLang() - could not load lang.po file for %s\n", fn);
-    return;
-  }
 }
 
 int max(int n1, int n2)

Modified: tuxtype/branches/soc-sreyas/src/options.c
===================================================================
--- tuxtype/branches/soc-sreyas/src/options.c	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/options.c	2008-08-21 14:33:38 UTC (rev 663)
@@ -32,6 +32,7 @@
 void Opts_Initialize(void)
 {
   strncpy(settings.theme_font_name, DEFAULT_MENU_FONT, FNLEN);
+  strncpy(settings.theme_locale_name, DEFAULT_LOCALE, FNLEN);
   settings.use_english = DEFAULT_USE_ENGLISH;
   settings.fullscreen = DEFAULT_FULLSCREEN;
   settings.sys_sound = DEFAULT_SYS_SOUND;

Modified: tuxtype/branches/soc-sreyas/src/pause.c
===================================================================
--- tuxtype/branches/soc-sreyas/src/pause.c	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/pause.c	2008-08-21 14:33:38 UTC (rev 663)
@@ -283,7 +283,7 @@
 
   if (settings.sys_sound)
   {
-    t = BlackOutline(_("Sound Effects Volume"), f1, &white);
+    t = BlackOutline(gettext("Sound Effects Volume"), f1, &white);
     if (t)
     {	
       s.y = 160;
@@ -292,7 +292,7 @@
       SDL_FreeSurface(t);
     }
 
-    t = BlackOutline(_("Music Volume"), f1, &white);
+    t = BlackOutline(gettext("Music Volume"), f1, &white);
     if (t)
     {
       s.y = 260;
@@ -303,7 +303,7 @@
   }
   else  /* No sound: */
   {
-    t = BlackOutline(_("Sound & Music Disabled"), f1, &white);
+    t = BlackOutline(gettext("Sound & Music Disabled"), f1, &white);
     if (t)
     {
       s.y = 160;
@@ -313,7 +313,7 @@
     }
   }
 
-  t = BlackOutline(_("Paused!"), f2, &white);
+  t = BlackOutline(gettext("Paused!"), f2, &white);
   if (t)
   {
 	s.y = 60;
@@ -322,7 +322,7 @@
 	SDL_FreeSurface(t);
   }
 
-  t = BlackOutline(_("Press escape again to return to menu"), f1, &white);
+  t = BlackOutline(gettext("Press escape again to return to menu"), f1, &white);
   if (t)
   {
     s.y = 400;
@@ -331,7 +331,7 @@
     SDL_FreeSurface(t);
   }
 
-  t = BlackOutline(_("Press space bar to return to game"), f1, &white);
+  t = BlackOutline(gettext("Press space bar to return to game"), f1, &white);
   if (t)
   {
     s.y = 440;

Modified: tuxtype/branches/soc-sreyas/src/playgame.c
===================================================================
--- tuxtype/branches/soc-sreyas/src/playgame.c	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/playgame.c	2008-08-21 14:33:38 UTC (rev 663)
@@ -22,6 +22,8 @@
 #include "playgame.h"
 #include "snow.h"
 
+#define _(String) gettext(String)
+
 //void add_words( int level );
 
 /* Should these be constants? */
@@ -233,7 +235,7 @@
 				if ( event.type == SDL_QUIT ) {
 					exit(0);
 				} else if (event.type == SDL_KEYDOWN) {
-	
+					
 					if (event.key.keysym.sym == SDLK_F11) 
 						SDL_SaveBMP( screen, "screenshot.bmp" );
 					if (event.key.keysym.sym == SDLK_F6){
@@ -940,14 +942,14 @@
 	}
 	font = LoadFont(settings.theme_font_name, GAME_FONT_SIZE);
 
-	curlev = BlackOutline(_("Level"), font, &white);
-	lives  = BlackOutline(_("Lives"), font, &white);
-	fish   = BlackOutline(_("Fish"), font, &white);
+	curlev = BlackOutline(gettext("Level"), font, &white);
+	lives  = BlackOutline(gettext("Lives"), font, &white);
+	fish   = BlackOutline(gettext("Fish"), font, &white);
 
-	level[0] = BlackOutline(_("Easy"), font, &white);
-	level[1] = BlackOutline(_("Medium"), font, &white);
-	level[2] = BlackOutline(_("Hard"), font, &white);
-	level[3] = BlackOutline(_("Practice"), font, &white);
+	level[0] = BlackOutline(gettext("Easy"), font, &white);
+	level[1] = BlackOutline(gettext("Medium"), font, &white);
+	level[2] = BlackOutline(gettext("Hard"), font, &white);
+	level[3] = BlackOutline(gettext("Practice"), font, &white);
 
 	number_max_w = 0;
 	for (i = 0; i < NUM_NUMS; i++) {
@@ -958,11 +960,11 @@
 	}
 
 	for (i = 0; i < CONGRATS_FRAMES; i++) {
-		congrats[i] = BlackOutline(_("Congratulations"), font, &white);
+		congrats[i] = BlackOutline(gettext("Congratulations"), font, &white);
 	}
 
 	for (i = 0; i < OH_NO_FRAMES; i++) {
-		ohno[i] = BlackOutline(_("Oh No!"), font, &white);
+		ohno[i] = BlackOutline(gettext("Oh No!"), font, &white);
 	}
 	
 	if (settings.sys_sound) {

Modified: tuxtype/branches/soc-sreyas/src/practice.c
===================================================================
--- tuxtype/branches/soc-sreyas/src/practice.c	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/practice.c	2008-08-21 14:33:38 UTC (rev 663)
@@ -75,12 +75,13 @@
       total = 0,
       state = 0;
   int key[100] = {0};
-  SDL_Rect dst, dst2, dst3, dst4;
+  int next_line=0;
+  SDL_Rect dst, dst2, dst4, mydest;
   char keytime[20],
        totaltime[20];
   SDL_Surface* srfc = NULL;
+  SDL_Surface* tmpsurf = NULL;  
   
-  
   if (!practice_load_media())
   {
     fprintf(stderr, "Phrases() - practice_load_media() failed, returning.\n");
@@ -88,8 +89,9 @@
   }
 
   SDL_BlitSurface(bg, NULL, screen, NULL);
-  SDL_BlitSurface(hands, NULL, screen, &hand_loc);
   SDL_BlitSurface(keyboard, NULL, screen, &keyboard_loc);
+  SDL_BlitSurface(screen, NULL, bg, NULL);
+  SDL_BlitSurface(hands, NULL, screen, &hand_loc);
   SDL_Flip(screen);
 
   wp = get_phrase(pphrase);
@@ -115,11 +117,6 @@
   dst2.w = srfc->w;
   dst2.h = srfc->h;
 
-  dst3.x = 0;
-  dst3.y = 400;
-  dst3.w = screen->w;
-  dst3.h = bg->h-dst3.y;
-
   dst4.x = 480;
   dst4.y = 400;
   dst4.w = 240;
@@ -127,6 +124,11 @@
 
   dst.x = 40;
 
+  mydest.x = 0;
+  mydest.y = dst.y;
+  mydest.w = screen->w;
+  mydest.h = screen->h-mydest.y;
+
   start = SDL_GetTicks();
 
   do
@@ -233,11 +235,11 @@
 
         if (event.key.keysym.sym == SDLK_ESCAPE)
           quit = 1;
-
+	else
         if (event.key.keysym.sym == SDLK_DOWN) 
         {
           //practice next phase in list
-          //a=a;
+          quit = 2;
         }
         else
         {
@@ -433,61 +435,46 @@
 /****************************************************/
           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);
-
-            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;
-              }
-            }
-
-            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;
-              }
-            }
-
-
-            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;
-            }
-
-            if (c == wp)
-            {
-              c++;
-              dst.x = 40;
-              dst.y = 142;
-            }
-
-            c++;
-          }
+		c++;
+		state = 0;
+		dst2.x = 40;
+		dst4.x = 480;
+		
+		if (c==wp+2){
+			//c++;
+			dst.x=40;
+			dst.y=dst.y+dst.h;
+			mydest.y=dst.y;
+			mydest.h=screen->h-mydest.y;
+			next_line=1;
+		}
+		SDL_BlitSurface(bg, &mydest, screen, &mydest);
+		SDL_Flip(screen);
+		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(keytime, font, &white);
+		SDL_BlitSurface(tmpsurf, NULL, screen, &dst2);
+		SDL_FreeSurface(tmpsurf);
+		tmpsurf = NULL;	
+		tmpsurf = BlackOutline(totaltime, font, &white);
+		SDL_BlitSurface(tmpsurf, NULL, screen, &dst4);
+		SDL_FreeSurface(tmpsurf);
+		tmpsurf = NULL;
+		if (c==(wcslen(pphrase))){
+				wchar_t buf[10];
+				ConvertFromUTF8(buf, gettext("Great!"));
+				print_at(buf, wcslen(buf), 275, 200);
+				SDL_Flip(screen);
+				SDL_Delay(2500);
+				next_line=0;
+				quit=2;
+		}
+	}
           else
           {
 		int key = GetIndex((wchar_t)event.key.keysym.unicode);
@@ -504,7 +491,7 @@
       }
     }
     SDL_Flip(screen);
-    SDL_Delay(30);
+    SDL_Delay(15);
 
   }while (!quit);
 
@@ -512,7 +499,7 @@
 
   practice_unload_media();
 
-  return 1;
+  return quit;
 }
 
 
@@ -581,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");
@@ -606,8 +593,8 @@
 	}
 	SDL_FreeSurface(keyboard);
         keyboard = NULL;
-	//TTF_CloseFont(font);
-
+	TTF_CloseFont(font);
+	font = NULL;
 	for (i=0; i<10; i++) 
         {
           SDL_FreeSurface(hand[i]);
@@ -780,79 +767,43 @@
 
 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(GetLastKey())->w;
-  letter_loc.h = GetWhiteGlyph(GetLastKey())->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");
+	int z=0;
+	SDL_Surface *tmp;
+	letter_loc.x = x;
+	letter_loc.y = y;
+	//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, 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, font, &white, wrap+1);
+		letter_loc.w = tmp->w+5;
+		letter_loc.h = tmp->h+5;
+		SDL_BlitSurface(tmp, NULL, screen, &letter_loc);
+		SDL_FreeSurface(tmp);
+		letter_loc.x = 40;
+                // - (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+1, font, &white, wcslen(pphrase));
+		letter_loc.w = tmp->w+5;
+		letter_loc.h = tmp->h+5;
+		SDL_BlitSurface(tmp, NULL, screen, &letter_loc);
+		SDL_FreeSurface(tmp);
+	}
+	//TTF_CloseFont(font);
+	// DEBUGCODE { exit(-1); }
+	DEBUGCODE { printf("Leaving print_at \n\n\n"); }
 }
-
 static void next_letter(wchar_t *t, int c)
 {
 	int i;
 	wchar_t buf[30];
-        i=ConvertFromUTF8(buf, _("Next letter "));
+        i=ConvertFromUTF8(buf, gettext("Next letter "));
 	buf[i]=t[c];
 	buf[i+1]=0;
         print_at(buf,wcslen(buf),215 ,420);

Modified: tuxtype/branches/soc-sreyas/src/setup.c
===================================================================
--- tuxtype/branches/soc-sreyas/src/setup.c	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/setup.c	2008-08-21 14:33:38 UTC (rev 663)
@@ -180,7 +180,7 @@
 
   if (!fp)
   {
-    fprintf(stderr, "load_settings_filename(): no theme-specific settings found\n");
+    fprintf(stderr, "load_settings_filename(): no theme-specific settings found%s\n",fn);
     return;
   }
 	
@@ -261,6 +261,13 @@
       strncpy(settings.theme_font_name, value, FNLEN - 1);
       setting_found = 1;
     }
+    else if (strncmp( setting, "theme_locale_name", FNLEN ) == 0 )
+    {
+      DEBUGCODE {fprintf(stderr, "load_settings_fp(): Setting theme locale to %s", value);}
+      strncpy(settings.theme_locale_name, value, FNLEN - 1);
+      setting_found = 1;
+      fprintf(stderr, "load_settings_fp(): Setting theme locale to %s", value);
+    }
     else
       DEBUGCODE {fprintf(stderr, "load_settings_fp(): unrecognized string: %s", value);}
 
@@ -404,6 +411,7 @@
       /* a special font to a theme that uses the default, but lacks */
       /* an explicit statement to use the default(                  */
       strncpy(settings.theme_font_name, DEFAULT_MENU_FONT, FNLEN);
+      
 
       /* Load fontname or any other theme-specific settings: */
       sprintf(theme_settings_path, "%s/settings.txt", full_theme_path);
@@ -420,6 +428,7 @@
       settings.use_english = 1; // default is to use English if we cannot find theme
       strcpy(settings.theme_name, "");
       strncpy(settings.theme_font_name, DEFAULT_MENU_FONT, FNLEN);
+      strncpy(settings.theme_locale_name, DEFAULT_LOCALE,FNLEN);
       fprintf(stderr, "SetupPaths(): could not find '%s'\n", full_theme_path);
     }
   }
@@ -427,6 +436,7 @@
   {
     settings.use_english = 1; // default is to use English if we cannot find theme
     strcpy(settings.theme_name, "");
+    strncpy(settings.theme_locale_name, DEFAULT_LOCALE,FNLEN);
   }
 
 

Modified: tuxtype/branches/soc-sreyas/src/titlescreen.c
===================================================================
--- tuxtype/branches/soc-sreyas/src/titlescreen.c	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/titlescreen.c	2008-08-21 14:33:38 UTC (rev 663)
@@ -65,6 +65,31 @@
 static void unload_media(void);
 static void unload_menu(void);
 
+/* --- menu text --- */
+
+
+     
+static const char *menu_text[]= 
+{"", "",            "",             "",            ""    ,
+ "",gettext_noop("Fish Cascade"),gettext_noop("Easy"),gettext_noop("Space Cadet"),gettext_noop("Edit Word Lists"),
+ "",gettext_noop("Comet Zap"),gettext_noop("Medium"),gettext_noop("Pilot"),gettext_noop("Practice"),
+ "",gettext_noop("Lessons"),gettext_noop("Hard"), gettext_noop("Ace"),gettext_noop("Project Info"),
+ "", gettext_noop("Options"),gettext_noop("Instructions"),gettext_noop("Commander"),gettext_noop("Setup Language"),
+ "", gettext_noop("Quit"),gettext_noop("Main Menu"),gettext_noop("Main Menu"),gettext_noop("Main Menu")};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 /************************************************************************/
 /*                                                                      */ 
 /*         "Public" functions (callable throughout program)             */
@@ -701,12 +726,14 @@
 	{
 		fscanf( fp, "%[^\n]\n", str);
 		ConvertFromUTF8(phrase, str);
-		Phrases( phrase );
+		if(Phrases( phrase )==1)
+			break;
       		//Practice();
-      		load_media();
-      		redraw = 1;
-	} while (0);
+
+	} while (!feof(fp));
 	fclose(fp);
+  	load_media();
+      	redraw = 1;
       //Phrases( phrase );
       //Practice();
       //load_media();
@@ -970,12 +997,12 @@
       DEBUGCODE
       {
         fprintf(stderr, "i = '%d'\tj = '%d'\ttext = '%s'\n",
-                i, j,  _((unsigned char*)menu_text[i][j]));
+                i, j,  gettext((unsigned char*)menu_text[j+5*i]));
       }
 
       /* --- create text surfaces --- */
-      reg_text[i][j] = BlackOutline( _((unsigned char*)menu_text[i][j]), font, &white);
-      sel_text[i][j] = BlackOutline( _((unsigned char*)menu_text[i][j]), font, &yellow);
+      reg_text[i][j] = BlackOutline( gettext((unsigned char*)menu_text[j+5*i]), font, &white);
+      sel_text[i][j] = BlackOutline( gettext((unsigned char*)menu_text[j+5*i]), font, &yellow);
 
       /* (first make sure ptr valid to avoid segfault) */
       if (sel_text[i][j] && sel_text[i][j]->w > max)
@@ -1191,9 +1218,9 @@
 
   LOG( "NotImplemented() - creating text\n" );
 
-  s1 = BlackOutline( _("Work In Progress!"), font, &white);
-  s2 = BlackOutline( _("This feature is not ready yet"), font, &white);
-  s3 = BlackOutline( _("Discuss the future of TuxTyping at"), font, &white);
+  s1 = BlackOutline( gettext_noop("Work In Progress!"), font, &white);
+  s2 = BlackOutline( gettext_noop("This feature is not ready yet"), font, &white);
+  s3 = BlackOutline( gettext_noop("Discuss the future of TuxTyping at"), font, &white);
 
   /* we always want the URL in english */
   /* NOTE: all fonts are almost certain to include glyphs for ASCII, */

Modified: tuxtype/branches/soc-sreyas/src/titlescreen.h
===================================================================
--- tuxtype/branches/soc-sreyas/src/titlescreen.h	2008-08-21 12:12:08 UTC (rev 662)
+++ tuxtype/branches/soc-sreyas/src/titlescreen.h	2008-08-21 14:33:38 UTC (rev 663)
@@ -18,14 +18,6 @@
 			   {0, OPTIONS,   INSTRUCT,  LEVEL4,  SET_LANGUAGE},
 			   {0, QUIT_GAME, MAIN,      MAIN,    MAIN}};
 
-/* --- menu text --- */
-const unsigned char *menu_text[][6]= 
-{{"", "",            "",             "",            ""    },
- {"", gettext_noop("Fish Cascade"), gettext_noop("Easy"),         gettext_noop("Space Cadet"), gettext_noop("Edit Word Lists")},
- {"", gettext_noop("Comet Zap"),    gettext_noop("Medium"),       gettext_noop("Pilot"),       gettext_noop("Practice")},
- {"", gettext_noop("Lessons"),     gettext_noop("Hard"),         gettext_noop("Ace"),         gettext_noop("Project Info")},
- {"", gettext_noop("Options"),      gettext_noop("Instructions"), gettext_noop("Commander"),   gettext_noop("Setup Language")},
- {"", gettext_noop("Quit"),         gettext_noop("Main Menu"),    gettext_noop("Main Menu"),   gettext_noop("Main Menu")}};
 
 /* --- menu icons --- */
 const unsigned char *menu_icon[][6]= 




More information about the Tux4kids-commits mailing list