// $Id: highscoresdisplay.h,v 1.6 2006/08/23 22:43:17 matthew Exp $ // Fish Supper // Copyright (C) 2006 Matthew Clarke // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #ifndef _HIGHSCORESDISPLAY_H_ #define _HIGHSCORESDISPLAY_H_ #include #include "SDL.h" #include "SDL_image.h" #include "Font.hpp" #include #include #include #include #include #include #include // for toupper() namespace FS { class HighScoresDisplay { private: static const int NAME_MAX_LEN = 10; static const int NUM_ENTRIES = 5; static const int TOP_Y = 125; static const int Y_GAP = 80; static const int NAME_X = 100; static const int SCORE_X = 500; struct HighScoreEntry { char name[NAME_MAX_LEN+1]; int score; }; // struct HighScoreEntry std::list my_entries; void read_high_scores(); void populate_default_table(); SDL_Surface * background; const SFont & my_font; const SFont & my_font_faint; // These variables are used for controlling name-input. std::list::iterator new_entry; int new_entry_y; std::string new_entry_name; int font_height; SDL_Rect erase_rect; SDL_Rect dest_rect; public: HighScoresDisplay(); ~HighScoresDisplay(); // Returns true if sc would get a place on high-score table; // else false. bool check_candidate(int sc); // Add this name and score to the high-score table, removing // the lowest entry. Call this when check_candiate() returns // true. void add_entry(const char * nm, int sc); // Console print-out for time being... void print_table(); void show_high_scores(SDL_Surface * screen); void init_input(int score, SDL_Surface * screen); bool input(SDL_keysym * keys_down, int n, SDL_Surface * screen); void write_high_scores(); }; // class HighScoresDisplay } // namespace FS #endif