* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "config.h"
-
-#include "SFont.h"
-#include "file.h"
-#include "score.h"
-
#include <SDL.h>
#include <SDL_keysym.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include "SFont.h"
+
+#include "common.h"
+#include "config.h"
+#include "file.h"
+#include "score.h"
+
// High score table
struct highscore g_scores[N_SCORES] = {
{1*60*1000,"-"},
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()
if(f) {
// If the file exists, read from it
for(i = 0; i<N_SCORES; i++) {
- g_scores[i].score = 0;
- g_scores[i].name[0] = 0;
fscanf(f, "%d %31[^\n]", &g_scores[i].score, g_scores[i].name);
}
fclose(f);
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);
}
}
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;
}