00001 /********************************************************************************* 00002 * 00003 * Razor! Engine - A modular C++ presentation engine 00004 * 00005 * $Id: HighscoreModel.h,v 1.1 2003/01/26 10:44:08 teacy Exp $ 00006 * 00007 * Copyright (c) 2000-2003 Tilo Christ. All Rights Reserved. 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining a 00010 * copy of this software and associated documentation files (the "Software"), 00011 * to deal in the Software without restriction, including without limitation 00012 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00013 * and/or sell copies of the Software, and to permit persons to whom the Software 00014 * is furnished to do so, subject to the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be included in all 00017 * copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 00020 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 00021 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 00022 * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00023 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00024 * 00025 **********************************************************************************/ 00026 00027 #ifndef HIGHSCOREMODEL_H 00028 #define HIGHSCOREMODEL_H 00029 00030 #include <PalmOS.h> 00031 #include "Sections.h" 00032 00033 00034 /** 00035 * An entry in the highscore table. 00036 */ 00037 class HighscoreEntry 00038 { 00039 public: 00040 UInt32 score; 00041 Char name[16]; 00042 }; 00043 00044 00045 /** 00046 * A model and the neccessary logic for highscore management. 00047 */ 00048 class HighscoreModel 00049 { 00050 /** 00051 * For internal usage by highscore model. 00052 * 00053 * Class that holds all table entries. 00054 */ 00055 class HighscoreState 00056 { 00057 HighscoreEntry entries[30]; 00058 }; 00059 00060 public: 00061 00062 ///@name Construction / Destruction 00063 //@{ 00064 /** 00065 * Construct the model from a save-state. 00066 */ 00067 HighscoreModel(void *highscoreState); 00068 00069 /** 00070 * Destroy the model. 00071 */ 00072 ~HighscoreModel(); 00073 //@} 00074 00075 00076 ///@name Logic 00077 //@{ 00078 /** 00079 * Return whether the supplied score qualifies as a highscore. 00080 */ 00081 Boolean isHighscore(UInt32 score); 00082 00083 /** 00084 * Add the highscore to the highscore table. 00085 * If the number of highscores exceeds the limit, the lowest existing highscore will be discarded. 00086 */ 00087 void addHighscore(UInt32 score, Char *name = NULL); 00088 00089 /** 00090 * Get the number of highscores in the highscore table. 00091 */ 00092 UInt8 getNumHighScores(); 00093 00094 /** 00095 * Get the nth entry from the highscore table. 00096 */ 00097 HighscoreEntry& getEntry(UInt8 index); 00098 //@} 00099 00100 00101 ///@name Persistence 00102 //@{ 00103 /** 00104 * Return a descriptor for a freshly initialized state. 00105 */ 00106 static StateDescriptor *createStateDescriptor(); 00107 //@} 00108 }; 00109 00110 #endif