[Tux4kids-commits] r149 - in tuxmath/trunk: . docs src
David Bruce
dbruce-guest at alioth.debian.org
Sat Apr 7 19:49:42 UTC 2007
Author: dbruce-guest
Date: 2007-04-07 19:49:41 +0000 (Sat, 07 Apr 2007)
New Revision: 149
Modified:
tuxmath/trunk/Makefile.am
tuxmath/trunk/Makefile.in
tuxmath/trunk/docs/changelog
tuxmath/trunk/src/Makefile.in
tuxmath/trunk/src/alphabet.c
tuxmath/trunk/src/highscore.c
tuxmath/trunk/src/highscore.h
tuxmath/trunk/src/titlescreen.c
tuxmath/trunk/src/titlescreen.h
tuxmath/trunk/src/tuxmath.c
tuxmath/trunk/src/tuxmath.h
Log:
More high score table work, and fix of black_outline()
Modified: tuxmath/trunk/Makefile.am
===================================================================
--- tuxmath/trunk/Makefile.am 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/Makefile.am 2007-04-07 19:49:41 UTC (rev 149)
@@ -19,7 +19,6 @@
(cd $(top_srcdir)/$(PACKAGE_DATA_DIR) ; tar cf - --exclude "Makefile.in" --exclude "*.in" --exclude "*~" --exclude \ "Makefile" --exclude "Makefile.am" --exclude CVS --exclude .xvpics --exclude "1[1-9].ogg" --exclude "2?.ogg" --exclude "*.svn*" * ) \
| ( cd $(top_srcdir)/$(NSI_INSTALL_DIR)/$(PACKAGE_DATA_DIR) ; tar xf -) ; \
cp $(NSI_DLL_DIR)/*.dll $(top_srcdir)/$(NSI_INSTALL_DIR) ; \
- cp $(NSI_DLL_DIR)/*.ttf $(top_srcdir)/$(NSI_INSTALL_DIR)/data/fonts ; \
cp $(SUBDIRS)/*.exe $(top_srcdir)/$(NSI_INSTALL_DIR) ;
if NSI_USE_TUXMATH_CONF
Modified: tuxmath/trunk/Makefile.in
===================================================================
--- tuxmath/trunk/Makefile.in 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/Makefile.in 2007-04-07 19:49:41 UTC (rev 149)
@@ -37,8 +37,8 @@
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure $(top_srcdir)/nsis/tuxmath.nsi.in \
$(top_srcdir)/nsis/tuxmath_with_conf.nsi.in AUTHORS COPYING \
- ChangeLog INSTALL NEWS config.guess config.sub depcomp \
- install-sh missing mkinstalldirs
+ ChangeLog INSTALL NEWS config.guess config.rpath config.sub \
+ depcomp install-sh missing mkinstalldirs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
@@ -634,7 +634,6 @@
(cd $(top_srcdir)/$(PACKAGE_DATA_DIR) ; tar cf - --exclude "Makefile.in" --exclude "*.in" --exclude "*~" --exclude \ "Makefile" --exclude "Makefile.am" --exclude CVS --exclude .xvpics --exclude "1[1-9].ogg" --exclude "2?.ogg" --exclude "*.svn*" * ) \
| ( cd $(top_srcdir)/$(NSI_INSTALL_DIR)/$(PACKAGE_DATA_DIR) ; tar xf -) ; \
cp $(NSI_DLL_DIR)/*.dll $(top_srcdir)/$(NSI_INSTALL_DIR) ; \
- cp $(NSI_DLL_DIR)/*.ttf $(top_srcdir)/$(NSI_INSTALL_DIR)/data/fonts ; \
cp $(SUBDIRS)/*.exe $(top_srcdir)/$(NSI_INSTALL_DIR) ;
@NSI_USE_TUXMATH_CONF_TRUE@ $(INSTALL) -d $(top_srcdir)/$(NSI_INSTALL_DIR)/TuxMathConfig ;
@@ -652,9 +651,6 @@
rm -fr $(NSI_INSTALL_DIR); \
fi
# -rm tuxmath- at VERSION@-win32-installer.exe
-
-macapp:
- cd src && $(MAKE) $(AM_MAKEFLAGS) bundle && $(MAKE) $(AM_MAKEFLAGS) bundle-fw && $(MAKE) $(AM_MAKEFLAGS) bundle-libs && $(MAKE) $(AM_MAKEFLAGS) bundle-dmg
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
Modified: tuxmath/trunk/docs/changelog
===================================================================
--- tuxmath/trunk/docs/changelog 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/docs/changelog 2007-04-07 19:49:41 UTC (rev 149)
@@ -1,4 +1,14 @@
changelog for "tuxmath"
+
+2007.Apr.07 (svn.debian.org/tux4kids - revision 149)
+ Game:
+ * Partially implemented high-score table in place (no support
+ yet for player to put in own name).
+ * Font rendering addressed - black_outline() now works as
+ intended (perhaps appearance can be improved).
+
+ David Bruce <dbruce at tampabay.rr.com>
+
2007.Mar.15 (svn.debian.org/tux4kids - revision ??? & ???)
Build:
* First revision adds Xcode building for MacOSX
Modified: tuxmath/trunk/src/Makefile.in
===================================================================
--- tuxmath/trunk/src/Makefile.in 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/src/Makefile.in 2007-04-07 19:49:41 UTC (rev 149)
@@ -205,14 +205,6 @@
AM_CFLAGS = -Wall -g -DDATA_PREFIX=\"${DATA_PREFIX}\" -DDEBUG \
-DVERSION=\"@NAME_VERSION@\" -D$(SOUND)SOUND
-
-#------------------ Packaging rules for Mac OSX ------------------------
-#---Many thanks to the developers (esp. Sidney Markowitz?) of Enigma,---
-#---whose Makefiles were the template for this one.---------------------
-bundle_name := $(top_builddir)/macbuild/TuxMath.app
-
-# Special target to create a binary linked with Mac OS X frameworks
-static_prefix := `$(SDL_CONFIG) --prefix`
noinst_HEADERS = highscore.h
all: all-am
@@ -494,39 +486,6 @@
# How to make an RC file
tuxmathrc.o: tuxmathrc.rc
$(WINDRES) -i $< -o $@
-# Special target to copy all needed game files to TuxMath.app/Contents/Resources.
-# For Mac OS X bundle.
-.PHONY: bundle
-bundle:
- -rm -rf $(bundle_name)/Contents
- mkdir -p $(bundle_name)/Contents/MacOS
- mkdir -p $(bundle_name)/Contents/Resources/data/
- echo "APPL????" > $(bundle_name)/Contents/PkgInfo
- cp $(top_builddir)/Info.plist $(bundle_name)/Contents/
- cp $(top_builddir)/data/images/tuxmath.icns $(bundle_name)/Contents/Resources/
- tar -cf - --exclude .svn -C $(top_builddir)/data . | tar xpf - -C $(bundle_name)/Contents/Resources/data
- mkdir -p $(bundle_name)/Contents/lib
- mkdir -p $(bundle_name)/Contents/bin
- cp $(top_builddir)/tuxmath.sh $(bundle_name)/Contents/MacOS/tuxmath
-
-# Special target to copy the binary to Enigma.app/Contents/MacOS.
-.PHONY: bundle-fw
-bundle-fw: tuxmath-fw-mosx
- cp tuxmath-fw $(bundle_name)/Contents/bin/tuxmath
- strip $(bundle_name)/Contents/bin/tuxmath
-
-# Special target to copy the libraries from /sw/lib (from Fink)
-.PHONY: bundle-libs
-bundle-libs: tuxmath-fw-mosx
- $(top_builddir)/mac_cplibs.sh tuxmath-fw $(bundle_name)/Contents/lib/
-.PHONY: tuxmath-fw-mosx
-tuxmath-fw-mosx: $(tuxmath_OBJECTS) $(tuxmath_DEPENDENCIES)
- $(CXX) $(LDFLAGS) -o tuxmath-fw $(tuxmath_OBJECTS) $(tuxmath_DEPENDENCIES) -L$(static_prefix)/lib -lSDLmain -lSDL -lSDL_image -lSDL_mixer -framework Cocoa -framework OpenGL
-
-# Special target to make a disk image of the bundled app
-.PHONY: bundle-dmg
-bundle-dmg:
- hdiutil create -ov -srcfolder $(bundle_name) -volname TuxMath -imagekey zlib-level=6 $(top_builddir)/macbuild/TuxMath.dmg
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
Modified: tuxmath/trunk/src/alphabet.c
===================================================================
--- tuxmath/trunk/src/alphabet.c 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/src/alphabet.c 2007-04-07 19:49:41 UTC (rev 149)
@@ -119,57 +119,71 @@
}
-/* FIXME this function segfaults if passed "" as the char arg */
-SDL_Surface* black_outline(unsigned char *t, TTF_Font *font, SDL_Color *c) {
- SDL_Surface *out, *tmp, *tmp2;
- SDL_Rect dstrect;
+/* black_outline() creates a surface containing text of the designated */
+/* foreground color, surrounded by a black shadow, on a transparent */
+/* background. The appearance can be tuned by adjusting the number of */
+/* background copies and the offset where the foreground text is */
+/* finally written (see below). */
+SDL_Surface* black_outline(unsigned char *t, TTF_Font *font, 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;
- /* --- create the blocky black "outline" of the text --- */
+ if (!t || !font || !c)
+ {
+ fprintf(stderr, "black_outline(): invalid ptr parameter, returning.");
+ return NULL;
+ }
+
#ifdef TUXMATH_DEBUG
fprintf( stderr, "\nEntering black_outline(): \n");
fprintf( stderr, "black_outline of \"%s\"\n", t );
#endif
- tmp = TTF_RenderUTF8_Shaded(font, t, black,black);
- if (!tmp)
- {
- fprintf(stderr, "Could not create rendered SDL_Surface of %s\n", t);
- return NULL;
- }
+ black_letters = TTF_RenderUTF8_Blended(font, t, black);
- tmp2 = SDL_CreateRGBSurface(SDL_SWSURFACE, (tmp->w)+5, (tmp->h)+5, BPP, rmask, gmask, bmask, amask);
- out = SDL_DisplayFormatAlpha(tmp2);
- SDL_FreeSurface(tmp2);
+ bg = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ (black_letters->w) + 5,
+ (black_letters->h) + 5,
+ 32,
+ rmask, gmask, bmask, amask);
+ /* Use color key for eventual transparency: */
+ color_key = SDL_MapRGB(bg->format, 10, 10, 10);
+ SDL_FillRect(bg, NULL, color_key);
- dstrect.w = tmp->w;
- dstrect.h = tmp->h;
+ /* Now draw black outline/shadow 2 pixels on each side: */
+ dstrect.w = black_letters->w;
+ dstrect.h = black_letters->h;
- for (dstrect.x = 1; dstrect.x < 4; dstrect.x++)
- for (dstrect.y = 1; dstrect.y < 4; dstrect.y++)
- SDL_BlitSurface( tmp, NULL, out, &dstrect );
+ /* 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(tmp);
+ SDL_FreeSurface(black_letters);
- /* --- Put the color version of the text on top! --- */
+ /* --- Put the color version of the text on top! --- */
+ white_letters = TTF_RenderUTF8_Blended(font, t, *c);
+ dstrect.x = 1;
+ dstrect.y = 1;
+ SDL_BlitSurface(white_letters, NULL, bg, &dstrect);
+ SDL_FreeSurface(white_letters);
- tmp = TTF_RenderUTF8_Blended(font, t, *c);
+ /* --- Convert to the screen format for quicker blits --- */
+ SDL_SetColorKey(bg, SDL_SRCCOLORKEY|SDL_RLEACCEL, color_key);
+ out = SDL_DisplayFormatAlpha(bg);
+ SDL_FreeSurface(bg);
- dstrect.x = dstrect.y = 2;
-
- SDL_BlitSurface(tmp, NULL, out, &dstrect);
-
- SDL_FreeSurface(tmp);
-
- /* --- Convert to the screen format for quicker blits --- */
-
- tmp = SDL_DisplayFormatAlpha(out);
- SDL_FreeSurface(out);
-
#ifdef TUXMATH_DEBUG
fprintf( stderr, "\nLeaving black_outline(): \n");
#endif
- return tmp;
+ return out;
}
void show_letters( void ) {
Modified: tuxmath/trunk/src/highscore.c
===================================================================
--- tuxmath/trunk/src/highscore.c 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/src/highscore.c 2007-04-07 19:49:41 UTC (rev 149)
@@ -39,9 +39,8 @@
}
/* Test to see where a new score ranks on the list. */
-/* The return value is the ordinary language place (e.g. */
-/* 1 for the top of the list), rather than the index */
-/* itself (e.g. 0 for the top of the list - sorry RMS!) */
+/* The return value is the index value - add one to get */
+/* the common-language place on the list. */
int check_score_place(int diff_level, int new_score)
{
int i = 0;
@@ -61,12 +60,8 @@
break;
}
- if (HIGH_SCORES_SAVED == i) /* i.e. reached end of list */
- {
- return 0;
- }
- else
- return (i + 1);
+ return i; /* So if we return HIGH_SCORES_SAVED, the score did not */
+ /* make the list. */
}
/* Put a new high score entry into the table for the corresponding */
@@ -78,15 +73,10 @@
insert_place = check_score_place(diff_level, new_score);
- if (!insert_place) /* Score didn't make the top 10 */
+ if (HIGH_SCORES_SAVED == insert_place) /* Score didn't make the top 10 */
{
return 0;
}
- else /* Subtract one to get index instead of common-language */
- /* list position. */
- {
- insert_place--;
- }
/* Move lower entries down: */
for (i = HIGH_SCORES_SAVED - 1; i > insert_place; i--)
@@ -142,7 +132,7 @@
for (j = 0; j < HIGH_SCORES_SAVED; j++)
{
fprintf(fp, "%d.\t%s\t%d\n",
- j + 1,
+ j + 1, //Convert to common-language ordinals
high_scores[i][j].name,
high_scores[i][j].score);
}
@@ -230,3 +220,51 @@
}
return;
}
+
+
+/* Return the score associated with a table entry: */
+/* Note: the place is given as the array index, i.e. */
+/* 0 for the top of the list. */
+int HS_Score(int diff_level, int place)
+{
+ /* Make sure diff_level is valid: */
+ if (diff_level < 0
+ || diff_level > ACE_HIGH_SCORE)
+ {
+ fprintf(stderr, "In HS_Score(), diff_level invalid!\n");
+ return -1;
+ }
+
+ /* Make sure place is valid: */
+ if (place < 0
+ || place >= HIGH_SCORES_SAVED)
+ {
+ fprintf(stderr, "In HS_Score(), place invalid!\n");
+ return -1;
+ }
+
+ return high_scores[diff_level][place].score;
+}
+
+
+/* Return (pointer to) the name associated with a table entry: */
+char* HS_Name(int diff_level, int place)
+{
+ /* Make sure diff_level is valid: */
+ if (diff_level < 0
+ || diff_level > ACE_HIGH_SCORE)
+ {
+ fprintf(stderr, "In HS_Score(), diff_level invalid!\n");
+ return -1;
+ }
+
+ /* Make sure place is valid: */
+ if (place < 0
+ || place >= HIGH_SCORES_SAVED)
+ {
+ fprintf(stderr, "In HS_Score(), place invalid!\n");
+ return -1;
+ }
+
+ return &high_scores[diff_level][place].name;
+}
Modified: tuxmath/trunk/src/highscore.h
===================================================================
--- tuxmath/trunk/src/highscore.h 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/src/highscore.h 2007-04-07 19:49:41 UTC (rev 149)
@@ -25,4 +25,6 @@
int read_high_scores_fp(FILE* fp);
void write_high_scores_fp(FILE* fp);
+int HS_Score(int diff_level, int place);
+char* HS_Name(int diff_level, int place);
#endif
Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/src/titlescreen.c 2007-04-07 19:49:41 UTC (rev 149)
@@ -26,6 +26,7 @@
#include "titlescreen.h"
// tuxmath includes:
+#include "tuxmath.h"
#include "options.h"
#include "fileops.h"
#include "game.h"
@@ -34,6 +35,8 @@
#include "credits.h"
#include "highscore.h"
+
+
/* --- Data Structure for Dirty Blitting --- */
SDL_Rect srcupdate[MAX_UPDATES];
SDL_Rect dstupdate[MAX_UPDATES];
@@ -68,17 +71,17 @@
{0, ARCADE, ARCADE_SCOUT, HELP, FREETYPE },
{0, OPTIONS, ARCADE_RANGER, CREDITS, PROJECT_INFO},
{0, GAME_OPTIONS, ARCADE_ACE, PROJECT_INFO, SET_LANGUAGE},
- {0, QUIT_GAME, MAIN, MAIN, MAIN }};
+ {0, QUIT_GAME, HIGH_SCORES, MAIN, MAIN }};
/* --- menu text --- */
const unsigned char* menu_text[TITLE_MENU_ITEMS + 1][TITLE_MENU_DEPTH + 1] =
/* Main Menu 'Arcade' Games Options Game Options */
{{"", "", "", "", "" },
- {"", N_("Math Command Training Academy"), N_("Space Cadet"), N_("Settings"), N_("Speed") },
- {"", N_("Play Arcade Game"), N_("Scout"), N_("Help"), N_("Sound") },
- {"", N_("Play Custom Game"), N_("Ranger"), N_("Credits"), N_("Graphics") },
- {"", N_("More Options"), N_("Ace"), N_("Project Info"), N_("Advanced Options")},
- {"", N_("Quit"), N_("Main Menu"), N_("Main Menu"), N_("Main Menu") }};
+ {"", N_("Math Command Training Academy"), N_("Space Cadet"), N_("Settings"), N_("Speed") },
+ {"", N_("Play Arcade Game"), N_("Scout"), N_("Help"), N_("Sound") },
+ {"", N_("Play Custom Game"), N_("Ranger"), N_("Credits"), N_("Graphics") },
+ {"", N_("More Options"), N_("Ace"), N_("Project Info"), N_("Advanced Options")},
+ {"", N_("Quit"), N_("Hall Of Fame"), N_("Main Menu"), N_("Main Menu") }};
/* These are the filenames of the images used in the animated menu icons: */
@@ -151,6 +154,7 @@
void TitleScreen_load_media(void);
void TitleScreen_unload_media(void);
void NotImplemented(void);
+void HighScoreScreen(void);
void TransWipe(SDL_Surface* newbkg, int type, int var1, int var2);
void UpdateScreen(int* frame);
void AddRect(SDL_Rect* src, SDL_Rect* dst);
@@ -615,10 +619,10 @@
audioMusicUnload();
game();
/* See if player made high score list! */
- if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()))
+ if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()) < HIGH_SCORES_SAVED)
{
/* (Get name string from player) */
- insert_score("Little Kindy", CADET_HIGH_SCORE, Opts_LastScore());
+ insert_score("Cadet (temporary)", CADET_HIGH_SCORE, Opts_LastScore());
write_high_scores();
#ifdef TUXMATH_DEBUG
print_high_scores(stderr);
@@ -649,10 +653,10 @@
audioMusicUnload();
game();
/* See if player made high score list! */
- if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()))
+ if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()) < HIGH_SCORES_SAVED)
{
/* (Get name string from player) */
- insert_score("Toothless Wonder", SCOUT_HIGH_SCORE, Opts_LastScore());
+ insert_score("Scout (temporary)", SCOUT_HIGH_SCORE, Opts_LastScore());
write_high_scores();
#ifdef TUXMATH_DEBUG
print_high_scores(stderr);
@@ -684,10 +688,10 @@
audioMusicUnload();
game();
/* See if player made high score list! */
- if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()))
+ if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()) < HIGH_SCORES_SAVED)
{
/* (Get name string from player) */
- insert_score("Rock Climber", RANGER_HIGH_SCORE, Opts_LastScore());
+ insert_score("Ranger (temporary)", RANGER_HIGH_SCORE, Opts_LastScore());
write_high_scores();
#ifdef TUXMATH_DEBUG
print_high_scores(stderr);
@@ -722,10 +726,10 @@
/* next mission file forgets to specify it: */
MC_SetFractionToKeep(1.0);
/* See if player made high score list! */
- if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()))
+ if (check_score_place(ACE_HIGH_SCORE, Opts_LastScore()) < HIGH_SCORES_SAVED)
{
/* (Get name string from player) */
- insert_score("Good Player", ACE_HIGH_SCORE, Opts_LastScore());
+ insert_score("Ace (temporary)", ACE_HIGH_SCORE, Opts_LastScore());
write_high_scores();
#ifdef TUXMATH_DEBUG
print_high_scores(stderr);
@@ -746,10 +750,9 @@
}
/* Go back to main menu: */
- case MAIN:
+ case HIGH_SCORES:
{
- menu_depth = ROOTMENU;
- update_locs = 1;
+ HighScoreScreen();
redraw = 1;
break;
}
@@ -791,6 +794,15 @@
break;
}
+ /* Go back to main menu: */
+ case MAIN:
+ {
+ menu_depth = ROOTMENU;
+ update_locs = 1;
+ redraw = 1;
+ break;
+ }
+
default:
{
/* Do nothing */
@@ -1232,7 +1244,6 @@
void NotImplemented(void)
{
SDL_Surface *s1, *s2, *s3, *s4;
- sprite *tux;
SDL_Rect loc;
int finished = 0;
int tux_frame = 0;
@@ -1302,10 +1313,9 @@
SDL_BlitSurface(images[IMG_STOP], NULL, screen, &stopRect);
}
- tux = LoadSprite("tux/bigtux", IMG_ALPHA);
- if (tux && tux->num_frames) /* make sure sprite has at least one frame */
+ if (Tux && Tux->num_frames) /* make sure sprite has at least one frame */
{
- SDL_BlitSurface(tux->frame[0], NULL, screen, &Tuxdest);
+ SDL_BlitSurface(Tux->frame[0], NULL, screen, &Tuxdest);
}
SDL_UpdateRect(screen, 0, 0, 0, 0);
@@ -1352,9 +1362,9 @@
default: tux_frame = 0;
}
- if (tux && tux_frame)
+ if (Tux && tux_frame)
{
- SDL_BlitSurface(tux->frame[tux_frame - 1], NULL, screen, &Tuxdest);
+ SDL_BlitSurface(Tux->frame[tux_frame - 1], NULL, screen, &Tuxdest);
SDL_UpdateRect(screen, Tuxdest.x+37, Tuxdest.y+40, 70, 45);
}
/* Wait so we keep frame rate constant: */
@@ -1369,12 +1379,251 @@
SDL_FreeSurface(s2);
SDL_FreeSurface(s3);
SDL_FreeSurface(s4);
- FreeSprite(tux);
}
+/* Display high scores: */
+void HighScoreScreen(void)
+{
+ int i = 0;
+ int finished = 0;
+ int tux_frame = 0;
+ Uint32 frame = 0;
+ Uint32 start = 0;
+ int diff_level = CADET_HIGH_SCORE;
+ int old_diff_level = SCOUT_HIGH_SCORE; //So table gets refreshed first time through
+ char* diff_level_name = _("Space Cadet");
+ /* Surfaces, char buffers, and rects for table: */
+ SDL_Surface* score_entries[HIGH_SCORES_SAVED];
+ /* 20 spaces should be enough room for place and score on each line: */
+ char score_texts[HIGH_SCORES_SAVED][HIGH_SCORE_NAME_LENGTH + 20];
+
+
+ SDL_Rect score_rects[HIGH_SCORES_SAVED];
+ SDL_Rect leftRect, rightRect;
+
+ int score_table_x = 240;
+ int score_table_y = 100;
+
+ /* set SDL_Surface* to null before use: */
+ for (i = 0; i < HIGH_SCORES_SAVED; i++)
+ {
+ score_entries[i] = NULL;
+ }
+
+ /* Draw background & title: */
+ if (images[IMG_MENU_BKG])
+ SDL_BlitSurface( images[IMG_MENU_BKG], NULL, screen, NULL );
+ if (images[IMG_MENU_TITLE])
+ SDL_BlitSurface(images[IMG_MENU_TITLE], NULL, screen, &Titledest);
+
+ /* Put arrow buttons in right lower corner, inset by 20 pixels */
+ /* with a 10 pixel space between: */
+ if (images[IMG_RIGHT])
+ {
+ rightRect.w = images[IMG_RIGHT]->w;
+ rightRect.h = images[IMG_RIGHT]->h;
+ rightRect.x = screen->w - images[IMG_RIGHT]->w - 20;
+ rightRect.y = screen->h - images[IMG_RIGHT]->h - 20;
+ SDL_BlitSurface(images[IMG_RIGHT], NULL, screen, &rightRect);
+ }
+
+ if (images[IMG_LEFT])
+ {
+ leftRect.w = images[IMG_LEFT]->w;
+ leftRect.h = images[IMG_LEFT]->h;
+ leftRect.x = rightRect.x - 10 - images[IMG_LEFT]->w;
+ leftRect.y = screen->h - images[IMG_LEFT]->h - 20;
+ SDL_BlitSurface(images[IMG_LEFT_GRAY], NULL, screen, &leftRect);
+ }
+
+ /* Red "Stop" circle in upper right corner to go back to main menu: */
+ if (images[IMG_STOP])
+ {
+ stopRect.w = images[IMG_STOP]->w;
+ stopRect.h = images[IMG_STOP]->h;
+ stopRect.x = screen->w - images[IMG_STOP]->w;
+ stopRect.y = 0;
+ SDL_BlitSurface(images[IMG_STOP], NULL, screen, &stopRect);
+ }
+
+ if (Tux && Tux->num_frames) /* make sure sprite has at least one frame */
+ {
+ SDL_BlitSurface(Tux->frame[0], NULL, screen, &Tuxdest);
+ }
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+ while (!finished)
+ {
+ start = SDL_GetTicks();
+
+ /* Check for user events: */
+ while (SDL_PollEvent(&event))
+ {
+ switch (event.type)
+ {
+ case SDL_QUIT:
+ {
+ cleanup();
+ }
+
+ case SDL_MOUSEBUTTONDOWN:
+ /* "Stop" button - go to main menu: */
+ {
+ if (inRect(stopRect, event.button.x, event.button.y ))
+ {
+ finished = 1;
+ tuxtype_playsound(sounds[SND_TOCK]);
+ }
+
+ /* "Left" button - go to previous page: */
+ if (inRect(leftRect, event.button.x, event.button.y))
+ {
+ if (diff_level > CADET_HIGH_SCORE)
+ {
+ diff_level--;
+ if (Opts_MenuSound())
+ {
+ tuxtype_playsound(sounds[SND_TOCK]);
+ }
+ }
+ }
+
+ /* "Right" button - go to next page: */
+ if (inRect( rightRect, event.button.x, event.button.y ))
+ {
+ if (diff_level < ACE_HIGH_SCORE)
+ {
+ diff_level++;
+ if (Opts_MenuSound())
+ {
+ tuxtype_playsound(sounds[SND_TOCK]);
+ }
+ }
+ }
+ break;
+ }
+
+
+ case SDL_KEYDOWN:
+ {
+ finished = 1;
+ tuxtype_playsound(sounds[SND_TOCK]);
+ }
+ }
+ }
+
+
+ /* If needed, redraw: */
+ if (diff_level != old_diff_level)
+ {
+ /* Draw background & title: */
+ if (images[IMG_MENU_BKG])
+ SDL_BlitSurface( images[IMG_MENU_BKG], NULL, screen, NULL );
+ if (images[IMG_MENU_TITLE])
+ SDL_BlitSurface(images[IMG_MENU_TITLE], NULL, screen, &Titledest);
+ /* Draw Tux: */
+ if (Tux && Tux->num_frames) /* make sure sprite has at least one frame */
+ SDL_BlitSurface(Tux->frame[0], NULL, screen, &Tuxdest);
+ /* Draw controls: */
+ if (images[IMG_STOP])
+ SDL_BlitSurface(images[IMG_STOP], NULL, screen, &stopRect);
+ /* Draw regular or grayed-out left arrow: */
+ if (diff_level == CADET_HIGH_SCORE)
+ {
+ if (images[IMG_LEFT_GRAY])
+ SDL_BlitSurface(images[IMG_LEFT_GRAY], NULL, screen, &leftRect);
+ }
+ else
+ {
+ if (images[IMG_LEFT])
+ SDL_BlitSurface(images[IMG_LEFT], NULL, screen, &leftRect);
+ }
+ /* Draw regular or grayed-out right arrow: */
+ if (diff_level == ACE_HIGH_SCORE)
+ {
+ if (images[IMG_RIGHT_GRAY])
+ SDL_BlitSurface(images[IMG_RIGHT_GRAY], NULL, screen, &rightRect);
+ }
+ else
+ {
+ if (images[IMG_RIGHT])
+ SDL_BlitSurface(images[IMG_RIGHT], NULL, screen, &rightRect);
+ }
+
+ /* Generate and draw desired table: */
+ for (i = 0; i < HIGH_SCORES_SAVED; i++)
+ {
+ /* Get data for entries: */
+ sprintf(score_texts[i],
+ "%d.\t%d\t%s",
+ i + 1, /* Add one to get common-language place number */
+ HS_Score(diff_level, i),
+ HS_Name(diff_level, i));
+
+ /* Clear out old surfaces and update: */
+ if (score_entries[i])
+ SDL_FreeSurface(score_entries[i]);
+
+ score_entries[i] = black_outline(N_(score_texts[i]), default_font, &white);
+
+ /* Get out if black_outline() fails: */
+ if (!score_entries[i])
+ continue;
+
+ /* Set up entries in vertical column: */
+ if (0 == i)
+ score_rects[i].y = score_table_y;
+ else
+ score_rects[i].y = score_rects[i -1].y + score_rects[i -1].h;
+
+ score_rects[i].x = score_table_x;
+ score_rects[i].h = score_entries[i]->h;
+ score_rects[i].w = score_entries[i]->w;
+
+ SDL_BlitSurface(score_entries[i], NULL, screen, &score_rects[i]);
+ }
+ /* Update screen: */
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+ old_diff_level = diff_level;
+ }
+
+
+
+
+ /* --- make tux blink --- */
+ switch (frame % TUX6)
+ {
+ case 0: tux_frame = 1; break;
+ case TUX1: tux_frame = 2; break;
+ case TUX2: tux_frame = 3; break;
+ case TUX3: tux_frame = 4; break;
+ case TUX4: tux_frame = 3; break;
+ case TUX5: tux_frame = 2; break;
+ default: tux_frame = 0;
+ }
+
+ if (Tux && tux_frame)
+ {
+ SDL_BlitSurface(Tux->frame[tux_frame - 1], NULL, screen, &Tuxdest);
+ SDL_UpdateRect(screen, Tuxdest.x+37, Tuxdest.y+40, 70, 45);
+ }
+
+
+ /* Wait so we keep frame rate constant: */
+ while ((SDL_GetTicks() - start) < 33)
+ {
+ SDL_Delay(20);
+ }
+ frame++;
+ } // End of while (!finished) loop
+}
+
+
+
/* choose_config_file() - adapted from chooseWordlist() from tuxtype. */
/* Display a list of tuxmath config files in the missions directory */
/* and allow the player to pick one (AKA "Lessons"). */
@@ -1387,7 +1636,6 @@
{
SDL_Surface* titles[MAX_LESSONS];
SDL_Surface* select[MAX_LESSONS];
-// sprite* tux = NULL;
SDL_Rect leftRect, rightRect;
SDL_Rect titleRects[8]; //8 lessons displayed per page
@@ -1477,7 +1725,6 @@
continue;
}
- printf("%s\n",name_buf);
/* check to see if it has a \r at the end of it (dos format!) */
length = strlen(name_buf);
@@ -1506,14 +1753,14 @@
closedir(lesson_dir);
+
/* Display the list of lessons for the player to select: */
-
- /* FIXME black_outline() segfaults if passed "" as arg */
for (i = 0; i < lessons; i++)
{
titles[i] = black_outline( _(lesson_names[i]), default_font, &white );
select[i] = black_outline( _(lesson_names[i]), default_font, &yellow);
+ printf("Lesson %d: %s\n", i, lesson_names[i]);
}
// if (images[IMG_MENU_BKG])
Modified: tuxmath/trunk/src/titlescreen.h
===================================================================
--- tuxmath/trunk/src/titlescreen.h 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/src/titlescreen.h 2007-04-07 19:49:41 UTC (rev 149)
@@ -41,7 +41,7 @@
#define RES_X 640
#define RES_Y 480
-#define BPP 16
+#define BPP 32
#define MAX_SPRITE_FRAMES 30
@@ -129,8 +129,8 @@
/* Menu Prototypes */
enum Game_Type {
LESSONS, ARCADE, OPTIONS, GAME_OPTIONS, QUIT_GAME,
- ARCADE_CADET, ARCADE_SCOUT, ARCADE_RANGER, ARCADE_ACE, MAIN,
- INTERFACE_OPTIONS, HELP, CREDITS, PROJECT_INFO,
+ ARCADE_CADET, ARCADE_SCOUT, ARCADE_RANGER, ARCADE_ACE, HIGH_SCORES,
+ MAIN, INTERFACE_OPTIONS, HELP, CREDITS, PROJECT_INFO,
INSTRUCT_CASCADE, CASCADE1, CASCADE2, CASCADE3, CASCADE4,
INSTRUCT_LASER, LASER1, LASER2, LASER3, LASER4,
FREETYPE, ASDF, ALL, SET_LANGUAGE, EDIT_WORDLIST,
Modified: tuxmath/trunk/src/tuxmath.c
===================================================================
--- tuxmath/trunk/src/tuxmath.c 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/src/tuxmath.c 2007-04-07 19:49:41 UTC (rev 149)
@@ -32,11 +32,14 @@
int main(int argc, char * argv[])
{
#ifndef MACOSX
+#ifndef WIN32
setlocale( LC_ALL, "" );
bindtextdomain( "tuxmath", LOCALEDIR );
bind_textdomain_codeset("tuxmath", "UTF-8");
textdomain( "tuxmath" );
#endif
+#endif
+
/* Link control of tuxtype-derived code's debug to TUXMATH_DEBUG: */
debugOn = 0; //for tuxtype-derived code
#ifdef TUXMATH_DEBUG
Modified: tuxmath/trunk/src/tuxmath.h
===================================================================
--- tuxmath/trunk/src/tuxmath.h 2007-04-07 19:31:33 UTC (rev 148)
+++ tuxmath/trunk/src/tuxmath.h 2007-04-07 19:49:41 UTC (rev 149)
@@ -23,16 +23,21 @@
#define TUXMATH_H
// Translation stuff:
-#ifndef MACOSX
+#ifdef MACOSX
+#define N_(String) String
+#define _(String) String
+#else
+#ifdef WIN32
+#define N_(String) String
+#define _(String) String
+#else
#include <libintl.h>
#include <locale.h>
#define _(String) gettext (String)
#define gettext_noop(String) String
#define N_(String) gettext_noop (String)
-#else
-#define N_(String) String
-#define _(String) String
#endif
+#endif
#include <SDL.h>
#include <SDL_ttf.h>
@@ -42,7 +47,7 @@
#endif
//#define NOSOUND
-#define TUXMATH_DEBUG /* for conditional compilation of debugging output */
+//#define TUXMATH_DEBUG /* for conditional compilation of debugging output */
//#define FEEDBACK_DEBUG /* for Tim's feedback speed control code */
/* Maximum length of file path: */
More information about the Tux4kids-commits
mailing list