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 (HAVE_CONFIG_H)
20 #include <config.h>
21 #endif // HAVE_CONFIG_H
22 #include <sstream>
23 #include "File.h"
24 #include "System.h"
25 #include "TournamentSetupState.h"
26 #include "TournamentState.h"
27 
28 using namespace Amoebax;
29 
30 static const uint16_t k_CharacterImageX = 993;
31 static const uint16_t k_CharacterImageY = 412;
32 static const uint8_t k_ComputerFacesRow = 2;
33 static const uint16_t k_ComputerFacesRowY = 730;
34 static const uint8_t k_ComputerCharactersColumns = 6;
35 static const uint16_t k_ComputerCharactersLabelY = 645;
36 static const uint16_t k_FaceHeight = 128;
37 static const uint16_t k_FaceSpan = 154;
38 static const uint8_t k_FacesPerRow = 7;
39 static const uint16_t k_FaceStartX = 160;
40 static const uint16_t k_FaceWidth = 128;
41 static const uint8_t k_FemaleFacesRow = 0;
42 static const uint16_t k_FemaleFacesRowY = 350;
43 static const uint8_t k_HumanCharactersColumns = 4;
44 static const uint16_t k_HumanCharactersLabelY = 265;
45 static const uint8_t k_MaleFacesRow = 1;
46 static const uint16_t k_MaleFacesRowY = 504;
47 static const uint8_t k_NumCharacters = 14;
48 static const uint8_t k_NumCharactersRows = 3;
49 static const uint16_t k_SelectPlayerX = 160;
50 static const uint16_t k_SelectPlayerY = 190;
51 static const int32_t k_TimeToWait = 2500;
52 
53 ///
54 /// \brief Default constructor.
55 ///
56 /// \param players The number of players.
57 ///
TournamentSetupState(uint8_t players)58 TournamentSetupState::TournamentSetupState (uint8_t players):
59     IState (),
60     m_Background (0),
61     m_CurrentPlayer (0),
62     m_Font (0),
63     m_NumPlayers (players),
64     m_Characters (),
65     m_SelectedCharacters (),
66     m_SelectedCol (0),
67     m_SelectedRow (0),
68     m_Selection (0),
69     m_TimeToWait (k_TimeToWait)
70 {
71     m_Characters[0].name = "Kim";
72     m_Characters[1].name = "Sasha";
73     m_Characters[2].name = "Brooke";
74     m_Characters[3].name = "Lem";
75     m_Characters[4].name = "Tom";
76     m_Characters[5].name = "Ed";
77     m_Characters[6].name = "Gary";
78     m_Characters[7].name = "Nicholas";
79     m_Characters[8].name = "K.Quita";
80     m_Characters[9].name = "Angus";
81     m_Characters[10].name = "Kerberos";
82     m_Characters[11].name = "Spike";
83     m_Characters[12].name = "Mr.Bones";
84     m_Characters[13].name = "Pen";
85     loadGraphicResources ();
86 }
87 
88 void
activate(void)89 TournamentSetupState::activate (void)
90 {
91 }
92 
93 ///
94 /// \brief Tells if all characters are selected.
95 ///
96 /// \return \a true if all players have selected a characters,
97 ///         \a false otherwise.
98 ///
99 inline bool
allCharactersSelected(void) const100 TournamentSetupState::allCharactersSelected (void) const
101 {
102     return getCurrentPlayer () == getNumPlayers ();
103 }
104 
105 ///
106 /// \brief Deselects the last selected character.
107 ///
108 /// If there's now selected character, this function return to the main
109 /// menu.
110 ///
111 void
deselectCharacter(void)112 TournamentSetupState::deselectCharacter (void)
113 {
114     if ( m_SelectedCharacters.empty () )
115     {
116         System::getInstance ().returnToMainMenu ();
117     }
118     else
119     {
120         setSelectedCol (m_SelectedCharacters.back ().col);
121         setSelectedRow (m_SelectedCharacters.back ().row);
122         m_SelectedCharacters.pop_back ();
123         setPreviousPlayer ();
124     }
125 }
126 
127 ///
128 /// \brief Gets the player that currently selects a character.
129 ///
130 /// \return The player index in the range of 0..getNumPlayers()-1.
131 ///
132 inline uint8_t
getCurrentPlayer(void) const133 TournamentSetupState::getCurrentPlayer (void) const
134 {
135     return m_CurrentPlayer;
136 }
137 
138 ///
139 /// \brief Gets the number of players that will select a character.
140 ///
141 /// \return The number of players that need to select a player.
142 ///
143 inline uint8_t
getNumPlayers(void) const144 TournamentSetupState::getNumPlayers (void) const
145 {
146     return m_NumPlayers;
147 }
148 
149 ///
150 /// \brief Gets the time to wait before changing to the tournament state.
151 ///
152 /// \return The number of milliseconds to wait before we can change
153 ///         the current state to the tournament state.
154 ///
155 inline int32_t
getTimeToWait(void) const156 TournamentSetupState::getTimeToWait (void) const
157 {
158     return m_TimeToWait;
159 }
160 
161 ///
162 /// \brief Gets the unscaled X position of a column of the character grid.
163 ///
164 /// \param col The column to compute the X position of.
165 /// \return The unscaled X position of column \p col.
166 ///
167 inline uint16_t
getXPositionOfCol(uint8_t col) const168 TournamentSetupState::getXPositionOfCol (uint8_t col) const
169 {
170     return k_FaceStartX + k_FaceSpan * col;
171 }
172 
173 ///
174 /// \brief Gets the unscaled Y position of a row of the characters grid.
175 ///
176 /// \param row The row to compute the Y position of.
177 /// \return The unscaled Y position of row \p row.
178 ///
179 uint16_t
getYPositionOfRow(uint8_t row) const180 TournamentSetupState::getYPositionOfRow (uint8_t row) const
181 {
182     uint16_t y;
183     switch ( row )
184     {
185         case k_FemaleFacesRow:
186             y = k_FemaleFacesRowY;
187             break;
188 
189         case k_MaleFacesRow:
190             y = k_MaleFacesRowY;
191             break;
192 
193         case k_ComputerFacesRow:
194             y = k_ComputerFacesRowY;
195             break;
196 
197         default:
198             y = k_FemaleFacesRowY;
199             break;
200     }
201 
202     return y;
203 }
204 
205 ///
206 /// \brief Tells if the currently selected grid position is valid.
207 ///
208 /// A valid position is any position where there's no selected character.
209 ///
210 bool
isSelectedPositionValid(void) const211 TournamentSetupState::isSelectedPositionValid (void) const
212 {
213     for ( std::vector<SelectedCharacter>::const_iterator currentCharacter = m_SelectedCharacters.begin () ;
214           currentCharacter != m_SelectedCharacters.end () ;
215           ++currentCharacter )
216     {
217         if ( currentCharacter->col == getSelectedCol () &&
218              currentCharacter->row == getSelectedRow () )
219         {
220             return false;
221         }
222     }
223     return true;
224 }
225 
226 void
joyMotion(uint8_t joystick,uint8_t axis,int16_t value)227 TournamentSetupState::joyMotion (uint8_t joystick, uint8_t axis, int16_t value)
228 {
229 }
230 
231 void
joyDown(uint8_t joystick,uint8_t button)232 TournamentSetupState::joyDown (uint8_t joystick, uint8_t button)
233 {
234 #if defined (IS_GP2X_HOST)
235     switch (button)
236     {
237         case GP2X_BUTTON_A:
238         case GP2X_BUTTON_B:
239         case GP2X_BUTTON_CLICK:
240             selectCharacter ();
241             break;
242 
243         case GP2X_BUTTON_DOWN:
244             selectNextRow ();
245             break;
246 
247         case GP2X_BUTTON_LEFT:
248             selectPreviousCol ();
249             break;
250 
251         case GP2X_BUTTON_RIGHT:
252             selectNextCol ();
253             break;
254 
255         case GP2X_BUTTON_UP:
256             selectPreviousRow ();
257             break;
258 
259         case GP2X_BUTTON_X:
260             deselectCharacter ();
261             break;
262     }
263 #endif // IS_GP2X_HOST
264 }
265 
266 void
joyUp(uint8_t joystick,uint8_t button)267 TournamentSetupState::joyUp (uint8_t joystick, uint8_t button)
268 {
269 }
270 
271 #if !defined (IS_GP2X_HOST)
272 void
keyDown(uint32_t key)273 TournamentSetupState::keyDown (uint32_t key)
274 {
275     switch (key)
276     {
277         case SDLK_DOWN:
278             selectNextRow ();
279             break;
280 
281         case SDLK_ESCAPE:
282             deselectCharacter ();
283             break;
284 
285         case SDLK_LEFT:
286             selectPreviousCol ();
287             break;
288 
289         case SDLK_RETURN:
290             selectCharacter ();
291             break;
292 
293         case SDLK_RIGHT:
294             selectNextCol ();
295             break;
296 
297         case SDLK_UP:
298             selectPreviousRow ();
299             break;
300     }
301 }
302 
303 void
keyUp(uint32_t key)304 TournamentSetupState::keyUp (uint32_t key)
305 {
306 }
307 #endif // !IS_GP2X_HOST
308 
309 ///
310 /// \brief Gets the currently selected column.
311 ///
312 /// \return The index of the column of the currently selected character.
313 ///
314 inline uint8_t
getSelectedCol(void) const315 TournamentSetupState::getSelectedCol (void) const
316 {
317     return m_SelectedCol;
318 }
319 
320 ///
321 /// \brief Gets the currently selected character.
322 ///
323 /// \return The currently selected character.
324 ///
325 inline const TournamentSetupState::CharacterInfo &
getSelectedCharacter(void) const326 TournamentSetupState::getSelectedCharacter (void) const
327 {
328     return m_Characters[getSelectedCharacterIndex ()];
329 }
330 
331 ///
332 /// \brief Gets the index of the currently selected character.
333 ///
334 /// \return The index of the currently selected character.
335 ///
336 inline uint8_t
getSelectedCharacterIndex(void) const337 TournamentSetupState::getSelectedCharacterIndex (void) const
338 {
339     return getSelectedRow () * 4 + getSelectedCol ();
340 }
341 
342 ///
343 /// \brief Gets the currently selelected row.
344 ///
345 /// \return The index of the column of the selected character.
346 ///
347 inline uint8_t
getSelectedRow(void) const348 TournamentSetupState::getSelectedRow (void) const
349 {
350     return m_SelectedRow;
351 }
352 
353 ///
354 /// \brief Loads graphic resources.
355 ///
356 void
loadGraphicResources(void)357 TournamentSetupState::loadGraphicResources (void)
358 {
359     const float screenScale = System::getInstance ().getScreenScaleFactor ();
360 #if defined (IS_GP2X_HOST)
361     const float originalScale = screenScale;
362     const uint16_t faceHeight = static_cast<uint16_t>(k_FaceHeight * screenScale);
363     const uint16_t faceWidth = static_cast<uint16_t>(k_FaceWidth * screenScale);
364 #else // !IS_GP2X_HOST
365     const float originalScale = 1.0f;
366     const uint16_t faceHeight = k_FaceHeight;
367     const uint16_t faceWidth =  k_FaceWidth ;
368 #endif // IS_GP2X_HOST
369     m_Background.reset (
370             Surface::fromFile (File::getGraphicsFilePath ("menuBackground.png")));
371     {
372         std::auto_ptr<Surface> faces (
373                 Surface::fromFile (File::getGraphicsFilePath ("faces.png")));
374         for ( uint16_t currentCharacter = 0 ; currentCharacter < 4 ;
375               currentCharacter++ )
376         {
377             faces->blit ((currentCharacter % k_FacesPerRow) * faceWidth, 0,
378                          faceWidth, faceHeight,
379                          static_cast<uint16_t> (
380                              getXPositionOfCol (currentCharacter) *
381                              originalScale),
382                          static_cast<uint16_t> (k_FemaleFacesRowY *
383                                                 originalScale),
384                          m_Background->toSDLSurface());
385         }
386         for ( uint16_t currentCharacter = 4 ; currentCharacter < 8 ;
387               currentCharacter++ )
388         {
389             faces->blit ((currentCharacter % k_FacesPerRow) * faceWidth,
390                          (currentCharacter / k_FacesPerRow) * faceHeight,
391                          faceWidth, faceHeight,
392                          static_cast<uint16_t> (
393                              getXPositionOfCol (currentCharacter - 4) *
394                              originalScale),
395                          static_cast<uint16_t> (k_MaleFacesRowY *
396                                                 originalScale),
397                          m_Background->toSDLSurface());
398         }
399         for ( uint16_t currentCharacter = 1 ; currentCharacter < 7 ;
400               currentCharacter++ )
401         {
402             faces->blit ((currentCharacter % k_FacesPerRow) * faceWidth,
403                          faceHeight, faceWidth, faceHeight,
404                          static_cast<uint16_t> (
405                              getXPositionOfCol (currentCharacter - 1) *
406                              originalScale),
407                          static_cast<uint16_t> (k_ComputerFacesRowY *
408                                                 originalScale),
409                          m_Background->toSDLSurface());
410         }
411     }
412     {
413         std::auto_ptr<Surface> title (
414                 Surface::fromFile (File::getGraphicsFilePath ("humanplayers.png")));
415         title->blit (static_cast<uint16_t> (k_FaceStartX * originalScale),
416                      static_cast<uint16_t> (k_HumanCharactersLabelY *
417                                             originalScale),
418                      m_Background->toSDLSurface ());
419     }
420     {
421         std::auto_ptr<Surface> title (
422                 Surface::fromFile (File::getGraphicsFilePath ("computerplayers.png")));
423         title->blit (static_cast<uint16_t> (k_FaceStartX * originalScale),
424                      static_cast<uint16_t> (k_ComputerCharactersLabelY *
425                                             originalScale),
426                      m_Background->toSDLSurface ());
427     }
428     {
429         std::auto_ptr<Surface> title (
430                 Surface::fromFile (File::getGraphicsFilePath ("tournament.png")));
431         title->blit (m_Background->getWidth () / 2 -
432                      title->getWidth () / 2, 0, m_Background->toSDLSurface ());
433     }
434     m_Background->resize (screenScale);
435 
436     for ( uint32_t currentCharacter = 0 ; currentCharacter < k_NumCharacters ;
437           ++currentCharacter )
438     {
439         m_Characters[currentCharacter].image.reset (
440                 Surface::fromFile (File::getGraphicsFilePath (
441                         m_Characters[currentCharacter].name + ".png")));
442         m_Characters[currentCharacter].image->resize (screenScale);
443     }
444 
445     m_Selection.reset (
446             Surface::fromFile (File::getGraphicsFilePath ("faceSelection.png")));
447     m_Selection->resize (screenScale);
448 
449     m_Font.reset (
450             Font::fromFile (File::getFontFilePath ("fontMenu")));
451 }
452 
453 void
redrawBackground(SDL_Rect * region,SDL_Surface * screen)454 TournamentSetupState::redrawBackground (SDL_Rect *region, SDL_Surface *screen)
455 {
456     m_Background->blit (region->x, region->y, region->w, region->h,
457                         region->x, region->y, screen);
458 }
459 
460 void
render(SDL_Surface * screen)461 TournamentSetupState::render (SDL_Surface *screen)
462 {
463     const float screenScale = System::getInstance ().getScreenScaleFactor ();
464 
465     if ( !allCharactersSelected () )
466     {
467         std::ostringstream selectPlayerString;
468         selectPlayerString << "Select Player ";
469         selectPlayerString << getCurrentPlayer() + 1;
470         m_Font->write (selectPlayerString.str(),
471                        static_cast<uint16_t> (k_SelectPlayerX * screenScale),
472                        static_cast<uint16_t> (k_SelectPlayerY * screenScale),
473                        screen);
474     }
475 
476     // Render the currently selected character's image and name.
477     uint16_t x =
478         static_cast<uint16_t> (k_CharacterImageX * screenScale -
479                                getSelectedCharacter ().image->getWidth () / 2);
480     uint16_t y =
481         static_cast<uint16_t> (k_CharacterImageY * screenScale -
482                                getSelectedCharacter ().image->getHeight () / 2);
483     getSelectedCharacter ().image->blit (x, y, screen);
484     uint16_t textWidth = m_Font->getTextWidth (getSelectedCharacter ().name);
485     m_Font->write (getSelectedCharacter ().name,
486                    static_cast<uint16_t> (k_CharacterImageX * screenScale -
487                                           textWidth / 2),
488                    y + getSelectedCharacter ().image->getHeight (), screen);
489 
490 
491     // Render the already selected characters.
492     for ( std::vector<SelectedCharacter>::const_iterator currentCharacter = m_SelectedCharacters.begin () ;
493           currentCharacter != m_SelectedCharacters.end () ;
494           ++currentCharacter )
495     {
496         x = static_cast<uint16_t> (getXPositionOfCol (currentCharacter->col) *
497                                    screenScale);
498         y = static_cast<uint16_t> (getYPositionOfRow (currentCharacter->row) *
499                                    screenScale);
500 
501         m_Selection->blit (m_Selection->getWidth () - m_Selection->getHeight (),
502                            0,
503                            m_Selection->getHeight (), m_Selection->getHeight (),
504                            x, y, screen);
505     }
506     // Render the character selection on the character grid.
507     if ( !allCharactersSelected () )
508     {
509         x = static_cast<uint16_t> (getXPositionOfCol (getSelectedCol ()) *
510                                    screenScale);
511         y = static_cast<uint16_t> (getYPositionOfRow (getSelectedRow ()) *
512                                    screenScale);
513         m_Selection->blit (m_Selection->getHeight () * getCurrentPlayer (), 0,
514                            m_Selection->getHeight (), m_Selection->getHeight (),
515                            x, y, screen);
516     }
517 }
518 
519 ///
520 /// \brief Selects the currently selected character as the player's character.
521 ///
522 void
selectCharacter(void)523 TournamentSetupState::selectCharacter (void)
524 {
525     // If all characters are selected, then we just move
526     // forward to the next state.
527     if ( allCharactersSelected () )
528     {
529         setTimeToWait (0);
530         return;
531     }
532 
533     SelectedCharacter selectedCharacter;
534     selectedCharacter.col = getSelectedCol ();
535     selectedCharacter.index = getSelectedCharacterIndex ();
536     selectedCharacter.row = getSelectedRow ();
537     m_SelectedCharacters.push_back (selectedCharacter);
538 
539     setNextPlayer ();
540     if ( allCharactersSelected () )
541     {
542         setTimeToWait (k_TimeToWait);
543     }
544     else
545     {
546         selectFirstCharacter ();
547     }
548 }
549 
550 ///
551 /// \brief Sets the first available character as the selected.
552 ///
553 void
selectFirstCharacter(void)554 TournamentSetupState::selectFirstCharacter (void)
555 {
556     if ( allCharactersSelected () )
557     {
558         return;
559     }
560 
561     setSelectedCol (0);
562     setSelectedRow (0);
563     if ( !isSelectedPositionValid () )
564     {
565         selectNextCol ();
566     }
567 }
568 
569 ///
570 /// \brief Selects the next available column.
571 ///
572 /// If the next row is behind the last one, the first column
573 /// of the next row is selected.
574 ///
575 void
selectNextCol(void)576 TournamentSetupState::selectNextCol (void)
577 {
578     if ( allCharactersSelected () )
579     {
580         return;
581     }
582 
583     if ( (getSelectedRow () != k_ComputerFacesRow &&
584           getSelectedCol () < (k_HumanCharactersColumns - 1)) ||
585          (getSelectedRow () == k_ComputerFacesRow &&
586           getSelectedCol () < (k_ComputerCharactersColumns - 1)) )
587     {
588         setSelectedCol (getSelectedCol () + 1);
589     }
590     else
591     {
592         selectNextRow ();
593         setSelectedCol (0);
594     }
595     if ( !isSelectedPositionValid () )
596     {
597         selectNextCol ();
598     }
599 }
600 
601 ///
602 /// \brief Selects the next available row.
603 ///
604 /// If the next row is after the last one, the first row is selected.
605 ///
606 void
selectNextRow(void)607 TournamentSetupState::selectNextRow (void)
608 {
609     if ( allCharactersSelected () )
610     {
611         return;
612     }
613 
614     setSelectedRow ((getSelectedRow () + 1) % k_NumCharactersRows);
615     if ( getSelectedRow () != k_ComputerFacesRow &&
616          getSelectedCol () > (k_HumanCharactersColumns - 1) )
617     {
618         setSelectedCol (k_HumanCharactersColumns - 1);
619     }
620     if ( !isSelectedPositionValid () )
621     {
622         selectNextCol ();
623     }
624 }
625 
626 ///
627 /// \brief Selects the previous available column.
628 ///
629 /// If the previous column is before the first one, the last column
630 /// of the previous column is selected.
631 ///
632 void
selectPreviousCol(void)633 TournamentSetupState::selectPreviousCol (void)
634 {
635     if ( allCharactersSelected () )
636     {
637         return;
638     }
639 
640     if ( getSelectedCol () > 0 )
641     {
642         setSelectedCol (getSelectedCol () - 1);
643     }
644     else
645     {
646         if ( getSelectedRow () == k_FemaleFacesRow )
647         {
648             setSelectedCol (k_ComputerCharactersColumns - 1);
649         }
650         else
651         {
652             setSelectedCol (k_HumanCharactersColumns - 1);
653         }
654         selectPreviousRow ();
655     }
656     if ( !isSelectedPositionValid () )
657     {
658         selectPreviousCol ();
659     }
660 }
661 
662 ///
663 /// \brief Selectes the previous row.
664 ///
665 /// If the previous row is before the first, the last column is selected.
666 ///
667 void
selectPreviousRow(void)668 TournamentSetupState::selectPreviousRow (void)
669 {
670     if ( allCharactersSelected () )
671     {
672         return;
673     }
674 
675     if ( getSelectedRow () > 0 )
676     {
677         setSelectedRow (getSelectedRow () - 1);
678         // Since the computer characters row is the last one, we
679         // can be sure that the row we are now is a human characters row.
680         if ( getSelectedCol () > (k_HumanCharactersColumns - 1) )
681         {
682             setSelectedCol (k_HumanCharactersColumns - 1);
683         }
684     }
685     else
686     {
687         setSelectedRow (k_ComputerFacesRow);
688     }
689     if ( !isSelectedPositionValid () )
690     {
691         selectNextCol ();
692     }
693 }
694 
695 ///
696 /// \brief Increments the current player.
697 ///
698 inline void
setNextPlayer(void)699 TournamentSetupState::setNextPlayer (void)
700 {
701     ++m_CurrentPlayer;
702 }
703 
704 ///
705 /// \brief Decrements the current player.
706 ///
707 inline void
setPreviousPlayer(void)708 TournamentSetupState::setPreviousPlayer (void)
709 {
710     --m_CurrentPlayer;
711 }
712 
713 ///
714 /// \brief Sets the currently selected column.
715 ///
716 /// \param col The column to set as selected.
717 ///
718 inline void
setSelectedCol(uint8_t col)719 TournamentSetupState::setSelectedCol (uint8_t col)
720 {
721     m_SelectedCol = col;
722 }
723 
724 ///
725 /// \brief Sets the currently selected row.
726 ///
727 /// \param row The row to set as selected.
728 ///
729 inline void
setSelectedRow(uint8_t row)730 TournamentSetupState::setSelectedRow (uint8_t row)
731 {
732     m_SelectedRow = row;
733 }
734 
735 ///
736 /// \brief Sets the time to wait before changing to the tournament state.
737 ///
738 /// \param timeToWait The time to wait in milliseconds.
739 ///
740 inline void
setTimeToWait(int32_t timeToWait)741 TournamentSetupState::setTimeToWait (int32_t timeToWait)
742 {
743     m_TimeToWait = timeToWait;
744 }
745 
746 void
update(uint32_t elapsedTime)747 TournamentSetupState::update (uint32_t elapsedTime)
748 {
749     if ( allCharactersSelected () )
750     {
751         setTimeToWait (getTimeToWait () - elapsedTime);
752         if ( getTimeToWait () <= 0 )
753         {
754             std::vector <TournamentState::Player> tournamentPlayers;
755             for (std::vector <SelectedCharacter>::const_iterator currentPlayer = m_SelectedCharacters.begin() ;
756                  currentPlayer != m_SelectedCharacters.end() ; ++currentPlayer)
757             {
758                 TournamentState::Player player;
759                 player.characterIndex = currentPlayer->index;
760                 player.name = m_Characters[currentPlayer->index].name;
761                 player.isComputerPlayer = k_ComputerFacesRow == currentPlayer->row;
762                 player.computerPlayerLevel = currentPlayer->col;
763                 tournamentPlayers.push_back (player);
764             }
765             System::getInstance ().removeActiveState (false);
766             System::getInstance ().setActiveState (
767                     new TournamentState (tournamentPlayers));
768         }
769     }
770 
771 }
772 
773 void
videoModeChanged(void)774 TournamentSetupState::videoModeChanged (void)
775 {
776     loadGraphicResources ();
777 }
778