[Tux4kids-commits] r759 - tuxtype/trunk/src
dbruce-guest at alioth.debian.org
dbruce-guest at alioth.debian.org
Thu Oct 9 00:39:42 UTC 2008
Author: dbruce-guest
Date: 2008-10-09 00:39:42 +0000 (Thu, 09 Oct 2008)
New Revision: 759
Modified:
tuxtype/trunk/src/SDL_extras.c
tuxtype/trunk/src/practice.c
Log:
some tweaks to practice activity
Modified: tuxtype/trunk/src/SDL_extras.c
===================================================================
--- tuxtype/trunk/src/SDL_extras.c 2008-09-23 12:16:42 UTC (rev 758)
+++ tuxtype/trunk/src/SDL_extras.c 2008-10-09 00:39:42 UTC (rev 759)
@@ -461,7 +461,7 @@
if (!font || !c)
{
- fprintf(stderr, "BlackOutline_wchar(): invalid ptr parameter, returning.");
+ fprintf(stderr, "BlackOutline_Unicode(): invalid ptr parameter, returning.");
return NULL;
}
/* (cast to stop compiler complaint) */
@@ -469,7 +469,7 @@
if (!black_letters)
{
- fprintf (stderr, "Warning - BlackOutline_wchar() could not create image for %S\n", t);
+ fprintf (stderr, "Warning - BlackOutline_Unicode() could not create image for %S\n", t);
return NULL;
}
Modified: tuxtype/trunk/src/practice.c
===================================================================
--- tuxtype/trunk/src/practice.c 2008-09-23 12:16:42 UTC (rev 758)
+++ tuxtype/trunk/src/practice.c 2008-10-09 00:39:42 UTC (rev 759)
@@ -36,6 +36,7 @@
static SDL_Surface* keypress2 = NULL;
static SDL_Surface* hand[11] = {NULL};
static TTF_Font* font = NULL;
+static TTF_Font* bigfont = NULL;
static wchar_t phrases[MAX_PHRASES][MAX_PHRASE_LENGTH];
static Mix_Chunk* wrong = NULL;
@@ -47,6 +48,7 @@
static SDL_Rect keytime_rect;
static SDL_Rect totaltime_rect;
static SDL_Rect congrats_rect;
+static SDL_Rect nextletter_rect;
static SDL_Rect mydest;
static SDL_Rect hand_loc;
static SDL_Rect letter_loc;
@@ -685,10 +687,10 @@
wrong = LoadSound("tock.wav");
- /* load needed font: */
+ /* load needed fonts: */
font = LoadFont(settings.theme_font_name, 30);
+ bigfont = LoadFont(settings.theme_font_name, 80);
-
/* Get out if anything failed to load: */
if (load_failed
||!num_phrases
@@ -696,6 +698,7 @@
||!CurrentBkgd()
||!wrong
||!font
+ ||!bigfont
||!keyboard
||!hand_shift[0]
||!hand_shift[1]
@@ -722,17 +725,19 @@
static void recalc_positions(void)
{
- /* we can't just use phr_text_rect.w because SDL_BlitSurface() clobbers it: */
- phrase_draw_width = screen->w - 80;
+ /* we can't just use phr_text_rect.w to calc wrap */
+ /* because SDL_BlitSurface() clobbers it: */
+ phrase_draw_width = screen->w * 0.9;
- phr_text_rect.x = 40;
- phr_text_rect.y = 10;
+ phr_text_rect.x = screen->w * 0.1;
+ phr_text_rect.y = screen->h * 0.1;
- user_text_rect.x = 40;
- user_text_rect.y = 100;
- user_text_rect.w = screen->w;
+ user_text_rect.x = screen->w * 0.1;
+ user_text_rect.y = phr_text_rect.y + 60;
+ user_text_rect.w = screen->w * 0.8;
user_text_rect.h = 30; /* FIXME ideally should calculate from font height */
+
keytime_rect.x = 50;
keytime_rect.y = screen->h - 80;
keytime_rect.w = 100;
@@ -753,16 +758,21 @@
mydest.h = screen->h-mydest.y;
hand_loc.x = (screen->w/2) - (hand[0]->w/2);
- hand_loc.y = screen->h - (hand[0]->h);
+ hand_loc.y = screen->h - (hand[0]->h) - 20;
hand_loc.w = (hand[0]->w);
hand_loc.h = (hand[0]->h);
/**** Position of keyboard image */
- keyboard_loc.x = screen->w/2 -keyboard->w/2;
- keyboard_loc.y = screen->h/2;
+ keyboard_loc.x = screen->w/2 -keyboard->w/2 - 50;
+ keyboard_loc.y = screen->h * 0.4;
keyboard_loc.w = screen->w/8;
keyboard_loc.h = screen->h/8;
+ nextletter_rect.x = keyboard_loc.x + keyboard->w + 20;
+ nextletter_rect.y = keyboard_loc.y;
+ nextletter_rect.w = 80;
+ nextletter_rect.h = 80;
+
}
static void practice_unload_media(void)
@@ -791,6 +801,10 @@
TTF_CloseFont(font);
font = NULL;
+ if (bigfont)
+ TTF_CloseFont(bigfont);
+ bigfont = NULL;
+
for (i = 0; i < 10; i++)
{
if (hand[i])
@@ -1155,12 +1169,22 @@
static void next_letter(wchar_t *t, int c)
{
- int i;
- wchar_t buf[30];
- i=ConvertFromUTF8(buf, gettext("Next letter "));
- buf[i]=t[c];
- buf[i+1]=0;
- print_at(buf,wcslen(buf),215 ,420);
+ int i;
+ Uint16 ltr[2];
+ SDL_Surface* s = NULL;
+
+ ltr[0] = t[c];
+ ltr[1] = '\0';
+
+ s = BlackOutline_Unicode(ltr, bigfont, &white);
+
+ if (s)
+ {
+ SDL_BlitSurface(CurrentBkgd(), &nextletter_rect, screen, &nextletter_rect);
+ SDL_BlitSurface(s, NULL, screen, &nextletter_rect);
+ SDL_FreeSurface(s);
+ s = NULL;
+ }
}
SDL_Surface* GetKeypress1(int index)
More information about the Tux4kids-commits
mailing list