[Tux4kids-commits] r883 - tuxtype/trunk/src
dbruce-guest at alioth.debian.org
dbruce-guest at alioth.debian.org
Fri Feb 13 19:56:31 UTC 2009
Author: dbruce-guest
Date: 2009-02-13 19:56:31 +0000 (Fri, 13 Feb 2009)
New Revision: 883
Modified:
tuxtype/trunk/src/alphabet.c
tuxtype/trunk/src/globals.h
tuxtype/trunk/src/loaders.c
tuxtype/trunk/src/main.c
tuxtype/trunk/src/practice.c
Log:
code clean up and fix of keyboard hint bug
Modified: tuxtype/trunk/src/alphabet.c
===================================================================
--- tuxtype/trunk/src/alphabet.c 2009-02-13 06:07:24 UTC (rev 882)
+++ tuxtype/trunk/src/alphabet.c 2009-02-13 19:56:31 UTC (rev 883)
@@ -271,30 +271,50 @@
fprintf(stderr, "GetIndex - Unicode char '%C' not found in list.\n", uni_char);
return -1;
}
+ fprintf(stderr, "Done with GetIndex()\n");
return i;
}
-void GetKeyPos(int index, char *buf)
+void GetKeyPos(int index, char* buf)
{
- sprintf(buf,"keyboard/keyboard_%s.png", keyboard_list[index].keyname);
+ if (index < 0 || index > MAX_UNICODES)
+ {
+ fprintf(stderr, "GetKeyPos() - invalid argument 'index' = %d\n", index);
+ buf = "";
+ return;
+ }
+ sprintf(buf,"keyboard/keyboard_%s.png", keyboard_list[index].keyname);
}
void GetWrongKeyPos(int index, char *buf)
{
- sprintf(buf,"keyboard/keyboardN_%s.png", keyboard_list[index].keyname);
+ if (index < 0 || index > MAX_UNICODES)
+ {
+ fprintf(stderr, "GetWrongKeyPos() - invalid argument 'index' = %d\n", index);
+ buf = "";
+ return;
+ }
+ sprintf(buf,"keyboard/keyboardN_%s.png", keyboard_list[index].keyname);
}
void GetKeyShift(int index, char* buf)
{
+ if (index < 0 || index > MAX_UNICODES)
+ {
+ fprintf(stderr, "GetKeyShift() - invalid argument 'index' = %d\n", index);
+ buf = "";
+ return;
+ }
+
if(keyboard_list[index].shift == 0)
sprintf(buf,"keyboard/keyboard_None.png");
else if(keyboard_list[index].shift == 1)
sprintf(buf,"keyboard/keyboard_D00.png");
else
- sprintf(buf,"%s/images/keyboard/keyboard_D12.png", settings.default_data_path);
+ sprintf(buf,"keyboard/keyboard_D12.png");
}
Modified: tuxtype/trunk/src/globals.h
===================================================================
--- tuxtype/trunk/src/globals.h 2009-02-13 06:07:24 UTC (rev 882)
+++ tuxtype/trunk/src/globals.h 2009-02-13 19:56:31 UTC (rev 883)
@@ -36,8 +36,7 @@
#define MAX_SPRITE_FRAMES 30
-//#define LOCALEDIR "/usr/local/share"
-#include "../config.h"
+#include "config.h"
// Translation stuff (now works for Mac and Win too!):
#include "gettext.h"
Modified: tuxtype/trunk/src/loaders.c
===================================================================
--- tuxtype/trunk/src/loaders.c 2009-02-13 06:07:24 UTC (rev 882)
+++ tuxtype/trunk/src/loaders.c 2009-02-13 19:56:31 UTC (rev 883)
@@ -221,8 +221,6 @@
DEBUGCODE { fprintf(stderr, "Warning - could not load graphics file %s\n", datafile);}
return NULL;
}
-
-// exit(1);
}
Modified: tuxtype/trunk/src/main.c
===================================================================
--- tuxtype/trunk/src/main.c 2009-02-13 06:07:24 UTC (rev 882)
+++ tuxtype/trunk/src/main.c 2009-02-13 19:56:31 UTC (rev 883)
@@ -18,6 +18,7 @@
#include "globals.h"
#include "funcs.h"
+#include "SDL_extras.h"
SDL_Surface* screen;
SDL_Event event;
Modified: tuxtype/trunk/src/practice.c
===================================================================
--- tuxtype/trunk/src/practice.c 2009-02-13 06:07:24 UTC (rev 882)
+++ tuxtype/trunk/src/practice.c 2009-02-13 19:56:31 UTC (rev 883)
@@ -228,6 +228,8 @@
wchar_t buf[200];
wcsncpy(buf, &phrases[cur_phrase][prev_wrap], wrap_pt + 1);
buf[wrap_pt + 1]= '\0';
+ fprintf(stderr, "wrap_pt = %d\t cursor = %d\t prev_wrap = %d\n",
+ wrap_pt, cursor, prev_wrap);
fprintf(stderr, "Phrase to be typed is: %S\n", buf);
}
@@ -242,14 +244,18 @@
}
/* Draw the text the player has typed so far: */
+
tmpsurf = BlackOutline_w(&phrases[cur_phrase][prev_wrap],
medfont, &white,
cursor - prev_wrap);
+
DEBUGCODE
{
wchar_t buf[200];
wcsncpy(buf, &phrases[cur_phrase][prev_wrap], cursor - prev_wrap);
- buf[cursor - prev_wrap + 1]= '\0';
+ buf[cursor - prev_wrap]= '\0';
+ fprintf(stderr, "wrap_pt = %d\t cursor = %d\t prev_wrap = %d\n",
+ wrap_pt, cursor, prev_wrap);
fprintf(stderr, "Text typed so far is: %S\n", buf);
}
@@ -286,6 +292,7 @@
/* If no typing for 0.5 sec, display hint: */
if (SDL_GetTicks() - start > 500)
{
+
/* Show finger hint, if available. Note that GetFinger() */
/* returns negative values on error and never returns a */
/* value greater than 9. */
@@ -295,27 +302,27 @@
keypress1 = GetKeypress1(key);
keypress2 = GetKeypress2(key);
- if (!keypress1)
+ SDL_BlitSurface(CurrentBkgd(), &hand_loc, screen, &hand_loc);
+ SDL_BlitSurface(hands, NULL, screen, &hand_loc);
+
+ if (fing >= 0)
+ SDL_BlitSurface(hand[fing], NULL, screen, &hand_loc);
+ SDL_BlitSurface(hand_shift[shift], NULL, screen, &hand_loc);
+
+ if (keypress1)
{
- fprintf(stderr, "Phrases() - GetKeypress1 failed, returning.\n");
- return 0;
+ SDL_BlitSurface(keypress1, NULL, screen, &keyboard_loc);
+ SDL_FreeSurface(keypress1);
+ keypress1 = NULL;
}
- if(!keypress2)
+ if (keypress2)
{
- fprintf(stderr, "Phrases() - GetKeypress2 failed, returning.\n");
- return 0;
- }
+ SDL_BlitSurface(keypress2, NULL, screen, &keyboard_loc);
+ SDL_FreeSurface(keypress2);
+ keypress2 = NULL;
+ }
- SDL_BlitSurface(CurrentBkgd(), &hand_loc, screen, &hand_loc);
- SDL_BlitSurface(hands, NULL, screen, &hand_loc);
- if (fing >= 0)
- SDL_BlitSurface(hand[fing], NULL, screen, &hand_loc);
- SDL_BlitSurface(hand_shift[shift], NULL, screen, &hand_loc);
- SDL_BlitSurface(keypress1, NULL, screen, &keyboard_loc);
- SDL_BlitSurface(keypress2, NULL, screen, &keyboard_loc);
- SDL_FreeSurface(keypress1);
- SDL_FreeSurface(keypress2);
state = 4;
}
break;
@@ -342,28 +349,29 @@
int shift = GetShift(key);
keypress1 = GetKeypress1(key);
keypress2 = GetKeypress2(key);
+
+ SDL_BlitSurface(CurrentBkgd(), &hand_loc, screen, &hand_loc);
+ SDL_BlitSurface(hands, NULL, screen, &hand_loc);
- if (!keypress1)
+ if (fing >= 0)
+ SDL_BlitSurface(hand[fing], NULL, screen, &hand_loc);
+
+ SDL_BlitSurface(hand_shift[shift], NULL, screen, &hand_loc);
+
+ if (keypress1)
{
- fprintf(stderr, "Phrases() - GetKeypress1 failed, returning.\n");
- return 0;
+ SDL_BlitSurface(keypress1, NULL, screen, &keyboard_loc);
+ SDL_FreeSurface(keypress1);
+ keypress1 = NULL;
}
- if(!keypress2)
+ if (keypress2)
{
- fprintf(stderr, "Phrases() - GetKeypress2 failed, returning.\n");
- return 0;
+ SDL_BlitSurface(keypress2, NULL, screen, &keyboard_loc);
+ SDL_FreeSurface(keypress2);
+ keypress2 = NULL;
}
- SDL_BlitSurface(CurrentBkgd(), &hand_loc, screen, &hand_loc);
- SDL_BlitSurface(hands, NULL, screen, &hand_loc);
- if (fing >= 0)
- SDL_BlitSurface(hand[fing], NULL, screen, &hand_loc);
- SDL_BlitSurface(hand_shift[shift], NULL, screen, &hand_loc);
- SDL_BlitSurface(keypress1, NULL, screen, &keyboard_loc);
- SDL_BlitSurface(keypress2, NULL, screen, &keyboard_loc);
- SDL_FreeSurface(keypress1);
- SDL_FreeSurface(keypress2);
state = 13;
break;
}
@@ -656,7 +664,6 @@
/* Redraw everything below any "completed" lines of input text, */
/* except we don't want to redraw keyboard to avoid flicker: */
-
tmpsurf = BlackOutline_w(&phrases[cur_phrase][prev_wrap],
medfont, &white,
cursor - prev_wrap);
@@ -1457,7 +1464,8 @@
SDL_Surface* GetKeypress2(int index)
{
+
char buf[50];
- GetKeyShift(index,buf);
+ GetKeyShift(index, buf);
return (LoadImage(buf, IMG_ALPHA));
}
More information about the Tux4kids-commits
mailing list