JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fixes to new name input code
authorJoshua Grams <josh@qualdan.com>
Tue, 4 Jan 2005 21:19:46 +0000 (21:19 +0000)
committerJoshua Grams <josh@qualdan.com>
Tue, 4 Jan 2005 21:19:46 +0000 (21:19 +0000)
SFont.c
SFont.h
score.c

diff --git a/SFont.c b/SFont.c
index 7e750bf..a13e75d 100644 (file)
--- a/SFont.c
+++ b/SFont.c
@@ -1,7 +1,6 @@
 /*  SFont: a simple font library that uses special images as fonts
     Copyright (C) 2003 Karl Bartel
 
 /*  SFont: a simple font library that uses special images as fonts
     Copyright (C) 2003 Karl Bartel
 
-    License: GPL or LGPL (at your choice)
     WWW: http://www.linux-games.com/sfont/
 
     This program is free software; you can redistribute it and/or modify        
     WWW: http://www.linux-games.com/sfont/
 
     This program is free software; you can redistribute it and/or modify        
diff --git a/SFont.h b/SFont.h
index 1ba77da..b577d2b 100644 (file)
--- a/SFont.h
+++ b/SFont.h
@@ -1,7 +1,6 @@
 /*  SFont: a simple font-library that uses special bitmaps as fonts
     Copyright (C) 2003 Karl Bartel
 
 /*  SFont: a simple font-library that uses special bitmaps as fonts
     Copyright (C) 2003 Karl Bartel
 
-    License: GPL or LGPL (at your choice)
     WWW: http://www.linux-games.com/sfont/
 
     This program is free software; you can redistribute it and/or modify        
     WWW: http://www.linux-games.com/sfont/
 
     This program is free software; you can redistribute it and/or modify        
 
 #include <SDL.h>
 
 
 #include <SDL.h>
 
-#ifdef __cplusplus 
-extern "C" {
-#endif
-
 // Delcare one variable of this type for each font you are using.
 // To load the fonts, load the font image into YourFont->Surface
 // and call SFont_InitFont(YourFont);
 // Delcare one variable of this type for each font you are using.
 // To load the fonts, load the font image into YourFont->Surface
 // and call SFont_InitFont(YourFont);
@@ -76,8 +71,4 @@ int SFont_TextHeight(const SFont_Font* Font);
 void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font* Font, int y,
                                           const char *text);
 
 void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font* Font, int y,
                                           const char *text);
 
-#ifdef __cplusplus
-}
-#endif
-
 #endif /* SFONT_H */
 #endif /* SFONT_H */
diff --git a/score.c b/score.c
index e49e956..faef94a 100644 (file)
--- a/score.c
+++ b/score.c
@@ -43,7 +43,7 @@ struct highscore g_scores[N_SCORES] = {
 
 extern SFont_Font *g_font;
 
 
 extern SFont_Font *g_font;
 
-int cur_score; // which score we're currently entering.
+int cur_score = -1; // which score we're currently entering.
 
 void
 read_high_score_table()
 
 void
 read_high_score_table()
@@ -144,7 +144,8 @@ display_scores(SDL_Surface *s, uint32_t x, uint32_t y)
                SFont_Write(s, g_font, x, y, t);
                snprintscore(t, 1024, g_scores[i].score);
                SFont_Write(s, g_font, x+50, y, t);
                SFont_Write(s, g_font, x, y, t);
                snprintscore(t, 1024, g_scores[i].score);
                SFont_Write(s, g_font, x+50, y, t);
-               snprintf(t, 1024, "%s", g_scores[i].name);
+               if(i == cur_score) snprintf(t, 1024, "%s_", g_scores[i].name);
+               else snprintf(t, 1024, "%s", g_scores[i].name);
                SFont_Write(s, g_font, x+180, y, t);
        }
 }
                SFont_Write(s, g_font, x+180, y, t);
        }
 }
@@ -162,12 +163,15 @@ process_score_input(void)
        while(SDL_PollEvent(&e) && e.type == SDL_KEYDOWN) {
                c = e.key.keysym.unicode;
                k = e.key.keysym.sym;
        while(SDL_PollEvent(&e) && e.type == SDL_KEYDOWN) {
                c = e.key.keysym.unicode;
                k = e.key.keysym.sym;
-               if(k == SDLK_BACKSPACE && n > 0) name[n--]=0;
-               else if(e.key.keysym.sym == SDLK_RETURN) {
-                       SDL_EnableUNICODE(0);
-                       return false;
+               if(k == SDLK_BACKSPACE) {
+                       if(n > 0) name[--n]=0;
+               } else {
+                       if(k == SDLK_RETURN) {
+                               SDL_EnableUNICODE(0);
+                               cur_score = -1;
+                               return false;
+                       } else name[n++] = c;
                }
                }
-               else name[n++] = c;
        }
        return true;
 }
        }
        return true;
 }