X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=score.c;h=30d30a5eb4c479124b0f83fb296bd45b92368745;hp=406576c85b6a5cf3aee8f995528e824534959706;hb=19f8eb7a835a2b084010a8deb8f3d200f995559d;hpb=f1768e98ddbe134b9f6fd6056caf2393b666bb5a diff --git a/score.c b/score.c index 406576c..30d30a5 100644 --- a/score.c +++ b/score.c @@ -22,7 +22,7 @@ #include #include -#include "SFont.h" +#include "font.h" #include "common.h" #include "config.h" @@ -31,33 +31,32 @@ #include "score.h" // High score table +// below are the defaults (when there's no high score file) in miliseconds struct highscore g_scores[2][N_SCORES] = { { - {1*60*1000,"-"}, - {45*1000,"-"}, - {30*1000,"-"}, - {20*1000,"-"}, - {10*1000,"-"}, - {7*1000,"-"}, - {5*1000,"-"}, - {3*1000,"-"} + {120000,"-"}, + {105000,"-"}, + { 90000,"-"}, + { 75000,"-"}, + { 60000,"-"}, + { 50000,"-"}, + { 40000,"-"}, + { 30000,"-"} }, { - {1*60*1000,"-"}, - {45*1000,"-"}, - {30*1000,"-"}, - {20*1000,"-"}, - {10*1000,"-"}, - {7*1000,"-"}, - {5*1000,"-"}, - {3*1000,"-"} + {120000,"-"}, + {105000,"-"}, + { 90000,"-"}, + { 75000,"-"}, + { 60000,"-"}, + { 50000,"-"}, + { 40000,"-"}, + { 30000,"-"} } }; static char *titles[2] = { "Normal\n", "Easy\n" }; -extern SFont_Font *g_font; - int g_easy = 0; int cur_score = -1; // which score we're currently entering. @@ -145,7 +144,7 @@ snprintscore(char *s, size_t n, int score) if(min) { return snprintf(s, n, "%2d:%.2d.%d", min, sec, tenths); } else { - return snprintf(s, n, "%2d.%d", sec, tenths); + return snprintf(s, n, " %2d.%d", sec, tenths); } } @@ -155,53 +154,57 @@ show_score(void) char s[16]; int r = snprintf(s, 16, "Time: "); snprintscore(s+r, 16-r, score); - SFont_Write(surf_screen, g_font, XSIZE-250, 0, s); + font_write(XSIZE-250, 0, s); } void -display_scores(SDL_Surface *s, uint32_t x, uint32_t y) +display_scores(uint32_t x, uint32_t y) { char t[1024]; - int i,h = SFont_TextHeight(g_font); + int i,h = font_height(); + int display_cursor = (SDL_GetTicks() / CURSOR_BLINK_TIME) % 2; + - SFont_Write(s,g_font,x+30,y,"High scores"); + font_write(x+30, y, "High scores"); y += h; - if(g_easy) SFont_Write(s,g_font,x+75,y,"(easy)"); - else SFont_Write(s,g_font,x+60,y,"(normal)"); + if(g_easy) font_write(x+75,y,"(easy)"); + else font_write(x+60,y,"(normal)"); for(i = 0; i 0) name[--n]=0; - } else { - if(k == SDLK_RETURN) { - SDL_EnableUNICODE(0); - cur_score = -1; - return false; - } else name[n++] = c; - } + if(key->sym == SDLK_BACKSPACE) { + if(n > 0) name[--n]=0; + } else { + if(key->sym == SDLK_RETURN || key->sym == SDLK_KP_ENTER) { + SDL_EnableUNICODE(0); + cur_score = -1; + if(n == 0) { + name[0] = '-'; + } + return false; + } else if(n < 12) { + if(key->unicode >= 32 && key->unicode <= 126) { + name[n++] = key->unicode; + } + } // else drop it } return true; }