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_TOURNAMENT_SETUP_STATE_H) 20 #define AMOEBAX_TOURNAMENT_SETUP_STATE_H 21 22 #include <string> 23 #include <vector> 24 #include "IState.h" 25 #include "Surface.h" 26 #include "Font.h" 27 28 namespace Amoebax 29 { 30 /// 31 /// \class TournamentSetupState. 32 /// \brief Tournament's set-up. 33 /// 34 class TournamentSetupState: public IState 35 { 36 public: 37 TournamentSetupState (uint8_t players); 38 39 virtual void activate (void); 40 virtual void joyMotion (uint8_t joystick, uint8_t axis, 41 int16_t value); 42 virtual void joyDown (uint8_t joystick, uint8_t button); 43 virtual void joyUp (uint8_t joystick, uint8_t button); 44 #if !defined (IS_GP2X_HOST) 45 virtual void keyDown (uint32_t key); 46 virtual void keyUp (uint32_t key); 47 #endif // !IS_GP2X_HOST 48 virtual void redrawBackground (SDL_Rect *region, SDL_Surface *screen); 49 virtual void render (SDL_Surface *screen); 50 virtual void update (uint32_t elapsedTime); 51 virtual void videoModeChanged (void); 52 53 private: 54 /// 55 /// \struct CharacterInfo 56 /// \brief Information about a character. 57 /// 58 struct CharacterInfo 59 { 60 /// The character's name, 61 std::string name; 62 /// The character's avatar image. 63 std::auto_ptr<Surface> image; 64 }; 65 66 /// 67 /// \struct SelectedCharacter 68 /// \brief Information about a selected character. 69 /// 70 struct SelectedCharacter 71 { 72 /// The characters grid's column. 73 uint8_t col; 74 /// The character index. 75 uint8_t index; 76 /// The characters grid's row. 77 uint8_t row; 78 }; 79 80 bool allCharactersSelected (void) const; 81 void deselectCharacter (void); 82 uint8_t getCurrentPlayer (void) const; 83 uint8_t getNumPlayers (void) const; 84 uint8_t getSelectedCol (void) const; 85 const CharacterInfo &getSelectedCharacter (void) const; 86 uint8_t getSelectedCharacterIndex (void) const; 87 uint8_t getSelectedRow (void) const; 88 int32_t getTimeToWait (void) const; 89 uint16_t getXPositionOfCol (uint8_t col) const; 90 uint16_t getYPositionOfRow (uint8_t row) const; 91 bool isSelectedPositionValid (void) const; 92 void loadGraphicResources (void); 93 void selectCharacter (void); 94 void selectFirstCharacter (void); 95 void selectNextCol (void); 96 void selectNextRow (void); 97 void selectPreviousCol (void); 98 void selectPreviousRow (void); 99 void setNextPlayer (void); 100 void setPreviousPlayer (void); 101 void setSelectedCol (uint8_t col); 102 void setSelectedRow (uint8_t row); 103 void setTimeToWait (int32_t timeToWait); 104 105 /// The background. 106 std::auto_ptr<Surface> m_Background; 107 /// The player that is selecting a character. 108 uint8_t m_CurrentPlayer; 109 /// The font used to draw all texts. 110 std::auto_ptr<Font> m_Font; 111 /// The number of players. 112 uint8_t m_NumPlayers; 113 /// The faces' information. 114 CharacterInfo m_Characters[14]; 115 /// The selected characters by players. 116 std::vector<SelectedCharacter> m_SelectedCharacters; 117 /// The currently selected column. 118 uint8_t m_SelectedCol; 119 /// The currently selected row. 120 uint8_t m_SelectedRow; 121 /// The current selection. 122 std::auto_ptr<Surface> m_Selection; 123 /// The time to wait before changing to the tournament state. 124 int32_t m_TimeToWait; 125 }; 126 } 127 128 #endif // !AMOEBAX_TOURNAMENT_SETUP_STATE_H 129