1 // 2 // Cross-platform free Puyo-Puyo clone. 3 // Copyright (C) 2006, 2007 Emma's Software 4 // 5 // This program is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 2 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with this program; if not, write to the Free Software 17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 // 19 #if !defined (AMOEBAX_NEW_HIGH_SCORE_STATE_H) 20 #define AMOEBAX_NEW_HIGH_SCORE_STATE_H 21 22 #include "IState.h" 23 24 namespace Amoebax 25 { 26 /// 27 /// \class NewHighScoreState. 28 /// \brief Prompts the player for her name. 29 /// 30 class NewHighScoreState: public IState 31 { 32 public: 33 explicit NewHighScoreState (uint32_t score); 34 virtual ~NewHighScoreState (void); 35 36 virtual void activate (void); 37 virtual void joyMotion (uint8_t joystick, uint8_t axis, 38 int16_t value); 39 virtual void joyDown (uint8_t joystick, uint8_t button); 40 virtual void joyUp (uint8_t joystick, uint8_t button); 41 #if !defined (IS_GP2X_HOST) 42 virtual void keyDown (uint32_t key); 43 virtual void keyUp (uint32_t key); 44 #endif // !IS_GP2X_HOST 45 virtual void redrawBackground (SDL_Rect *region, SDL_Surface *screen); 46 virtual void render (SDL_Surface *screen); 47 virtual void unicodeCharacterPressed (uint16_t code); 48 virtual void update (uint32_t elapsedTime); 49 virtual void videoModeChanged (void); 50 51 private: 52 /// The time required change cursor's visibility (in ms.) 53 static const uint32_t k_CursorVisibleTime = 300; 54 /// The Y screen position to write the new high score. 55 static const uint16_t k_ScorePosition = 300; 56 /// The maximum length in characters that the name can have. 57 static const std::string::size_type k_NameMaxLength = 15; 58 /// The Y screen position to write the name. 59 static const uint16_t k_NamePosition = 615; 60 61 void acceptName (void); 62 void addNewCharacter (void); 63 bool isCursorVisible (void) const; 64 const std::string getCursorValue (void) const; 65 int32_t getCursorVisibleTime (void) const; 66 uint32_t getScore (void) const; 67 void loadGraphicResources (void); 68 void removePreviousCharacter (); 69 void resetCursorVisibility (void); 70 void selectNextCursorValue (void); 71 void selectPreviousCursorValue (void); 72 void setCursorVisible (bool visible); 73 void setCursorVisibleTime (int32_t time); 74 75 /// The background image. 76 std::auto_ptr<Surface> m_Background; 77 /// Background music. 78 std::auto_ptr<Music> m_BackgroundMusic; 79 /// The current index of m_CursorValues. 80 uint8_t m_CursorValueIndex; 81 /// The possible values that the cursor can take. 82 const std::string m_CursorValues; 83 /// Tells if the cursor is visible. 84 bool m_CursorVisible; 85 /// The time the cursor should remain visible or invisible. 86 int32_t m_CursorVisibleTime; 87 /// The font to use to highlight. 88 std::auto_ptr<Font> m_HighLightFont; 89 /// The name to set as the high score. 90 std::string m_Name; 91 /// The font to use to draw the currently entered name. 92 std::auto_ptr<Font> m_NameFont; 93 /// The score to save. 94 uint32_t m_Score; 95 }; 96 } 97 98 #endif // !AMOEBAX_NEW_HIGH_SCORE_STATE_H 99