[Tux4kids-commits] r1611 - in tuxtype/trunk: . doc src
David Bruce
dbruce-guest at alioth.debian.org
Tue Oct 27 11:05:57 UTC 2009
Author: dbruce-guest
Date: 2009-10-27 11:05:56 +0000 (Tue, 27 Oct 2009)
New Revision: 1611
Modified:
tuxtype/trunk/TODO
tuxtype/trunk/doc/README
tuxtype/trunk/src/playgame.c
tuxtype/trunk/src/scripting.c
tuxtype/trunk/src/titlescreen.c
Log:
fix of display bug in XML_Lesson() as well as some minor code cleanup
Modified: tuxtype/trunk/TODO
===================================================================
--- tuxtype/trunk/TODO 2009-10-26 22:51:18 UTC (rev 1610)
+++ tuxtype/trunk/TODO 2009-10-27 11:05:56 UTC (rev 1611)
@@ -1,3 +1 @@
--Clean up this TODO and reflect the current status!
-
-...
+see doc/TODO
\ No newline at end of file
Modified: tuxtype/trunk/doc/README
===================================================================
--- tuxtype/trunk/doc/README 2009-10-26 22:51:18 UTC (rev 1610)
+++ tuxtype/trunk/doc/README 2009-10-27 11:05:56 UTC (rev 1611)
@@ -1,57 +1 @@
-NOTE - this document is reasonably correct but not completely current.
-It will updated as the maintainer's time allows - DSB
-
-
-Tux Typing:
-An Educational Typing Tutor Game Starring Tux, the Linux Penguin
-----------------------------------------------------------------
-
-(To install the game on your system, please read the INSTALL file.)
-
- If you are interested in Translation/moving this game to another
- language, please send a mail to
-
- David Bruce <davidstuartbruce at gmail.com>,
- Holger Levsen <debian at layer-acht.org>, or to:
-
- <tux4kids-tuxtype-dev at lists.alioth.debian.org>
-
- Additional information on this subject is covered in "HowToTheme.html"
- in the "doc/en" directory of this package.
-
-This is version 1.7.6 of Tux Typing.
-
-In Fish Cascade you control Tux as he searches for fish to eat. Fish fall
-from the top of the screen. These fish have letters on them. Unforunately
-for Tux, eating a fish with a letter on it will cause his stomach to
-become ill, so it is up to you to help Tux eat fish! By typing the
-letters, it will cause them to disappear so tux can chow down on the
-fish.
-
-In Comet Zap you control Tux as he defends the cities from comets. To
-protect a city from a comet, type the letter on the comet and it will
-cause Tux to destroy it with a laser! (In case you wondered, Comet Zap
-is an adaptation of the *great* math drill game, "Tux, of Math Command").
-
-"Lessons" and "Practice" are additional typing activities. "Practice"
-involves typing phrases or complete sentences, with measurment of accuracy
-and typing speed. "Lessons" uses XML-based scripting to run various other
-parts of the program in a specified order, including the "Practice" activity.
-These features are not yet completed, but represent ways to add additional
-"content" without requiring more programming per se. You will find other
-menu entries for planned features that still need to be implemented.
-
-Tux Typing is Free-Software, distributable under the GNU General Public
-License. Please read COPYING for more info.
-
-Also, for those who may or may not be wondering: Yes, the rumors are
-true.... Tux Typing has a few special `hidden' options. See if you can
-figure out what it is... ;)
-
-Enjoy!
-
-David Bruce
-davidstuartbruce at gmail.com
-
-(previous maintainer -Jesse Andrews -- jdandr2 at uky.edu
- http://tux4kids.net/~jdandr2)
+For now, see doc/README
\ No newline at end of file
Modified: tuxtype/trunk/src/playgame.c
===================================================================
--- tuxtype/trunk/src/playgame.c 2009-10-26 22:51:18 UTC (rev 1610)
+++ tuxtype/trunk/src/playgame.c 2009-10-27 11:05:56 UTC (rev 1611)
@@ -93,8 +93,8 @@
int won_level = 0;
int quitting = 0;
int curlevel = 0;
- int i;
- int curlives;
+ int i = 0;
+ int curlives = 0;
int oldlives = 0;
int oldfish_left = 0;
int fish_left = 0;
@@ -402,7 +402,7 @@
}
else
{
- fprintf(stderr, "Did not achieve desired frame rate!\n");
+ LOG("Did not achieve desired frame rate!\n");
}
} /* End per-frame game loop - level completed */
Modified: tuxtype/trunk/src/scripting.c
===================================================================
--- tuxtype/trunk/src/scripting.c 2009-10-26 22:51:18 UTC (rev 1610)
+++ tuxtype/trunk/src/scripting.c 2009-10-27 11:05:56 UTC (rev 1611)
@@ -239,10 +239,12 @@
leftRect.w = left->w;
leftRect.h = left->h;
leftRect.x = screen->w/2 - 80 - (leftRect.w/2);
- leftRect.y = screen->h/2 - 50;
+ leftRect.y = screen->h - 50;
- rightRect.w = right->w; rightRect.h = right->h;
- rightRect.x = screen->w/2 + 80 - (rightRect.w/2); rightRect.y = screen->h/2 - 50;
+ rightRect.w = right->w;
+ rightRect.h = right->h;
+ rightRect.x = screen->w/2 + 80 - (rightRect.w/2);
+ rightRect.y = screen->h - 50;
/* set initial rect sizes */
titleRects[0].y = 30;
Modified: tuxtype/trunk/src/titlescreen.c
===================================================================
--- tuxtype/trunk/src/titlescreen.c 2009-10-26 22:51:18 UTC (rev 1610)
+++ tuxtype/trunk/src/titlescreen.c 2009-10-27 11:05:56 UTC (rev 1611)
@@ -59,8 +59,6 @@
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);
@@ -501,7 +499,7 @@
{
// not_implemented();
SDL_BlitSurface(CurrentBkgd(), NULL, screen, NULL);
- SDL_Flip( screen );
+ SDL_Flip(screen);
unload_media();
if (settings.menu_music)
@@ -1551,507 +1549,3 @@
return 1;
}
-
-
-
-static void ChooseFile(void)
-{
- SDL_Surface* titles[MAX_WORD_LISTS] = {NULL};
- SDL_Surface* select[MAX_WORD_LISTS] = {NULL};
- SDL_Surface* bkg = NULL;
- SDL_Rect titleRects[8];
- int stop = 0;
- int loc = 0;
- int old_loc = 1;
-
- int themes = 0;
- int i;
- char fn[FNLEN];
- char wordTypes[MAX_WORD_LISTS][FNLEN];
- char fileNames[MAX_WORD_LISTS][FNLEN];
-
- int old_use_english;
- char old_theme_path[FNLEN];
-
- FILE* fp;
-
- DIR* themesDir = NULL;
- struct dirent* themesFile = NULL;
-
- /* save previous settings in case we back out: */
- old_use_english = settings.use_english;
- strncpy(old_theme_path, settings.theme_data_path, FNLEN - 1);
-
- if(settings.use_english)
- {
- sprintf(fn , "%s/words", settings.default_data_path);
- fprintf(stderr , "%s/words", settings.default_data_path);
- }
- else
- {
- sprintf(fn , "%s/words", settings.theme_data_path);
- fprintf(stderr , "%s/words", settings.theme_data_path);
- }
-
- themesDir = opendir(fn);
-
- if (!themesDir)
- {
- fprintf(stderr, "Choosefile() - cannot open themes directory!");
- return;
- }
-
- do
- {
- themesFile = readdir(themesDir);
- if (!themesFile)
- break;
-
- /* we ignore any hidden file and CVS */
-
- if (themesFile->d_name[0] == '.')
- continue;
-
- if (strcmp("CVS", themesFile->d_name)==0)
- continue;
-
- if(settings.use_english)
- {
- sprintf(fn, "%s/words/%s",settings.default_data_path, themesFile->d_name);
- }
- else
- {
- sprintf(fn, "%s/words/%s", settings.theme_data_path, themesFile->d_name);
- }
-
- /* CheckFile() returns 2 if dir, 1 if file, 0 if neither: */
- if (CheckFile(fn) == 1)
- {
- /* We know it opens safely because CheckFile() returned 1 */
- fp = fopen(fn,"r");
- /* HACK: we should get the names from file :) */
- if (EOF ==fscanf(fp, "%[^\n]\n", wordTypes[themes]))
- continue;
- /* Make sure theme name is capitalized: */
- wordTypes[themes][0] = toupper(wordTypes[themes][0]);
- fclose(fp);
- strncpy( fileNames[themes++], themesFile->d_name, FNLEN-1 );
- }
- } while (1);
-
- closedir(themesDir);
-
- settings.use_english = 1;
- // HACK: is font empty now???
-
- for (i = 0; i<themes; i++)
- {
- titles[i] = BlackOutline(wordTypes[i], DEFAULT_MENU_FONT_SIZE, &white);
- select[i] = BlackOutline(wordTypes[i], DEFAULT_MENU_FONT_SIZE, &yellow);
- }
-
-
- settings.use_english = old_use_english;
-
- bkg = LoadImage("main_bkg.png", IMG_REGULAR);
-
-
- /* set initial rect sizes */
- titleRects[0].y = 150;
- titleRects[0].w = titleRects[0].h = titleRects[0].x = 0;
- for (i = 1; i<8; i++)
- {
- titleRects[i].y = titleRects[i-1].y + 50;
- titleRects[i].w = titleRects[i].h = titleRects[i].x = 0;
- }
-
-
- while (!stop)
- {
- while (SDL_PollEvent(&event))
- switch (event.type)
- {
- case SDL_QUIT:
- exit(0);
- break;
-
- case SDL_MOUSEMOTION:
- for (i = 0; (i < 8) && (loc - (loc % 8) + i < themes); i++)
- if (inRect(titleRects[i], event.motion.x, event.motion.y))
- {
- loc = loc - (loc % 8) + i;
- break; /* out of for loop */
- }
- break; /* out of switch-case */
-
- case SDL_MOUSEBUTTONDOWN:
- for (i = 0; (i < 8) && (loc - (loc % 8) + i <themes); i++)
- if (inRect(titleRects[i], event.button.x, event.button.y))
- {
- loc = loc - (loc % 8) + i;
- ChooseWord(fileNames[loc]);
- break;
- }
- break;
-
- case SDL_KEYDOWN:
- if (event.key.keysym.sym == SDLK_ESCAPE)
- {
- settings.use_english = old_use_english;
- strncpy(settings.theme_data_path, old_theme_path, FNLEN - 1);
- stop = 1;
- break;
- }
-
- if (event.key.keysym.sym == SDLK_RETURN)
- {
- ChooseWord(fileNames[loc]);
- loc = 0;
- break;
- }
-
- if ((event.key.keysym.sym == SDLK_LEFT)
- || (event.key.keysym.sym == SDLK_PAGEUP))
- {
- if (loc - (loc % 8) - 8 >= 0)
- loc = loc - (loc % 8) - 8;
- }
-
- if ((event.key.keysym.sym == SDLK_RIGHT)
- || (event.key.keysym.sym == SDLK_PAGEDOWN))
- {
- if (loc - (loc % 8) + 8 < themes)
- loc = (loc - (loc % 8) + 8);
- }
-
- if (event.key.keysym.sym == SDLK_UP)
- {
- if (loc > 0)
- loc--;
- }
-
- if (event.key.keysym.sym == SDLK_DOWN)
- {
- if (loc + 1 < themes)
- loc++;
- }
- }
-
- if (old_loc != loc)
- {
- int start;
-
- SDL_BlitSurface( bkg, NULL, screen, NULL );
-
- //if (loc) SetupPaths(fileNames[loc]); else SetupPaths(NULL);
-
- start = loc - (loc % 8);
-
- for (i = start; i < MIN (start + 8,themes); i++)
- {
- titleRects[i % 8].x = 320 - (titles[i]->w/2);
- if (i == loc)
- SDL_BlitSurface(select[loc], NULL, screen, &titleRects[i % 8]);
- else
- SDL_BlitSurface(titles[i], NULL, screen, &titleRects[i % 8]);
- }
-
- SDL_UpdateRect(screen, 0, 0, 0 ,0);
- }
- SDL_Delay(40);
- old_loc = loc;
- }
-
- /* --- clear graphics before quitting --- */
-
- for (i = 0; i<themes; i++)
-
- {
- SDL_FreeSurface(titles[i]);
- SDL_FreeSurface(select[i]);
- }
-
-
- SDL_FreeSurface(bkg);
-
- bkg = NULL; /* the other pointers are going out of scope so we don't */
- /* have to worry about setting them to NULL */
-}
-
-
-static void ChooseWord(char *words_file)
-{
- SDL_Surface* titles[MAX_WORD_LISTS] = {NULL};
- SDL_Surface* select[MAX_WORD_LISTS] = {NULL};
- SDL_Surface* left = NULL, *right = NULL;
- SDL_Rect leftRect, rightRect;
- SDL_Surface* bkg = NULL;
- SDL_Rect titleRects[8];
- int stop = 0;
- int loc = 0;
- int old_loc = 1;
- int result = 0;
-
- FILE* fp = NULL;
-
- int start,themes,themest = 0;
- int i,len;
- char fn[FNLEN];
- char str[FNLEN];
- char editWordW[MAX_WORD_LISTS][FNLEN];
- char editWordY[MAX_WORD_LISTS][FNLEN];
-
- wchar_t temp[FNLEN];
-
- int old_use_english;
- char old_theme_path[FNLEN];
-
- /* save previous settings in case we back out: */
- old_use_english = settings.use_english;
- strncpy(old_theme_path, settings.theme_data_path, FNLEN - 1);
-
- if(settings.use_english)
- {
- sprintf(fn , "%s/words/%s", settings.default_data_path,words_file);
- }
- else
- {
- sprintf(fn , "%s/words/%s", settings.theme_data_path,words_file);
- }
-
- fp = fopen(fn,"r");
- result = fscanf(fp, "%[^\n]\n", str);
-
- while(!feof(fp))
- {
- /* HACK: we should get the strings from file :) */
- if (EOF ==fscanf(fp, "%[^\n]\n", editWordW[themes]))
- continue;
- themest=themes;
- strcpy(editWordY[themes++],editWordW[themest]);
- }
-
- fclose(fp);
-
- settings.use_english = 1;
-
- for (i = 0; i<themes; i++)
- {
- titles[i] = BlackOutline(editWordW[i], DEFAULT_MENU_FONT_SIZE, &white);
- strcat(editWordY[i],"|");
- select[i] = BlackOutline(editWordY[i], DEFAULT_MENU_FONT_SIZE, &yellow);
- }
-
- settings.use_english = old_use_english;
- strncpy(settings.theme_data_path, old_theme_path, FNLEN - 1);
-
- bkg = LoadImage("main_bkg.png", IMG_REGULAR);
-
- left = LoadImage("left.png", IMG_ALPHA);
- leftRect.w = left->w; leftRect.h = left->h;
- leftRect.x = 320 - 100 - (leftRect.w/2); leftRect.y = 430;
-
- right = LoadImage("right.png", IMG_ALPHA);
- rightRect.w = right->w; rightRect.h = right->h;
- rightRect.x = 320 + 100 - (rightRect.w/2); rightRect.y = 430;
-
- /* set initial rect sizes */
- titleRects[0].y = 30;
- titleRects[0].w = titleRects[0].h = titleRects[0].x = 0;
- for (i = 1; i<8; i++)
- {
- titleRects[i].y = titleRects[i-1].y + 50;
- titleRects[i].w = titleRects[i].h = titleRects[i].x = 0;
- }
-
-
- while (!stop)
- {
- while (SDL_PollEvent(&event))
- switch (event.type)
- {
- case SDL_QUIT:
- exit(0);
- break;
-
- case SDL_MOUSEBUTTONDOWN:
- if (inRect(leftRect, event.button.x, event.button.y))
- if (loc - (loc % 8) - 8 >= 0)
- {
- loc = loc - (loc % 8) - 8;
- break;
- }
-
- if (inRect(rightRect, event.button.x, event.button.y))
- if (loc - (loc % 8) + 8 < themes)
- {
- loc = loc - (loc % 8) + 8;
- break;
- }
-
- for (i = 0; (i < 8) && (loc - (loc % 8) + i < themes); i++)
- if (inRect(titleRects[i], event.motion.x, event.motion.y))
- {
- loc = loc - (loc % 8) + i;
- break;
- }
- break;
-
- case SDL_KEYDOWN:
- i = 1;
-
- if (event.key.keysym.sym == SDLK_BACKSPACE)
- {
- len = ConvertFromUTF8(temp, editWordW[loc], FNLEN);
- temp[len - 1] = temp[len];
- len = ConvertToUTF8(temp, editWordW[loc], FNLEN);
- titles[loc] = BlackOutline(editWordW[loc], DEFAULT_MENU_FONT_SIZE, &white );
- len = ConvertFromUTF8(temp, editWordY[loc], FNLEN);
- temp[len - 2] = temp[len - 1];
- temp[len - 1] = temp[len];
- len = ConvertToUTF8(temp, editWordY[loc], FNLEN);
- select[loc] = BlackOutline(editWordY[loc], DEFAULT_MENU_FONT_SIZE, &yellow);
- break;
- }
-
- if (event.key.keysym.sym == SDLK_ESCAPE)
- {
- settings.use_english = old_use_english;
- strncpy(settings.theme_data_path, old_theme_path, FNLEN - 1);
- stop = 1;
- break;
- }
-
- if ((event.key.keysym.sym == SDLK_LEFT)
- || (event.key.keysym.sym == SDLK_PAGEUP))
- {
- if (loc - (loc % 8) - 8 >= 0)
- loc = loc - (loc % 8) - 8;
- break;
- }
-
- if ((event.key.keysym.sym == SDLK_RIGHT)
- || (event.key.keysym.sym == SDLK_PAGEDOWN))
- {
- if (loc - (loc % 8) + 8 < themes)
- loc = (loc - (loc % 8) + 8);
- break;
- }
-
- if (event.key.keysym.sym == SDLK_UP)
- {
- if (loc > 0)
- loc--;
- break;
- }
-
- if (event.key.keysym.sym == SDLK_DOWN)
- {
- if (loc + 1 < themes)
- loc++;
- break;
- }
-
- switch (event.key.keysym.sym)
- {
- case SDLK_CAPSLOCK:
- case SDLK_RALT:
- case SDLK_LALT:
- case SDLK_RSHIFT:
- case SDLK_LSHIFT:
- case SDLK_RCTRL:
- case SDLK_LCTRL:
- i=0;
- break;
- default: // ignore any other keys
- {}
- }
-
- if(i)
- {
- len = ConvertFromUTF8(temp, editWordW[loc], FNLEN);
- temp[len] = event.key.keysym.unicode;
- temp[len + 1] = 0;
- ConvertToUTF8(temp,editWordW[loc], FNLEN);
- titles[loc] = BlackOutline(editWordW[loc], DEFAULT_MENU_FONT_SIZE, &white );
- len = ConvertFromUTF8(temp,editWordY[loc], FNLEN);
- temp[len + 1]=0;
- temp[len] = temp[len-1];
- temp[len - 1] = event.key.keysym.unicode;
- ConvertToUTF8(temp,editWordY[loc], FNLEN);
- select[loc] = BlackOutline(editWordY[loc], DEFAULT_MENU_FONT_SIZE, &yellow);
- i = 0;
- break;
- }
- }
-
- if(!stop)
- {
- SDL_BlitSurface( bkg, NULL, screen, NULL );
-
-// if (loc) SetupPaths(fileNames[loc]); else SetupPaths(NULL);
-
- start = loc - (loc % 8);
- for (i = start; i < MIN(start + 8,themes); i++)
- {
- titleRects[i % 8].x = 320 - (titles[i]->w/2);
- if (i == loc)
- SDL_BlitSurface(select[loc], NULL, screen, &titleRects[i%8]);
- else
- SDL_BlitSurface(titles[i], NULL, screen, &titleRects[i%8]);
- }
-
- /* --- draw buttons --- */
-
- if (start > 0)
- SDL_BlitSurface( left, NULL, screen, &leftRect );
-
- if (start + 8 < themes)
- SDL_BlitSurface(right, NULL, screen, &rightRect);
-
- SDL_UpdateRect(screen, 0, 0, 0 ,0);
- }
- //SDL_Delay(40);
- old_loc = loc;
- }
-
- /* Write changes to file, if possible: */
- fprintf(stderr, "In ChooseWord(), about to write changes\n");
- fp = fopen(fn,"w");
-
- if (fp)
- {
- fseek(fp, 0, SEEK_SET);
- fprintf(fp, "%s\n", str);
- i = 0;
-
- while(i < themes)
- {
- fprintf(fp, "%s\n", editWordW[i++]);
- i++;
- }
-
- fclose(fp);
- fp = NULL;
- fprintf(stderr, "In ChooseWord(), changes written successfully\n");
- }
- else
- {
- fprintf(stderr, "In ChooseWord(), unable to open %s for writing\n", fn);
- }
-
-
- /* --- clear graphics before quitting --- */
- /* FIXME none of this is safe if any of the images is NULL */
- for (i = 0; i < themes; i++)
- {
- SDL_FreeSurface(titles[i]);
- SDL_FreeSurface(select[i]);
- }
-
- SDL_FreeSurface(bkg);
- SDL_FreeSurface(left);
- SDL_FreeSurface(right);
- bkg = NULL; /* the other pointers are going out of scope so we don't */
- /* have to worry about setting them to NULL */
-}
More information about the Tux4kids-commits
mailing list